[PATCH] D138373: [clang-format] Don't eat two semicolons after namespace

Björn Schäpers via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Nov 19 20:23:34 PST 2022


HazardyKnusperkeks created this revision.
HazardyKnusperkeks added reviewers: owenpan, MyDeveloperDay, rymiel.
HazardyKnusperkeks added a project: clang-format.
Herald added a project: All.
HazardyKnusperkeks requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Remove the double check, move the comment.

This changes behavior, but I think for the better. Despite the comment my personal opinion would be to not even gracefully handle the one semicolon, it shouldn't be there.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D138373

Files:
  clang/lib/Format/UnwrappedLineParser.cpp


Index: clang/lib/Format/UnwrappedLineParser.cpp
===================================================================
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -2989,6 +2989,8 @@
     FormatToken *LBrace = FormatTok;
     LBrace->setFinalizedType(TT_NamespaceLBrace);
 
+    // Munch the semicolon after a namespace. This is more common than one would
+    // think. Putting the semicolon into its own line is very ugly.
     parseBlock(/*MustBeDeclaration=*/true, AddLevels, /*MunchSemi=*/true,
                /*KeepBraces=*/nullptr, /*IfKind=*/nullptr,
                ManageWhitesmithsBraces);
@@ -2996,11 +2998,6 @@
     if (LBrace->MatchingParen)
       LBrace->MatchingParen->setFinalizedType(TT_NamespaceRBrace);
 
-    // Munch the semicolon after a namespace. This is more common than one would
-    // think. Putting the semicolon into its own line is very ugly.
-    if (FormatTok->is(tok::semi))
-      nextToken();
-
     addUnwrappedLine(AddLevels > 0 ? LineLevel::Remove : LineLevel::Keep);
 
     if (ManageWhitesmithsBraces)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D138373.476724.patch
Type: text/x-patch
Size: 1092 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221120/69e42297/attachment.bin>


More information about the cfe-commits mailing list