diff options
author | Gabor Horvath <xazax.hun@gmail.com> | 2016-03-30 10:08:59 +0000 |
---|---|---|
committer | Gabor Horvath <xazax.hun@gmail.com> | 2016-03-30 10:08:59 +0000 |
commit | a26e4e76c2abe29a074fac69ae56575a5d050333 (patch) | |
tree | bf57a084988a296d826bd42c3453f0bdf1918281 /lib/StaticAnalyzer/Core/IssueHash.cpp | |
parent | 8d88a9262fa0065d980f1c25893d6a4bae6be665 (diff) | |
download | clang-a26e4e76c2abe29a074fac69ae56575a5d050333.tar.gz |
[analyzer] Fix an assertion fail in hash generation.
In case the (uniqueing) location of the diagnostic is in a line that only
contains whitespaces there was an assertion fail during issue hash generation.
Unfortunately I am unable to reproduce this error with the built in checkers,
so no there is no failing test case with this patch. It would be possible to
write a debug checker for that purpuse but it does not worth the effort.
Differential Revision: http://reviews.llvm.org/D18210
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@264851 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, 5 insertions, 2 deletions
diff --git a/lib/StaticAnalyzer/Core/IssueHash.cpp b/lib/StaticAnalyzer/Core/IssueHash.cpp index c352f12111..bd5c81179a 100644 --- a/lib/StaticAnalyzer/Core/IssueHash.cpp +++ b/lib/StaticAnalyzer/Core/IssueHash.cpp @@ -132,8 +132,11 @@ static std::string NormalizeLine(const SourceManager &SM, FullSourceLoc &L, StringRef Str = GetNthLineOfFile(SM.getBuffer(L.getFileID(), L), L.getExpansionLineNumber()); - unsigned col = Str.find_first_not_of(Whitespaces); - col++; + StringRef::size_type col = Str.find_first_not_of(Whitespaces); + if (col == StringRef::npos) + col = 1; // The line only contains whitespace. + else + col++; SourceLocation StartOfLine = SM.translateLineCol(SM.getFileID(L), L.getExpansionLineNumber(), col); llvm::MemoryBuffer *Buffer = |