summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Format/UnwrappedLineParser.cpp4
-rw-r--r--clang/unittests/Format/FormatTest.cpp8
2 files changed, 10 insertions, 2 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp
index e06903c306c..ac534a2abe5 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -321,7 +321,7 @@ void UnwrappedLineParser::calculateBraceTypes(bool ExpectClassBody) {
SmallVector<FormatToken *, 8> LBraceStack;
assert(Tok->Tok.is(tok::l_brace));
do {
- // Get next none-comment token.
+ // Get next non-comment token.
FormatToken *NextTok;
unsigned ReadTokens = 0;
do {
@@ -403,6 +403,7 @@ void UnwrappedLineParser::parseBlock(bool MustBeDeclaration, bool AddLevel,
assert(FormatTok->isOneOf(tok::l_brace, TT_MacroBlockBegin) &&
"'{' or macro block token expected");
const bool MacroBlock = FormatTok->is(TT_MacroBlockBegin);
+ FormatTok->BlockKind = BK_Block;
unsigned InitialLevel = Line->Level;
nextToken();
@@ -421,6 +422,7 @@ void UnwrappedLineParser::parseBlock(bool MustBeDeclaration, bool AddLevel,
if (MacroBlock ? !FormatTok->is(TT_MacroBlockEnd)
: !FormatTok->is(tok::r_brace)) {
Line->Level = InitialLevel;
+ FormatTok->BlockKind = BK_Block;
return;
}
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 1f09ee3d513..6245f8c0434 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -313,7 +313,7 @@ TEST_F(FormatTest, FormatIfWithoutCompoundStatement) {
" f();\n"
"}",
AllowsMergedIf);
- verifyFormat("if (a) {/* Never merge this */\n"
+ verifyFormat("if (a) { /* Never merge this */\n"
" f();\n"
"}",
AllowsMergedIf);
@@ -6532,6 +6532,12 @@ TEST_F(FormatTest, FormatsBracedListsInColumnLayout) {
" bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb};");
verifyNoCrash("a<,");
+
+ // No braced initializer here.
+ verifyFormat("void f() {\n"
+ " struct Dummy {};\n"
+ " f(v);\n"
+ "}");
}
TEST_F(FormatTest, PullTrivialFunctionDefinitionsIntoSingleLine) {
OpenPOWER on IntegriCloud