[lld] r197751 - Make SimpleFileNode inherit from FileNode.
Joey Gouly
joey.gouly at gmail.com
Thu Dec 19 15:39:03 PST 2013
Author: joey
Date: Thu Dec 19 17:39:02 2013
New Revision: 197751
URL: http://llvm.org/viewvc/llvm-project?rev=197751&view=rev
Log:
Make SimpleFileNode inherit from FileNode.
This removes a lot of duplicated code.
Modified:
lld/trunk/include/lld/Core/InputGraph.h
lld/trunk/lib/Core/InputGraph.cpp
lld/trunk/lib/Driver/Driver.cpp
Modified: lld/trunk/include/lld/Core/InputGraph.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/InputGraph.h?rev=197751&r1=197750&r2=197751&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/InputGraph.h (original)
+++ lld/trunk/include/lld/Core/InputGraph.h Thu Dec 19 17:39:02 2013
@@ -129,7 +129,6 @@ public:
/// Each input element in the graph can be a File or a control
enum class Kind : uint8_t {
Control, // Represents a type associated with ControlNodes
- SimpleFile, // Represents a type reserved for internal files
File // Represents a type associated with File Nodes
};
@@ -354,44 +353,17 @@ public:
};
/// \brief Represents Internal Input files
-class SimpleFileNode : public InputElement {
+class SimpleFileNode : public FileNode {
public:
SimpleFileNode(StringRef path, int64_t ordinal = -1);
- virtual ErrorOr<StringRef> path(const LinkingContext &) const {
- return _path;
- }
-
- // The saved input path thats used when a file is not found while
- // trying to parse a file
- StringRef getUserPath() const { return _path; }
-
virtual ~SimpleFileNode() {}
- /// \brief Casting support
- static inline bool classof(const InputElement *a) {
- return a->kind() == InputElement::Kind::SimpleFile;
- }
-
- /// \brief Get the list of files
- range<InputGraph::FileIterT> files() {
- return make_range(_files.begin(), _files.end());
- }
-
- /// \brief number of files.
- size_t numFiles() const { return _files.size(); }
-
/// \brief add a file to the list of files
virtual void appendInputFile(std::unique_ptr<File> f) {
_files.push_back(std::move(f));
}
- /// \brief add a file to the list of files
- virtual void appendInputFiles(InputGraph::FileVectorT files) {
- for (auto &ai : files)
- _files.push_back(std::move(ai));
- }
-
/// \brief validates the Input Element
virtual bool validate() { return true; }
@@ -411,23 +383,8 @@ public:
return *_files[_nextFileIndex++];
}
- /// \brief Set the resolver state.
- virtual void setResolveState(uint32_t resolveState) {
- _resolveState = resolveState;
- }
-
- /// \brief Retrieve the resolve state.
- virtual uint32_t getResolveState() const { return _resolveState; }
-
// Do nothing here.
virtual void resetNextIndex() {}
-
-protected:
- StringRef _path; // A string associated with this file.
- InputGraph::FileVectorT _files; // Vector of lld::File objects
- uint32_t _nextFileIndex; // The next file that would be processed by the
- // resolver
- uint32_t _resolveState; // The resolve state associated with this Node
};
} // namespace lld
Modified: lld/trunk/lib/Core/InputGraph.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/InputGraph.cpp?rev=197751&r1=197750&r2=197751&view=diff
==============================================================================
--- lld/trunk/lib/Core/InputGraph.cpp (original)
+++ lld/trunk/lib/Core/InputGraph.cpp Thu Dec 19 17:39:02 2013
@@ -177,8 +177,7 @@ void ControlNode::setResolveState(uint32
/// SimpleFileNode
SimpleFileNode::SimpleFileNode(StringRef path, int64_t ordinal)
- : InputElement(InputElement::Kind::SimpleFile, ordinal), _path(path),
- _nextFileIndex(0), _resolveState(Resolver::StateNoChange) {}
+ : FileNode(path, ordinal) {}
/// Group
Modified: lld/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/Driver.cpp?rev=197751&r1=197750&r2=197751&view=diff
==============================================================================
--- lld/trunk/lib/Driver/Driver.cpp (original)
+++ lld/trunk/lib/Driver/Driver.cpp Thu Dec 19 17:39:02 2013
@@ -90,13 +90,13 @@ bool Driver::link(LinkingContext &contex
context.createInternalFiles(internalFiles);
if (internalFiles.size())
- fileNode->appendInputFiles(std::move(internalFiles));
+ fileNode->addFiles(std::move(internalFiles));
// Give target a chance to add files.
InputGraph::FileVectorT implicitFiles;
context.createImplicitFiles(implicitFiles);
if (implicitFiles.size())
- fileNode->appendInputFiles(std::move(implicitFiles));
+ fileNode->addFiles(std::move(implicitFiles));
context.inputGraph().insertOneElementAt(std::move(fileNode),
InputGraph::Position::BEGIN);
More information about the llvm-commits
mailing list