Fix build errors.

This commit is contained in:
Manuel Klimek 2022-07-12 07:42:34 +00:00
parent e0aece276f
commit f44d28f840
2 changed files with 26 additions and 22 deletions

View File

@ -98,7 +98,7 @@ void MacroCallReconstructor::add(FormatToken *Token,
if (!ActiveExpansions.empty() && Token->MacroCtx && if (!ActiveExpansions.empty() && Token->MacroCtx &&
(Token->MacroCtx->Role != MR_Hidden || (Token->MacroCtx->Role != MR_Hidden ||
ActiveExpansions.size() != Token->MacroCtx->ExpandedFrom.size())) { ActiveExpansions.size() != Token->MacroCtx->ExpandedFrom.size())) {
if (bool PassedMacroComma = reconstructActiveCallUntil(Token)) if (/*PassedMacroComma = */ reconstructActiveCallUntil(Token))
First = true; First = true;
} }
@ -172,7 +172,7 @@ void MacroCallReconstructor::prepareParent(FormatToken *ExpandedParent,
} }
assert(!ActiveReconstructedLines.empty()); assert(!ActiveReconstructedLines.empty());
ActiveReconstructedLines.back()->Tokens.back()->Children.push_back( ActiveReconstructedLines.back()->Tokens.back()->Children.push_back(
std::make_unique<Line>()); std::make_unique<ReconstructedLine>());
ActiveReconstructedLines.push_back( ActiveReconstructedLines.push_back(
&*ActiveReconstructedLines.back()->Tokens.back()->Children.back()); &*ActiveReconstructedLines.back()->Tokens.back()->Children.back());
} else if (parentLine().Tokens.back()->Tok != Parent) { } else if (parentLine().Tokens.back()->Tok != Parent) {
@ -498,14 +498,16 @@ void MacroCallReconstructor::finalize() {
Top.Children.resize(1); Top.Children.resize(1);
} }
void MacroCallReconstructor::appendToken(FormatToken *Token, Line *L) { void MacroCallReconstructor::appendToken(FormatToken *Token,
ReconstructedLine *L) {
L = L ? L : currentLine(); L = L ? L : currentLine();
LLVM_DEBUG(llvm::dbgs() << "-> " << Token->TokenText << "\n"); LLVM_DEBUG(llvm::dbgs() << "-> " << Token->TokenText << "\n");
L->Tokens.push_back(std::make_unique<LineNode>(Token)); L->Tokens.push_back(std::make_unique<LineNode>(Token));
} }
UnwrappedLine MacroCallReconstructor::createUnwrappedLine(const Line &Line, UnwrappedLine
int Level) { MacroCallReconstructor::createUnwrappedLine(const ReconstructedLine &Line,
int Level) {
UnwrappedLine Result; UnwrappedLine Result;
Result.Level = Level; Result.Level = Level;
for (const auto &N : Line.Tokens) { for (const auto &N : Line.Tokens) {
@ -526,7 +528,7 @@ UnwrappedLine MacroCallReconstructor::createUnwrappedLine(const Line &Line,
return Result; 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) for (int i = 0; i < Level; ++i)
llvm::dbgs() << " "; llvm::dbgs() << " ";
for (const auto &N : Line.Tokens) { for (const auto &N : Line.Tokens) {
@ -544,17 +546,19 @@ void MacroCallReconstructor::debug(const Line &Line, int Level) {
llvm::dbgs() << "\n"; llvm::dbgs() << "\n";
} }
MacroCallReconstructor::Line &MacroCallReconstructor::parentLine() { MacroCallReconstructor::ReconstructedLine &
MacroCallReconstructor::parentLine() {
return **std::prev(std::prev(ActiveReconstructedLines.end())); return **std::prev(std::prev(ActiveReconstructedLines.end()));
} }
MacroCallReconstructor::Line *MacroCallReconstructor::currentLine() { MacroCallReconstructor::ReconstructedLine *
MacroCallReconstructor::currentLine() {
return ActiveReconstructedLines.back(); return ActiveReconstructedLines.back();
} }
MacroCallReconstructor::MacroCallState::MacroCallState( MacroCallReconstructor::MacroCallState::MacroCallState(
MacroCallReconstructor::Line *Line, FormatToken *ParentLastToken, MacroCallReconstructor::ReconstructedLine *Line,
FormatToken *MacroCallLParen) FormatToken *ParentLastToken, FormatToken *MacroCallLParen)
: Line(Line), ParentLastToken(ParentLastToken), : Line(Line), ParentLastToken(ParentLastToken),
MacroCallLParen(MacroCallLParen) { MacroCallLParen(MacroCallLParen) {
LLVM_DEBUG( LLVM_DEBUG(

View File

@ -234,13 +234,13 @@ private:
bool processNextReconstructed(); bool processNextReconstructed();
void finalize(); void finalize();
struct Line; struct ReconstructedLine;
void appendToken(FormatToken *Token, Line *L = nullptr); void appendToken(FormatToken *Token, ReconstructedLine *L = nullptr);
UnwrappedLine createUnwrappedLine(const Line &Line, int Level); UnwrappedLine createUnwrappedLine(const ReconstructedLine &Line, int Level);
void debug(const Line &Line, int Level); void debug(const ReconstructedLine &Line, int Level);
Line &parentLine(); ReconstructedLine &parentLine();
Line *currentLine(); ReconstructedLine *currentLine();
void debugParentMap() const; void debugParentMap() const;
#ifndef NDEBUG #ifndef NDEBUG
@ -258,13 +258,13 @@ private:
LineNode() = default; LineNode() = default;
LineNode(FormatToken *Tok) : Tok(Tok) {} LineNode(FormatToken *Tok) : Tok(Tok) {}
FormatToken *Tok = nullptr; FormatToken *Tok = nullptr;
llvm::SmallVector<std::unique_ptr<Line>> Children; llvm::SmallVector<std::unique_ptr<ReconstructedLine>> Children;
}; };
// Line in which we build up the resulting unwrapped line. // Line in which we build up the resulting unwrapped line.
// FIXME: Investigate changing UnwrappedLine to a pointer type and using it // FIXME: Investigate changing UnwrappedLine to a pointer type and using it
// instead of rolling our own type. // instead of rolling our own type.
struct Line { struct ReconstructedLine {
llvm::SmallVector<std::unique_ptr<LineNode>> Tokens; llvm::SmallVector<std::unique_ptr<LineNode>> Tokens;
}; };
@ -277,11 +277,11 @@ private:
// in order to format the overall expression as a single logical line - // 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 // if we created separate lines, we'd format them with their own top-level
// indent depending on the semantic structure, which is not desired. // 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 // Stack of currently "open" lines, where each line's predecessor's last
// token is the parent token for that line. // token is the parent token for that line.
llvm::SmallVector<Line *> ActiveReconstructedLines; llvm::SmallVector<ReconstructedLine *> ActiveReconstructedLines;
// Maps from the expanded token to the token that takes its place in the // Maps from the expanded token to the token that takes its place in the
// reconstructed token stream in terms of parent-child relationships. // reconstructed token stream in terms of parent-child relationships.
@ -324,10 +324,10 @@ private:
llvm::SmallVector<Expansion> ActiveExpansions; llvm::SmallVector<Expansion> ActiveExpansions;
struct MacroCallState { struct MacroCallState {
MacroCallState(Line *Line, FormatToken *ParentLastToken, MacroCallState(ReconstructedLine *Line, FormatToken *ParentLastToken,
FormatToken *MacroCallLParen); FormatToken *MacroCallLParen);
Line *Line; ReconstructedLine *Line;
// The last token in the parent line or expansion, or nullptr if the macro // The last token in the parent line or expansion, or nullptr if the macro
// expansion is on a top-level line. // expansion is on a top-level line.