summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer/Core/IssueHash.cpp
diff options
context:
space:
mode:
authorGabor Horvath <xazax.hun@gmail.com>2015-12-01 09:00:41 +0000
committerGabor Horvath <xazax.hun@gmail.com>2015-12-01 09:00:41 +0000
commitfe2c0ff942e8c9f407b2e669d366eb855ba0e127 (patch)
tree84ee9c786953ecccbed0a18c36864ad444d42650 /clang/lib/StaticAnalyzer/Core/IssueHash.cpp
parentb4a09278533a26371d89572f376bb75ff605240b (diff)
downloadbcm5719-llvm-fe2c0ff942e8c9f407b2e669d366eb855ba0e127.tar.gz
bcm5719-llvm-fe2c0ff942e8c9f407b2e669d366eb855ba0e127.zip
[analyzer] Fix IssueHash generation.
Differential Revision: http://reviews.llvm.org/D14919 Original patch by: Gyorgy Orban! llvm-svn: 254394
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/IssueHash.cpp')
-rw-r--r--clang/lib/StaticAnalyzer/Core/IssueHash.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/IssueHash.cpp b/clang/lib/StaticAnalyzer/Core/IssueHash.cpp
index abe20d6774f..0a3af3dcc7e 100644
--- a/clang/lib/StaticAnalyzer/Core/IssueHash.cpp
+++ b/clang/lib/StaticAnalyzer/Core/IssueHash.cpp
@@ -127,14 +127,13 @@ static StringRef GetNthLineOfFile(llvm::MemoryBuffer *Buffer, int Line) {
}
static std::string NormalizeLine(const SourceManager &SM, FullSourceLoc &L,
- const Decl *D) {
+ const LangOptions &LangOpts) {
static StringRef Whitespaces = " \t\n";
- const LangOptions &Opts = D->getASTContext().getLangOpts();
StringRef Str = GetNthLineOfFile(SM.getBuffer(L.getFileID(), L),
L.getExpansionLineNumber());
unsigned col = Str.find_first_not_of(Whitespaces);
-
+ col++;
SourceLocation StartOfLine =
SM.translateLineCol(SM.getFileID(L), L.getExpansionLineNumber(), col);
llvm::MemoryBuffer *Buffer =
@@ -145,7 +144,7 @@ static std::string NormalizeLine(const SourceManager &SM, FullSourceLoc &L,
const char *BufferPos = SM.getCharacterData(StartOfLine);
Token Token;
- Lexer Lexer(SM.getLocForStartOfFile(SM.getFileID(StartOfLine)), Opts,
+ Lexer Lexer(SM.getLocForStartOfFile(SM.getFileID(StartOfLine)), LangOpts,
Buffer->getBufferStart(), BufferPos, Buffer->getBufferEnd());
size_t NextStart = 0;
@@ -175,20 +174,23 @@ static llvm::SmallString<32> GetHashOfContent(StringRef Content) {
std::string clang::GetIssueString(const SourceManager &SM,
FullSourceLoc &IssueLoc,
StringRef CheckerName, StringRef BugType,
- const Decl *D) {
+ const Decl *D,
+ const LangOptions &LangOpts) {
static StringRef Delimiter = "$";
return (llvm::Twine(CheckerName) + Delimiter +
GetEnclosingDeclContextSignature(D) + Delimiter +
llvm::utostr(IssueLoc.getExpansionColumnNumber()) + Delimiter +
- NormalizeLine(SM, IssueLoc, D) + Delimiter + BugType)
+ NormalizeLine(SM, IssueLoc, LangOpts) + Delimiter + BugType)
.str();
}
SmallString<32> clang::GetIssueHash(const SourceManager &SM,
FullSourceLoc &IssueLoc,
StringRef CheckerName, StringRef BugType,
- const Decl *D) {
+ const Decl *D,
+ const LangOptions &LangOpts) {
+
return GetHashOfContent(
- GetIssueString(SM, IssueLoc, CheckerName, BugType, D));
+ GetIssueString(SM, IssueLoc, CheckerName, BugType, D, LangOpts));
}
OpenPOWER on IntegriCloud