diff options
| author | Rui Ueyama <ruiu@google.com> | 2015-04-07 20:43:38 +0000 |
|---|---|---|
| committer | Rui Ueyama <ruiu@google.com> | 2015-04-07 20:43:38 +0000 |
| commit | 3c45cffd68cd9839d4737ea260ed2706ab304cc9 (patch) | |
| tree | a9e98d63c888ff305a2683d6120ba195ccbed629 /lld/include | |
| parent | 6bea2f4f88ddc4437c4a072ca60118e7ad8ed834 (diff) | |
| download | bcm5719-llvm-3c45cffd68cd9839d4737ea260ed2706ab304cc9.tar.gz bcm5719-llvm-3c45cffd68cd9839d4737ea260ed2706ab304cc9.zip | |
Merge MutableFile with SimpleFile.
SimpleFile is the only derived class of MutableFile.
This patch reduces the height of class hierarchy by removing
MutableFile class.
llvm-svn: 234354
Diffstat (limited to 'lld/include')
| -rw-r--r-- | lld/include/lld/Core/File.h | 18 | ||||
| -rw-r--r-- | lld/include/lld/Core/Pass.h | 4 | ||||
| -rw-r--r-- | lld/include/lld/Core/PassManager.h | 4 | ||||
| -rw-r--r-- | lld/include/lld/Core/Resolver.h | 2 | ||||
| -rw-r--r-- | lld/include/lld/Core/Simple.h | 14 |
5 files changed, 11 insertions, 31 deletions
diff --git a/lld/include/lld/Core/File.h b/lld/include/lld/Core/File.h index 25b177ec879..d0f96581f28 100644 --- a/lld/include/lld/Core/File.h +++ b/lld/include/lld/Core/File.h @@ -272,24 +272,6 @@ private: std::mutex _parseMutex; }; -/// \brief A mutable File. -class MutableFile : public File { -public: - /// \brief Add an atom to the file. Invalidates iterators for all returned - /// containters. - virtual void addAtom(const Atom&) = 0; - - typedef range<std::vector<const DefinedAtom *>::iterator> DefinedAtomRange; - virtual DefinedAtomRange definedAtoms() = 0; - - virtual void - removeDefinedAtomsIf(std::function<bool(const DefinedAtom *)> pred) = 0; - -protected: - /// \brief only subclasses of MutableFile can be instantiated - MutableFile(StringRef p) : File(p, kindObject) {} -}; - /// An ErrorFile represents a file that doesn't exist. /// If you try to parse a file which doesn't exist, an instance of this /// class will be returned. That's parse method always returns an error. diff --git a/lld/include/lld/Core/Pass.h b/lld/include/lld/Core/Pass.h index 7a9d2453f48..14170d88c21 100644 --- a/lld/include/lld/Core/Pass.h +++ b/lld/include/lld/Core/Pass.h @@ -17,7 +17,7 @@ #include <vector> namespace lld { -class MutableFile; +class SimpleFile; /// Once the core linking is done (which resolves references, coalesces atoms /// and produces a complete Atom graph), the linker runs a series of passes @@ -34,7 +34,7 @@ public: virtual ~Pass() { } /// Do the actual work of the Pass. - virtual void perform(std::unique_ptr<MutableFile> &mergedFile) = 0; + virtual void perform(std::unique_ptr<SimpleFile> &mergedFile) = 0; protected: // Only subclassess can be instantiated. diff --git a/lld/include/lld/Core/PassManager.h b/lld/include/lld/Core/PassManager.h index 65fc4d806ce..290e527c280 100644 --- a/lld/include/lld/Core/PassManager.h +++ b/lld/include/lld/Core/PassManager.h @@ -16,7 +16,7 @@ #include <vector> namespace lld { -class MutableFile; +class SimpleFile; class Pass; /// \brief Owns and runs a collection of passes. @@ -31,7 +31,7 @@ public: _passes.push_back(std::move(pass)); } - std::error_code runOnFile(std::unique_ptr<MutableFile> &file) { + std::error_code runOnFile(std::unique_ptr<SimpleFile> &file) { for (std::unique_ptr<Pass> &pass : _passes) pass->perform(file); return std::error_code(); diff --git a/lld/include/lld/Core/Resolver.h b/lld/include/lld/Core/Resolver.h index e16c07b839f..05af7d9573e 100644 --- a/lld/include/lld/Core/Resolver.h +++ b/lld/include/lld/Core/Resolver.h @@ -54,7 +54,7 @@ public: /// @brief do work of merging and resolving and return list bool resolve(); - std::unique_ptr<MutableFile> resultFile() { return std::move(_result); } + std::unique_ptr<SimpleFile> resultFile() { return std::move(_result); } private: typedef std::function<void(StringRef, bool)> UndefCallback; diff --git a/lld/include/lld/Core/Simple.h b/lld/include/lld/Core/Simple.h index 6aa12ae9ce5..2a5a4b105a6 100644 --- a/lld/include/lld/Core/Simple.h +++ b/lld/include/lld/Core/Simple.h @@ -26,11 +26,11 @@ namespace lld { -class SimpleFile : public MutableFile { +class SimpleFile : public File { public: - SimpleFile(StringRef path) : MutableFile(path) {} + SimpleFile(StringRef path) : File(path, kindObject) {} - void addAtom(const Atom &atom) override { + void addAtom(const Atom &atom) { if (auto *defAtom = dyn_cast<DefinedAtom>(&atom)) { _definedAtoms._atoms.push_back(defAtom); } else if (auto *undefAtom = dyn_cast<UndefinedAtom>(&atom)) { @@ -44,8 +44,7 @@ public: } } - void - removeDefinedAtomsIf(std::function<bool(const DefinedAtom *)> pred) override { + void 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()); @@ -67,9 +66,8 @@ public: return _absoluteAtoms; } - DefinedAtomRange definedAtoms() override { - return make_range(_definedAtoms._atoms); - } + typedef range<std::vector<const DefinedAtom *>::iterator> DefinedAtomRange; + DefinedAtomRange definedAtoms() { return make_range(_definedAtoms._atoms); } private: atom_collection_vector<DefinedAtom> _definedAtoms; |

