1 //===-- llvm/Support/CallSite.h - Abstract Call & Invoke instrs -*- C++ -*-===//
3 // This file defines the CallSite class, which is a handy wrapper for code that
4 // wants to treat Call and Invoke instructions in a generic way.
6 //===----------------------------------------------------------------------===//
8 #ifndef LLVM_SUPPORT_CALLSITE_H
9 #define LLVM_SUPPORT_CALLSITE_H
11 #include "llvm/Instruction.h"
19 CallSite(CallInst *CI) : I((Instruction*)CI) {}
20 CallSite(InvokeInst *II) : I((Instruction*)II) {}
22 /// getCalledValue - Return the pointer to function that is being called...
24 Value *getCalledValue() const { return I->getOperand(0); }
26 /// getCalledFunction - Return the function being called if this is a direct
27 /// call, otherwise return null (if it's an indirect call).
29 Function *getCalledFunction() const {
30 return dyn_cast<Function>(getCalledValue());
33 /// arg_iterator - The type of iterator to use when looping over actual
34 /// arguments at this call site...
35 typedef User::op_iterator arg_iterator;
37 /// arg_begin/arg_end - Return iterators corresponding to the actual argument
38 /// list for a call site.
40 arg_iterator arg_begin() const {
41 if (I->getOpcode() == Instruction::Call)
42 return I->op_begin()+1; // Skip Function
44 return I->op_begin()+3; // Skip Function, BB, BB
46 arg_iterator arg_end() const { return I->op_begin(); }