From ca7bd720eb64b80bbe07322be94a327a2823dd9f Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Mon, 1 Jul 2013 16:43:38 +0000 Subject: Fix incorrect token counting introduced by r185319. This lead to weird formatting. Before: DoSomethingWithVector({ {} /* No data */ }, { { 1, 2 } }); After: DoSomethingWithVector({ {} /* No data */ }, { { 1, 2 } }); llvm-svn: 185346 --- clang/lib/Format/UnwrappedLineParser.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'clang/lib/Format/UnwrappedLineParser.cpp') diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index 170c8926091..98a5a8ae075 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -257,8 +257,10 @@ void UnwrappedLineParser::calculateBraceTypes() { 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 @@ void UnwrappedLineParser::calculateBraceTypes() { 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) { -- cgit v1.2.3