summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2015-08-24 13:23:37 +0000
committerDaniel Jasper <djasper@google.com>2015-08-24 13:23:37 +0000
commitb86e2727f0540917e1b29afa4377796e7e9ed41b (patch)
tree3010b03ac8a99864a68b07171c1ca98354ebdbb1
parente5197af4507c3cfe5b3af850597b841d7de404e0 (diff)
downloadbcm5719-llvm-b86e2727f0540917e1b29afa4377796e7e9ed41b.tar.gz
bcm5719-llvm-b86e2727f0540917e1b29afa4377796e7e9ed41b.zip
clang-format: Properly handle braced lists in macros.
Before: #define A \ { a, a } \ , After: #define A {a, a}, llvm-svn: 245837
-rw-r--r--clang/lib/Format/UnwrappedLineParser.cpp2
-rw-r--r--clang/unittests/Format/FormatTest.cpp1
2 files changed, 3 insertions, 0 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp
index 1bea7a9500e..e628072c639 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -284,6 +284,8 @@ void UnwrappedLineParser::parseLevel(bool HasOpeningBrace) {
case tok::l_brace:
// FIXME: Add parameter whether this can happen - if this happens, we must
// be in a non-declaration context.
+ if (!FormatTok->is(TT_MacroBlockBegin) && tryToParseBracedList())
+ continue;
parseBlock(/*MustBeDeclaration=*/false);
addUnwrappedLine();
break;
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 3f1dc59d933..0f4e46436b4 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -6144,6 +6144,7 @@ TEST_F(FormatTest, LayoutCxx11BraceInitializers) {
" void f() { int i{2}; }\n"
" };\n"
"};");
+ verifyFormat("#define A {a, a},");
// In combination with BinPackArguments = false.
FormatStyle NoBinPacking = getLLVMStyle();
OpenPOWER on IntegriCloud