diff options
Diffstat (limited to 'include/llvm')
-rw-r--r-- | include/llvm/Function.h | 10 | ||||
-rw-r--r-- | include/llvm/Instructions.h | 17 | ||||
-rw-r--r-- | include/llvm/Support/CallSite.h | 4 |
3 files changed, 28 insertions, 3 deletions
diff --git a/include/llvm/Function.h b/include/llvm/Function.h index 897e53b0a2..627b47f9d9 100644 --- a/include/llvm/Function.h +++ b/include/llvm/Function.h @@ -21,6 +21,7 @@ #include "llvm/GlobalValue.h" #include "llvm/BasicBlock.h" #include "llvm/Argument.h" +#include "llvm/ParameterAttributes.h" #include "llvm/Support/Annotation.h" namespace llvm { @@ -152,8 +153,15 @@ public: /// @brief Set the parameter attributes. void setParamAttrs(const ParamAttrsList *attrs); + /// @brief Determine whether the function has the given attribute. + bool paramHasAttr(uint16_t i, ParameterAttributes attr) const { + return ParamAttrs && ParamAttrs->paramHasAttr(i, attr); + } + /// @brief Determine if the function returns a structure. - bool isStructReturn() const; + bool isStructReturn() const { + return paramHasAttr(1, ParamAttr::StructRet); + } /// deleteBody - This method deletes the body of the function, and converts /// the linkage to external. diff --git a/include/llvm/Instructions.h b/include/llvm/Instructions.h index 96ca43d6ca..34b22c7802 100644 --- a/include/llvm/Instructions.h +++ b/include/llvm/Instructions.h @@ -20,6 +20,7 @@ #include "llvm/InstrTypes.h" #include "llvm/DerivedTypes.h" +#include "llvm/ParameterAttributes.h" namespace llvm { @@ -923,8 +924,14 @@ public: /// @brief Set the parameter attributes. void setParamAttrs(const ParamAttrsList *attrs); + /// @brief Determine whether the call or the callee has the given attribute. + bool paramHasAttr(uint16_t i, ParameterAttributes attr) const; + /// @brief Determine if the call returns a structure. - bool isStructReturn() const; + bool isStructReturn() const { + // Be friendly and also check the callee. + return paramHasAttr(1, ParamAttr::StructRet); + } /// getCalledFunction - Return the function being called by this instruction /// if it is a direct call. If it is a call through a function pointer, @@ -1701,8 +1708,14 @@ public: /// @brief Set the parameter attributes. void setParamAttrs(const ParamAttrsList *attrs); + /// @brief Determine whether the call or the callee has the given attribute. + bool paramHasAttr(uint16_t i, ParameterAttributes attr) const; + /// @brief Determine if the call returns a structure. - bool isStructReturn() const; + bool isStructReturn() const { + // Be friendly and also check the callee. + return paramHasAttr(1, ParamAttr::StructRet); + } /// getCalledFunction - Return the function called, or null if this is an /// indirect function invocation. diff --git a/include/llvm/Support/CallSite.h b/include/llvm/Support/CallSite.h index d03d209d5f..b613dffe97 100644 --- a/include/llvm/Support/CallSite.h +++ b/include/llvm/Support/CallSite.h @@ -22,6 +22,7 @@ #include "llvm/Instruction.h" #include "llvm/BasicBlock.h" +#include "llvm/ParameterAttributes.h" namespace llvm { @@ -63,6 +64,9 @@ public: const ParamAttrsList *getParamAttrs() const; void setParamAttrs(const ParamAttrsList *PAL); + /// paramHasAttr - whether the call or the callee has the given attribute. + bool paramHasAttr(uint16_t i, ParameterAttributes attr) const; + /// getType - Return the type of the instruction that generated this call site /// const Type *getType() const { return I->getType(); } |