summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Format/UnwrappedLineParser.cpp4
-rw-r--r--clang/unittests/Format/FormatTest.cpp1
2 files changed, 4 insertions, 1 deletions
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) {
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index affec471214..6df7e9b0e93 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -3683,6 +3683,7 @@ TEST_F(FormatTest, LayoutCxx11ConstructorBraceInitializers) {
" : vector<int>{ bbbbbbbbbbbbbbbbbbbbbbbbbbb,\n"
" bbbbbbbbbbbbbbbbbbbb, bbbbb };");
verifyFormat("DoSomethingWithVector({} /* No data */);");
+ verifyFormat("DoSomethingWithVector({ {} /* No data */ }, { { 1, 2 } });");
FormatStyle NoSpaces = getLLVMStyle();
NoSpaces.SpacesInBracedLists = false;
OpenPOWER on IntegriCloud