From: Daniel Jasper Date: Wed, 21 Jan 2015 18:35:47 +0000 (+0000) Subject: clang-format: Fix crasher caused by incorrect resetting of token info. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a569ace3d10e764fdd02f30ebbb9c0504710b740;p=clang clang-format: Fix crasher caused by incorrect resetting of token info. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@226685 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/TokenAnnotator.h b/lib/Format/TokenAnnotator.h index 8aa163aff6..f9e1efa31b 100644 --- a/lib/Format/TokenAnnotator.h +++ b/lib/Format/TokenAnnotator.h @@ -75,6 +75,7 @@ public: FormatToken *Current = First; while (Current) { Current->Children.clear(); + Current->Role.reset(); Current = Current->Next; } } diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index bb8f5bc0b8..553368d563 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -2613,6 +2613,7 @@ TEST_F(FormatTest, MacroDefinitionsWithIncompleteCode) { verifyNoCrash("#if a\na(\n#else\n#endif\n{a"); verifyNoCrash("a={0,1\n#if a\n#else\n;\n#endif\n}"); + verifyNoCrash("#if a\na(\n#else\n#endif\n) a {a,b,c,d,f,g};"); } TEST_F(FormatTest, MacrosWithoutTrailingSemicolon) {