owenpan created this revision. owenpan added reviewers: sstwcw, HazardyKnusperkeks, MyDeveloperDay, rymiel. owenpan added a project: clang-format. Herald added a project: All. owenpan requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
This assertion failure was introduced in 9ed2e68c9ae5 <https://reviews.llvm.org/rG9ed2e68c9ae5cf346f938cc095e5448c1ff60f51> and is manifested when both RemoveBracesLLVM and MacroBlockBegin are set. Fixes https://github.com/llvm/llvm-project/issues/59335. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D139281 Files: clang/lib/Format/FormatToken.h clang/unittests/Format/FormatTest.cpp Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -6602,6 +6602,13 @@ " x = 1;\n" "FOO_END(Baz)", Style); + + Style.RemoveBracesLLVM = true; + verifyNoCrash("for (;;)\n" + " FOO_BEGIN\n" + " foo();\n" + " FOO_END", + Style); } //===----------------------------------------------------------------------===// Index: clang/lib/Format/FormatToken.h =================================================================== --- clang/lib/Format/FormatToken.h +++ clang/lib/Format/FormatToken.h @@ -1787,8 +1787,7 @@ /// Whether the token begins a block. bool isBlockBegin(const FormatToken &Tok, const FormatStyle &Style) const { - return Tok.is(TT_MacroBlockBegin) || - (Style.isVerilog() ? isVerilogBegin(Tok) : Tok.is(tok::l_brace)); + return Style.isVerilog() ? isVerilogBegin(Tok) : Tok.is(tok::l_brace); } private:
Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -6602,6 +6602,13 @@ " x = 1;\n" "FOO_END(Baz)", Style); + + Style.RemoveBracesLLVM = true; + verifyNoCrash("for (;;)\n" + " FOO_BEGIN\n" + " foo();\n" + " FOO_END", + Style); } //===----------------------------------------------------------------------===// Index: clang/lib/Format/FormatToken.h =================================================================== --- clang/lib/Format/FormatToken.h +++ clang/lib/Format/FormatToken.h @@ -1787,8 +1787,7 @@ /// Whether the token begins a block. bool isBlockBegin(const FormatToken &Tok, const FormatStyle &Style) const { - return Tok.is(TT_MacroBlockBegin) || - (Style.isVerilog() ? isVerilogBegin(Tok) : Tok.is(tok::l_brace)); + return Style.isVerilog() ? isVerilogBegin(Tok) : Tok.is(tok::l_brace); } private:
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits