aboutsummaryrefslogtreecommitdiff
path: root/lib/IR/Attributes.cpp
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
commit85df6b43403d3ebf5d80023a85699c6fb254941a (patch)
tree425cb61abc00dbb19c13fdf0fdc118d8c1882d0c /lib/IR/Attributes.cpp
parent9c5861fdbd5e30df55cb7cd9a0edda8d92494100 (diff)
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
Diffstat (limited to 'lib/IR/Attributes.cpp')
-rw-r--r--lib/IR/Attributes.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/IR/Attributes.cpp b/lib/IR/Attributes.cpp
index dc1a657343..67ab4eaa69 100644
--- a/lib/IR/Attributes.cpp
+++ b/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);
}