From: Daniel Jasper Date: Wed, 21 Jan 2015 18:04:02 +0000 (+0000) Subject: clang-format: Fix bad memory access. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=392682050a0557e351af968cf7d44f2bc29eb63b;p=clang clang-format: Fix bad memory access. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@226680 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index df6bfd37ae..91aeb73e55 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -683,6 +683,7 @@ private: TT_TrailingReturnArrow)) CurrentToken->Type = TT_Unknown; CurrentToken->Role.reset(); + CurrentToken->MatchingParen = nullptr; CurrentToken->FakeLParens.clear(); CurrentToken->FakeRParens = 0; } diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 3aa53465d3..bb8f5bc0b8 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -2612,6 +2612,7 @@ TEST_F(FormatTest, MacroDefinitionsWithIncompleteCode) { verifyFormat("#if \"a"); verifyNoCrash("#if a\na(\n#else\n#endif\n{a"); + verifyNoCrash("a={0,1\n#if a\n#else\n;\n#endif\n}"); } TEST_F(FormatTest, MacrosWithoutTrailingSemicolon) {