summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2014-08-26 23:15:12 +0000
committerDaniel Jasper <djasper@google.com>2014-08-26 23:15:12 +0000
commit8f46365481a4cbb97a80a0bbde1531d3228065aa (patch)
tree44643f975bc2bef5ac687b96b9cecf098ae21f7e
parent7d4f2cebdf069778e2873c9f90357e336876bc10 (diff)
downloadbcm5719-llvm-8f46365481a4cbb97a80a0bbde1531d3228065aa.tar.gz
bcm5719-llvm-8f46365481a4cbb97a80a0bbde1531d3228065aa.zip
clang-format: Don't butcher __asm blocks.
Instead completely cop out of formatting them for now. This fixes llvm.org/PR20618. llvm-svn: 216501
-rw-r--r--clang/lib/Format/UnwrappedLineParser.cpp15
-rw-r--r--clang/unittests/Format/FormatTest.cpp15
2 files changed, 30 insertions, 0 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp
index 7e55e04c7f7..aad3faa1965 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/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/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 411282a69da..bf69d8b55ed 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/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) {
OpenPOWER on IntegriCloud