Index: BracesAroundStatementsCheck.cpp =================================================================== --- BracesAroundStatementsCheck.cpp +++ BracesAroundStatementsCheck.cpp @@ -143,14 +143,14 @@ } else if (auto S = Result.Nodes.getNodeAs("do")) { checkStmt(Result, S->getBody(), S->getDoLoc(), S->getWhileLoc()); } else if (auto S = Result.Nodes.getNodeAs("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("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());