/// 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...
///
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;
+}
+