From cb626e21eedfe0c61de90d938c58d19a6b124aeb Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Tue, 17 Feb 2015 09:58:03 +0000 Subject: [PATCH] clang-format: Fix crasher. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@229485 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/ContinuationIndenter.cpp | 2 +- unittests/Format/FormatTest.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Format/ContinuationIndenter.cpp b/lib/Format/ContinuationIndenter.cpp index fa7c7f1d5d..a02cb68072 100644 --- a/lib/Format/ContinuationIndenter.cpp +++ b/lib/Format/ContinuationIndenter.cpp @@ -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; } diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 242d2ba15e..52761f163a 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -5818,6 +5818,7 @@ TEST_F(FormatTest, IncorrectAccessSpecifier) { TEST_F(FormatTest, IncorrectCodeUnbalancedBraces) { verifyFormat("{"); verifyFormat("#})"); + verifyNoCrash("(/**/[:!] ?[)."); } TEST_F(FormatTest, IncorrectCodeDoNoWhile) { -- 2.40.0