From a3933711ef0e05f68496d5bf09aeff328e45e1b3 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Mon, 24 Aug 2015 13:23:37 +0000 Subject: [PATCH] clang-format: Properly handle braced lists in macros. Before: #define A \ { a, a } \ , After: #define A {a, a}, git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@245837 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/UnwrappedLineParser.cpp | 2 ++ unittests/Format/FormatTest.cpp | 1 + 2 files changed, 3 insertions(+) diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp index 1bea7a9500..e628072c63 100644 --- a/lib/Format/UnwrappedLineParser.cpp +++ b/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/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 3f1dc59d93..0f4e46436b 100644 --- a/unittests/Format/FormatTest.cpp +++ b/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(); -- 2.50.1