summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/ContinuationIndenter.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-08-28 09:17:37 +0000
committerDaniel Jasper <djasper@google.com>2013-08-28 09:17:37 +0000
commit96df37a6a14929ed3bb0cc2b736445f28775d671 (patch)
tree95548dda9273cf72d4435a97d37289a297ff8c3f /clang/lib/Format/ContinuationIndenter.cpp
parenta49393f54de2f9944972c7b52789ab4ac120353e (diff)
downloadbcm5719-llvm-96df37a6a14929ed3bb0cc2b736445f28775d671.tar.gz
bcm5719-llvm-96df37a6a14929ed3bb0cc2b736445f28775d671.zip
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. llvm-svn: 189460
Diffstat (limited to 'clang/lib/Format/ContinuationIndenter.cpp')
-rw-r--r--clang/lib/Format/ContinuationIndenter.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp
index 199fc022048..798e4f3aecd 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -536,9 +536,10 @@ unsigned ContinuationIndenter::moveStateToNextToken(LineState &State,
// 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;
}
OpenPOWER on IntegriCloud