[lld] r226321 - Remove duplication code.
Rui Ueyama
ruiu at google.com
Fri Jan 16 13:11:01 PST 2015
Author: ruiu
Date: Fri Jan 16 15:11:00 2015
New Revision: 226321
URL: http://llvm.org/viewvc/llvm-project?rev=226321&view=rev
Log:
Remove duplication code.
Modified:
lld/trunk/include/lld/Core/Resolver.h
lld/trunk/lib/Core/Resolver.cpp
lld/trunk/lib/ReaderWriter/CoreLinkingContext.cpp
Modified: lld/trunk/include/lld/Core/Resolver.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/Resolver.h?rev=226321&r1=226320&r2=226321&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/Resolver.h (original)
+++ lld/trunk/include/lld/Core/Resolver.h Fri Jan 16 15:11:00 2015
@@ -12,6 +12,7 @@
#include "lld/Core/File.h"
#include "lld/Core/SharedLibraryFile.h"
+#include "lld/Core/Simple.h"
#include "lld/Core/SymbolTable.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DenseSet.h"
@@ -73,37 +74,10 @@ private:
void markLive(const Atom *atom);
void addAtoms(const std::vector<const DefinedAtom *>&);
- class MergedFile : public MutableFile {
+ class MergedFile : public SimpleFile {
public:
- MergedFile() : MutableFile("<linker-internal>") {}
-
- const atom_collection<DefinedAtom> &defined() const override {
- return _definedAtoms;
- }
- const atom_collection<UndefinedAtom>& undefined() const override {
- return _undefinedAtoms;
- }
- const atom_collection<SharedLibraryAtom>& sharedLibrary() const override {
- return _sharedLibraryAtoms;
- }
- const atom_collection<AbsoluteAtom>& absolute() const override {
- return _absoluteAtoms;
- }
-
+ MergedFile() : SimpleFile("<linker-internal>") {}
void addAtoms(std::vector<const Atom*>& atoms);
-
- void addAtom(const Atom& atom) override;
-
- DefinedAtomRange definedAtoms() override;
-
- void removeDefinedAtomsIf(
- std::function<bool(const DefinedAtom *)> pred) override;
-
- private:
- atom_collection_vector<DefinedAtom> _definedAtoms;
- atom_collection_vector<UndefinedAtom> _undefinedAtoms;
- atom_collection_vector<SharedLibraryAtom> _sharedLibraryAtoms;
- atom_collection_vector<AbsoluteAtom> _absoluteAtoms;
};
LinkingContext &_context;
Modified: lld/trunk/lib/Core/Resolver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/Resolver.cpp?rev=226321&r1=226320&r2=226321&view=diff
==============================================================================
--- lld/trunk/lib/Core/Resolver.cpp (original)
+++ lld/trunk/lib/Core/Resolver.cpp Fri Jan 16 15:11:00 2015
@@ -458,32 +458,6 @@ bool Resolver::resolve() {
return true;
}
-void Resolver::MergedFile::addAtom(const Atom &atom) {
- if (auto *def = dyn_cast<DefinedAtom>(&atom)) {
- _definedAtoms._atoms.push_back(def);
- } else if (auto *undef = dyn_cast<UndefinedAtom>(&atom)) {
- _undefinedAtoms._atoms.push_back(undef);
- } else if (auto *shared = dyn_cast<SharedLibraryAtom>(&atom)) {
- _sharedLibraryAtoms._atoms.push_back(shared);
- } else if (auto *abs = dyn_cast<AbsoluteAtom>(&atom)) {
- _absoluteAtoms._atoms.push_back(abs);
- } else {
- llvm_unreachable("atom has unknown definition kind");
- }
-}
-
-MutableFile::DefinedAtomRange Resolver::MergedFile::definedAtoms() {
- return range<std::vector<const DefinedAtom *>::iterator>(
- _definedAtoms._atoms.begin(), _definedAtoms._atoms.end());
-}
-
-void Resolver::MergedFile::removeDefinedAtomsIf(
- std::function<bool(const DefinedAtom *)> pred) {
- auto &atoms = _definedAtoms._atoms;
- auto newEnd = std::remove_if(atoms.begin(), atoms.end(), pred);
- atoms.erase(newEnd, atoms.end());
-}
-
void Resolver::MergedFile::addAtoms(std::vector<const Atom *> &all) {
ScopedTask task(getDefaultDomain(), "addAtoms");
DEBUG_WITH_TYPE("resolver", llvm::dbgs() << "Resolver final atom list:\n");
Modified: lld/trunk/lib/ReaderWriter/CoreLinkingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/CoreLinkingContext.cpp?rev=226321&r1=226320&r2=226321&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/CoreLinkingContext.cpp (original)
+++ lld/trunk/lib/ReaderWriter/CoreLinkingContext.cpp Fri Jan 16 15:11:00 2015
@@ -155,34 +155,8 @@ public:
else
llvm_unreachable("atom has unknown definition kind");
}
-
- DefinedAtomRange definedAtoms() override {
- return range<std::vector<const DefinedAtom *>::iterator>(
- _definedAtoms._atoms.begin(), _definedAtoms._atoms.end());
- }
-
- const atom_collection<DefinedAtom> &defined() const override {
- return _definedAtoms;
- }
- const atom_collection<UndefinedAtom> &undefined() const override {
- return _undefinedAtoms;
- }
- const atom_collection<SharedLibraryAtom> &sharedLibrary() const override {
- return _sharedLibraryAtoms;
- }
- const atom_collection<AbsoluteAtom> &absolute() const override {
- return _absoluteAtoms;
- }
-
-private:
- atom_collection_vector<DefinedAtom> _definedAtoms;
- atom_collection_vector<UndefinedAtom> _undefinedAtoms;
- atom_collection_vector<SharedLibraryAtom> _sharedLibraryAtoms;
- atom_collection_vector<AbsoluteAtom> _absoluteAtoms;
};
-
-
} // anonymous namespace
CoreLinkingContext::CoreLinkingContext() {}
More information about the llvm-commits
mailing list