Start using more of the AttrNode in the AttributeSetImpl class.
authorBill Wendling <isanbard@gmail.com>
Sun, 27 Jan 2013 21:20:06 +0000 (21:20 +0000)
committerBill Wendling <isanbard@gmail.com>
Sun, 27 Jan 2013 21:20:06 +0000 (21:20 +0000)
Also add some asserts.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173627 91177308-0d34-0410-b5e6-96231b3b80d8

lib/IR/AttributeImpl.h
lib/IR/Attributes.cpp

index b4c788fa9d4a910d88978ee78887e4c51371409e..2aba3c4de2b686e2875833ca58e24b9c685f4b64 100644 (file)
@@ -116,15 +116,14 @@ class AttributeSetImpl : public FoldingSetNode {
   AttributeSetImpl(const AttributeSetImpl &) LLVM_DELETED_FUNCTION;
 public:
   AttributeSetImpl(LLVMContext &C, ArrayRef<AttributeWithIndex> attrs);
-  AttributeSetImpl(LLVMContext &C,
-                   ArrayRef<std::pair<uint64_t, AttributeSetNode*> > attrs);
 
   LLVMContext &getContext() { return Context; }
   ArrayRef<AttributeWithIndex> getAttributes() const { return AttrList; }
-  unsigned getNumAttributes() const { return AttrList.size(); }
+  unsigned getNumAttributes() const {
+    return AttrNodes.size();
+  }
   unsigned getSlotIndex(unsigned Slot) const {
-    // FIXME: This needs to use AttrNodes instead.
-    return AttrList[Slot].Index;
+    return AttrNodes[Slot].first;
   }
   AttributeSet getSlotAttributes(unsigned Slot) const {
     // FIXME: This needs to use AttrNodes instead.
index 780da00ac01689b3d68b8e527eac90859aced8c2..00b542dbc1da2d85c8a9e0e6d02981a84149fa9b 100644 (file)
@@ -553,12 +553,14 @@ AttributeSetImpl(LLVMContext &C,
     AttrNodes.push_back(std::make_pair(AWI.Index,
                                        AttributeSetNode::get(C, Attrs)));
   }
-}
 
-AttributeSetImpl::
-AttributeSetImpl(LLVMContext &C,
-                 ArrayRef<std::pair<uint64_t, AttributeSetNode*> > attrs)
-  : Context(C), AttrNodes(attrs.begin(), attrs.end()) {
+  assert(AttrNodes.size() == AttrList.size() &&
+         "Number of attributes is different between lists!");
+#ifndef NDEBUG
+  for (unsigned I = 0, E = AttrNodes.size(); I != E; ++I)
+    assert((I == 0 || AttrNodes[I - 1].first < AttrNodes[I].first) &&
+           "Attributes not in ascending order!");
+#endif
 }
 
 //===----------------------------------------------------------------------===//