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)
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)
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits