r226680 - clang-format: Fix bad memory access.

Daniel Jasper djasper at google.com
Wed Jan 21 10:04:02 PST 2015


Author: djasper
Date: Wed Jan 21 12:04:02 2015
New Revision: 226680

URL: http://llvm.org/viewvc/llvm-project?rev=226680&view=rev
Log:
clang-format: Fix bad memory access.

Modified:
    cfe/trunk/lib/Format/TokenAnnotator.cpp
    cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=226680&r1=226679&r2=226680&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Wed Jan 21 12:04:02 2015
@@ -683,6 +683,7 @@ private:
                                TT_TrailingReturnArrow))
       CurrentToken->Type = TT_Unknown;
     CurrentToken->Role.reset();
+    CurrentToken->MatchingParen = nullptr;
     CurrentToken->FakeLParens.clear();
     CurrentToken->FakeRParens = 0;
   }

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=226680&r1=226679&r2=226680&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Wed Jan 21 12:04:02 2015
@@ -2612,6 +2612,7 @@ TEST_F(FormatTest, MacroDefinitionsWithI
   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) {





More information about the cfe-commits mailing list