diff options
author | Bill Wendling <isanbard@gmail.com> | 2012-10-10 06:13:42 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2012-10-10 06:13:42 +0000 |
commit | 11d00420e42ba88c3b48cab997965a7be79315e2 (patch) | |
tree | 355c521bd3bafcb4e69ea7f47f61472782a831dd /include/llvm | |
parent | 82d46aec62f127856f4bfeb30f80aa12dd74bae0 (diff) |
Pass into the AttributeWithIndex::get method an ArrayRef of attribute
enums. These are then created via the correct Attributes creation method.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165607 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm')
-rw-r--r-- | include/llvm/Attributes.h | 39 | ||||
-rw-r--r-- | include/llvm/Function.h | 14 |
2 files changed, 35 insertions, 18 deletions
diff --git a/include/llvm/Attributes.h b/include/llvm/Attributes.h index 1c2770995c2..4825c97a9b9 100644 --- a/include/llvm/Attributes.h +++ b/include/llvm/Attributes.h @@ -97,18 +97,6 @@ DECLARE_LLVM_ATTRIBUTE(AddressSafety,1ULL<<32) ///< Address safety checking is o #undef DECLARE_LLVM_ATTRIBUTE -/// Note that uwtable is about the ABI or the user mandating an entry in the -/// unwind table. The nounwind attribute is about an exception passing by the -/// function. -/// In a theoretical system that uses tables for profiling and sjlj for -/// exceptions, they would be fully independent. In a normal system that -/// uses tables for both, the semantics are: -/// nil = Needs an entry because an exception might pass by. -/// nounwind = No need for an entry -/// uwtable = Needs an entry because the ABI says so and because -/// an exception might pass by. -/// uwtable + nounwind = Needs an entry because the ABI says so. - } // namespace Attribute /// AttributeImpl - The internal representation of the Attributes class. This is @@ -118,6 +106,20 @@ class AttributesImpl; /// Attributes - A bitset of attributes. class Attributes { public: + /// Note that uwtable is about the ABI or the user mandating an entry in the + /// unwind table. The nounwind attribute is about an exception passing by the + /// function. + /// + /// In a theoretical system that uses tables for profiling and sjlj for + /// exceptions, they would be fully independent. In a normal system that uses + /// tables for both, the semantics are: + /// + /// nil = Needs an entry because an exception might pass by. + /// nounwind = No need for an entry + /// uwtable = Needs an entry because the ABI says so and because + /// an exception might pass by. + /// uwtable + nounwind = Needs an entry because the ABI says so. + enum AttrVal { None = 0, ///< No attributes have been set AddressSafety = 1, ///< Address safety checking is on. @@ -375,6 +377,19 @@ struct AttributeWithIndex { ///< Index 0 is used for return value attributes. ///< Index ~0U is used for function attributes. + static AttributeWithIndex get(unsigned Idx, + ArrayRef<Attributes::AttrVal> Attrs) { + Attributes::Builder B; + + for (ArrayRef<Attributes::AttrVal>::iterator I = Attrs.begin(), + E = Attrs.end(); I != E; ++I) + B.addAttribute(*I); + + AttributeWithIndex P; + P.Index = Idx; + P.Attrs = Attributes::get(B); + return P; + } static AttributeWithIndex get(unsigned Idx, Attributes Attrs) { AttributeWithIndex P; P.Index = Idx; diff --git a/include/llvm/Function.h b/include/llvm/Function.h index 2781959eafd..855c926bf5c 100644 --- a/include/llvm/Function.h +++ b/include/llvm/Function.h @@ -277,9 +277,10 @@ public: bool doesNotAlias(unsigned n) const { return getParamAttributes(n).hasAttribute(Attributes::NoAlias); } - void setDoesNotAlias(unsigned n, bool DoesNotAlias = true) { - if (DoesNotAlias) addAttribute(n, Attribute::NoAlias); - else removeAttribute(n, Attribute::NoAlias); + void setDoesNotAlias(unsigned n) { + Attributes::Builder B; + B.addAttribute(Attributes::NoAlias); + addAttribute(n, Attributes::get(B)); } /// @brief Determine if the parameter can be captured. @@ -287,9 +288,10 @@ public: bool doesNotCapture(unsigned n) const { return getParamAttributes(n).hasAttribute(Attributes::NoCapture); } - void setDoesNotCapture(unsigned n, bool DoesNotCapture = true) { - if (DoesNotCapture) addAttribute(n, Attribute::NoCapture); - else removeAttribute(n, Attribute::NoCapture); + void setDoesNotCapture(unsigned n) { + Attributes::Builder B; + B.addAttribute(Attributes::NoCapture); + addAttribute(n, Attributes::get(B)); } /// copyAttributesFrom - copy all additional attributes (those not needed to |