Author: owenca Date: 2025-08-26T09:00:56-07:00 New Revision: ac771f4574cc9cebfe374d6a2a631616a35fd69f
URL: https://github.com/llvm/llvm-project/commit/ac771f4574cc9cebfe374d6a2a631616a35fd69f DIFF: https://github.com/llvm/llvm-project/commit/ac771f4574cc9cebfe374d6a2a631616a35fd69f.diff LOG: [clang-format] Fix a bug in SkipMacroDefinitionBody (#155346) All comments before the macro definition body should be skipped. Added: Modified: clang/lib/Format/UnwrappedLineParser.cpp clang/unittests/Format/FormatTest.cpp Removed: ################################################################################ diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index ca7e2da3799c4..f4bbfcf8461bc 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -1207,11 +1207,8 @@ void UnwrappedLineParser::parsePPDefine() { return; } - if (auto *Prev = Tokens->getPreviousToken(); Prev->is(tok::comment) && - Prev->NewlinesBefore > 0 && - !Prev->HasUnescapedNewline) { - Prev->Finalized = true; - } + for (auto *Comment : CommentsBeforeNextToken) + Comment->Finalized = true; do { FormatTok->Finalized = true; diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 8bc4ba53c3e1a..46080c3369d36 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -25661,6 +25661,7 @@ TEST_F(FormatTest, SkipMacroDefinitionBody) { " A a", Style); verifyNoChange("#define MY_MACRO \\\n" + " /*foo*//*bar*/ \\\n" " /* comment */ \\\n" " 1", Style); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits