summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/UnwrappedLineParser.cpp
diff options
context:
space:
mode:
authorManuel Klimek <klimek@google.com>2013-01-11 19:23:05 +0000
committerManuel Klimek <klimek@google.com>2013-01-11 19:23:05 +0000
commit9fa8d5578d78be6b3a540e862de91cc29723b1ac (patch)
tree3b5f92faf93dd77664ae2d65ae9d9ee2384066a0 /clang/lib/Format/UnwrappedLineParser.cpp
parent2acb7b7bb14ced179f3d664337dc069bab9f4e89 (diff)
downloadbcm5719-llvm-9fa8d5578d78be6b3a540e862de91cc29723b1ac.tar.gz
bcm5719-llvm-9fa8d5578d78be6b3a540e862de91cc29723b1ac.zip
Fix crashes in UnwrappedLineParser on missing parens.
llvm-svn: 172239
Diffstat (limited to 'clang/lib/Format/UnwrappedLineParser.cpp')
-rw-r--r--clang/lib/Format/UnwrappedLineParser.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp
index 07ad7a7489e..0c8ff890491 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -450,7 +450,8 @@ void UnwrappedLineParser::parseForOrWhileLoop() {
assert((FormatTok.Tok.is(tok::kw_for) || FormatTok.Tok.is(tok::kw_while)) &&
"'for' or 'while' expected");
nextToken();
- parseParens();
+ if (FormatTok.Tok.is(tok::l_paren))
+ parseParens();
if (FormatTok.Tok.is(tok::l_brace)) {
parseBlock();
addUnwrappedLine();
@@ -510,7 +511,8 @@ void UnwrappedLineParser::parseCaseLabel() {
void UnwrappedLineParser::parseSwitch() {
assert(FormatTok.Tok.is(tok::kw_switch) && "'switch' expected");
nextToken();
- parseParens();
+ if (FormatTok.Tok.is(tok::l_paren))
+ parseParens();
if (FormatTok.Tok.is(tok::l_brace)) {
parseBlock(Style.IndentCaseLabels ? 2 : 1);
addUnwrappedLine();
OpenPOWER on IntegriCloud