From a5372d270864316fb0752dd366f03fc1b45c6143 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Sun, 27 Jan 2013 21:20:06 +0000 Subject: [PATCH] Start using more of the AttrNode in the AttributeSetImpl class. 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 | 9 ++++----- lib/IR/Attributes.cpp | 12 +++++++----- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/IR/AttributeImpl.h b/lib/IR/AttributeImpl.h index b4c788fa9d4..2aba3c4de2b 100644 --- a/lib/IR/AttributeImpl.h +++ b/lib/IR/AttributeImpl.h @@ -116,15 +116,14 @@ class AttributeSetImpl : public FoldingSetNode { AttributeSetImpl(const AttributeSetImpl &) LLVM_DELETED_FUNCTION; public: AttributeSetImpl(LLVMContext &C, ArrayRef attrs); - AttributeSetImpl(LLVMContext &C, - ArrayRef > attrs); LLVMContext &getContext() { return Context; } ArrayRef 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. diff --git a/lib/IR/Attributes.cpp b/lib/IR/Attributes.cpp index 780da00ac01..00b542dbc1d 100644 --- a/lib/IR/Attributes.cpp +++ b/lib/IR/Attributes.cpp @@ -553,12 +553,14 @@ AttributeSetImpl(LLVMContext &C, AttrNodes.push_back(std::make_pair(AWI.Index, AttributeSetNode::get(C, Attrs))); } -} -AttributeSetImpl:: -AttributeSetImpl(LLVMContext &C, - ArrayRef > 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 } //===----------------------------------------------------------------------===//