summaryrefslogtreecommitdiffstats
path: root/lld/lib/ReaderWriter/YAML
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2015-04-08 23:02:11 +0000
committerRui Ueyama <ruiu@google.com>2015-04-08 23:02:11 +0000
commitb0db07bf9049bdc028fcdd306710b86100d68a5f (patch)
tree458e64e4d774ed54456f36ad70bae1cc4109b8b2 /lld/lib/ReaderWriter/YAML
parent7a2e5c260c89fe40f0d65e165a83d75a34bc587e (diff)
downloadbcm5719-llvm-b0db07bf9049bdc028fcdd306710b86100d68a5f.tar.gz
bcm5719-llvm-b0db07bf9049bdc028fcdd306710b86100d68a5f.zip
Separate atom_collection type into two different types. NFC.
atom_collection is basically a wrapper for std::vector. The class provides begin and end member functions, so that it "hides" the other member functions provided by std::vector. However, you can still directly access _atoms member since the member is not protected. We cannot simply make the member private because we need that member when we are constructing atom vectors. This patch splits atom_collection into two types: std::vector<Atom *> and AtomRange. When we are constructing atom vectors, we use the former class. We return instances of the latter class from File objects so that callers cannot add or remove atoms from the lists. std::vector<Atom *> is automatically converted to AtomRange. llvm-svn: 234450
Diffstat (limited to 'lld/lib/ReaderWriter/YAML')
-rw-r--r--lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp b/lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
index 3bf8a943637..7e14b2c130d 100644
--- a/lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
+++ b/lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
@@ -215,7 +215,15 @@ private:
NameToAtom _groupMap;
};
-template <typename T> using AtomList = lld::File::atom_collection<T>;
+/// Mapping of Atoms.
+template <typename T> class AtomList {
+ typedef lld::File::atom_collection<T> Ty;
+
+public:
+ typename Ty::iterator begin() { return _atoms.begin(); }
+ typename Ty::iterator end() { return _atoms.end(); }
+ Ty _atoms;
+};
/// Mapping of kind: field in yaml files.
enum FileKinds {
@@ -633,17 +641,17 @@ template <> struct MappingTraits<const lld::File *> {
const lld::File *denormalize(IO &io);
const atom_collection<lld::DefinedAtom> &defined() const override {
- return _definedAtoms;
+ return _definedAtoms._atoms;
}
const atom_collection<lld::UndefinedAtom> &undefined() const override {
- return _undefinedAtoms;
+ return _undefinedAtoms._atoms;
}
virtual const atom_collection<lld::SharedLibraryAtom> &
sharedLibrary() const override {
- return _sharedLibraryAtoms;
+ return _sharedLibraryAtoms._atoms;
}
const atom_collection<lld::AbsoluteAtom> &absolute() const override {
- return _absoluteAtoms;
+ return _absoluteAtoms._atoms;
}
// Allocate a new copy of this string in _storage, so the strings
OpenPOWER on IntegriCloud