Skip to content

Commit

Permalink
Add Instruction::getFunction; NFC
Browse files Browse the repository at this point in the history
Will be used in a upcoming patch.

llvm-svn: 254975
  • Loading branch information
sanjoy committed Dec 8, 2015
1 parent 5ae3418 commit 411fdcd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions llvm/include/llvm/IR/Instruction.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ class Instruction : public User,
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.
///
Expand Down
5 changes: 5 additions & 0 deletions llvm/lib/IR/Instruction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit 411fdcd

Please sign in to comment.