aboutsummaryrefslogtreecommitdiff
path: root/llvm/include/llvm/IR/BasicBlock.h
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/include/llvm/IR/BasicBlock.h')
-rw-r--r--llvm/include/llvm/IR/BasicBlock.h9
1 files changed, 5 insertions, 4 deletions
diff --git a/llvm/include/llvm/IR/BasicBlock.h b/llvm/include/llvm/IR/BasicBlock.h
index 184ddfc01c29..d487223eca02 100644
--- a/llvm/include/llvm/IR/BasicBlock.h
+++ b/llvm/include/llvm/IR/BasicBlock.h
@@ -22,9 +22,6 @@
#include "llvm/IR/Instruction.h"
#include "llvm/IR/SymbolTableListTraits.h"
#include "llvm/IR/Value.h"
-#include "llvm/Support/CBindingWrapping.h"
-#include "llvm/Support/Casting.h"
-#include "llvm/Support/Compiler.h"
#include <cassert>
#include <cstddef>
#include <iterator>
@@ -119,7 +116,11 @@ public:
/// Returns the terminator instruction if the block is well formed or null
/// if the block is not well formed.
- const Instruction *getTerminator() const LLVM_READONLY;
+ const Instruction *getTerminator() const LLVM_READONLY {
+ if (InstList.empty() || !InstList.back().isTerminator())
+ return nullptr;
+ return &InstList.back();
+ }
Instruction *getTerminator() {
return const_cast<Instruction *>(
static_cast<const BasicBlock *>(this)->getTerminator());