Index: include/clang/StaticAnalyzer/Core/BugId.h =================================================================== --- include/clang/StaticAnalyzer/Core/BugId.h +++ include/clang/StaticAnalyzer/Core/BugId.h @@ -16,9 +16,16 @@ class SourceManager; class FullSourceLoc; -llvm::SmallString<32> GetIssueHash(const SourceManager *SM, FullSourceLoc &L, +llvm::SmallString<32> GetIssueHash(const SourceManager *SM, + FullSourceLoc &L, llvm::StringRef CheckerName, - llvm::StringRef HashField, const Decl *D); + llvm::StringRef BugType, + const Decl *DeclWithIssue); } +llvm::SmallString<32> GetBugIdHash(const SourceManager *SM, + FullSourceLoc &L, + llvm::StringRef CheckerName, + llvm::StringRef BugType, + const Decl *DeclWithIssue); #endif Index: lib/StaticAnalyzer/Core/BugId.cpp =================================================================== --- lib/StaticAnalyzer/Core/BugId.cpp +++ lib/StaticAnalyzer/Core/BugId.cpp @@ -184,15 +184,43 @@ return Res; } +// GetIssueHash generates issue_hash based on the following info: +// 1. column number +// 2. source line string after removing whitespace +// 3. bug type llvm::SmallString<32> clang::GetIssueHash(const SourceManager *SM, FullSourceLoc &L, StringRef CheckerName, - StringRef HashField, const Decl *D) { + StringRef BugType, + const Decl *DeclWithIssue) { static llvm::StringRef Delimiter = "$"; return GetHashOfContent( - (llvm::Twine(CheckerName) + Delimiter + GetEnclosingDeclContextSignature(D) + - Delimiter + std::to_string(L.getExpansionColumnNumber()) + Delimiter + - NormalizeLine(SM, L, D) + - Delimiter + HashField.str()).str()); + (llvm::Twine(std::to_string(L.getExpansionColumnNumber())) + Delimiter + + NormalizeLine(SM, L, DeclWithIssue) + Delimiter + + BugType.str()).str()); +} + +// Bud id is composited info in addition to the one of issue_hash. +// GetBugIdHash generates bug id based on the following info: +// 1. file name with absolute path +// 2. checker name +// 3. function name +// 4. column number +// 5. source line string after removing whitespace +// 6. bug type +llvm::SmallString<32> clang::GetBugIdHash(const SourceManager *SM, + FullSourceLoc &L, + StringRef CheckerName, + StringRef BugType, + const Decl *DeclWithIssue) { + static llvm::StringRef Delimiter = "$"; + + return GetHashOfContent( + (llvm::Twine(llvm::sys::path::filename(SM->getFilename(L))) + Delimiter + + CheckerName + Delimiter + + GetEnclosingDeclContextSignature(DeclWithIssue) + Delimiter + + std::to_string(L.getExpansionColumnNumber()) + Delimiter + + NormalizeLine(SM, L, DeclWithIssue) + Delimiter + + BugType.str()).str()); } Index: lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp =================================================================== --- lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp +++ lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp @@ -252,8 +252,8 @@ os << "\n\n"; - os << "\n\n"; os << "\n