r216501 - clang-format: Don't butcher __asm blocks.
Daniel Jasper
djasper at google.com
Tue Aug 26 16:15:12 PDT 2014
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) {
+ 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) {
More information about the cfe-commits
mailing list