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();
/// \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;
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);
}