Files
rk35xx-android14/frameworks/compile/mclinker/lib/MC/AttributeSet.cpp
T
hmz007 36ed224bac Rockchip Anroid14_SDK 20240628-rkr5 (2556df1a)
Signed-off-by: hmz007 <hmz007@gmail.com>
Change-Id: Ib87fdbe7a0be7dc961af3500fe9ea4589a127f9f
2024-10-29 18:12:02 +08:00

55 lines
1.3 KiB
C++

//===- AttributeSet.cpp ---------------------------------------------------===//
//
// The MCLinker Project
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "mcld/MC/AttributeSet.h"
#include "mcld/MC/Attribute.h"
#include <cstddef>
namespace mcld {
//===----------------------------------------------------------------------===//
// AttributeSet
//===----------------------------------------------------------------------===//
AttributeSet::AttributeSet(unsigned int pNum, const Attribute& pPredefined)
: m_AttrSet(), m_Predefined(pPredefined) {
m_AttrSet.reserve(pNum);
}
AttributeSet::~AttributeSet() {
iterator cur = m_AttrSet.begin();
iterator aEnd = m_AttrSet.end();
while (cur != aEnd) {
delete (*cur);
++cur;
}
}
Attribute* AttributeSet::exists(const Attribute& pAttr) const {
if (m_Predefined == pAttr)
return const_cast<Attribute*>(&m_Predefined);
const_iterator cur = m_AttrSet.begin();
const_iterator aEnd = m_AttrSet.end();
while (cur != aEnd) {
if (*(*cur) == pAttr) {
return *cur;
}
++cur;
}
return NULL;
}
void AttributeSet::record(mcld::Attribute& pAttr) {
m_AttrSet.push_back(&pAttr);
}
} // namespace mcld