Author: Owen Pan Date: 2025-03-05T21:45:01-08:00 New Revision: a6ccda28f7569c1a03620d7520de7cfadc11f4a5
URL: https://github.com/llvm/llvm-project/commit/a6ccda28f7569c1a03620d7520de7cfadc11f4a5 DIFF: https://github.com/llvm/llvm-project/commit/a6ccda28f7569c1a03620d7520de7cfadc11f4a5.diff LOG: [clang-format][NFC] Use better names for a couple of data members Added: Modified: clang/lib/Format/ContinuationIndenter.cpp clang/lib/Format/FormatToken.h clang/lib/Format/UnwrappedLineParser.cpp clang/lib/Format/UnwrappedLineParser.h Removed: ################################################################################ diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index 4cb24dbca5ad0..1969f4297b211 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/lib/Format/ContinuationIndenter.cpp @@ -629,7 +629,7 @@ bool ContinuationIndenter::mustBreak(const LineState &State) { !Style.isJavaScript() && Previous.isNot(tok::kw_template) && CurrentState.BreakBeforeParameter) { for (const auto *Tok = &Previous; Tok; Tok = Tok->Previous) - if (Tok->FirstAfterPPDirectiveLine || Tok->is(TT_LineComment)) + if (Tok->FirstAfterPPLine || Tok->is(TT_LineComment)) return false; return true; diff --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h index 2cace7c3f060e..77935e75d4b4c 100644 --- a/clang/lib/Format/FormatToken.h +++ b/clang/lib/Format/FormatToken.h @@ -594,8 +594,8 @@ struct FormatToken { /// Has "\n\f\n" or "\n\f\r\n" before TokenText. bool HasFormFeedBefore = false; - /// Is the first token after a PPDirective line. - bool FirstAfterPPDirectiveLine = false; + /// Is the first token after a preprocessor line. + bool FirstAfterPPLine = false; /// Number of optional braces to be inserted after this token: /// -1: a single left brace diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index 2da0432816df7..efb22bcdbe53f 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -119,7 +119,7 @@ class ScopedLineState { assert(Parser.Line->Tokens.empty()); Parser.Line = std::move(PreBlockLine); if (Parser.CurrentLines == &Parser.PreprocessorDirectives) - Parser.MustBreakBeforeNextToken = true; + Parser.AtEndOfPPLine = true; Parser.CurrentLines = OriginalLines; } @@ -158,8 +158,8 @@ UnwrappedLineParser::UnwrappedLineParser( ArrayRef<FormatToken *> Tokens, UnwrappedLineConsumer &Callback, llvm::SpecificBumpPtrAllocator<FormatToken> &Allocator, IdentifierTable &IdentTable) - : Line(new UnwrappedLine), MustBreakBeforeNextToken(false), - CurrentLines(&Lines), Style(Style), IsCpp(Style.isCpp()), + : Line(new UnwrappedLine), AtEndOfPPLine(false), CurrentLines(&Lines), + Style(Style), IsCpp(Style.isCpp()), LangOpts(getFormattingLangOpts(Style)), Keywords(Keywords), CommentPragmasRegex(Style.CommentPragmas), Tokens(nullptr), Callback(Callback), AllTokens(Tokens), PPBranchLevel(-1), @@ -180,7 +180,7 @@ void UnwrappedLineParser::reset() { Line.reset(new UnwrappedLine); CommentsBeforeNextToken.clear(); FormatTok = nullptr; - MustBreakBeforeNextToken = false; + AtEndOfPPLine = false; IsDecltypeAutoFunction = false; PreprocessorDirectives.clear(); CurrentLines = &Lines; @@ -5090,12 +5090,12 @@ UnwrappedLineParser::parseMacroCall() { void UnwrappedLineParser::pushToken(FormatToken *Tok) { Line->Tokens.push_back(UnwrappedLineNode(Tok)); - if (MustBreakBeforeNextToken) { + if (AtEndOfPPLine) { auto &Tok = *Line->Tokens.back().Tok; Tok.MustBreakBefore = true; Tok.MustBreakBeforeFinalized = true; - Tok.FirstAfterPPDirectiveLine = true; - MustBreakBeforeNextToken = false; + Tok.FirstAfterPPLine = true; + AtEndOfPPLine = false; } } diff --git a/clang/lib/Format/UnwrappedLineParser.h b/clang/lib/Format/UnwrappedLineParser.h index 08bff2748eb8f..87650c2756cd1 100644 --- a/clang/lib/Format/UnwrappedLineParser.h +++ b/clang/lib/Format/UnwrappedLineParser.h @@ -298,8 +298,11 @@ class UnwrappedLineParser { // Since the next token might already be in a new unwrapped line, we need to // store the comments belonging to that token. SmallVector<FormatToken *, 1> CommentsBeforeNextToken; + FormatToken *FormatTok = nullptr; - bool MustBreakBeforeNextToken; + + // Has just finished parsing a preprocessor line. + bool AtEndOfPPLine; // The parsed lines. Only added to through \c CurrentLines. SmallVector<UnwrappedLine, 8> Lines; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits