From 3c002deeb1e5f315d728f885da7cfd46417423c8 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Tue, 26 Aug 2014 23:15:12 +0000 Subject: [PATCH] clang-format: Don't butcher __asm blocks. Instead completely cop out of formatting them for now. This fixes llvm.org/PR20618. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@216501 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/UnwrappedLineParser.cpp | 15 +++++++++++++++ unittests/Format/FormatTest.cpp | 15 +++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp index 7e55e04c7f..aad3faa196 100644 --- a/lib/Format/UnwrappedLineParser.cpp +++ b/lib/Format/UnwrappedLineParser.cpp @@ -658,6 +658,21 @@ void UnwrappedLineParser::parseStructuralElement() { break; } break; + case tok::kw_asm: + FormatTok->Finalized = true; + nextToken(); + if (FormatTok->is(tok::l_brace)) { + FormatTok->Finalized = true; + while (FormatTok) { + FormatTok->Finalized = true; + if (FormatTok->is(tok::r_brace)) { + nextToken(); + break; + } + nextToken(); + } + } + break; case tok::kw_namespace: parseNamespace(); return; diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 411282a69d..bf69d8b55e 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -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) { -- 2.40.0