From d1debfc2bb8f8bd87652d3938626a093cf1e5d5a Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Wed, 21 Jan 2015 18:04:02 +0000 Subject: [PATCH] clang-format: Fix bad memory access. llvm-svn: 226680 --- clang/lib/Format/TokenAnnotator.cpp | 1 + clang/unittests/Format/FormatTest.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index df6bfd3..91aeb73 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/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/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 3aa5346..bb8f5bc 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/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) { -- 2.7.4