clang-format: Don't butcher __asm blocks.

Instead completely cop out of formatting them for now.

This fixes llvm.org/PR20618.

llvm-svn: 216501
This commit is contained in:
Daniel Jasper 2014-08-26 23:15:12 +00:00
parent 7d4f2cebdf
commit 8f46365481
2 changed files with 30 additions and 0 deletions

View File

@ -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;

View File

@ -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) {