Remove assertion that can be triggered on bad input.

clang-format can't do anything useful, so it should leave the remainder
of the line unchanged, but it should not assert/segfault.

llvm-svn: 177530
This commit is contained in:
Daniel Jasper 2013-03-20 15:58:10 +00:00
parent ed34d0ef1a
commit 291f936351
2 changed files with 5 additions and 3 deletions

View File

@ -601,9 +601,8 @@ private:
unsigned addTokenToState(bool Newline, bool DryRun, LineState &State) {
const AnnotatedToken &Current = *State.NextToken;
const AnnotatedToken &Previous = *State.NextToken->Parent;
assert(State.Stack.size());
if (Current.Type == TT_ImplicitStringLiteral) {
if (State.Stack.size() == 0 || Current.Type == TT_ImplicitStringLiteral) {
State.Column += State.NextToken->FormatTok.WhiteSpaceLength +
State.NextToken->FormatTok.TokenLength;
if (State.NextToken->Children.empty())

View File

@ -2413,7 +2413,10 @@ TEST_F(FormatTest, IncorrectAccessSpecifier) {
"B { int x; }");
}
TEST_F(FormatTest, IncorrectCodeUnbalancedBraces) { verifyFormat("{"); }
TEST_F(FormatTest, IncorrectCodeUnbalancedBraces) {
verifyFormat("{");
verifyFormat("#})");
}
TEST_F(FormatTest, IncorrectCodeDoNoWhile) {
verifyFormat("do {\n}");