r216501 - clang-format: Don't butcher __asm blocks.

Daniel Jasper djasper at google.com
Wed Aug 27 10:26:16 PDT 2014


Fixed both in r216565.


On Wed, Aug 27, 2014 at 7:22 PM, Nico Weber <thakis at chromium.org> wrote:

> Thanks! One comment below:
>
>
> On Tue, Aug 26, 2014 at 4:15 PM, Daniel Jasper <djasper at google.com> wrote:
>
>> Author: djasper
>> Date: Tue Aug 26 18:15:12 2014
>> New Revision: 216501
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=216501&view=rev
>> Log:
>> clang-format: Don't butcher __asm blocks.
>>
>> Instead completely cop out of formatting them for now.
>>
>> This fixes llvm.org/PR20618.
>>
>> 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=216501&r1=216500&r2=216501&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
>> +++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Tue Aug 26 18:15:12 2014
>> @@ -658,6 +658,21 @@ void UnwrappedLineParser::parseStructura
>>        break;
>>      }
>>      break;
>> +  case tok::kw_asm:
>> +    FormatTok->Finalized = true;
>> +    nextToken();
>> +    if (FormatTok->is(tok::l_brace)) {
>> +      FormatTok->Finalized = true;
>> +      while (FormatTok) {
>>
>
> That looks like it might be an infinite loop…yes, `echo '__asm { int 3' |
> bin/clang-format` seems to hang.
>
>
>> +        FormatTok->Finalized = true;
>> +        if (FormatTok->is(tok::r_brace)) {
>> +          nextToken();
>> +          break;
>> +        }
>> +        nextToken();
>> +      }
>> +    }
>> +    break;
>>    case tok::kw_namespace:
>>      parseNamespace();
>>      return;
>>
>> Modified: cfe/trunk/unittests/Format/FormatTest.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=216501&r1=216500&r2=216501&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/unittests/Format/FormatTest.cpp (original)
>> +++ cfe/trunk/unittests/Format/FormatTest.cpp Tue Aug 26 18:15:12 2014
>> @@ -2070,6 +2070,21 @@ TEST_F(FormatTest, FormatsInlineASM) {
>>        "    \"xchgq\\t%%rbx, %%rsi\\n\\t\"\n"
>>        "    : \"=a\"(*rEAX), \"=S\"(*rEBX), \"=c\"(*rECX),
>> \"=d\"(*rEDX)\n"
>>        "    : \"a\"(value));");
>> +  EXPECT_EQ(
>> +      "void NS_InvokeByIndex(void *that, unsigned int methodIndex) {\n"
>> +      "    __asm {\n"
>> +      "        mov     edx,[that] // vtable in edx\n"
>> +      "        mov     eax,methodIndex\n"
>> +      "        call    [edx][eax*4] // stdcall\n"
>> +      "    }\n"
>> +      "}",
>> +      format("void NS_InvokeByIndex(void *that,   unsigned int
>> methodIndex) {\n"
>> +             "    __asm {\n"
>> +             "        mov     edx,[that] // vtable in edx\n"
>> +             "        mov     eax,methodIndex\n"
>> +             "        call    [edx][eax*4] // stdcall\n"
>> +             "    }\n"
>> +             "}"));
>>  }
>>
>>  TEST_F(FormatTest, FormatTryCatch) {
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140827/f5acede9/attachment.html>


More information about the cfe-commits mailing list