diff --git a/clang/lib/Format/MacroCallReconstructor.cpp b/clang/lib/Format/MacroCallReconstructor.cpp index 67711cc91d0b80..ccff183cf0da17 100644 --- a/clang/lib/Format/MacroCallReconstructor.cpp +++ b/clang/lib/Format/MacroCallReconstructor.cpp @@ -98,7 +98,7 @@ void MacroCallReconstructor::add(FormatToken *Token, if (!ActiveExpansions.empty() && Token->MacroCtx && (Token->MacroCtx->Role != MR_Hidden || ActiveExpansions.size() != Token->MacroCtx->ExpandedFrom.size())) { - if (bool PassedMacroComma = reconstructActiveCallUntil(Token)) + if (/*PassedMacroComma = */ reconstructActiveCallUntil(Token)) First = true; } @@ -172,7 +172,7 @@ void MacroCallReconstructor::prepareParent(FormatToken *ExpandedParent, } assert(!ActiveReconstructedLines.empty()); ActiveReconstructedLines.back()->Tokens.back()->Children.push_back( - std::make_unique()); + std::make_unique()); ActiveReconstructedLines.push_back( &*ActiveReconstructedLines.back()->Tokens.back()->Children.back()); } else if (parentLine().Tokens.back()->Tok != Parent) { @@ -498,14 +498,16 @@ void MacroCallReconstructor::finalize() { Top.Children.resize(1); } -void MacroCallReconstructor::appendToken(FormatToken *Token, Line *L) { +void MacroCallReconstructor::appendToken(FormatToken *Token, + ReconstructedLine *L) { L = L ? L : currentLine(); LLVM_DEBUG(llvm::dbgs() << "-> " << Token->TokenText << "\n"); L->Tokens.push_back(std::make_unique(Token)); } -UnwrappedLine MacroCallReconstructor::createUnwrappedLine(const Line &Line, - int Level) { +UnwrappedLine +MacroCallReconstructor::createUnwrappedLine(const ReconstructedLine &Line, + int Level) { UnwrappedLine Result; Result.Level = Level; for (const auto &N : Line.Tokens) { @@ -526,7 +528,7 @@ UnwrappedLine MacroCallReconstructor::createUnwrappedLine(const Line &Line, return Result; } -void MacroCallReconstructor::debug(const Line &Line, int Level) { +void MacroCallReconstructor::debug(const ReconstructedLine &Line, int Level) { for (int i = 0; i < Level; ++i) llvm::dbgs() << " "; for (const auto &N : Line.Tokens) { @@ -544,17 +546,19 @@ void MacroCallReconstructor::debug(const Line &Line, int Level) { llvm::dbgs() << "\n"; } -MacroCallReconstructor::Line &MacroCallReconstructor::parentLine() { +MacroCallReconstructor::ReconstructedLine & +MacroCallReconstructor::parentLine() { return **std::prev(std::prev(ActiveReconstructedLines.end())); } -MacroCallReconstructor::Line *MacroCallReconstructor::currentLine() { +MacroCallReconstructor::ReconstructedLine * +MacroCallReconstructor::currentLine() { return ActiveReconstructedLines.back(); } MacroCallReconstructor::MacroCallState::MacroCallState( - MacroCallReconstructor::Line *Line, FormatToken *ParentLastToken, - FormatToken *MacroCallLParen) + MacroCallReconstructor::ReconstructedLine *Line, + FormatToken *ParentLastToken, FormatToken *MacroCallLParen) : Line(Line), ParentLastToken(ParentLastToken), MacroCallLParen(MacroCallLParen) { LLVM_DEBUG( diff --git a/clang/lib/Format/Macros.h b/clang/lib/Format/Macros.h index 59774647a56948..ded792c628701f 100644 --- a/clang/lib/Format/Macros.h +++ b/clang/lib/Format/Macros.h @@ -234,13 +234,13 @@ class MacroCallReconstructor { bool processNextReconstructed(); void finalize(); - struct Line; + struct ReconstructedLine; - void appendToken(FormatToken *Token, Line *L = nullptr); - UnwrappedLine createUnwrappedLine(const Line &Line, int Level); - void debug(const Line &Line, int Level); - Line &parentLine(); - Line *currentLine(); + void appendToken(FormatToken *Token, ReconstructedLine *L = nullptr); + UnwrappedLine createUnwrappedLine(const ReconstructedLine &Line, int Level); + void debug(const ReconstructedLine &Line, int Level); + ReconstructedLine &parentLine(); + ReconstructedLine *currentLine(); void debugParentMap() const; #ifndef NDEBUG @@ -258,13 +258,13 @@ class MacroCallReconstructor { LineNode() = default; LineNode(FormatToken *Tok) : Tok(Tok) {} FormatToken *Tok = nullptr; - llvm::SmallVector> Children; + llvm::SmallVector> Children; }; // Line in which we build up the resulting unwrapped line. // FIXME: Investigate changing UnwrappedLine to a pointer type and using it // instead of rolling our own type. - struct Line { + struct ReconstructedLine { llvm::SmallVector> Tokens; }; @@ -277,11 +277,11 @@ class MacroCallReconstructor { // in order to format the overall expression as a single logical line - // if we created separate lines, we'd format them with their own top-level // indent depending on the semantic structure, which is not desired. - Line Result; + ReconstructedLine Result; // Stack of currently "open" lines, where each line's predecessor's last // token is the parent token for that line. - llvm::SmallVector ActiveReconstructedLines; + llvm::SmallVector ActiveReconstructedLines; // Maps from the expanded token to the token that takes its place in the // reconstructed token stream in terms of parent-child relationships. @@ -324,10 +324,10 @@ class MacroCallReconstructor { llvm::SmallVector ActiveExpansions; struct MacroCallState { - MacroCallState(Line *Line, FormatToken *ParentLastToken, + MacroCallState(ReconstructedLine *Line, FormatToken *ParentLastToken, FormatToken *MacroCallLParen); - Line *Line; + ReconstructedLine *Line; // The last token in the parent line or expansion, or nullptr if the macro // expansion is on a top-level line.