]> granicus.if.org Git - clang/commitdiff
clang-format: Fix crasher.
authorDaniel Jasper <djasper@google.com>
Tue, 17 Feb 2015 09:58:03 +0000 (09:58 +0000)
committerDaniel Jasper <djasper@google.com>
Tue, 17 Feb 2015 09:58:03 +0000 (09:58 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@229485 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Format/ContinuationIndenter.cpp
unittests/Format/FormatTest.cpp

index fa7c7f1d5d8c004db721d6f4558ab13caf6dfe83..a02cb68072899c92865c138b6fdd24f036c40023 100644 (file)
@@ -365,7 +365,7 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
       const FormatToken *Next = Previous.MatchingParen->getNextNonComment();
       HasTrailingCall = Next && Next->isMemberAccess();
     }
-    if (HasTrailingCall &&
+    if (HasTrailingCall && State.Stack.size() > 1 &&
         State.Stack[State.Stack.size() - 2].CallContinuation == 0)
       State.Stack.back().LastSpace = State.Column;
   }
index 242d2ba15e8a09f31bf646f02fad8d2a0ba21beb..52761f163ac3ab71a7f0746b35350cbeaad8d9b0 100644 (file)
@@ -5818,6 +5818,7 @@ TEST_F(FormatTest, IncorrectAccessSpecifier) {
 TEST_F(FormatTest, IncorrectCodeUnbalancedBraces) {
   verifyFormat("{");
   verifyFormat("#})");
+  verifyNoCrash("(/**/[:!] ?[).");
 }
 
 TEST_F(FormatTest, IncorrectCodeDoNoWhile) {