Thank you. Now with a test.

Eugene


On Mon, Sep 15, 2014 at 6:10 PM, Daniel Jasper <[email protected]> wrote:

> I think the change itself look good (although I don't use inline assembly
> much). Please add a test.
>
> On Mon, Sep 15, 2014 at 11:14 PM, Eugene Toder <[email protected]> wrote:
>
>> Hello,
>>
>> When inline assembly has only clobber constraints it's common to write
>> all three colons without spaces, for example:
>>
>> asm volatile("nop" ::: "memory");
>>
>> Currently clang-format splits ::: into coloncolon and colon, and inserts
>> a space before the colon, which looks strange:
>>
>> asm volatile("nop" :: : "memory");
>>
>> I suggest to allow having ::: without spaces in this case. Attached is a
>> simple patch to that effect.
>>
>> Thanks,
>> Eugene
>>
>> _______________________________________________
>> cfe-commits mailing list
>> [email protected]
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>>
>>
>
diff --git a/llvm/tools/clang/lib/Format/TokenAnnotator.cpp b/llvm/tools/clang/lib/Format/TokenAnnotator.cpp
index 4f3ec0b..94cb99c 100644
--- a/llvm/tools/clang/lib/Format/TokenAnnotator.cpp
+++ b/llvm/tools/clang/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/llvm/tools/clang/test/Format/asm.cpp b/llvm/tools/clang/test/Format/asm.cpp
new file mode 100644
index 0000000..be4533d
--- /dev/null
+++ b/llvm/tools/clang/test/Format/asm.cpp
@@ -0,0 +1,6 @@
+// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
+// RUN: clang-format -style=LLVM -i %t.cpp
+// RUN: FileCheck -strict-whitespace -input-file=%t.cpp %s
+
+// CHECK: {{^asm\("nop"\ :::\ "memory"\);}}
+asm("nop" ::: "memory");
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to