+ IterTy getCallee() const {
+ // FIXME: this is slow, since we do not have the fast versions
+ // of the op_*() functions here. See CallSite::getCallee.
+ //
+ if (isCall())
+ return getInstruction()->op_begin(); // Unchanged (ATM)
+ else
+ return getInstruction()->op_end() - 3; // Skip BB, BB, Function
+ }
+};
+
+/// ImmutableCallSite - establish a view to a call site for examination
+class ImmutableCallSite : public CallSiteBase<> {
+ typedef CallSiteBase<> _Base;
+public:
+ ImmutableCallSite(const Value* V) : _Base(V) {}
+ ImmutableCallSite(const CallInst *CI) : _Base(CI) {}
+ ImmutableCallSite(const InvokeInst *II) : _Base(II) {}
+ ImmutableCallSite(const Instruction *II) : _Base(II) {}
+};
+
+class CallSite : public CallSiteBase<Function, Value, User, Instruction,
+ CallInst, InvokeInst, User::op_iterator> {
+ typedef CallSiteBase<Function, Value, User, Instruction,
+ CallInst, InvokeInst, User::op_iterator> _Base;
+public:
+ CallSite() {}
+ CallSite(_Base B) : _Base(B) {}
+ CallSite(CallInst *CI) : _Base(CI) {}
+ CallSite(InvokeInst *II) : _Base(II) {}
+ CallSite(Instruction *II) : _Base(II) {}
+
+ bool operator==(const CallSite &CS) const { return I == CS.I; }
+ bool operator!=(const CallSite &CS) const { return I != CS.I; }
+
+ /// CallSite::get - This static method is sort of like a constructor. It will
+ /// create an appropriate call site for a Call or Invoke instruction, but it
+ /// can also create a null initialized CallSite object for something which is
+ /// NOT a call site.
+ ///
+ static CallSite get(Value *V) {
+ return _Base::get(V);
+ }
+
+ /// getCallingConv/setCallingConv - get or set the calling convention of the
+ /// call.
+ CallingConv::ID getCallingConv() const;
+ void setCallingConv(CallingConv::ID CC);
+
+ /// getAttributes/setAttributes - get or set the parameter attributes of
+ /// the call.
+ const AttrListPtr &getAttributes() const;
+ void setAttributes(const AttrListPtr &PAL);
+
+ /// paramHasAttr - whether the call or the callee has the given attribute.
+ bool paramHasAttr(uint16_t i, Attributes attr) const;
+
+ /// @brief Extract the alignment for a call or parameter (0=unknown).
+ uint16_t getParamAlignment(uint16_t i) const;
+
+ /// @brief Return true if the call should not be inlined.
+ bool isNoInline() const;
+ void setIsNoInline(bool Value = true);
+
+ /// @brief Determine if the call does not access memory.
+ bool doesNotAccessMemory() const;
+ void setDoesNotAccessMemory(bool doesNotAccessMemory = true);
+
+ /// @brief Determine if the call does not access or only reads memory.
+ bool onlyReadsMemory() const;
+ void setOnlyReadsMemory(bool onlyReadsMemory = true);
+
+ /// @brief Determine if the call cannot return.
+ bool doesNotReturn() const;
+ void setDoesNotReturn(bool doesNotReturn = true);
+
+ /// @brief Determine if the call cannot unwind.
+ bool doesNotThrow() const;
+ void setDoesNotThrow(bool doesNotThrow = true);
+
+ /// getType - Return the type of the instruction that generated this call site
+ ///
+ const Type *getType() const { return (*this)->getType(); }
+
+ /// getCaller - Return the caller function for this call site
+ ///
+ Function *getCaller() const { return (*this)->getParent()->getParent(); }
+
+ /// hasArgument - Returns true if this CallSite passes the given Value* as an
+ /// argument to the called function.
+ bool hasArgument(const Value *Arg) const;
+
+ bool operator<(const CallSite &CS) const {
+ return getInstruction() < CS.getInstruction();
+ }
+
+private: