From: Daniel Jasper Date: Tue, 16 Sep 2014 16:36:57 +0000 (+0000) Subject: clang-format: Allow unbroken ::: in inline assembly. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ac1430893ac4c83edcc9ab44bbf8691e588ff1e1;p=clang clang-format: Allow unbroken ::: in inline assembly. Before: asm volatile("nop" :: : "memory"); After: asm volatile("nop" ::: "memory"); Patch by Eugene Toder. Thank you. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217883 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index 4c18b72d3c..db08f59b84 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -1653,6 +1653,8 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line, 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; diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 4b0791d673..7da0b534be 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -2105,6 +2105,7 @@ TEST_F(FormatTest, FormatsExternC) { verifyFormat("extern \"C\" {\nint a;"); } 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"