llvm.org GIT mirror llvm / 986da6c
add CallSite/CallInst/InvokeInst::hasFnAttr() git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159144 91177308-0d34-0410-b5e6-96231b3b80d8 Nuno Lopes 7 years ago
2 changed file(s) with 26 addition(s) and 11 deletion(s). Raw diff Collapse all Expand all
12661266 /// removeAttribute - removes the attribute from the list of attributes.
12671267 void removeAttribute(unsigned i, Attributes attr);
12681268
1269 /// \brief Return true if this call has the given attribute.
1270 bool hasFnAttr(Attributes N) const {
1271 return paramHasAttr(~0, N);
1272 }
1273
12691274 /// @brief Determine whether the call or the callee has the given attribute.
12701275 bool paramHasAttr(unsigned i, Attributes attr) const;
12711276
12751280 }
12761281
12771282 /// @brief Return true if the call should not be inlined.
1278 bool isNoInline() const { return paramHasAttr(~0, Attribute::NoInline); }
1283 bool isNoInline() const { return hasFnAttr(Attribute::NoInline); }
12791284 void setIsNoInline(bool Value = true) {
12801285 if (Value) addAttribute(~0, Attribute::NoInline);
12811286 else removeAttribute(~0, Attribute::NoInline);
12831288
12841289 /// @brief Return true if the call can return twice
12851290 bool canReturnTwice() const {
1286 return paramHasAttr(~0, Attribute::ReturnsTwice);
1291 return hasFnAttr(Attribute::ReturnsTwice);
12871292 }
12881293 void setCanReturnTwice(bool Value = true) {
12891294 if (Value) addAttribute(~0, Attribute::ReturnsTwice);
12921297
12931298 /// @brief Determine if the call does not access memory.
12941299 bool doesNotAccessMemory() const {
1295 return paramHasAttr(~0, Attribute::ReadNone);
1300 return hasFnAttr(Attribute::ReadNone);
12961301 }
12971302 void setDoesNotAccessMemory(bool NotAccessMemory = true) {
12981303 if (NotAccessMemory) addAttribute(~0, Attribute::ReadNone);
13011306
13021307 /// @brief Determine if the call does not access or only reads memory.
13031308 bool onlyReadsMemory() const {
1304 return doesNotAccessMemory() || paramHasAttr(~0, Attribute::ReadOnly);
1309 return doesNotAccessMemory() || hasFnAttr(Attribute::ReadOnly);
13051310 }
13061311 void setOnlyReadsMemory(bool OnlyReadsMemory = true) {
13071312 if (OnlyReadsMemory) addAttribute(~0, Attribute::ReadOnly);
13091314 }
13101315
13111316 /// @brief Determine if the call cannot return.
1312 bool doesNotReturn() const { return paramHasAttr(~0, Attribute::NoReturn); }
1317 bool doesNotReturn() const { return hasFnAttr(Attribute::NoReturn); }
13131318 void setDoesNotReturn(bool DoesNotReturn = true) {
13141319 if (DoesNotReturn) addAttribute(~0, Attribute::NoReturn);
13151320 else removeAttribute(~0, Attribute::NoReturn);
13161321 }
13171322
13181323 /// @brief Determine if the call cannot unwind.
1319 bool doesNotThrow() const { return paramHasAttr(~0, Attribute::NoUnwind); }
1324 bool doesNotThrow() const { return hasFnAttr(Attribute::NoUnwind); }
13201325 void setDoesNotThrow(bool DoesNotThrow = true) {
13211326 if (DoesNotThrow) addAttribute(~0, Attribute::NoUnwind);
13221327 else removeAttribute(~0, Attribute::NoUnwind);
30233028 /// removeAttribute - removes the attribute from the list of attributes.
30243029 void removeAttribute(unsigned i, Attributes attr);
30253030
3031 /// \brief Return true if this call has the given attribute.
3032 bool hasFnAttr(Attributes N) const {
3033 return paramHasAttr(~0, N);
3034 }
3035
30263036 /// @brief Determine whether the call or the callee has the given attribute.
30273037 bool paramHasAttr(unsigned i, Attributes attr) const;
30283038
30323042 }
30333043
30343044 /// @brief Return true if the call should not be inlined.
3035 bool isNoInline() const { return paramHasAttr(~0, Attribute::NoInline); }
3045 bool isNoInline() const { return hasFnAttr(Attribute::NoInline); }
30363046 void setIsNoInline(bool Value = true) {
30373047 if (Value) addAttribute(~0, Attribute::NoInline);
30383048 else removeAttribute(~0, Attribute::NoInline);
30403050
30413051 /// @brief Determine if the call does not access memory.
30423052 bool doesNotAccessMemory() const {
3043 return paramHasAttr(~0, Attribute::ReadNone);
3053 return hasFnAttr(Attribute::ReadNone);
30443054 }
30453055 void setDoesNotAccessMemory(bool NotAccessMemory = true) {
30463056 if (NotAccessMemory) addAttribute(~0, Attribute::ReadNone);
30493059
30503060 /// @brief Determine if the call does not access or only reads memory.
30513061 bool onlyReadsMemory() const {
3052 return doesNotAccessMemory() || paramHasAttr(~0, Attribute::ReadOnly);
3062 return doesNotAccessMemory() || hasFnAttr(Attribute::ReadOnly);
30533063 }
30543064 void setOnlyReadsMemory(bool OnlyReadsMemory = true) {
30553065 if (OnlyReadsMemory) addAttribute(~0, Attribute::ReadOnly);
30573067 }
30583068
30593069 /// @brief Determine if the call cannot return.
3060 bool doesNotReturn() const { return paramHasAttr(~0, Attribute::NoReturn); }
3070 bool doesNotReturn() const { return hasFnAttr(Attribute::NoReturn); }
30613071 void setDoesNotReturn(bool DoesNotReturn = true) {
30623072 if (DoesNotReturn) addAttribute(~0, Attribute::NoReturn);
30633073 else removeAttribute(~0, Attribute::NoReturn);
30643074 }
30653075
30663076 /// @brief Determine if the call cannot unwind.
3067 bool doesNotThrow() const { return paramHasAttr(~0, Attribute::NoUnwind); }
3077 bool doesNotThrow() const { return hasFnAttr(Attribute::NoUnwind); }
30683078 void setDoesNotThrow(bool DoesNotThrow = true) {
30693079 if (DoesNotThrow) addAttribute(~0, Attribute::NoUnwind);
30703080 else removeAttribute(~0, Attribute::NoUnwind);
183183 CALLSITE_DELEGATE_SETTER(setAttributes(PAL));
184184 }
185185
186 /// \brief Return true if this function has the given attribute.
187 bool hasFnAttr(Attributes N) const {
188 CALLSITE_DELEGATE_GETTER(hasFnAttr(N));
189 }
190
186191 /// paramHasAttr - whether the call or the callee has the given attribute.
187192 bool paramHasAttr(uint16_t i, Attributes attr) const {
188193 CALLSITE_DELEGATE_GETTER(paramHasAttr(i, attr));