Skip to content

[NFC][TableGen] Use auto when initializing variables with cast<> #113171

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions llvm/include/llvm/TableGen/Record.h
Original file line number Diff line number Diff line change
Expand Up @@ -401,9 +401,7 @@ class Init {
/// variables which may not be defined at the time the expression is formed.
/// If a value is set for the variable later, this method will be called on
/// users of the value to allow the value to propagate out.
virtual const Init *resolveReferences(Resolver &R) const {
return const_cast<Init *>(this);
}
virtual const Init *resolveReferences(Resolver &R) const { return this; }

/// Get the \p Init value of the specified bit.
virtual const Init *getBit(unsigned Bit) const = 0;
Expand Down Expand Up @@ -475,9 +473,7 @@ class UnsetInit : public Init {
const Init *getCastTo(const RecTy *Ty) const override;
const Init *convertInitializerTo(const RecTy *Ty) const override;

const Init *getBit(unsigned Bit) const override {
return const_cast<UnsetInit*>(this);
}
const Init *getBit(unsigned Bit) const override { return this; }

/// Is this a complete value with no unset (uninitialized) subvalues?
bool isComplete() const override { return false; }
Expand Down Expand Up @@ -579,7 +575,7 @@ class BitInit final : public TypedInit {

const Init *getBit(unsigned Bit) const override {
assert(Bit < 1 && "Bit index out of range!");
return const_cast<BitInit*>(this);
return this;
}

bool isConcrete() const override { return true; }
Expand Down Expand Up @@ -1318,7 +1314,7 @@ class VarBitInit final : public TypedInit {

const Init *getBit(unsigned B) const override {
assert(B < 1 && "Bit index out of range!");
return const_cast<VarBitInit*>(this);
return this;
}
};

Expand Down
Loading
Loading