HazardyKnusperkeks added a comment. In D138263#3938593 <https://reviews.llvm.org/D138263#3938593>, @owenpan wrote:
> Something like the following: > > diff --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h > index 87515372046d..3dc5e411df55 100644 > --- a/clang/lib/Format/FormatToken.h > +++ b/clang/lib/Format/FormatToken.h > @@ -98,6 +98,8 @@ namespace format { > TYPE(MacroBlockBegin) > \ > TYPE(MacroBlockEnd) > \ > TYPE(ModulePartitionColon) > \ > + TYPE(NamespaceLBrace) > \ > + TYPE(NamespaceRBrace) > \ > TYPE(NamespaceMacro) > \ > TYPE(NonNullAssertion) > \ > TYPE(NullCoalescingEqual) > \ > diff --git a/clang/lib/Format/UnwrappedLineParser.cpp > b/clang/lib/Format/UnwrappedLineParser.cpp > index 18ec0844db3d..6eb1086015f0 100644 > --- a/clang/lib/Format/UnwrappedLineParser.cpp > +++ b/clang/lib/Format/UnwrappedLineParser.cpp > @@ -920,6 +920,9 @@ FormatToken *UnwrappedLineParser::parseBlock( > return IfLBrace; > } > > + if (FormatTok->is(tok::r_brace) && Tok->is(TT_NamespaceLBrace)) > + FormatTok->setFinalizedType(TT_NamespaceRBrace); > + > const bool IsFunctionRBrace = > FormatTok->is(tok::r_brace) && Tok->is(TT_FunctionLBrace); > > @@ -2961,6 +2964,7 @@ void UnwrappedLineParser::parseNamespace() { > } > } > if (FormatTok->is(tok::l_brace)) { > + FormatTok->setFinalizedType(TT_NamespaceLBrace); > if (ShouldBreakBeforeBrace(Style, InitialToken)) > addUnwrappedLine(); > > diff --git a/clang/lib/Format/WhitespaceManager.cpp > b/clang/lib/Format/WhitespaceManager.cpp > index 1f29f7ab917c..0867a8585b50 100644 > --- a/clang/lib/Format/WhitespaceManager.cpp > +++ b/clang/lib/Format/WhitespaceManager.cpp > @@ -990,8 +990,7 @@ void WhitespaceManager::alignTrailingComments() { > // If this comment follows an } in column 0, it probably documents the > // closing of a namespace and we don't want to align it. > bool FollowsRBraceInColumn0 = i > 0 && Changes[i].NewlinesBefore == 0 > && > - Changes[i - 1].Tok->is(tok::r_brace) && > - Changes[i - 1].StartOfTokenColumn == 0; > + Changes[i - > 1].Tok->is(TT_NamespaceRBrace); > bool WasAlignedWithStartOfNextLine = false; > if (Changes[i].NewlinesBefore >= 1) { // A comment on its own line. > unsigned CommentColumn = SourceMgr.getSpellingColumnNumber( Actually read this only now. Basically doing the same thing. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D138263/new/ https://reviews.llvm.org/D138263 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits