Add Instruction::getFunction; NFC
authorSanjoy Das <sanjoy@playingwithpointers.com>
Tue, 8 Dec 2015 00:13:12 +0000 (00:13 +0000)
committerSanjoy Das <sanjoy@playingwithpointers.com>
Tue, 8 Dec 2015 00:13:12 +0000 (00:13 +0000)
Will be used in a upcoming patch.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254975 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/IR/Instruction.h
lib/IR/Instruction.cpp

index c7ba8721fe06b9deab25730520a20595ea30947e..77ba87c6b664b39512748d7207c1af17a905c575 100644 (file)
@@ -66,6 +66,13 @@ public:
   const Module *getModule() const;
   Module *getModule();
 
+  /// \brief 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();
+
   /// removeFromParent - This method unlinks 'this' from the containing basic
   /// block, but does not delete it.
   ///
index b5a30a4969b3e2bb3aa63d160ac4cbfb24cbb630..7bd50328b126bc95a4a24f3b81f24cca42fbb7c3 100644 (file)
@@ -62,6 +62,11 @@ Module *Instruction::getModule() {
   return getParent()->getModule();
 }
 
+Function *Instruction::getFunction() { return getParent()->getParent(); }
+
+const Function *Instruction::getFunction() const {
+  return getParent()->getParent();
+}
 
 void Instruction::removeFromParent() {
   getParent()->getInstList().remove(getIterator());