honggyu.kim updated the summary for this revision. honggyu.kim updated this revision to Diff 35070.
http://reviews.llvm.org/D12906 Files: include/clang/StaticAnalyzer/Core/BugId.h lib/StaticAnalyzer/Core/BugId.cpp lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp lib/StaticAnalyzer/Core/PlistDiagnostics.cpp utils/analyzer/CmpRuns.py
Index: utils/analyzer/CmpRuns.py =================================================================== --- utils/analyzer/CmpRuns.py +++ utils/analyzer/CmpRuns.py @@ -68,6 +68,8 @@ def getIssueIdentifier(self) : id = self.getFileName() + "+" + if 'check_name' in self._data : + id += self._data['check_name'] + "+" if 'issue_context' in self._data : id += self._data['issue_context'] + "+" if 'issue_hash' in self._data : Index: lib/StaticAnalyzer/Core/PlistDiagnostics.cpp =================================================================== --- lib/StaticAnalyzer/Core/PlistDiagnostics.cpp +++ lib/StaticAnalyzer/Core/PlistDiagnostics.cpp @@ -391,14 +391,6 @@ o << " <key>check_name</key>"; EmitString(o, D->getCheckName()) << '\n'; - o << " <key>bug_id_1</key>"; - PathDiagnosticLocation UPDLoc = D->getUniqueingLoc(); - FullSourceLoc UL(SM->getExpansionLoc(UPDLoc.asLocation()), *SM); - FullSourceLoc L(SM->getExpansionLoc(D->getLocation().asLocation()), *SM); - const Decl *DeclWithIssue = D->getDeclWithIssue(); - EmitString(o, GetIssueHash(SM, UPDLoc.isValid() ? UL : L, D->getCheckName(), - D->getBugType(), DeclWithIssue).str()) << '\n'; - // Output information about the semantic context where // the issue occurred. if (const Decl *DeclWithIssue = D->getDeclWithIssue()) { @@ -429,9 +421,9 @@ EmitString(o, declName) << '\n'; } - // Output the bug hash for issue unique-ing. Currently, it's just an - // offset from the beginning of the function. - if (const Stmt *Body = DeclWithIssue->getBody()) { + // Output the bug hash for issue unique-ing. + // Currently, it generates bugid information from GetIssueHash + if (DeclWithIssue->getBody()) { // If the bug uniqueing location exists, use it for the hash. // For example, this ensures that two leaks reported on the same line @@ -442,19 +434,18 @@ if (UPDLoc.isValid()) { FullSourceLoc UL(SM->getExpansionLoc(UPDLoc.asLocation()), *SM); - FullSourceLoc UFunL(SM->getExpansionLoc( - D->getUniqueingDecl()->getBody()->getLocStart()), *SM); o << " <key>issue_hash</key><string>" - << UL.getExpansionLineNumber() - UFunL.getExpansionLineNumber() + << GetIssueHash(SM, UL, D->getCheckName(), D->getBugType(), + DeclWithIssue) << "</string>\n"; // Otherwise, use the location on which the bug is reported. } else { FullSourceLoc L(SM->getExpansionLoc(D->getLocation().asLocation()), *SM); - FullSourceLoc FunL(SM->getExpansionLoc(Body->getLocStart()), *SM); o << " <key>issue_hash</key><string>" - << L.getExpansionLineNumber() - FunL.getExpansionLineNumber() + << GetIssueHash(SM, L, D->getCheckName(), D->getBugType(), + DeclWithIssue) << "</string>\n"; } Index: lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp =================================================================== --- lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp +++ lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp @@ -252,8 +252,8 @@ os << "\n<!-- FUNCTIONNAME " << declName << " -->\n"; - os << "\n<!-- BUGID1 " << - GetIssueHash(&SMgr, UPDLoc.isValid() ? UL : L, D.getCheckName(), D.getBugType(), DeclWithIssue).str() + os << "\n<!-- BUGID " << + GetBugIdHash(&SMgr, UPDLoc.isValid() ? UL : L, D.getCheckName(), D.getBugType(), DeclWithIssue).str() << " -->\n"; os << "\n<!-- BUGLINE " 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: 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
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits