[PATCH] D118969: [clang-format][NFC] Fix a bug in setting type FunctionLBrace

Owen Pan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 3 21:49:26 PST 2022


owenpan created this revision.
owenpan added reviewers: curdeius, MyDeveloperDay, HazardyKnusperkeks.
owenpan added a project: clang-format.
owenpan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The `l_brace` token in a macro definition should not be set to `TT_FunctionLBrace`.

This patch could have fixed https://github.com/llvm/llvm-project/issues/42087.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D118969

Files:
  clang/lib/Format/UnwrappedLineParser.cpp


Index: clang/lib/Format/UnwrappedLineParser.cpp
===================================================================
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1571,7 +1571,8 @@
         } else if (Style.BraceWrapping.AfterFunction) {
           addUnwrappedLine();
         }
-        FormatTok->setType(TT_FunctionLBrace);
+        if (!Line->InPPDirective)
+          FormatTok->setType(TT_FunctionLBrace);
         parseBlock();
         addUnwrappedLine();
         return;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118969.405869.patch
Type: text/x-patch
Size: 529 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220204/34b56f05/attachment.bin>


More information about the cfe-commits mailing list