Remove some dead code, improve some asserts, and other assorted changes. No functionality change.
llvm-svn: 174132
This commit is contained in:
parent
9631d908b0
commit
c79cdff195
|
@ -38,14 +38,9 @@ class AttributeImpl : public FoldingSetNode {
|
||||||
void operator=(const AttributeImpl &) LLVM_DELETED_FUNCTION;
|
void operator=(const AttributeImpl &) LLVM_DELETED_FUNCTION;
|
||||||
AttributeImpl(const AttributeImpl &) LLVM_DELETED_FUNCTION;
|
AttributeImpl(const AttributeImpl &) LLVM_DELETED_FUNCTION;
|
||||||
public:
|
public:
|
||||||
AttributeImpl(LLVMContext &C, Constant *Kind)
|
AttributeImpl(LLVMContext &C, Constant *Kind,
|
||||||
: Context(C), Kind(Kind) {}
|
ArrayRef<Constant*> Vals = ArrayRef<Constant*>())
|
||||||
AttributeImpl(LLVMContext &C, Constant *Kind, ArrayRef<Constant*> Vals)
|
|
||||||
: Context(C), Kind(Kind), Vals(Vals.begin(), Vals.end()) {}
|
: Context(C), Kind(Kind), Vals(Vals.begin(), Vals.end()) {}
|
||||||
explicit AttributeImpl(LLVMContext &C, Attribute::AttrKind data);
|
|
||||||
AttributeImpl(LLVMContext &C, Attribute::AttrKind data,
|
|
||||||
ArrayRef<Constant*> values);
|
|
||||||
AttributeImpl(LLVMContext &C, StringRef data);
|
|
||||||
|
|
||||||
LLVMContext &getContext() { return Context; }
|
LLVMContext &getContext() { return Context; }
|
||||||
|
|
||||||
|
|
|
@ -90,16 +90,16 @@ ArrayRef<Constant*> Attribute::getAttributeValues() const {
|
||||||
|
|
||||||
/// This returns the alignment field of an attribute as a byte alignment value.
|
/// This returns the alignment field of an attribute as a byte alignment value.
|
||||||
unsigned Attribute::getAlignment() const {
|
unsigned Attribute::getAlignment() const {
|
||||||
if (!hasAttribute(Attribute::Alignment))
|
assert(hasAttribute(Attribute::Alignment) &&
|
||||||
return 0;
|
"Trying to get alignment from non-alignment attribute!");
|
||||||
return pImpl->getAlignment();
|
return pImpl->getAlignment();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This returns the stack alignment field of an attribute as a byte alignment
|
/// This returns the stack alignment field of an attribute as a byte alignment
|
||||||
/// value.
|
/// value.
|
||||||
unsigned Attribute::getStackAlignment() const {
|
unsigned Attribute::getStackAlignment() const {
|
||||||
if (!hasAttribute(Attribute::StackAlignment))
|
assert(hasAttribute(Attribute::StackAlignment) &&
|
||||||
return 0;
|
"Trying to get alignment from non-alignment attribute!");
|
||||||
return pImpl->getStackAlignment();
|
return pImpl->getStackAlignment();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,6 +204,7 @@ std::string Attribute::getAsString() const {
|
||||||
if (I != E) Result += ' ';
|
if (I != E) Result += ' ';
|
||||||
}
|
}
|
||||||
if (Vals.size() > 1) Result += ')';
|
if (Vals.size() > 1) Result += ')';
|
||||||
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
llvm_unreachable("Unknown attribute");
|
llvm_unreachable("Unknown attribute");
|
||||||
|
@ -227,22 +228,6 @@ bool Attribute::operator<(Attribute A) const {
|
||||||
// AttributeImpl Definition
|
// AttributeImpl Definition
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
AttributeImpl::AttributeImpl(LLVMContext &C, Attribute::AttrKind kind)
|
|
||||||
: Context(C) {
|
|
||||||
Kind = ConstantInt::get(Type::getInt64Ty(C), kind);
|
|
||||||
}
|
|
||||||
AttributeImpl::AttributeImpl(LLVMContext &C, Attribute::AttrKind kind,
|
|
||||||
ArrayRef<Constant*> values)
|
|
||||||
: Context(C) {
|
|
||||||
Kind = ConstantInt::get(Type::getInt64Ty(C), kind);
|
|
||||||
Vals.reserve(values.size());
|
|
||||||
Vals.append(values.begin(), values.end());
|
|
||||||
}
|
|
||||||
AttributeImpl::AttributeImpl(LLVMContext &C, StringRef kind)
|
|
||||||
: Context(C) {
|
|
||||||
Kind = ConstantDataArray::getString(C, kind);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AttributeImpl::hasAttribute(Attribute::AttrKind A) const {
|
bool AttributeImpl::hasAttribute(Attribute::AttrKind A) const {
|
||||||
if (ConstantInt *CI = dyn_cast<ConstantInt>(Kind))
|
if (ConstantInt *CI = dyn_cast<ConstantInt>(Kind))
|
||||||
return CI->getZExtValue() == A;
|
return CI->getZExtValue() == A;
|
||||||
|
@ -282,6 +267,9 @@ bool AttributeImpl::operator!=(StringRef kind) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AttributeImpl::operator<(const AttributeImpl &AI) const {
|
bool AttributeImpl::operator<(const AttributeImpl &AI) const {
|
||||||
|
// This sorts the attributes with Attribute::AttrKinds coming first (sorted
|
||||||
|
// relative to their enum value) and then strings.
|
||||||
|
|
||||||
if (!Kind && !AI.Kind) return false;
|
if (!Kind && !AI.Kind) return false;
|
||||||
if (!Kind && AI.Kind) return true;
|
if (!Kind && AI.Kind) return true;
|
||||||
if (Kind && !AI.Kind) return false;
|
if (Kind && !AI.Kind) return false;
|
||||||
|
@ -409,9 +397,9 @@ unsigned AttributeSetNode::getStackAlignment() const {
|
||||||
std::string AttributeSetNode::getAsString() const {
|
std::string AttributeSetNode::getAsString() const {
|
||||||
std::string Str = "";
|
std::string Str = "";
|
||||||
for (SmallVectorImpl<Attribute>::const_iterator I = AttrList.begin(),
|
for (SmallVectorImpl<Attribute>::const_iterator I = AttrList.begin(),
|
||||||
E = AttrList.end(); I != E; ++I) {
|
E = AttrList.end(); I != E; ) {
|
||||||
if (I != AttrList.begin()) Str += " ";
|
|
||||||
Str += I->getAsString();
|
Str += I->getAsString();
|
||||||
|
if (++I != E) Str += " ";
|
||||||
}
|
}
|
||||||
return Str;
|
return Str;
|
||||||
}
|
}
|
||||||
|
@ -951,6 +939,7 @@ uint64_t AttrBuilder::Raw() const {
|
||||||
// AttributeFuncs Function Defintions
|
// AttributeFuncs Function Defintions
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
/// \brief Which attributes cannot be applied to a type.
|
||||||
AttributeSet AttributeFuncs::typeIncompatible(Type *Ty, uint64_t Index) {
|
AttributeSet AttributeFuncs::typeIncompatible(Type *Ty, uint64_t Index) {
|
||||||
AttrBuilder Incompatible;
|
AttrBuilder Incompatible;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue