mattsta updated this revision to Diff 43748.
mattsta added a comment.

Updated to include fix for:

  Assertion failed: (InitialLoc.isValid()), function checkStmt, file 
../llvm/tools/clang/tools/extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp,
 line 226.


Repository:
  rL LLVM

http://reviews.llvm.org/D15797

Files:
  BracesAroundStatementsCheck.cpp

Index: BracesAroundStatementsCheck.cpp
===================================================================
--- BracesAroundStatementsCheck.cpp
+++ BracesAroundStatementsCheck.cpp
@@ -143,14 +143,14 @@
   } else if (auto S = Result.Nodes.getNodeAs<DoStmt>("do")) {
     checkStmt(Result, S->getBody(), S->getDoLoc(), S->getWhileLoc());
   } else if (auto S = Result.Nodes.getNodeAs<WhileStmt>("while")) {
-    SourceLocation StartLoc = findRParenLoc(S, SM, Context);
-    if (StartLoc.isInvalid())
+    if (S->getCond()->getLocStart().isInvalid())
       return;
+    SourceLocation StartLoc = findRParenLoc(S, SM, Context);
     checkStmt(Result, S->getBody(), StartLoc);
   } else if (auto S = Result.Nodes.getNodeAs<IfStmt>("if")) {
-    SourceLocation StartLoc = findRParenLoc(S, SM, Context);
-    if (StartLoc.isInvalid())
+    if (S->getCond()->getLocStart().isInvalid())
       return;
+    SourceLocation StartLoc = findRParenLoc(S, SM, Context);
     if (ForceBracesStmts.erase(S))
       ForceBracesStmts.insert(S->getThen());
     bool BracedIf = checkStmt(Result, S->getThen(), StartLoc, S->getElseLoc());
@@ -219,7 +219,7 @@
   CharSourceRange FileRange = Lexer::makeFileCharRange(
       CharSourceRange::getTokenRange(S->getSourceRange()), SM,
       Context->getLangOpts());
-  if (FileRange.isInvalid())
+  if (FileRange.isInvalid() || InitialLoc.isInvalid())
     return false;
 
   // InitialLoc points at the last token before opening brace to be inserted.


Index: BracesAroundStatementsCheck.cpp
===================================================================
--- BracesAroundStatementsCheck.cpp
+++ BracesAroundStatementsCheck.cpp
@@ -143,14 +143,14 @@
   } else if (auto S = Result.Nodes.getNodeAs<DoStmt>("do")) {
     checkStmt(Result, S->getBody(), S->getDoLoc(), S->getWhileLoc());
   } else if (auto S = Result.Nodes.getNodeAs<WhileStmt>("while")) {
-    SourceLocation StartLoc = findRParenLoc(S, SM, Context);
-    if (StartLoc.isInvalid())
+    if (S->getCond()->getLocStart().isInvalid())
       return;
+    SourceLocation StartLoc = findRParenLoc(S, SM, Context);
     checkStmt(Result, S->getBody(), StartLoc);
   } else if (auto S = Result.Nodes.getNodeAs<IfStmt>("if")) {
-    SourceLocation StartLoc = findRParenLoc(S, SM, Context);
-    if (StartLoc.isInvalid())
+    if (S->getCond()->getLocStart().isInvalid())
       return;
+    SourceLocation StartLoc = findRParenLoc(S, SM, Context);
     if (ForceBracesStmts.erase(S))
       ForceBracesStmts.insert(S->getThen());
     bool BracedIf = checkStmt(Result, S->getThen(), StartLoc, S->getElseLoc());
@@ -219,7 +219,7 @@
   CharSourceRange FileRange = Lexer::makeFileCharRange(
       CharSourceRange::getTokenRange(S->getSourceRange()), SM,
       Context->getLangOpts());
-  if (FileRange.isInvalid())
+  if (FileRange.isInvalid() || InitialLoc.isInvalid())
     return false;
 
   // InitialLoc points at the last token before opening brace to be inserted.
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to