summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Format/ContinuationIndenter.cpp2
-rw-r--r--clang/unittests/Format/FormatTest.cpp1
2 files changed, 2 insertions, 1 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp
index fa7c7f1d5d8..a02cb680728 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/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/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 242d2ba15e8..52761f163ac 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -5818,6 +5818,7 @@ TEST_F(FormatTest, IncorrectAccessSpecifier) {
TEST_F(FormatTest, IncorrectCodeUnbalancedBraces) {
verifyFormat("{");
verifyFormat("#})");
+ verifyNoCrash("(/**/[:!] ?[).");
}
TEST_F(FormatTest, IncorrectCodeDoNoWhile) {
OpenPOWER on IntegriCloud