diff options
author | Gabor Horvath <xazax.hun@gmail.com> | 2017-10-30 12:16:07 +0000 |
---|---|---|
committer | Gabor Horvath <xazax.hun@gmail.com> | 2017-10-30 12:16:07 +0000 |
commit | 1157fbd7d668f9579b5a633dd245657bb940076b (patch) | |
tree | 81efd54e35670b3ed2ea22f429c1aefc8184b68b /lib/StaticAnalyzer/Core/IssueHash.cpp | |
parent | a154e5b192b01366f25a62715a145a4cec3f8d23 (diff) | |
download | clang-1157fbd7d668f9579b5a633dd245657bb940076b.tar.gz |
[analyzer] Use the signature of the primary template for issue hash calculation
Now when a template is instantiated more times and there is a bug found in the
instantiations the issue hash will be different for each instantiation even if
every other property of the bug (path, message, location) is the same.
This patch aims to resolve this issue. Note that explicit specializations still
generate different hashes but that is intended.
Differential Revision: https://reviews.llvm.org/D38728
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@316900 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer/Core/IssueHash.cpp')
-rw-r--r-- | lib/StaticAnalyzer/Core/IssueHash.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/StaticAnalyzer/Core/IssueHash.cpp b/lib/StaticAnalyzer/Core/IssueHash.cpp index abdea88b1d..274ebe7a94 100644 --- a/lib/StaticAnalyzer/Core/IssueHash.cpp +++ b/lib/StaticAnalyzer/Core/IssueHash.cpp @@ -33,6 +33,13 @@ static std::string GetSignature(const FunctionDecl *Target) { return ""; std::string Signature; + // When a flow sensitive bug happens in templated code we should not generate + // distinct hash value for every instantiation. Use the signature from the + // primary template. + if (const FunctionDecl *InstantiatedFrom = + Target->getTemplateInstantiationPattern()) + Target = InstantiatedFrom; + if (!isa<CXXConstructorDecl>(Target) && !isa<CXXDestructorDecl>(Target) && !isa<CXXConversionDecl>(Target)) Signature.append(Target->getReturnType().getAsString()).append(" "); |