[PATCH] D60308: Leave alone the semicolon after the MacroBlockBegin name

Owen Pan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 4 23:21:58 PDT 2019


owenpan created this revision.
owenpan added reviewers: sammccall, klimek, djasper, krasimir.
owenpan added a project: clang.
Herald added a subscriber: cfe-commits.

This patch fixes the bug below.

The code:

  FOO_BEGIN();
    FOO_ENTRY
  FOO_END();

is erroneously formatted to:

  FOO_BEGIN()
    ;
    FOO_ENTRY
  FOO_END();


Repository:
  rC Clang

https://reviews.llvm.org/D60308

Files:
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===================================================================
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -3480,6 +3480,9 @@
                "  int x;\n"
                "  x = 1;\n"
                "FOO_END(Baz)", Style);
+  verifyFormat("FOO_BEGIN();\n"
+               "  FOO_ENTRY\n"
+               "FOO_END();", Style);
 }
 
 //===----------------------------------------------------------------------===//
Index: clang/lib/Format/UnwrappedLineParser.cpp
===================================================================
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -540,6 +540,9 @@
   if (MacroBlock && FormatTok->is(tok::l_paren))
     parseParens();
 
+  if (MunchSemi && FormatTok->Tok.is(tok::semi))
+    nextToken();
+
   size_t NbPreprocessorDirectives =
       CurrentLines == &Lines ? PreprocessorDirectives.size() : 0;
   addUnwrappedLine();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60308.193836.patch
Type: text/x-patch
Size: 1002 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190405/e345bdba/attachment-0001.bin>


More information about the cfe-commits mailing list