Index: clang-tidy/readability/BracesAroundStatementsCheck.cpp =================================================================== --- clang-tidy/readability/BracesAroundStatementsCheck.cpp +++ clang-tidy/readability/BracesAroundStatementsCheck.cpp @@ -176,6 +176,11 @@ if (S->getLocStart().isMacroID()) return SourceLocation(); + // Ignore cases that there are parsing errors in condition expression of + // IfStmt. Avoid triggering assert failure. + if (isa(S->getCond())) + return SourceLocation(); + SourceLocation CondEndLoc = S->getCond()->getLocEnd(); if (const DeclStmt *CondVar = S->getConditionVariableDeclStmt()) CondEndLoc = CondVar->getLocEnd(); Index: test/clang-tidy/readability-braces-around-statements-assert-failure.cpp =================================================================== --- /dev/null +++ test/clang-tidy/readability-braces-around-statements-assert-failure.cpp @@ -0,0 +1,7 @@ +// RUN: %check_clang_tidy %s readability-braces-around-statements %t + +int test_failure() { + if (std::rand()) { + // CHECK-MESSAGES: :[[@LINE-1]]:7: error: use of undeclared identifier 'std' + } +}