summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@gmail.com>2017-01-22 06:53:04 +0000
committerCraig Topper <craig.topper@gmail.com>2017-01-22 06:53:04 +0000
commit6f8e989b21892913be4c01d4c51bd4a3cefcecb3 (patch)
treede514e483f2682c123453a94a0e897194f1df302 /llvm
parentf0eb6c6c311bd8fd0852f7105fe26192d25b235c (diff)
downloadbcm5719-llvm-6f8e989b21892913be4c01d4c51bd4a3cefcecb3.tar.gz
bcm5719-llvm-6f8e989b21892913be4c01d4c51bd4a3cefcecb3.zip
[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
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm/IR/BasicBlock.h8
-rw-r--r--llvm/lib/IR/BasicBlock.cpp9
2 files changed, 6 insertions, 11 deletions
diff --git a/llvm/include/llvm/IR/BasicBlock.h b/llvm/include/llvm/IR/BasicBlock.h
index 93dbd573ee1..ae40e710e1e 100644
--- a/llvm/include/llvm/IR/BasicBlock.h
+++ b/llvm/include/llvm/IR/BasicBlock.h
@@ -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
diff --git a/llvm/lib/IR/BasicBlock.cpp b/llvm/lib/IR/BasicBlock.cpp
index 19e78492365..8187ee93f17 100644
--- a/llvm/lib/IR/BasicBlock.cpp
+++ b/llvm/lib/IR/BasicBlock.cpp
@@ -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;
OpenPOWER on IntegriCloud