Index: clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp =================================================================== --- clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp +++ clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp @@ -186,6 +186,10 @@ bool BracesAroundStatementsCheck::checkStmt( const MatchFinder::MatchResult &Result, const Stmt *S, SourceLocation InitialLoc, SourceLocation EndLocHint) { + + while (const auto *AS = dyn_cast(S)) + S = AS->getSubStmt(); + // 1) If there's a corresponding "else" or "while", the check inserts "} " // right before that token. // 2) If there's a multi-line block comment starting on the same line after Index: clang-tools-extra/test/clang-tidy/checkers/readability-braces-around-statements-attributes.cpp =================================================================== --- /dev/null +++ clang-tools-extra/test/clang-tidy/checkers/readability-braces-around-statements-attributes.cpp @@ -0,0 +1,24 @@ +// RUN: %check_clang_tidy -std=c++20-or-later %s readability-braces-around-statements %t + +void test(bool b) { + if (b) { + return; + } + if (b) [[likely]] { + // CHECK-FIXES-NOT: if (b) { {{[[][[]}}likely{{[]][]]}} { + return; + } + if (b) [[unlikely]] { + // CHECK-FIXES-NOT: if (b) { {{[[][[]}}unlikely{{[]][]]}} { + return; + } + + if (b) [[likely]] + // CHECK-FIXES: if (b) {{[[][[]}}likely{{[]][]]}} { + return; + // CHECK-FIXES: } + if (b) [[unlikely]] + // CHECK-FIXES: if (b) {{[[][[]}}unlikely{{[]][]]}} { + return; + // CHECK-FIXES: } +}