[clang-tools-extra] [clang-tidy] Avoid brace fix-it crash in macro body expansion (PR #198788)

Victor Chernyakin via cfe-commits cfe-commits at lists.llvm.org
Wed May 20 08:39:36 PDT 2026


================
@@ -157,6 +159,12 @@ BraceInsertionHints getBraceInsertionsHints(const Stmt *const S,
     EndLoc = EndLocHint;
     ClosingInsertion = "} ";
   } else {
+    const SourceLocation StmtEndLoc = S->getEndLoc();
+    if (StmtEndLoc.isMacroID() && SM.isMacroBodyExpansion(StmtEndLoc) &&
+        !Lexer::isAtEndOfMacroExpansion(StmtEndLoc, SM, LangOpts)) {
----------------
localspook wrote:

Is the intent to provide fix-its for cases like this?
```cpp
#define ONE_FULL_STATEMENT(x) do_something(x);
if (b)
  ONE_FULL_STATEMENT // <--- fix-it here?
```
If yes, can we add a test for that?

https://github.com/llvm/llvm-project/pull/198788


More information about the cfe-commits mailing list