r217883 - clang-format: Allow unbroken ::: in inline assembly.

Daniel Jasper djasper at google.com
Tue Sep 16 09:36:58 PDT 2014


Author: djasper
Date: Tue Sep 16 11:36:57 2014
New Revision: 217883

URL: http://llvm.org/viewvc/llvm-project?rev=217883&view=rev
Log:
clang-format: Allow unbroken ::: in inline assembly.

Before:
  asm volatile("nop" :: : "memory");

After:
  asm volatile("nop" ::: "memory");

Patch by Eugene Toder. Thank you.

Modified:
    cfe/trunk/lib/Format/TokenAnnotator.cpp
    cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=217883&r1=217882&r2=217883&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Tue Sep 16 11:36:57 2014
@@ -1653,6 +1653,8 @@ bool TokenAnnotator::spaceRequiredBefore
     return !Line.First->isOneOf(tok::kw_case, tok::kw_default) &&
            Tok.getNextNonComment() && Tok.Type != TT_ObjCMethodExpr &&
            !Tok.Previous->is(tok::question) &&
+           !(Tok.Type == TT_InlineASMColon &&
+             Tok.Previous->is(tok::coloncolon)) &&
            (Tok.Type != TT_DictLiteral || Style.SpacesInContainerLiterals);
   if (Tok.Previous->Type == TT_UnaryOperator)
     return Tok.Type == TT_BinaryOperator;

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=217883&r1=217882&r2=217883&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Tue Sep 16 11:36:57 2014
@@ -2105,6 +2105,7 @@ TEST_F(FormatTest, FormatsExternC) { ver
 
 TEST_F(FormatTest, FormatsInlineASM) {
   verifyFormat("asm(\"xyz\" : \"=a\"(a), \"=d\"(b) : \"a\"(data));");
+  verifyFormat("asm(\"nop\" ::: \"memory\");");
   verifyFormat(
       "asm(\"movq\\t%%rbx, %%rsi\\n\\t\"\n"
       "    \"cpuid\\n\\t\"\n"





More information about the cfe-commits mailing list