]> granicus.if.org Git - clang/commitdiff
clang-format: Don't use incorrect space in macro calls with operators.
authorDaniel Jasper <djasper@google.com>
Fri, 20 Nov 2015 15:26:50 +0000 (15:26 +0000)
committerDaniel Jasper <djasper@google.com>
Fri, 20 Nov 2015 15:26:50 +0000 (15:26 +0000)
Before:
  MACRO(> );

After:
  MACRO(>);

Not overly important, but easy and good for symmetry reasons :-).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@253669 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Format/TokenAnnotator.cpp
unittests/Format/FormatTest.cpp

index 70ff7d8b9e4dd27ea18e26b13f4c9bb38c718032..751b070cdf92124ab2fd0ad24da57ba8475e2245 100644 (file)
@@ -2047,7 +2047,8 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line,
   if ((Left.is(TT_TemplateOpener)) != (Right.is(TT_TemplateCloser)))
     return Style.SpacesInAngles;
   if ((Right.is(TT_BinaryOperator) && !Left.is(tok::l_paren)) ||
-      Left.isOneOf(TT_BinaryOperator, TT_ConditionalExpr))
+      (Left.isOneOf(TT_BinaryOperator, TT_ConditionalExpr) &&
+       !Right.is(tok::r_paren)))
     return true;
   if (Left.is(TT_TemplateCloser) && Right.is(tok::l_paren) &&
       Right.isNot(TT_FunctionTypeLParen))
index 1c5e63b3e081b0d8eae45ae94bbb0005116e6641..f0646c62e1ee2e7f23da6146593a17f1fc21d176 100644 (file)
@@ -2927,6 +2927,8 @@ TEST_F(FormatTest, MacroCallsWithoutTrailingSemicolon) {
                    "  EXCLUSIVE_LOCK_FUNCTION(mu_);\n"
                    "};",
                    getLLVMStyleWithColumns(40)));
+
+  verifyFormat("MACRO(>)");
 }
 
 TEST_F(FormatTest, LayoutMacroDefinitionsStatementsSpanningBlocks) {