forked from OSchip/llvm-project
[IR] Use const_cast to reuse the const version of two BasicBlock methods that are duplicated for both const and non-const. NFC
Similar is already done for other methods in BasicBlock. llvm-svn: 292753
This commit is contained in:
parent
f0eb6c6c31
commit
6f8e989b21
|
@ -104,13 +104,17 @@ public:
|
|||
/// or nullptr it the function does not have a module.
|
||||
///
|
||||
/// Note: this is undefined behavior if the block does not have a parent.
|
||||
const Module *getModule() const;
|
||||
Module *getModule();
|
||||
const Module *getModule() const {
|
||||
return const_cast<BasicBlock *>(this)->getModule();
|
||||
}
|
||||
|
||||
/// \brief Returns the terminator instruction if the block is well formed or
|
||||
/// null if the block is not well formed.
|
||||
TerminatorInst *getTerminator();
|
||||
const TerminatorInst *getTerminator() const;
|
||||
const TerminatorInst *getTerminator() const {
|
||||
return const_cast<BasicBlock *>(this)->getTerminator();
|
||||
}
|
||||
|
||||
/// \brief Returns the call instruction calling @llvm.experimental.deoptimize
|
||||
/// prior to the terminating return instruction of this basic block, if such a
|
||||
|
|
|
@ -113,10 +113,6 @@ void BasicBlock::moveAfter(BasicBlock *MovePos) {
|
|||
getIterator());
|
||||
}
|
||||
|
||||
const Module *BasicBlock::getModule() const {
|
||||
return getParent()->getParent();
|
||||
}
|
||||
|
||||
Module *BasicBlock::getModule() {
|
||||
return getParent()->getParent();
|
||||
}
|
||||
|
@ -126,11 +122,6 @@ TerminatorInst *BasicBlock::getTerminator() {
|
|||
return dyn_cast<TerminatorInst>(&InstList.back());
|
||||
}
|
||||
|
||||
const TerminatorInst *BasicBlock::getTerminator() const {
|
||||
if (InstList.empty()) return nullptr;
|
||||
return dyn_cast<TerminatorInst>(&InstList.back());
|
||||
}
|
||||
|
||||
CallInst *BasicBlock::getTerminatingMustTailCall() {
|
||||
if (InstList.empty())
|
||||
return nullptr;
|
||||
|
|
Loading…
Reference in New Issue