mirror of
https://github.com/RPCS3/llvm.git
synced 2025-01-01 17:28:21 +00:00
Add methods to merge an AttrBuilder into another builder.
This is useful when parsing an object that references multiple attribute groups. N.B. If both builders have alignments specified, then they should match! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174480 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
9c5861fdbd
commit
85df6b4340
@ -373,6 +373,10 @@ public:
|
||||
addAttribute(A);
|
||||
}
|
||||
AttrBuilder(AttributeSet AS, unsigned Idx);
|
||||
AttrBuilder(const AttrBuilder &B)
|
||||
: Attrs(B.Attrs),
|
||||
TargetDepAttrs(B.TargetDepAttrs.begin(), B.TargetDepAttrs.end()),
|
||||
Alignment(B.Alignment), StackAlignment(B.StackAlignment) {}
|
||||
|
||||
void clear();
|
||||
|
||||
@ -394,6 +398,9 @@ public:
|
||||
/// \brief Remove the target-dependent attribute to the builder.
|
||||
AttrBuilder &removeAttribute(StringRef A);
|
||||
|
||||
/// \brief Add the attributes from the builder.
|
||||
AttrBuilder &merge(const AttrBuilder &B);
|
||||
|
||||
/// \brief Return true if the builder has the specified attribute.
|
||||
bool contains(Attribute::AttrKind A) const;
|
||||
|
||||
|
@ -956,6 +956,23 @@ AttrBuilder &AttrBuilder::addStackAlignmentAttr(unsigned Align) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
AttrBuilder &AttrBuilder::merge(const AttrBuilder &B) {
|
||||
// FIXME: What if both have alignments, but they don't match?!
|
||||
if (!Alignment)
|
||||
Alignment = B.Alignment;
|
||||
|
||||
if (!StackAlignment)
|
||||
StackAlignment = B.StackAlignment;
|
||||
|
||||
Attrs.insert(B.Attrs.begin(), B.Attrs.end());
|
||||
|
||||
for (td_const_iterator I = B.TargetDepAttrs.begin(),
|
||||
E = B.TargetDepAttrs.end(); I != E; ++I)
|
||||
TargetDepAttrs[I->first] = I->second;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool AttrBuilder::contains(Attribute::AttrKind A) const {
|
||||
return Attrs.count(A);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user