r270028 - clang-format: Fix incorrect indentation in last line of macro definition
Daniel Jasper via cfe-commits
cfe-commits at lists.llvm.org
Wed May 18 23:30:49 PDT 2016
Author: djasper
Date: Thu May 19 01:30:48 2016
New Revision: 270028
URL: http://llvm.org/viewvc/llvm-project?rev=270028&view=rev
Log:
clang-format: Fix incorrect indentation in last line of macro definition
Before:
#define MACRO(a) \
if (a) { \
f(); \
} else \
g()
After:
#define MACRO(a) \
if (a) { \
f(); \
} else \
g()
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=270028&r1=270027&r2=270028&view=diff
==============================================================================
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Thu May 19 01:30:48 2016
@@ -1430,6 +1430,8 @@ void UnwrappedLineParser::parseIfThenEls
addUnwrappedLine();
++Line->Level;
parseStructuralElement();
+ if (FormatTok->is(tok::eof))
+ addUnwrappedLine();
--Line->Level;
}
} else if (NeedsUnwrappedLine) {
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=270028&r1=270027&r2=270028&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Thu May 19 01:30:48 2016
@@ -2767,6 +2767,12 @@ TEST_F(FormatTest, MacroDefinitionsWithI
" case 1: \\\n"
" case 2\n",
getLLVMStyleWithColumns(20));
+ verifyFormat("#define MACRO(a) \\\n"
+ " if (a) \\\n"
+ " f(); \\\n"
+ " else \\\n"
+ " g()",
+ getLLVMStyleWithColumns(18));
verifyFormat("#define A template <typename T>");
verifyIncompleteFormat("#define STR(x) #x\n"
"f(STR(this_is_a_string_literal{));");
More information about the cfe-commits
mailing list