]> granicus.if.org Git - clang/commitdiff
clang-format: Don't merge subsequent lines into _asm blocks.
authorDaniel Jasper <djasper@google.com>
Mon, 11 May 2015 11:59:46 +0000 (11:59 +0000)
committerDaniel Jasper <djasper@google.com>
Mon, 11 May 2015 11:59:46 +0000 (11:59 +0000)
Before:
  _asm {
  } int i;

After:
  _asm {
  }
  int i;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@236985 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Format/UnwrappedLineParser.cpp
unittests/Format/FormatTest.cpp

index a2afcc0fd5beb003001ec6eb4f160b755966937d..6dee251a918a622b53b8a8591523a72d873e3a61 100644 (file)
@@ -672,6 +672,7 @@ void UnwrappedLineParser::parseStructuralElement() {
         if (FormatTok->is(tok::r_brace)) {
           FormatTok->Type = TT_InlineASMBrace;
           nextToken();
+          addUnwrappedLine();
           break;
         }
         FormatTok->Finalized = true;
index a70cab1096f4603ea03c0b2eda03760ee760062f..43f94f0ce6df277e96f2fac015c2e137b167c9fb 100644 (file)
@@ -2328,6 +2328,12 @@ TEST_F(FormatTest, FormatsInlineASM) {
                "  // comment\n"
                "  asm(\"\");\n"
                "}");
+  EXPECT_EQ("__asm {\n"
+            "}\n"
+            "int i;",
+            format("__asm   {\n"
+                   "}\n"
+                   "int   i;"));
 }
 
 TEST_F(FormatTest, FormatTryCatch) {