forked from OSchip/llvm-project
[IR] Share implementation for pairs of const and non-const methods using const_cast. NFCI
llvm-svn: 298830
This commit is contained in:
parent
70c8efd03c
commit
1c78f4a0ff
|
@ -337,8 +337,11 @@ public:
|
|||
bool isLandingPad() const;
|
||||
|
||||
/// \brief Return the landingpad instruction associated with the landing pad.
|
||||
LandingPadInst *getLandingPadInst();
|
||||
const LandingPadInst *getLandingPadInst() const;
|
||||
LandingPadInst *getLandingPadInst() {
|
||||
return const_cast<LandingPadInst *>(
|
||||
static_cast<const BasicBlock *>(this)->getLandingPadInst());
|
||||
}
|
||||
|
||||
private:
|
||||
/// \brief Increment the internal refcount of the number of BlockAddresses
|
||||
|
|
|
@ -68,14 +68,20 @@ public:
|
|||
/// Note: this is undefined behavior if the instruction does not have a
|
||||
/// parent, or the parent basic block does not have a parent function.
|
||||
const Module *getModule() const;
|
||||
Module *getModule();
|
||||
Module *getModule() {
|
||||
return const_cast<Module *>(
|
||||
static_cast<const Instruction *>(this)->getModule());
|
||||
}
|
||||
|
||||
/// Return the function this instruction belongs to.
|
||||
///
|
||||
/// Note: it is undefined behavior to call this on an instruction not
|
||||
/// currently inserted into a function.
|
||||
const Function *getFunction() const;
|
||||
Function *getFunction();
|
||||
Function *getFunction() {
|
||||
return const_cast<Function *>(
|
||||
static_cast<const Instruction *>(this)->getFunction());
|
||||
}
|
||||
|
||||
/// This method unlinks 'this' from the containing basic block, but does not
|
||||
/// delete it.
|
||||
|
|
|
@ -429,9 +429,6 @@ bool BasicBlock::isLandingPad() const {
|
|||
}
|
||||
|
||||
/// Return the landingpad instruction associated with the landing pad.
|
||||
LandingPadInst *BasicBlock::getLandingPadInst() {
|
||||
return dyn_cast<LandingPadInst>(getFirstNonPHI());
|
||||
}
|
||||
const LandingPadInst *BasicBlock::getLandingPadInst() const {
|
||||
return dyn_cast<LandingPadInst>(getFirstNonPHI());
|
||||
}
|
||||
|
|
|
@ -60,12 +60,6 @@ const Module *Instruction::getModule() const {
|
|||
return getParent()->getModule();
|
||||
}
|
||||
|
||||
Module *Instruction::getModule() {
|
||||
return getParent()->getModule();
|
||||
}
|
||||
|
||||
Function *Instruction::getFunction() { return getParent()->getParent(); }
|
||||
|
||||
const Function *Instruction::getFunction() const {
|
||||
return getParent()->getParent();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue