summaryrefslogtreecommitdiff
path: root/lib/VMCore
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2012-10-09 19:01:18 +0000
committerBill Wendling <isanbard@gmail.com>2012-10-09 19:01:18 +0000
commit3a106e60366a51b4594ec303ff8dbbc58913227f (patch)
tree8973e141d93b0cdaab17368f090f640a776cb38b /lib/VMCore
parent62430fd1a1d901956dfbac7b0ab49e2e653d6fc5 (diff)
downloadllvm-3a106e60366a51b4594ec303ff8dbbc58913227f.tar.gz
llvm-3a106e60366a51b4594ec303ff8dbbc58913227f.tar.bz2
llvm-3a106e60366a51b4594ec303ff8dbbc58913227f.tar.xz
Move the 'FunctionOnly' attributes thingy inside of the Attributes class.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165530 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r--lib/VMCore/Attributes.cpp28
-rw-r--r--lib/VMCore/Verifier.cpp18
2 files changed, 25 insertions, 21 deletions
diff --git a/lib/VMCore/Attributes.cpp b/lib/VMCore/Attributes.cpp
index f6906d72b7..45972635cb 100644
--- a/lib/VMCore/Attributes.cpp
+++ b/lib/VMCore/Attributes.cpp
@@ -120,20 +120,18 @@ uint64_t Attributes::Raw() const {
Attributes Attributes::typeIncompatible(Type *Ty) {
Attributes::Builder Incompatible;
- if (!Ty->isIntegerTy()) {
+ if (!Ty->isIntegerTy())
// Attributes that only apply to integers.
- Incompatible.addAttribute(Attributes::SExt);
- Incompatible.addAttribute(Attributes::ZExt);
- }
+ Incompatible.addAttribute(Attributes::SExt)
+ .addAttribute(Attributes::ZExt);
- if (!Ty->isPointerTy()) {
+ if (!Ty->isPointerTy())
// Attributes that only apply to pointers.
- Incompatible.addAttribute(Attributes::ByVal);
- Incompatible.addAttribute(Attributes::Nest);
- Incompatible.addAttribute(Attributes::NoAlias);
- Incompatible.addAttribute(Attributes::NoCapture);
- Incompatible.addAttribute(Attributes::StructRet);
- }
+ Incompatible.addAttribute(Attributes::ByVal)
+ .addAttribute(Attributes::Nest)
+ .addAttribute(Attributes::NoAlias)
+ .addAttribute(Attributes::NoCapture)
+ .addAttribute(Attributes::StructRet);
return Attributes(Incompatible.Bits); // FIXME: Use Attributes::get().
}
@@ -210,8 +208,10 @@ std::string Attributes::getAsString() const {
// Attributes::Builder Implementation
//===----------------------------------------------------------------------===//
-void Attributes::Builder::addAttribute(Attributes::AttrVal Val) {
+Attributes::Builder &Attributes::Builder::
+addAttribute(Attributes::AttrVal Val) {
Bits |= AttributesImpl::getAttrMask(Val);
+ return *this;
}
void Attributes::Builder::addAlignmentAttr(unsigned Align) {
@@ -228,8 +228,10 @@ void Attributes::Builder::addStackAlignmentAttr(unsigned Align) {
Bits |= (Log2_32(Align) + 1) << 26;
}
-void Attributes::Builder::removeAttribute(Attributes::AttrVal Val) {
+Attributes::Builder &Attributes::Builder::
+removeAttribute(Attributes::AttrVal Val) {
Bits &= ~AttributesImpl::getAttrMask(Val);
+ return *this;
}
void Attributes::Builder::removeAttributes(const Attributes &A) {
diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp
index 8b47f2518b..5d389a86ed 100644
--- a/lib/VMCore/Verifier.cpp
+++ b/lib/VMCore/Verifier.cpp
@@ -529,9 +529,9 @@ void Verifier::VerifyParameterAttrs(Attributes Attrs, Type *Ty,
if (!Attrs.hasAttributes())
return;
- Attributes FnCheckAttr = Attrs & Attribute::FunctionOnly;
- Assert1(!FnCheckAttr, "Attribute " + FnCheckAttr.getAsString() +
- " only applies to the function!", V);
+ Assert1(!Attrs.hasFunctionOnlyAttrs(),
+ "Some attributes in '" + Attrs.getAsString() +
+ "' only apply to functions!", V);
if (isReturnValue)
Assert1(!Attrs.hasParameterOnlyAttrs(),
@@ -541,8 +541,8 @@ void Verifier::VerifyParameterAttrs(Attributes Attrs, Type *Ty,
for (unsigned i = 0;
i < array_lengthof(Attribute::MutuallyIncompatible); ++i) {
Attributes MutI = Attrs & Attribute::MutuallyIncompatible[i];
- Assert1(MutI.isEmptyOrSingleton(), "Attributes " +
- MutI.getAsString() + " are incompatible!", V);
+ Assert1(MutI.isEmptyOrSingleton(), "Attributes '" +
+ MutI.getAsString() + "' are incompatible!", V);
}
Attributes TypeI = Attrs & Attributes::typeIncompatible(Ty);
@@ -592,9 +592,11 @@ void Verifier::VerifyFunctionAttrs(FunctionType *FT,
}
Attributes FAttrs = Attrs.getFnAttributes();
- Attributes NotFn = FAttrs & (~Attribute::FunctionOnly);
- Assert1(!NotFn, "Attribute " + NotFn.getAsString() +
- " does not apply to the function!", V);
+ Attributes::Builder NotFn(FAttrs);
+ NotFn.removeFunctionOnlyAttrs();
+ Assert1(!NotFn.hasAttributes(), "Attributes '" +
+ Attributes::get(NotFn).getAsString() +
+ "' do not apply to the function!", V);
for (unsigned i = 0;
i < array_lengthof(Attribute::MutuallyIncompatible); ++i) {