Author: Owen Pan Date: 2024-11-02T14:42:41-07:00 New Revision: df232d46f5b62220073f106e960575b9cf6cc39d
URL: https://github.com/llvm/llvm-project/commit/df232d46f5b62220073f106e960575b9cf6cc39d DIFF: https://github.com/llvm/llvm-project/commit/df232d46f5b62220073f106e960575b9cf6cc39d.diff LOG: [clang-format] Don't re-annotate CaseLabelColon as ConditionalExpr (#114639) Fixes #114627. Added: Modified: clang/lib/Format/TokenAnnotator.cpp clang/unittests/Format/FormatTest.cpp Removed: ################################################################################ diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 13037b6d00604b..269cbef2720792 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -1259,7 +1259,7 @@ class AnnotatingParser { bool parseConditional() { while (CurrentToken) { - if (CurrentToken->is(tok::colon)) { + if (CurrentToken->is(tok::colon) && CurrentToken->is(TT_Unknown)) { CurrentToken->setType(TT_ConditionalExpr); next(); return true; diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index cdb68b74ca79ff..250e51b5421664 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -24393,6 +24393,8 @@ TEST_F(FormatTest, DisableRegions) { TEST_F(FormatTest, DoNotCrashOnInvalidInput) { format("? ) ="); verifyNoCrash("#define a\\\n /**/}"); + verifyNoCrash(" tst %o5 ! are we doing the gray case?\n" + "LY52: ! [internal]"); } TEST_F(FormatTest, FormatsTableGenCode) { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits