[PATCH] Remove an unnecessary check for FormatTok not being null.

Alexander Kornienko alexfh at google.com
Tue Mar 11 06:43:54 PDT 2014


Hi djasper,

This check hints clang analyzer, that FormatTok may be null, and it
reports a null pointer dereference error:
http://buildd-clang.debian.net/scan-build/report-827c64.html#Path28

http://llvm-reviews.chandlerc.com/D3040

Files:
  lib/Format/UnwrappedLineParser.cpp

Index: lib/Format/UnwrappedLineParser.cpp
===================================================================
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -768,7 +768,7 @@
   if (!tryToParseLambdaIntroducer())
     return false;
 
-  while (FormatTok && FormatTok->isNot(tok::l_brace)) {
+  while (FormatTok->isNot(tok::l_brace)) {
     if (FormatTok->isSimpleTypeSpecifier()) {
       nextToken();
       continue;
@@ -1367,6 +1367,7 @@
   bool CommentsInCurrentLine = true;
   do {
     FormatTok = Tokens->getNextToken();
+    assert(FormatTok);
     while (!Line->InPPDirective && FormatTok->Tok.is(tok::hash) &&
            (FormatTok->HasUnescapedNewline || FormatTok->IsFirst)) {
       // If there is an unfinished unwrapped line, we flush the preprocessor
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D3040.1.patch
Type: text/x-patch
Size: 801 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140311/812aed0f/attachment.bin>


More information about the cfe-commits mailing list