mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 19:52:54 +01:00
Don't treat 0 as a special value for int attributes.
Split the get() to not use a default value. This way attributes can be added that have 0 as a legitimate value. llvm-svn: 217107
This commit is contained in:
parent
a018fde83e
commit
4e7d8af048
@ -126,7 +126,8 @@ public:
|
|||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
|
|
||||||
/// \brief Return a uniquified Attribute object.
|
/// \brief Return a uniquified Attribute object.
|
||||||
static Attribute get(LLVMContext &Context, AttrKind Kind, uint64_t Val = 0);
|
static Attribute get(LLVMContext &Context, AttrKind Kind);
|
||||||
|
static Attribute get(LLVMContext &Context, AttrKind Kind, uint64_t Val);
|
||||||
static Attribute get(LLVMContext &Context, StringRef Kind,
|
static Attribute get(LLVMContext &Context, StringRef Kind,
|
||||||
StringRef Val = StringRef());
|
StringRef Val = StringRef());
|
||||||
|
|
||||||
@ -273,13 +274,13 @@ public:
|
|||||||
/// \brief Remove the specified attribute at the specified index from this
|
/// \brief Remove the specified attribute at the specified index from this
|
||||||
/// attribute list. Since attribute lists are immutable, this returns the new
|
/// attribute list. Since attribute lists are immutable, this returns the new
|
||||||
/// list.
|
/// list.
|
||||||
AttributeSet removeAttribute(LLVMContext &C, unsigned Index,
|
AttributeSet removeAttribute(LLVMContext &C, unsigned Index,
|
||||||
Attribute::AttrKind Attr) const;
|
Attribute::AttrKind Attr) const;
|
||||||
|
|
||||||
/// \brief Remove the specified attributes at the specified index from this
|
/// \brief Remove the specified attributes at the specified index from this
|
||||||
/// attribute list. Since attribute lists are immutable, this returns the new
|
/// attribute list. Since attribute lists are immutable, this returns the new
|
||||||
/// list.
|
/// list.
|
||||||
AttributeSet removeAttributes(LLVMContext &C, unsigned Index,
|
AttributeSet removeAttributes(LLVMContext &C, unsigned Index,
|
||||||
AttributeSet Attrs) const;
|
AttributeSet Attrs) const;
|
||||||
|
|
||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
|
@ -31,12 +31,10 @@ using namespace llvm;
|
|||||||
// Attribute Construction Methods
|
// Attribute Construction Methods
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
Attribute Attribute::get(LLVMContext &Context, Attribute::AttrKind Kind,
|
Attribute Attribute::get(LLVMContext &Context, Attribute::AttrKind Kind) {
|
||||||
uint64_t Val) {
|
|
||||||
LLVMContextImpl *pImpl = Context.pImpl;
|
LLVMContextImpl *pImpl = Context.pImpl;
|
||||||
FoldingSetNodeID ID;
|
FoldingSetNodeID ID;
|
||||||
ID.AddInteger(Kind);
|
ID.AddInteger(Kind);
|
||||||
if (Val) ID.AddInteger(Val);
|
|
||||||
|
|
||||||
void *InsertPoint;
|
void *InsertPoint;
|
||||||
AttributeImpl *PA = pImpl->AttrsSet.FindNodeOrInsertPos(ID, InsertPoint);
|
AttributeImpl *PA = pImpl->AttrsSet.FindNodeOrInsertPos(ID, InsertPoint);
|
||||||
@ -44,10 +42,28 @@ Attribute Attribute::get(LLVMContext &Context, Attribute::AttrKind Kind,
|
|||||||
if (!PA) {
|
if (!PA) {
|
||||||
// If we didn't find any existing attributes of the same shape then create a
|
// If we didn't find any existing attributes of the same shape then create a
|
||||||
// new one and insert it.
|
// new one and insert it.
|
||||||
if (!Val)
|
PA = new EnumAttributeImpl(Kind);
|
||||||
PA = new EnumAttributeImpl(Kind);
|
pImpl->AttrsSet.InsertNode(PA, InsertPoint);
|
||||||
else
|
}
|
||||||
PA = new IntAttributeImpl(Kind, Val);
|
|
||||||
|
// Return the Attribute that we found or created.
|
||||||
|
return Attribute(PA);
|
||||||
|
}
|
||||||
|
|
||||||
|
Attribute Attribute::get(LLVMContext &Context, Attribute::AttrKind Kind,
|
||||||
|
uint64_t Val) {
|
||||||
|
LLVMContextImpl *pImpl = Context.pImpl;
|
||||||
|
FoldingSetNodeID ID;
|
||||||
|
ID.AddInteger(Kind);
|
||||||
|
ID.AddInteger(Val);
|
||||||
|
|
||||||
|
void *InsertPoint;
|
||||||
|
AttributeImpl *PA = pImpl->AttrsSet.FindNodeOrInsertPos(ID, InsertPoint);
|
||||||
|
|
||||||
|
if (!PA) {
|
||||||
|
// If we didn't find any existing attributes of the same shape then create a
|
||||||
|
// new one and insert it.
|
||||||
|
PA = new IntAttributeImpl(Kind, Val);
|
||||||
pImpl->AttrsSet.InsertNode(PA, InsertPoint);
|
pImpl->AttrsSet.InsertNode(PA, InsertPoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user