diff --git a/clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp b/clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp index a9d11990c44a..9077a0275493 100644 --- a/clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp @@ -176,8 +176,6 @@ BracesAroundStatementsCheck::findRParenLoc(const IfOrWhileStmt *S, if (S->getLocStart().isMacroID()) return SourceLocation(); - static const char *const ErrorMessage = - "cannot find location of closing parenthesis ')'"; SourceLocation CondEndLoc = S->getCond()->getLocEnd(); if (const DeclStmt *CondVar = S->getConditionVariableDeclStmt()) CondEndLoc = CondVar->getLocEnd(); @@ -185,21 +183,15 @@ BracesAroundStatementsCheck::findRParenLoc(const IfOrWhileStmt *S, assert(CondEndLoc.isValid()); SourceLocation PastCondEndLoc = Lexer::getLocForEndOfToken(CondEndLoc, 0, SM, Context->getLangOpts()); - if (PastCondEndLoc.isInvalid()) { - diag(CondEndLoc, ErrorMessage); + if (PastCondEndLoc.isInvalid()) return SourceLocation(); - } SourceLocation RParenLoc = forwardSkipWhitespaceAndComments(PastCondEndLoc, SM, Context); - if (RParenLoc.isInvalid()) { - diag(PastCondEndLoc, ErrorMessage); + if (RParenLoc.isInvalid()) return SourceLocation(); - } tok::TokenKind TokKind = getTokenKind(RParenLoc, SM, Context); - if (TokKind != tok::r_paren) { - diag(RParenLoc, ErrorMessage); + if (TokKind != tok::r_paren) return SourceLocation(); - } return RParenLoc; }