r245837 - clang-format: Properly handle braced lists in macros.
Daniel Jasper via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 24 06:23:40 PDT 2015
Author: djasper
Date: Mon Aug 24 08:23:37 2015
New Revision: 245837
URL: http://llvm.org/viewvc/llvm-project?rev=245837&view=rev
Log:
clang-format: Properly handle braced lists in macros.
Before:
#define A \
{ a, a } \
,
After:
#define A {a, a},
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=245837&r1=245836&r2=245837&view=diff
==============================================================================
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Mon Aug 24 08:23:37 2015
@@ -284,6 +284,8 @@ void UnwrappedLineParser::parseLevel(boo
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;
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=245837&r1=245836&r2=245837&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Aug 24 08:23:37 2015
@@ -6144,6 +6144,7 @@ TEST_F(FormatTest, LayoutCxx11BraceIniti
" void f() { int i{2}; }\n"
" };\n"
"};");
+ verifyFormat("#define A {a, a},");
// In combination with BinPackArguments = false.
FormatStyle NoBinPacking = getLLVMStyle();
More information about the cfe-commits
mailing list