summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2013-02-06 01:16:00 +0000
committerBill Wendling <isanbard@gmail.com>2013-02-06 01:16:00 +0000
commite261492fd485b51c581673530668b0da4c3f93c1 (patch)
treece5b85e72078ebbd965aac8027ed773a6781a2a4 /llvm/lib
parentd2c38d684a733ef0facf670bbd0a85040ca48a9c (diff)
downloadbcm5719-llvm-e261492fd485b51c581673530668b0da4c3f93c1.tar.gz
bcm5719-llvm-e261492fd485b51c581673530668b0da4c3f93c1.zip
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! llvm-svn: 174480
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/IR/Attributes.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp
index dc1a6573439..67ab4eaa699 100644
--- a/llvm/lib/IR/Attributes.cpp
+++ b/llvm/lib/IR/Attributes.cpp
@@ -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);
}
OpenPOWER on IntegriCloud