summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2015-01-15 07:56:14 +0000
committerRui Ueyama <ruiu@google.com>2015-01-15 07:56:14 +0000
commitdf3fca25200b3f558712b71f4575ae832afe91f3 (patch)
tree5d17269503f05a12e390f7028f53f07a1abe848b
parent7c4ba12769cf7e2347ea9021b023428cca2f5d20 (diff)
downloadbcm5719-llvm-df3fca25200b3f558712b71f4575ae832afe91f3.tar.gz
bcm5719-llvm-df3fca25200b3f558712b71f4575ae832afe91f3.zip
Remove FileNode::parse.
FileNode::parse was just a forwarder to File::parse so we could remove that. Also removed dead code. llvm-svn: 226144
-rw-r--r--lld/include/lld/Core/InputGraph.h58
-rw-r--r--lld/lib/Core/CMakeLists.txt1
-rw-r--r--lld/lib/Core/InputGraph.cpp21
-rw-r--r--lld/lib/Driver/Driver.cpp20
4 files changed, 17 insertions, 83 deletions
diff --git a/lld/include/lld/Core/InputGraph.h b/lld/include/lld/Core/InputGraph.h
index 07d61aced48..61c50c7b612 100644
--- a/lld/include/lld/Core/InputGraph.h
+++ b/lld/include/lld/Core/InputGraph.h
@@ -33,24 +33,8 @@ namespace lld {
class InputElement;
class LinkingContext;
-/// \brief The inputs to the linker are represented by an InputGraph. The
-/// nodes in the input graph contains Input elements. The InputElements are
-/// either Input Files or Control Options. The Input Files represent each Input
-/// File to the linker and the control option specify what the linker needs
-/// to do when it processes the option.
-/// Each InputElement that is part of the Graph has an Ordinal value
-/// associated with it. The ordinal value is needed for the Writer to figure out
-/// the relative position of the arguments that appeared in the Command Line.
class InputGraph {
public:
- typedef std::vector<std::unique_ptr<InputElement> > InputElementVectorT;
- typedef InputElementVectorT::iterator InputElementIterT;
- typedef std::vector<std::unique_ptr<File> > FileVectorT;
- typedef FileVectorT::iterator FileIterT;
-
- /// \brief Initialize the inputgraph
- InputGraph() : _index(0) {}
-
/// \brief Adds a node into the InputGraph
void addInputElement(std::unique_ptr<InputElement> ie) {
_members.push_back(std::move(ie));
@@ -61,13 +45,12 @@ public:
_members.insert(_members.begin(), std::move(ie));
}
- InputElementVectorT &members() { return _members; }
+ std::vector<std::unique_ptr<InputElement>> &members() {
+ return _members;
+ }
protected:
- // Input arguments
- InputElementVectorT _members;
- // Index of the next element to be processed
- size_t _index;
+ std::vector<std::unique_ptr<InputElement>> _members;
};
/// \brief This describes each element in the InputGraph. The Kind
@@ -86,9 +69,6 @@ public:
/// Return the Element Type for an Input Element
virtual Kind kind() const { return _kind; }
- /// \brief parse the input element
- virtual std::error_code parse(const LinkingContext &, raw_ostream &) = 0;
-
protected:
Kind _kind; // The type of the Element
};
@@ -105,50 +85,26 @@ public:
return a->kind() == Kind::GroupEnd;
}
- /// \brief Parse the group members.
- std::error_code parse(const LinkingContext &ctx, raw_ostream &diag) override {
- return std::error_code();
- }
-
private:
int _size;
};
-/// \brief Represents an Input file in the graph
-///
-/// This class represents an input to the linker. It create the MemoryBuffer
-/// lazily when needed based on the file path. It can also take a MemoryBuffer
-/// directly.
+// A container of File.
class FileNode : public InputElement {
public:
explicit FileNode(std::unique_ptr<File> f)
- : InputElement(InputElement::Kind::File), _file(std::move(f)),
- _done(false) {}
+ : InputElement(InputElement::Kind::File), _file(std::move(f)) {}
virtual ~FileNode() {}
- /// \brief Casting support
static inline bool classof(const InputElement *a) {
return a->kind() == InputElement::Kind::File;
}
- /// \brief Get the list of files
File *getFile() { return _file.get(); }
- /// \brief add a file to the list of files
- virtual void addFiles(InputGraph::FileVectorT files) {
- assert(files.size() == 1);
- assert(!_file);
- _file = std::move(files[0]);
- }
-
- std::error_code parse(const LinkingContext &, raw_ostream &) override;
-
protected:
- std::unique_ptr<File> _file; // An lld File object
-
- // The next file that would be processed by the resolver
- bool _done;
+ std::unique_ptr<File> _file;
};
} // namespace lld
diff --git a/lld/lib/Core/CMakeLists.txt b/lld/lib/Core/CMakeLists.txt
index 9b6d032aa8a..bbd5bf89aec 100644
--- a/lld/lib/Core/CMakeLists.txt
+++ b/lld/lib/Core/CMakeLists.txt
@@ -4,7 +4,6 @@ add_lld_library(lldCore
DefinedAtom.cpp
Error.cpp
File.cpp
- InputGraph.cpp
LinkingContext.cpp
Resolver.cpp
SymbolTable.cpp
diff --git a/lld/lib/Core/InputGraph.cpp b/lld/lib/Core/InputGraph.cpp
deleted file mode 100644
index b5b68da88bc..00000000000
--- a/lld/lib/Core/InputGraph.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-//===- lib/Core/InputGraph.cpp --------------------------------------------===//
-//
-// The LLVM Linker
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "lld/Core/InputGraph.h"
-#include "lld/Core/Resolver.h"
-#include <memory>
-
-using namespace lld;
-
-std::error_code FileNode::parse(const LinkingContext &, raw_ostream &) {
- if (_file)
- if (std::error_code ec = _file->parse())
- return ec;
- return std::error_code();
-}
diff --git a/lld/lib/Driver/Driver.cpp b/lld/lib/Driver/Driver.cpp
index 9882b550a6e..5d9d6807f4a 100644
--- a/lld/lib/Driver/Driver.cpp
+++ b/lld/lib/Driver/Driver.cpp
@@ -93,14 +93,14 @@ bool Driver::link(LinkingContext &context, raw_ostream &diagnostics) {
std::string buf;
llvm::raw_string_ostream stream(buf);
- if (std::error_code ec = ie->parse(context, stream)) {
- if (FileNode *fileNode = dyn_cast<FileNode>(ie.get())) {
- stream << "Cannot open " + fileNode->getFile()->path()
- << ": " << ec.message() << "\n";
- } else {
- llvm_unreachable("Unknown type of input element");
- }
- fail = true;
+ if (FileNode *node = dyn_cast<FileNode>(ie.get())) {
+ if (File *file = node->getFile()) {
+ if (std::error_code ec = file->parse()) {
+ stream << "Cannot open " + file->path()
+ << ": " << ec.message() << "\n";
+ fail = true;
+ }
+ }
}
stream.flush();
@@ -116,7 +116,7 @@ bool Driver::link(LinkingContext &context, raw_ostream &diagnostics) {
if (fail)
return false;
- InputGraph::FileVectorT internalFiles;
+ std::vector<std::unique_ptr<File>> internalFiles;
context.createInternalFiles(internalFiles);
for (auto i = internalFiles.rbegin(), e = internalFiles.rend(); i != e; ++i) {
context.getInputGraph().addInputElementFront(
@@ -124,7 +124,7 @@ bool Driver::link(LinkingContext &context, raw_ostream &diagnostics) {
}
// Give target a chance to add files.
- InputGraph::FileVectorT implicitFiles;
+ std::vector<std::unique_ptr<File>> implicitFiles;
context.createImplicitFiles(implicitFiles);
for (auto i = implicitFiles.rbegin(), e = implicitFiles.rend(); i != e; ++i) {
context.getInputGraph().addInputElementFront(
OpenPOWER on IntegriCloud