[llvm] r254975 - Add Instruction::getFunction; NFC
Sanjoy Das via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 7 16:13:12 PST 2015
Author: sanjoy
Date: Mon Dec 7 18:13:12 2015
New Revision: 254975
URL: http://llvm.org/viewvc/llvm-project?rev=254975&view=rev
Log:
Add Instruction::getFunction; NFC
Will be used in a upcoming patch.
Modified:
llvm/trunk/include/llvm/IR/Instruction.h
llvm/trunk/lib/IR/Instruction.cpp
Modified: llvm/trunk/include/llvm/IR/Instruction.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Instruction.h?rev=254975&r1=254974&r2=254975&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Instruction.h (original)
+++ llvm/trunk/include/llvm/IR/Instruction.h Mon Dec 7 18:13:12 2015
@@ -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.
///
Modified: llvm/trunk/lib/IR/Instruction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Instruction.cpp?rev=254975&r1=254974&r2=254975&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Instruction.cpp (original)
+++ llvm/trunk/lib/IR/Instruction.cpp Mon Dec 7 18:13:12 2015
@@ -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());
More information about the llvm-commits
mailing list