diff options
| author | Bill Wendling <isanbard@gmail.com> | 2012-12-30 01:38:39 +0000 |
|---|---|---|
| committer | Bill Wendling <isanbard@gmail.com> | 2012-12-30 01:38:39 +0000 |
| commit | 529ec718ac6844d2b8b60cb668c80dc5d5acf979 (patch) | |
| tree | f0385a5488cc818c244293b79c5a2f306d6c6d97 /lib/VMCore/Attributes.cpp | |
| parent | b4912b9dccd7250c372a40ba0734171c6b0f5e9b (diff) | |
Add a few (as yet unused) query methods to determine if the attribute that's
stored here is of a certain kind. This is in preparation for when an Attribute
object represents a single attribute, instead of a bitmask of attributes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171247 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Attributes.cpp')
| -rw-r--r-- | lib/VMCore/Attributes.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/VMCore/Attributes.cpp b/lib/VMCore/Attributes.cpp index a1e0856971..52405f25ae 100644 --- a/lib/VMCore/Attributes.cpp +++ b/lib/VMCore/Attributes.cpp @@ -302,7 +302,21 @@ AttributeImpl::AttributeImpl(LLVMContext &C, uint64_t data) { Data = ConstantInt::get(Type::getInt64Ty(C), data); } +bool AttributeImpl::contains(Attribute::AttrKind Kind) const { + if (ConstantInt *CI = dyn_cast<ConstantInt>(Data)) + return CI->getZExtValue() == Kind; + return false; +} + +bool AttributeImpl::contains(StringRef Kind) const { + if (ConstantDataArray *CDA = dyn_cast<ConstantDataArray>(Data)) + if (CDA->isString()) + return CDA->getAsString() == Kind; + return false; +} + uint64_t AttributeImpl::getBitMask() const { + // FIXME: Remove this. return cast<ConstantInt>(Data)->getZExtValue(); } |
