diff options
author | Manuel Klimek <klimek@google.com> | 2013-01-11 19:23:05 +0000 |
---|---|---|
committer | Manuel Klimek <klimek@google.com> | 2013-01-11 19:23:05 +0000 |
commit | 6eca03fcac1e408470d48e6309a280d3681f717d (patch) | |
tree | e10c31ca7b055bc95eb2a16d764fc208568a024f /lib/Format/UnwrappedLineParser.cpp | |
parent | d5688cf3e314819ca196053ac245c19a7c321332 (diff) |
Fix crashes in UnwrappedLineParser on missing parens.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172239 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Format/UnwrappedLineParser.cpp')
-rw-r--r-- | lib/Format/UnwrappedLineParser.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp index 07ad7a7489..0c8ff89049 100644 --- a/lib/Format/UnwrappedLineParser.cpp +++ b/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(); |