clang-format: Fix segfault in 'incomplete' macros.
The code leading to a segfault was:
#pragma omp threadprivate(y)), // long comment leading to a line break
This fixes llvm.org/PR16513.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189460 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Format/ContinuationIndenter.cpp b/lib/Format/ContinuationIndenter.cpp
index 199fc02..798e4f3 100644
--- a/lib/Format/ContinuationIndenter.cpp
+++ b/lib/Format/ContinuationIndenter.cpp
@@ -536,9 +536,10 @@
// If we encounter a closing ), ], } or >, we can remove a level from our
// stacks.
- if (Current.isOneOf(tok::r_paren, tok::r_square) ||
- (Current.is(tok::r_brace) && State.NextToken != Line.First) ||
- State.NextToken->Type == TT_TemplateCloser) {
+ if (State.Stack.size() > 1 &&
+ (Current.isOneOf(tok::r_paren, tok::r_square) ||
+ (Current.is(tok::r_brace) && State.NextToken != Line.First) ||
+ State.NextToken->Type == TT_TemplateCloser)) {
State.Stack.pop_back();
--State.ParenLevel;
}