[PATCH] D18210: [analyzer] Fix an assertion fail in hash generation.

Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 30 03:14:12 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL264851: [analyzer] Fix an assertion fail in hash generation. (authored by xazax).

Changed prior to commit:
  http://reviews.llvm.org/D18210?vs=50819&id=52033#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D18210

Files:
  cfe/trunk/lib/StaticAnalyzer/Core/IssueHash.cpp

Index: cfe/trunk/lib/StaticAnalyzer/Core/IssueHash.cpp
===================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/IssueHash.cpp
+++ cfe/trunk/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 =


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18210.52033.patch
Type: text/x-patch
Size: 758 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160330/06a4ef64/attachment.bin>


More information about the cfe-commits mailing list