Index: clang-tidy/readability/BracesAroundStatementsCheck.cpp =================================================================== --- clang-tidy/readability/BracesAroundStatementsCheck.cpp +++ clang-tidy/readability/BracesAroundStatementsCheck.cpp @@ -180,7 +180,10 @@ if (const DeclStmt *CondVar = S->getConditionVariableDeclStmt()) CondEndLoc = CondVar->getLocEnd(); - assert(CondEndLoc.isValid()); + if (!CondEndLoc.isValid()) { + return SourceLocation(); + } + SourceLocation PastCondEndLoc = Lexer::getLocForEndOfToken(CondEndLoc, 0, SM, Context->getLangOpts()); if (PastCondEndLoc.isInvalid()) 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' + } +}