Did I mention that I _HATE_ CPRs?

llvm-svn: 9639
This commit is contained in:
Chris Lattner 2003-10-31 18:38:06 +00:00
parent ff91940879
commit 9157ec025b
2 changed files with 14 additions and 3 deletions

View File

@ -58,9 +58,8 @@ public:
/// getCalledFunction - Return the function being called if this is a direct
/// call, otherwise return null (if it's an indirect call).
///
Function *getCalledFunction() const {
return dyn_cast<Function>(getCalledValue());
}
/// FIXME: This should be inlined once ConstantPointerRefs are gone. :(
Function *getCalledFunction() const;
/// setCalledFunction - Set the callee to the specified value...
///

View File

@ -143,3 +143,15 @@ Function *InvokeInst::getCalledFunction() {
return cast<Function>(CPR->getValue());
return 0;
}
#include "llvm/Support/CallSite.h"
Function *CallSite::getCalledFunction() const {
Value *Callee = getCalledValue();
if (Function *F = dyn_cast<Function>(Callee))
return F;
if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(Callee))
return cast<Function>(CPR->getValue());
return 0;
}