Fix incorrect token counting introduced by r185319.
This lead to weird formatting.
Before:
DoSomethingWithVector({ {} /* No data */ }, {
{ 1, 2 }
});
After:
DoSomethingWithVector({ {} /* No data */ }, { { 1, 2 } });
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185346 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp
index 170c892..98a5a8a 100644
--- a/lib/Format/UnwrappedLineParser.cpp
+++ b/lib/Format/UnwrappedLineParser.cpp
@@ -257,8 +257,10 @@
do {
// Get next none-comment token.
FormatToken *NextTok;
+ unsigned ReadTokens = 0;
do {
NextTok = Tokens->getNextToken();
+ ++ReadTokens;
} while (NextTok->is(tok::comment));
switch (Tok->Tok.getKind()) {
@@ -298,7 +300,7 @@
break;
}
Tok = NextTok;
- ++Position;
+ Position += ReadTokens;
} while (Tok->Tok.isNot(tok::eof));
// Assume other blocks for all unclosed opening braces.
for (unsigned i = 0, e = LBraceStack.size(); i != e; ++i) {