r185319 - Fix braced-list detection in lieu of trailing comments.
Daniel Jasper
djasper at google.com
Mon Jul 1 02:15:47 PDT 2013
Author: djasper
Date: Mon Jul 1 04:15:46 2013
New Revision: 185319
URL: http://llvm.org/viewvc/llvm-project?rev=185319&view=rev
Log:
Fix braced-list detection in lieu of trailing comments.
Before:
DoSomethingWithVector({
} /* No data */);
After:
DoSomethingWithVector({} /* No data */);
Modified:
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=185319&r1=185318&r2=185319&view=diff
==============================================================================
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Mon Jul 1 04:15:46 2013
@@ -255,7 +255,12 @@ void UnwrappedLineParser::calculateBrace
SmallVector<unsigned, 8> LBraceStack;
assert(Tok->Tok.is(tok::l_brace));
do {
- FormatToken *NextTok = Tokens->getNextToken();
+ // Get next none-comment token.
+ FormatToken *NextTok;
+ do {
+ NextTok = Tokens->getNextToken();
+ } while (NextTok->is(tok::comment));
+
switch (Tok->Tok.getKind()) {
case tok::l_brace:
LBraceStack.push_back(Position);
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=185319&r1=185318&r2=185319&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Jul 1 04:15:46 2013
@@ -3641,6 +3641,7 @@ TEST_F(FormatTest, LayoutCxx11Constructo
" aaaaaaaaaaaaaaaaaaaa, aaaaa }\n"
" : vector<int>{ bbbbbbbbbbbbbbbbbbbbbbbbbbb,\n"
" bbbbbbbbbbbbbbbbbbbb, bbbbb };");
+ verifyFormat("DoSomethingWithVector({} /* No data */);");
FormatStyle NoSpaces = getLLVMStyle();
NoSpaces.SpacesInBracedLists = false;
More information about the cfe-commits
mailing list