From c11338cf10a01b70961536250358b0dc6ebd4438 Mon Sep 17 00:00:00 2001 From: Sanjoy Das Date: Tue, 8 Dec 2015 00:13:12 +0000 Subject: [PATCH] Add Instruction::getFunction; NFC 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 | 7 +++++++ lib/IR/Instruction.cpp | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/include/llvm/IR/Instruction.h b/include/llvm/IR/Instruction.h index c7ba8721fe0..77ba87c6b66 100644 --- a/include/llvm/IR/Instruction.h +++ b/include/llvm/IR/Instruction.h @@ -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. /// diff --git a/lib/IR/Instruction.cpp b/lib/IR/Instruction.cpp index b5a30a4969b..7bd50328b12 100644 --- a/lib/IR/Instruction.cpp +++ b/lib/IR/Instruction.cpp @@ -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()); -- 2.34.1