xazax.hun created this revision.
xazax.hun added reviewers: dcoughlin, zaks.anna.
xazax.hun added subscribers: cfe-commits, dkrupp.
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.
This error was reproduced by an internal checker that warned when the header
guard is missing in a header. The location of the warning was the sart location
of the header file which might only contain whitespaces in some cases.
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 easy to wrote
a custom debug checker for that purpuse but I think it might not worth the
effort.
http://reviews.llvm.org/D18210
Files:
lib/StaticAnalyzer/Core/IssueHash.cpp
Index: lib/StaticAnalyzer/Core/IssueHash.cpp
===================================================================
--- lib/StaticAnalyzer/Core/IssueHash.cpp
+++ lib/StaticAnalyzer/Core/IssueHash.cpp
@@ -132,8 +132,11 @@
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 =
Index: lib/StaticAnalyzer/Core/IssueHash.cpp
===================================================================
--- lib/StaticAnalyzer/Core/IssueHash.cpp
+++ lib/StaticAnalyzer/Core/IssueHash.cpp
@@ -132,8 +132,11 @@
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 =
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits