clang-format can't do anything useful, so it should leave the remainder
of the line unchanged, but it should not assert/segfault.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177530
91177308-0d34-0410-b5e6-
96231b3b80d8
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())
"B { int x; }");
}
-TEST_F(FormatTest, IncorrectCodeUnbalancedBraces) { verifyFormat("{"); }
+TEST_F(FormatTest, IncorrectCodeUnbalancedBraces) {
+ verifyFormat("{");
+ verifyFormat("#})");
+}
TEST_F(FormatTest, IncorrectCodeDoNoWhile) {
verifyFormat("do {\n}");