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 &&
(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<Line>());
std::make_unique<ReconstructedLine>());
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<LineNode>(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(

View File

@ -234,13 +234,13 @@ private:
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 @@ private:
LineNode() = default;
LineNode(FormatToken *Tok) : Tok(Tok) {}
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.
// FIXME: Investigate changing UnwrappedLine to a pointer type and using it
// instead of rolling our own type.
struct Line {
struct ReconstructedLine {
llvm::SmallVector<std::unique_ptr<LineNode>> Tokens;
};
@ -277,11 +277,11 @@ private:
// 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<Line *> ActiveReconstructedLines;
llvm::SmallVector<ReconstructedLine *> 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 @@ private:
llvm::SmallVector<Expansion> 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.