diff options
| author | Rui Ueyama <ruiu@google.com> | 2014-04-01 21:55:36 +0000 |
|---|---|---|
| committer | Rui Ueyama <ruiu@google.com> | 2014-04-01 21:55:36 +0000 |
| commit | 5632e26d364bb3639a50ae1bcbda117862bf44c0 (patch) | |
| tree | f35f78640330ba94bdb5d49713c64ae324e54592 | |
| parent | c744492f7c19ef6baeb9b60dc2ad7ff9cc2051f5 (diff) | |
| download | bcm5719-llvm-5632e26d364bb3639a50ae1bcbda117862bf44c0.tar.gz bcm5719-llvm-5632e26d364bb3639a50ae1bcbda117862bf44c0.zip | |
Greatly simplify InputGraph.
InputGraph has too many knobs and controls that are not being used. This
patch is to remove dead code, unused features and a class. There are two
things that worth noting, besides simple dead code removal:
1. ControlNode class is removed. We had it as the base class of Group
class, but it provides no functionality particularly meaningful. We now
have shallower class hierarchy that is easier to understand.
2. InputGraph provides a feature to replace a node with its internal data.
It is being used to "expand" some type of node, such as a Linker Script
node, with its actual files. We used to have two options when replacing
it -- ExpandOnly or ExpandAndReplace. ExpandOnly was to expand it but not
remove the node from the tree. There is no use of that option in the code,
so it was a dead feature.
Differential Revision: http://llvm-reviews.chandlerc.com/D3252
llvm-svn: 205363
| -rw-r--r-- | lld/include/lld/Core/InputGraph.h | 130 | ||||
| -rw-r--r-- | lld/include/lld/Driver/CoreInputGraph.h | 19 | ||||
| -rw-r--r-- | lld/include/lld/Driver/DarwinInputGraph.h | 14 | ||||
| -rw-r--r-- | lld/include/lld/Driver/GnuLdInputGraph.h | 59 | ||||
| -rw-r--r-- | lld/include/lld/Driver/WinLinkInputGraph.h | 9 | ||||
| -rw-r--r-- | lld/lib/Core/InputGraph.cpp | 61 | ||||
| -rw-r--r-- | lld/lib/Driver/CoreDriver.cpp | 2 | ||||
| -rw-r--r-- | lld/lib/Driver/Driver.cpp | 3 | ||||
| -rw-r--r-- | lld/lib/Driver/GnuLdDriver.cpp | 16 | ||||
| -rw-r--r-- | lld/lib/Driver/GnuLdInputGraph.cpp | 8 | ||||
| -rw-r--r-- | lld/lib/Driver/WinLinkDriver.cpp | 2 | ||||
| -rw-r--r-- | lld/unittests/DriverTests/InputGraphTest.cpp | 289 |
12 files changed, 120 insertions, 492 deletions
diff --git a/lld/include/lld/Core/InputGraph.h b/lld/include/lld/Core/InputGraph.h index f65a203aa06..c53173b1004 100644 --- a/lld/include/lld/Core/InputGraph.h +++ b/lld/include/lld/Core/InputGraph.h @@ -40,8 +40,6 @@ class LinkingContext; /// 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. -/// InputElements have a weight function that can be used to determine the -/// weight of the file, for statistical purposes. class InputGraph { public: typedef std::vector<std::unique_ptr<InputElement> > InputElementVectorT; @@ -66,10 +64,10 @@ public: /// \brief Set Ordinals for all the InputElements that form the InputGraph virtual bool assignOrdinals(); - /// Normalize the InputGraph. + /// Normalize the InputGraph. It visits all nodes in the tree to replace a + /// node with its children if it's shouldExpand() returnst true. virtual void normalize(); - /// Destructor virtual ~InputGraph() {} /// \brief Do postprocessing of the InputGraph if there is a need for the @@ -82,36 +80,26 @@ public: return make_range(_inputArgs.begin(), _inputArgs.end()); } - /// \brief Validate the input graph - virtual bool validate(); - // \brief Does the inputGraph contain any elements size_t size() const { return _inputArgs.size(); } /// \brief Dump the input Graph - virtual bool dump(raw_ostream &diagnostics = llvm::errs()); + bool dump(raw_ostream &diagnostics = llvm::errs()); InputElement &operator[](size_t index) const { return (*_inputArgs[index]); } - /// \brief Insert a vector of elements into the input graph at position. - virtual void insertElementsAt(std::vector<std::unique_ptr<InputElement> >, - Position position, size_t pos = 0); - /// \brief Insert an element into the input graph at position. - virtual void insertOneElementAt(std::unique_ptr<InputElement>, - Position position, size_t pos = 0); + void insertOneElementAt(std::unique_ptr<InputElement>, + Position position, size_t pos = 0); /// \brief Helper functions for the resolver - virtual ErrorOr<InputElement *> getNextInputElement(); - - /// \brief Set the index on what inputElement has to be returned - virtual error_code setNextElementIndex(uint32_t index = 0); + ErrorOr<InputElement *> getNextInputElement(); /// \brief Reset the inputGraph for the inputGraph to start processing /// files from the beginning - virtual error_code reset() { return setNextElementIndex(0); } + void reset() { _nextElementIndex = 0; } protected: // Input arguments @@ -128,17 +116,10 @@ class InputElement { 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 + Group, // Represents a type associated with Group File // Represents a type associated with File Nodes }; - /// How does the inputGraph expand the InputElement - enum class ExpandType : uint8_t { - None, // Do nothing(Default) - ReplaceAndExpand, // Replace current node and expand - ExpandOnly // Expand the current node - }; - /// \brief Initialize the Input Element, The ordinal value of an input Element /// is initially set to -1, if the user wants to override its ordinal, /// let the user do it @@ -156,15 +137,8 @@ public: virtual int64_t getOrdinal() const { return _ordinal; } - virtual int64_t weight() const { return _weight; } - - virtual void setWeight(int64_t weight) { _weight = weight; } - - /// \brief validates the Input Element - virtual bool validate() = 0; - /// \brief Dump the Input Element - virtual bool dump(raw_ostream &diagnostics) = 0; + virtual bool dump(raw_ostream &diagnostics) { return true; } /// \brief parse the input element virtual error_code parse(const LinkingContext &, raw_ostream &) = 0; @@ -183,14 +157,10 @@ public: /// \brief Reset the next index virtual void resetNextIndex() = 0; - /// \brief Is this a hidden node, hidden nodes are not part of - /// of the resolver. - virtual bool isHidden() const { return false; } - /// Normalize functions - /// \brief How do we want to expand the current node ? - virtual ExpandType expandType() const { return ExpandType::None; } + /// Returns true if we want to replace this node with children. + virtual bool shouldExpand() const { return false; } /// \brief Get the elements that we want to expand with. virtual range<InputGraph::InputElementIterT> expandElements() { @@ -200,43 +170,26 @@ public: protected: Kind _kind; // The type of the Element int64_t _ordinal; // The ordinal value - int64_t _weight; // Weight of the file }; -/// \brief The Control class represents a control node in the InputGraph -class ControlNode : public InputElement { +/// \brief A Control node which contains a group of InputElements +/// This affects the resolver so that it resolves undefined symbols +/// in the group completely before looking at other input files that +/// follow the group +class Group : public InputElement { public: - /// A control node could be of several types supported by InputGraph - /// Future kinds of Control node could be added - enum class ControlKind : uint8_t { - Simple, // Represents a simple control node - Group // Represents a type associated with ControlNodes - }; - - ControlNode(ControlNode::ControlKind controlKind = - ControlNode::ControlKind::Simple, - int64_t _ordinal = -1) - : InputElement(InputElement::Kind::Control, _ordinal), - _controlKind(controlKind), _currentElementIndex(0), - _nextElementIndex(0) {} - - virtual ~ControlNode() {} - - /// \brief Return the kind of control node - virtual ControlKind controlKind() { return _controlKind; } - - /// \brief Process control start/exit - virtual bool processControlEnter() { return true; } - - /// \brief Process control start/exit - virtual bool processControlExit() { return true; } - - /// Process the input Elemenet - virtual bool processInputElement(std::unique_ptr<InputElement> element) = 0; + Group(int64_t ordinal) + : InputElement(InputElement::Kind::Group, ordinal), + _currentElementIndex(0), _nextElementIndex(0) {} - /// \brief Casting support static inline bool classof(const InputElement *a) { - return a->kind() == InputElement::Kind::Control; + return a->kind() == InputElement::Kind::Group; + } + + /// \brief Process input element and add it to the group + bool addFile(std::unique_ptr<InputElement> element) { + _elements.push_back(std::move(element)); + return true; } range<InputGraph::InputElementIterT> elements() { @@ -250,11 +203,10 @@ public: } uint32_t getResolveState() const override; - void setResolveState(uint32_t) override; + ErrorOr<File &> getNextFile() override; protected: - ControlKind _controlKind; InputGraph::InputElementVectorT _elements; uint32_t _currentElementIndex; uint32_t _nextElementIndex; @@ -330,28 +282,6 @@ protected: // resolver }; -/// \brief A Control node which contains a group of InputElements -/// This affects the resolver so that it resolves undefined symbols -/// in the group completely before looking at other input files that -/// follow the group -class Group : public ControlNode { -public: - Group(int64_t ordinal) - : ControlNode(ControlNode::ControlKind::Group, ordinal) {} - - static inline bool classof(const InputElement *a) { - return a->kind() == InputElement::Kind::Control; - } - - /// \brief Process input element and add it to the group - bool processInputElement(std::unique_ptr<InputElement> element) override { - _elements.push_back(std::move(element)); - return true; - } - - ErrorOr<File &> getNextFile() override; -}; - /// \brief Represents Internal Input files class SimpleFileNode : public FileNode { public: @@ -364,12 +294,6 @@ public: _files.push_back(std::move(f)); } - /// \brief validates the Input Element - bool validate() override { return true; } - - /// \brief Dump the Input Element - bool dump(raw_ostream &) override { return true; } - /// \brief parse the input element error_code parse(const LinkingContext &, raw_ostream &) override { return error_code::success(); diff --git a/lld/include/lld/Driver/CoreInputGraph.h b/lld/include/lld/Driver/CoreInputGraph.h index ee122978f8f..0152d6d3497 100644 --- a/lld/include/lld/Driver/CoreInputGraph.h +++ b/lld/include/lld/Driver/CoreInputGraph.h @@ -26,17 +26,10 @@ namespace lld { -/// \brief Represents a CORE File -class COREFileNode : public FileNode { +/// \brief Represents a Core File +class CoreFileNode : public FileNode { public: - COREFileNode(CoreLinkingContext &ctx, StringRef path) - : FileNode(path), _ctx(ctx) {} - - /// \brief validates the Input Element - bool validate() override { - (void)_ctx; - return true; - } + CoreFileNode(CoreLinkingContext &, StringRef path) : FileNode(path) {} /// \brief Parse the input file to lld::File. error_code parse(const LinkingContext &ctx, raw_ostream &diagnostics) override { @@ -62,12 +55,6 @@ public: return make_error_code(InputGraphError::no_more_files); return *_files[_nextFileIndex++]; } - - /// \brief Dump the Input Element - bool dump(raw_ostream &) override { return true; } - -private: - CoreLinkingContext &_ctx; }; } // namespace lld diff --git a/lld/include/lld/Driver/DarwinInputGraph.h b/lld/include/lld/Driver/DarwinInputGraph.h index aaf0641d020..e9184348854 100644 --- a/lld/include/lld/Driver/DarwinInputGraph.h +++ b/lld/include/lld/Driver/DarwinInputGraph.h @@ -28,14 +28,8 @@ namespace lld { /// \brief Represents a MachO File class MachOFileNode : public FileNode { public: - MachOFileNode(MachOLinkingContext &ctx, StringRef path, bool isWholeArchive) - : FileNode(path), _ctx(ctx), _isWholeArchive(isWholeArchive) {} - - /// \brief validates the Input Element - bool validate() override { - (void)_ctx; - return true; - } + MachOFileNode(MachOLinkingContext &, StringRef path, bool isWholeArchive) + : FileNode(path), _isWholeArchive(isWholeArchive) {} /// \brief Parse the input file to lld::File. error_code parse(const LinkingContext &ctx, raw_ostream &diagnostics) override { @@ -80,11 +74,7 @@ public: return *_files[_nextFileIndex++]; } - /// \brief Dump the Input Element - bool dump(raw_ostream &) override { return true; } - private: - const MachOLinkingContext &_ctx; bool _isWholeArchive; }; diff --git a/lld/include/lld/Driver/GnuLdInputGraph.h b/lld/include/lld/Driver/GnuLdInputGraph.h index a54533e913f..d8142f5d76c 100644 --- a/lld/include/lld/Driver/GnuLdInputGraph.h +++ b/lld/include/lld/Driver/GnuLdInputGraph.h @@ -37,24 +37,21 @@ public: ErrorOr<StringRef> getPath(const LinkingContext &ctx) const override; - /// \brief validates the Input Element - bool validate() override { return true; } - /// \brief create an error string for printing purposes std::string errStr(error_code) override; /// \brief Dump the Input Element bool dump(raw_ostream &diagnostics) override { - diagnostics << "Name : " << *getPath(_elfLinkingContext) << "\n"; - diagnostics << "Type : " + diagnostics << "Name : " << *getPath(_elfLinkingContext) << "\n" + << "Type : " << "ELF File" - << "\n"; - diagnostics << "Ordinal : " << getOrdinal() << "\n"; - diagnostics << "Attributes : " - << "\n"; - diagnostics << " - wholeArchive : " - << ((_isWholeArchive) ? "true" : "false") << "\n"; - diagnostics << " - asNeeded : " << ((_asNeeded) ? "true" : "false") + << "\n" + << "Ordinal : " << getOrdinal() << "\n" + << "Attributes : " + << "\n" + << " - wholeArchive : " + << ((_isWholeArchive) ? "true" : "false") << "\n" + << " - asNeeded : " << ((_asNeeded) ? "true" : "false") << "\n"; return true; } @@ -70,8 +67,9 @@ public: /// a shared library void resetNextIndex() override { if ((!_isWholeArchive && (_files[0]->kind() == File::kindArchiveLibrary)) || - (_files[0]->kind() == File::kindSharedLibrary)) + (_files[0]->kind() == File::kindSharedLibrary)) { _nextFileIndex = 0; + } setResolveState(Resolver::StateNoChange); } @@ -97,17 +95,8 @@ private: /// \brief Represents a ELF control node class ELFGroup : public Group { public: - ELFGroup(const ELFLinkingContext &ctx, int64_t ordinal) - : Group(ordinal), _elfLinkingContext(ctx) {} - - /// \brief Validate the options - bool validate() override { - (void)_elfLinkingContext; - return true; - } - - /// \brief Dump the ELFGroup - bool dump(raw_ostream &) override { return true; } + ELFGroup(const ELFLinkingContext &, int64_t ordinal) + : Group(ordinal) {} /// \brief Parse the group members. error_code parse(const LinkingContext &ctx, raw_ostream &diagnostics) override { @@ -116,9 +105,6 @@ public: return ec; return error_code::success(); } - -private: - const ELFLinkingContext &_elfLinkingContext; }; /// \brief Parse GNU Linker scripts. @@ -126,20 +112,7 @@ class GNULdScript : public FileNode { public: GNULdScript(ELFLinkingContext &ctx, StringRef userPath, int64_t ordinal) : FileNode(userPath, ordinal), _elfLinkingContext(ctx), - _linkerScript(nullptr) - {} - - /// \brief Is this node part of resolution ? - bool isHidden() const override { return true; } - - /// \brief Validate the options - bool validate() override { - (void)_elfLinkingContext; - return true; - } - - /// \brief Dump the Linker script. - bool dump(raw_ostream &) override { return true; } + _linkerScript(nullptr) {} /// \brief Parse the linker script. error_code parse(const LinkingContext &, raw_ostream &) override; @@ -159,9 +132,7 @@ public: error_code parse(const LinkingContext &ctx, raw_ostream &diagnostics) override; - ExpandType expandType() const override { - return InputElement::ExpandType::ExpandOnly; - } + bool shouldExpand() const override { return true; } /// Unused functions for ELFGNULdScript Nodes. ErrorOr<File &> getNextFile() override { diff --git a/lld/include/lld/Driver/WinLinkInputGraph.h b/lld/include/lld/Driver/WinLinkInputGraph.h index bf673e3783b..e5b816ca26d 100644 --- a/lld/include/lld/Driver/WinLinkInputGraph.h +++ b/lld/include/lld/Driver/WinLinkInputGraph.h @@ -37,12 +37,6 @@ public: /// \brief Parse the input file to lld::File. error_code parse(const LinkingContext &ctx, raw_ostream &diagnostics) override; - /// \brief validates the Input Element - bool validate() override { return true; } - - /// \brief Dump the Input Element - bool dump(raw_ostream &) override { return true; } - ErrorOr<File &> getNextFile() override; protected: @@ -66,9 +60,6 @@ class PECOFFGroup : public Group { public: PECOFFGroup(PECOFFLinkingContext &ctx) : Group(0), _ctx(ctx) {} - bool validate() override { return true; } - bool dump(raw_ostream &) override { return true; } - /// \brief Parse the group members. error_code parse(const LinkingContext &ctx, raw_ostream &diagnostics) override { std::lock_guard<std::recursive_mutex> lock(_ctx.getMutex()); diff --git a/lld/lib/Core/InputGraph.cpp b/lld/lib/Core/InputGraph.cpp index b11e076ac5e..93d82446d08 100644 --- a/lld/lib/Core/InputGraph.cpp +++ b/lld/lib/Core/InputGraph.cpp @@ -35,13 +35,6 @@ void InputGraph::doPostProcess() { std::stable_sort(_inputArgs.begin(), _inputArgs.end(), sortInputElements); } -bool InputGraph::validate() { - for (auto &ie : _inputArgs) - if (!ie->validate()) - return false; - return true; -} - bool InputGraph::dump(raw_ostream &diagnostics) { for (auto &ie : _inputArgs) if (!ie->dump(diagnostics)) @@ -50,18 +43,6 @@ bool InputGraph::dump(raw_ostream &diagnostics) { } /// \brief Insert element at position -void InputGraph::insertElementsAt( - std::vector<std::unique_ptr<InputElement> > inputElements, - Position position, size_t pos) { - if (position == InputGraph::Position::BEGIN) - pos = 0; - else if (position == InputGraph::Position::END) - pos = _inputArgs.size(); - _inputArgs.insert(_inputArgs.begin() + pos, - std::make_move_iterator(inputElements.begin()), - std::make_move_iterator(inputElements.end())); -} - void InputGraph::insertOneElementAt(std::unique_ptr<InputElement> element, Position position, size_t pos) { if (position == InputGraph::Position::BEGIN) @@ -75,49 +56,26 @@ void InputGraph::insertOneElementAt(std::unique_ptr<InputElement> element, ErrorOr<InputElement *> InputGraph::getNextInputElement() { if (_nextElementIndex >= _inputArgs.size()) return make_error_code(InputGraphError::no_more_elements); - auto elem = _inputArgs[_nextElementIndex++].get(); - // Do not return Hidden elements. - if (!elem->isHidden()) - return elem; - return getNextInputElement(); + return _inputArgs[_nextElementIndex++].get(); } -/// \brief Set the index on what inputElement has to be returned -error_code InputGraph::setNextElementIndex(uint32_t index) { - if (index > _inputArgs.size()) - return make_error_code(llvm::errc::invalid_argument); - _nextElementIndex = index; - return error_code::success(); -} - -// Normalize the InputGraph. void InputGraph::normalize() { auto iterb = _inputArgs.begin(); auto itere = _inputArgs.end(); auto currentIter = _inputArgs.begin(); - bool replaceCurrentNode = false; - bool expand = false; std::vector<std::unique_ptr<InputElement> > _workInputArgs; while (iterb != itere) { - replaceCurrentNode = false; - expand = false; - InputElement::ExpandType expandType = (*iterb)->expandType(); - if (expandType == InputElement::ExpandType::ReplaceAndExpand) { - replaceCurrentNode = true; - expand = true; - } else if (expandType == InputElement::ExpandType::ExpandOnly) { - replaceCurrentNode = false; - expand = true; - } + bool expand = (*iterb)->shouldExpand(); currentIter = iterb++; - if (expand) + if (expand) { _workInputArgs.insert( _workInputArgs.end(), std::make_move_iterator((*currentIter)->expandElements().begin()), std::make_move_iterator((*currentIter)->expandElements().end())); - if (!replaceCurrentNode) + } else { _workInputArgs.push_back(std::move(*currentIter)); + } } _inputArgs = std::move(_workInputArgs); } @@ -128,7 +86,7 @@ void InputGraph::normalize() { /// is initially set to -1, if the user wants to override its ordinal, /// let the user do it InputElement::InputElement(Kind type, int64_t ordinal) - : _kind(type), _ordinal(ordinal), _weight(0) {} + : _kind(type), _ordinal(ordinal) {} /// FileNode FileNode::FileNode(StringRef path, int64_t ordinal) @@ -139,12 +97,9 @@ FileNode::FileNode(StringRef path, int64_t ordinal) error_code FileNode::getBuffer(StringRef filePath) { // Create a memory buffer std::unique_ptr<MemoryBuffer> mb; - if (error_code ec = MemoryBuffer::getFileOrSTDIN(filePath, mb)) return ec; - _buffer = std::move(mb); - return error_code::success(); } @@ -160,7 +115,7 @@ void FileNode::resetNextIndex() { /// \brief Get the resolver State. The return value of the resolve /// state for a control node is the or'ed value of the resolve states /// contained in it. -uint32_t ControlNode::getResolveState() const { +uint32_t Group::getResolveState() const { uint32_t resolveState = Resolver::StateNoChange; for (auto &elem : _elements) resolveState |= elem->getResolveState(); @@ -169,7 +124,7 @@ uint32_t ControlNode::getResolveState() const { /// \brief Set the resolve state for the current element /// thats processed by the resolver. -void ControlNode::setResolveState(uint32_t resolveState) { +void Group::setResolveState(uint32_t resolveState) { if (_elements.empty()) return; _elements[_currentElementIndex]->setResolveState(resolveState); diff --git a/lld/lib/Driver/CoreDriver.cpp b/lld/lib/Driver/CoreDriver.cpp index f4821f92fe8..2aa9e477f54 100644 --- a/lld/lib/Driver/CoreDriver.cpp +++ b/lld/lib/Driver/CoreDriver.cpp @@ -154,7 +154,7 @@ bool CoreDriver::parse(int argc, const char *argv[], CoreLinkingContext &ctx, case OPT_INPUT: inputGraph->addInputElement(std::unique_ptr<InputElement>( - new COREFileNode(ctx, inputArg->getValue()))); + new CoreFileNode(ctx, inputArg->getValue()))); break; default: diff --git a/lld/lib/Driver/Driver.cpp b/lld/lib/Driver/Driver.cpp index cb2ec4d3f96..0f3f1bfe689 100644 --- a/lld/lib/Driver/Driver.cpp +++ b/lld/lib/Driver/Driver.cpp @@ -55,9 +55,6 @@ bool Driver::link(LinkingContext &context, raw_ostream &diagnostics) { TaskGroup tg; std::mutex diagnosticsMutex; for (auto &ie : inputGraph.inputElements()) { - // Skip Hidden elements. - if (ie->isHidden()) - continue; tg.spawn([&] { // Writes to the same output stream is not guaranteed to be thread-safe. // We buffer the diagnostics output to a separate string-backed output diff --git a/lld/lib/Driver/GnuLdDriver.cpp b/lld/lib/Driver/GnuLdDriver.cpp index 517e69f177e..fc7dbffa505 100644 --- a/lld/lib/Driver/GnuLdDriver.cpp +++ b/lld/lib/Driver/GnuLdDriver.cpp @@ -266,7 +266,7 @@ bool GnuLdDriver::parse(int argc, const char *argv[], } std::unique_ptr<InputGraph> inputGraph(new InputGraph()); - std::stack<ControlNode *> controlNodeStack; + std::stack<Group *> groupStack; // Positional options for an Input File bool isWholeArchive = false; @@ -430,16 +430,14 @@ bool GnuLdDriver::parse(int argc, const char *argv[], } case OPT_start_group: { - std::unique_ptr<ELFGroup> controlStart(new ELFGroup(*ctx, index++)); - controlNodeStack.push(controlStart.get()); - controlNodeStack.top()->processControlEnter(); - inputGraph->addInputElement(std::move(controlStart)); + std::unique_ptr<Group> group(new ELFGroup(*ctx, index++)); + groupStack.push(group.get()); + inputGraph->addInputElement(std::move(group)); break; } case OPT_end_group: - controlNodeStack.top()->processControlExit(); - controlNodeStack.pop(); + groupStack.pop(); break; case OPT_INPUT: @@ -485,10 +483,10 @@ bool GnuLdDriver::parse(int argc, const char *argv[], } } std::unique_ptr<InputElement> inputFile(inputNode); - if (controlNodeStack.empty()) { + if (groupStack.empty()) { inputGraph->addInputElement(std::move(inputFile)); } else { - controlNodeStack.top()->processInputElement(std::move(inputFile)); + groupStack.top()->addFile(std::move(inputFile)); } break; } diff --git a/lld/lib/Driver/GnuLdInputGraph.cpp b/lld/lib/Driver/GnuLdInputGraph.cpp index 9becadb5ed9..f65dcc5f178 100644 --- a/lld/lib/Driver/GnuLdInputGraph.cpp +++ b/lld/lib/Driver/GnuLdInputGraph.cpp @@ -79,7 +79,7 @@ error_code ELFGNULdScript::parse(const LinkingContext &ctx, return ec; for (const auto &c : _linkerScript->_commands) { if (auto group = dyn_cast<script::Group>(c)) { - std::unique_ptr<InputElement> controlStart( + std::unique_ptr<Group> groupStart( new ELFGroup(_elfLinkingContext, index++)); for (auto &path : group->getPaths()) { // TODO : Propagate Set WholeArchive/dashlPrefix @@ -87,10 +87,10 @@ error_code ELFGNULdScript::parse(const LinkingContext &ctx, _elfLinkingContext, _elfLinkingContext.allocateString(path._path), index++, false, path._asNeeded, false); std::unique_ptr<InputElement> inputFile(inputNode); - dyn_cast<ControlNode>(controlStart.get()) - ->processInputElement(std::move(inputFile)); + cast<Group>(groupStart.get())->addFile( + std::move(inputFile)); } - _expandElements.push_back(std::move(controlStart)); + _expandElements.push_back(std::move(groupStart)); } } return error_code::success(); diff --git a/lld/lib/Driver/WinLinkDriver.cpp b/lld/lib/Driver/WinLinkDriver.cpp index 19ee0827ed3..6a31aa95a6e 100644 --- a/lld/lib/Driver/WinLinkDriver.cpp +++ b/lld/lib/Driver/WinLinkDriver.cpp @@ -1257,7 +1257,7 @@ bool WinLinkDriver::parse(int argc, const char *argv[], if (isReadingDirectiveSection) if (lib->parse(ctx, diag)) return false; - ctx.getLibraryGroup()->processInputElement(std::move(lib)); + ctx.getLibraryGroup()->addFile(std::move(lib)); } } diff --git a/lld/unittests/DriverTests/InputGraphTest.cpp b/lld/unittests/DriverTests/InputGraphTest.cpp index 862962f1c8d..ebec3451e18 100644 --- a/lld/unittests/DriverTests/InputGraphTest.cpp +++ b/lld/unittests/DriverTests/InputGraphTest.cpp @@ -26,25 +26,15 @@ namespace { class MyLinkingContext : public LinkingContext { public: - Writer &writer() const override { llvm_unreachable("no writer!"); } bool validateImpl(raw_ostream &) override { return true; } }; -class MyInputGraph : public InputGraph { -public: - MyInputGraph() : InputGraph() {}; -}; - class MyFileNode : public FileNode { public: MyFileNode(StringRef path, int64_t ordinal) : FileNode(path, ordinal) {} - bool validate() override { return true; } - - bool dump(raw_ostream &) override { return true; } - error_code parse(const LinkingContext &, raw_ostream &) override { return error_code::success(); } @@ -60,10 +50,6 @@ class MyGroupNode : public Group { public: MyGroupNode(int64_t ordinal) : Group(ordinal) {} - bool validate() override { return true; } - - bool dump(raw_ostream &) override { return true; } - error_code parse(const LinkingContext &, raw_ostream &) override { return error_code::success(); } @@ -71,15 +57,8 @@ public: class MyExpandFileNode : public FileNode { public: - MyExpandFileNode(StringRef path, int64_t ordinal, - ExpandType expandType, bool isHidden=false) - : FileNode(path, ordinal), _expandType(expandType), - _isHidden(isHidden) - {} - - bool validate() override { return true; } - - bool dump(raw_ostream &) override { return true; } + MyExpandFileNode(StringRef path, int64_t ordinal) + : FileNode(path, ordinal) {} error_code parse(const LinkingContext &, raw_ostream &) override { return error_code::success(); @@ -92,7 +71,7 @@ public: } /// \brief How do we want to expand the current node ? - ExpandType expandType() const override { return _expandType; } + bool shouldExpand() const override { return true; } /// \brief Get the elements that we want to expand with. range<InputGraph::InputElementIterT> expandElements() override { @@ -105,24 +84,14 @@ public: return true; } - // Is hidden node - bool isHidden() const override { return _isHidden; } - private: InputGraph::InputElementVectorT _expandElements; - ExpandType _expandType; - bool _isHidden; -}; - -class MyObjFile : public SimpleFile { -public: - MyObjFile(LinkingContext &context, StringRef path) : SimpleFile(path) {} }; class InputGraphTest : public testing::Test { public: InputGraphTest() { - _inputGraph.reset(new MyInputGraph()); + _inputGraph.reset(new InputGraph()); _context.setInputGraph(std::move(_inputGraph)); } @@ -166,8 +135,8 @@ TEST_F(InputGraphTest, AddAFile) { TEST_F(InputGraphTest, AddAFileWithLLDFiles) { std::unique_ptr<MyFileNode> myfile(new MyFileNode("multi_files", 0)); std::vector<std::unique_ptr<File> > objfiles; - std::unique_ptr<MyObjFile> obj1(new MyObjFile(_context, "objfile1")); - std::unique_ptr<MyObjFile> obj2(new MyObjFile(_context, "objfile2")); + std::unique_ptr<SimpleFile> obj1(new SimpleFile("objfile1")); + std::unique_ptr<SimpleFile> obj2(new SimpleFile("objfile2")); objfiles.push_back(std::move(obj1)); objfiles.push_back(std::move(obj2)); myfile->addFiles(std::move(objfiles)); @@ -205,8 +174,8 @@ TEST_F(InputGraphTest, AddAFileWithLLDFiles) { TEST_F(InputGraphTest, AddNodeWithFilesAndGroup) { std::unique_ptr<MyFileNode> myfile(new MyFileNode("multi_files1", 0)); std::vector<std::unique_ptr<File> > objfiles; - std::unique_ptr<MyObjFile> obj1(new MyObjFile(_context, "objfile1")); - std::unique_ptr<MyObjFile> obj2(new MyObjFile(_context, "objfile2")); + std::unique_ptr<SimpleFile> obj1(new SimpleFile("objfile1")); + std::unique_ptr<SimpleFile> obj2(new SimpleFile("objfile2")); objfiles.push_back(std::move(obj1)); objfiles.push_back(std::move(obj2)); myfile->addFiles(std::move(objfiles)); @@ -218,30 +187,30 @@ TEST_F(InputGraphTest, AddNodeWithFilesAndGroup) { std::unique_ptr<MyGroupNode> mygroup(new MyGroupNode(1)); std::unique_ptr<MyFileNode> myarchive(new MyFileNode("archive_file", 2)); std::vector<std::unique_ptr<File> > objfiles_group; - std::unique_ptr<MyObjFile> obj_1(new MyObjFile(_context, "objfile_1")); - std::unique_ptr<MyObjFile> obj_2(new MyObjFile(_context, "objfile_2")); + std::unique_ptr<SimpleFile> obj_1(new SimpleFile("objfile_1")); + std::unique_ptr<SimpleFile> obj_2(new SimpleFile("objfile_2")); objfiles_group.push_back(std::move(obj_1)); objfiles_group.push_back(std::move(obj_2)); myarchive->addFiles(std::move(objfiles_group)); - EXPECT_EQ(true, mygroup->processInputElement(std::move(myarchive))); + EXPECT_EQ(true, mygroup->addFile(std::move(myarchive))); std::unique_ptr<MyFileNode> mygroupobjfile_1( new MyFileNode("group_objfile1", 3)); std::vector<std::unique_ptr<File> > objfiles_group1; - std::unique_ptr<MyObjFile> mygroupobj1( - new MyObjFile(_context, "group_objfile1")); + std::unique_ptr<SimpleFile> mygroupobj1( + new SimpleFile("group_objfile1")); objfiles_group1.push_back(std::move(mygroupobj1)); mygroupobjfile_1->addFiles(std::move(objfiles_group1)); - EXPECT_EQ(true, mygroup->processInputElement(std::move(mygroupobjfile_1))); + EXPECT_EQ(true, mygroup->addFile(std::move(mygroupobjfile_1))); std::unique_ptr<MyFileNode> mygroupobjfile_2( new MyFileNode("group_objfile2", 4)); std::vector<std::unique_ptr<File> > objfiles_group2; - std::unique_ptr<MyObjFile> mygroupobj2( - new MyObjFile(_context, "group_objfile2")); + std::unique_ptr<SimpleFile> mygroupobj2( + new SimpleFile("group_objfile2")); objfiles_group2.push_back(std::move(mygroupobj2)); mygroupobjfile_2->addFiles(std::move(objfiles_group2)); - EXPECT_EQ(true, mygroup->processInputElement(std::move(mygroupobjfile_2))); + EXPECT_EQ(true, mygroup->addFile(std::move(mygroupobjfile_2))); // Add the group to the InputGraph. EXPECT_EQ(true, inputGraph().addInputElement(std::move(mygroup))); @@ -268,24 +237,22 @@ TEST_F(InputGraphTest, AddNodeWithFilesAndGroup) { EXPECT_EQ(InputGraphError::no_more_files, objfile.getError()); nextElement = inputGraph().getNextInputElement(); - EXPECT_EQ(InputElement::Kind::Control, (*nextElement)->kind()); - ControlNode *controlNode = llvm::dyn_cast<ControlNode>(*nextElement); - - EXPECT_EQ(ControlNode::ControlKind::Group, controlNode->controlKind()); + Group *group = llvm::dyn_cast<Group>(*nextElement); + assert(group); - objfile = controlNode->getNextFile(); + objfile = group->getNextFile(); EXPECT_NE(InputGraphError::no_more_files, objfile.getError()); EXPECT_EQ("objfile_1", (*objfile).path()); - objfile = controlNode->getNextFile(); + objfile = group->getNextFile(); EXPECT_NE(InputGraphError::no_more_files, objfile.getError()); EXPECT_EQ("objfile_2", (*objfile).path()); - objfile = controlNode->getNextFile(); + objfile = group->getNextFile(); EXPECT_NE(InputGraphError::no_more_files, objfile.getError()); EXPECT_EQ("group_objfile1", (*objfile).path()); - objfile = controlNode->getNextFile(); + objfile = group->getNextFile(); EXPECT_NE(InputGraphError::no_more_files, objfile.getError()); EXPECT_EQ("group_objfile2", (*objfile).path()); @@ -297,8 +264,8 @@ TEST_F(InputGraphTest, AddNodeWithFilesAndGroup) { TEST_F(InputGraphTest, AddNodeWithGroupIteration) { std::unique_ptr<MyFileNode> myfile(new MyFileNode("multi_files1", 0)); std::vector<std::unique_ptr<File> > objfiles; - std::unique_ptr<MyObjFile> obj1(new MyObjFile(_context, "objfile1")); - std::unique_ptr<MyObjFile> obj2(new MyObjFile(_context, "objfile2")); + std::unique_ptr<SimpleFile> obj1(new SimpleFile("objfile1")); + std::unique_ptr<SimpleFile> obj2(new SimpleFile("objfile2")); objfiles.push_back(std::move(obj1)); objfiles.push_back(std::move(obj2)); myfile->addFiles(std::move(objfiles)); @@ -310,30 +277,30 @@ TEST_F(InputGraphTest, AddNodeWithGroupIteration) { std::unique_ptr<MyGroupNode> mygroup(new MyGroupNode(1)); std::unique_ptr<MyFileNode> myarchive(new MyFileNode("archive_file", 2)); std::vector<std::unique_ptr<File> > objfiles_group; - std::unique_ptr<MyObjFile> obj_1(new MyObjFile(_context, "objfile_1")); - std::unique_ptr<MyObjFile> obj_2(new MyObjFile(_context, "objfile_2")); + std::unique_ptr<SimpleFile> obj_1(new SimpleFile("objfile_1")); + std::unique_ptr<SimpleFile> obj_2(new SimpleFile("objfile_2")); objfiles_group.push_back(std::move(obj_1)); objfiles_group.push_back(std::move(obj_2)); myarchive->addFiles(std::move(objfiles_group)); - EXPECT_EQ(true, mygroup->processInputElement(std::move(myarchive))); + EXPECT_EQ(true, mygroup->addFile(std::move(myarchive))); std::unique_ptr<MyFileNode> mygroupobjfile_1( new MyFileNode("group_objfile1", 3)); std::vector<std::unique_ptr<File> > objfiles_group1; - std::unique_ptr<MyObjFile> mygroupobj1( - new MyObjFile(_context, "group_objfile1")); + std::unique_ptr<SimpleFile> mygroupobj1( + new SimpleFile("group_objfile1")); objfiles_group1.push_back(std::move(mygroupobj1)); mygroupobjfile_1->addFiles(std::move(objfiles_group1)); - EXPECT_EQ(true, mygroup->processInputElement(std::move(mygroupobjfile_1))); + EXPECT_EQ(true, mygroup->addFile(std::move(mygroupobjfile_1))); std::unique_ptr<MyFileNode> mygroupobjfile_2( new MyFileNode("group_objfile2", 4)); std::vector<std::unique_ptr<File> > objfiles_group2; - std::unique_ptr<MyObjFile> mygroupobj2( - new MyObjFile(_context, "group_objfile2")); + std::unique_ptr<SimpleFile> mygroupobj2( + new SimpleFile("group_objfile2")); objfiles_group2.push_back(std::move(mygroupobj2)); mygroupobjfile_2->addFiles(std::move(objfiles_group2)); - EXPECT_EQ(true, mygroup->processInputElement(std::move(mygroupobjfile_2))); + EXPECT_EQ(true, mygroup->addFile(std::move(mygroupobjfile_2))); // Add the group to the InputGraph. EXPECT_EQ(true, inputGraph().addInputElement(std::move(mygroup))); @@ -360,202 +327,50 @@ TEST_F(InputGraphTest, AddNodeWithGroupIteration) { EXPECT_EQ(InputGraphError::no_more_files, objfile.getError()); nextElement = inputGraph().getNextInputElement(); - EXPECT_EQ(InputElement::Kind::Control, (*nextElement)->kind()); - ControlNode *controlNode = llvm::dyn_cast<ControlNode>(*nextElement); + Group *group = llvm::dyn_cast<Group>(*nextElement); + assert(group); - EXPECT_EQ(ControlNode::ControlKind::Group, controlNode->controlKind()); - - objfile = controlNode->getNextFile(); + objfile = group->getNextFile(); EXPECT_NE(InputGraphError::no_more_files, objfile.getError()); EXPECT_EQ("objfile_1", (*objfile).path()); - objfile = controlNode->getNextFile(); + objfile = group->getNextFile(); EXPECT_NE(InputGraphError::no_more_files, objfile.getError()); EXPECT_EQ("objfile_2", (*objfile).path()); - objfile = controlNode->getNextFile(); + objfile = group->getNextFile(); EXPECT_NE(InputGraphError::no_more_files, objfile.getError()); EXPECT_EQ("group_objfile1", (*objfile).path()); - objfile = controlNode->getNextFile(); + objfile = group->getNextFile(); EXPECT_NE(InputGraphError::no_more_files, objfile.getError()); EXPECT_EQ("group_objfile2", (*objfile).path()); - controlNode->setResolveState(Resolver::StateNewDefinedAtoms); + group->setResolveState(Resolver::StateNewDefinedAtoms); - objfile = controlNode->getNextFile(); + objfile = group->getNextFile(); EXPECT_NE(InputGraphError::no_more_files, objfile.getError()); EXPECT_EQ("objfile_1", (*objfile).path()); - objfile = controlNode->getNextFile(); + objfile = group->getNextFile(); EXPECT_NE(InputGraphError::no_more_files, objfile.getError()); EXPECT_EQ("objfile_2", (*objfile).path()); - objfile = controlNode->getNextFile(); + objfile = group->getNextFile(); EXPECT_NE(InputGraphError::no_more_files, objfile.getError()); EXPECT_EQ("group_objfile1", (*objfile).path()); - objfile = controlNode->getNextFile(); + objfile = group->getNextFile(); EXPECT_NE(InputGraphError::no_more_files, objfile.getError()); EXPECT_EQ("group_objfile2", (*objfile).path()); } // Node expansion tests. -TEST_F(InputGraphTest, ExpandInputGraphNode) { - std::unique_ptr<MyFileNode> myfile(new MyFileNode("multi_files1", 0)); - std::vector<std::unique_ptr<File> > objfiles; - std::unique_ptr<MyObjFile> obj1(new MyObjFile(_context, "objfile1")); - std::unique_ptr<MyObjFile> obj2(new MyObjFile(_context, "objfile2")); - objfiles.push_back(std::move(obj1)); - objfiles.push_back(std::move(obj2)); - myfile->addFiles(std::move(objfiles)); - EXPECT_EQ(true, inputGraph().addInputElement(std::move(myfile))); - objfiles.clear(); - - std::unique_ptr<MyExpandFileNode> expandFile(new MyExpandFileNode( - "expand_node", 1, InputElement::ExpandType::ExpandOnly)); - - std::unique_ptr<MyFileNode> filenode1(new MyFileNode("expand_file1", 2)); - std::unique_ptr<MyObjFile> obj3(new MyObjFile(_context, "objfile3")); - objfiles.push_back(std::move(obj3)); - filenode1->addFiles(std::move(objfiles)); - expandFile->addElement(std::move(filenode1)); - objfiles.clear(); - - std::unique_ptr<MyFileNode> filenode2(new MyFileNode("expand_file2", 3)); - std::unique_ptr<MyObjFile> obj4(new MyObjFile(_context, "objfile4")); - objfiles.push_back(std::move(obj4)); - filenode2->addFiles(std::move(objfiles)); - expandFile->addElement(std::move(filenode2)); - objfiles.clear(); - - // Add expand file to InputGraph - EXPECT_EQ(true, inputGraph().addInputElement(std::move(expandFile))); - - std::unique_ptr<MyFileNode> filenode3(new MyFileNode("obj_after_expand", 4)); - std::unique_ptr<MyObjFile> obj5(new MyObjFile(_context, "objfile5")); - std::unique_ptr<MyObjFile> obj6(new MyObjFile(_context, "objfile6")); - objfiles.push_back(std::move(obj5)); - objfiles.push_back(std::move(obj6)); - filenode3->addFiles(std::move(objfiles)); - - // Add an extra obj after the expand node - EXPECT_EQ(true, inputGraph().addInputElement(std::move(filenode3))); - - inputGraph().normalize(); - - ErrorOr<InputElement *> nextElement = inputGraph().getNextInputElement(); - EXPECT_NE(InputGraphError::no_more_elements, nextElement.getError()); - EXPECT_EQ(InputElement::Kind::File, (*nextElement)->kind()); - FileNode *fileNode = llvm::dyn_cast<FileNode>(*nextElement); - EXPECT_EQ("multi_files1", (*fileNode).getUserPath()); - - nextElement = inputGraph().getNextInputElement(); - EXPECT_NE(InputGraphError::no_more_elements, nextElement.getError()); - EXPECT_EQ(InputElement::Kind::File, (*nextElement)->kind()); - fileNode = llvm::dyn_cast<FileNode>(*nextElement); - EXPECT_EQ("expand_file1", (*fileNode).getUserPath()); - - nextElement = inputGraph().getNextInputElement(); - EXPECT_NE(InputGraphError::no_more_elements, nextElement.getError()); - EXPECT_EQ(InputElement::Kind::File, (*nextElement)->kind()); - fileNode = llvm::dyn_cast<FileNode>(*nextElement); - EXPECT_EQ("expand_file2", (*fileNode).getUserPath()); - - nextElement = inputGraph().getNextInputElement(); - EXPECT_NE(InputGraphError::no_more_elements, nextElement.getError()); - EXPECT_EQ(InputElement::Kind::File, (*nextElement)->kind()); - fileNode = llvm::dyn_cast<FileNode>(*nextElement); - EXPECT_EQ("expand_node", (*fileNode).getUserPath()); - - nextElement = inputGraph().getNextInputElement(); - EXPECT_NE(InputGraphError::no_more_elements, nextElement.getError()); - EXPECT_EQ(InputElement::Kind::File, (*nextElement)->kind()); - fileNode = llvm::dyn_cast<FileNode>(*nextElement); - EXPECT_EQ("obj_after_expand", (*fileNode).getUserPath()); - - nextElement = inputGraph().getNextInputElement(); - EXPECT_EQ(InputGraphError::no_more_elements, nextElement.getError()); -} - -// Node expansion tests. TEST_F(InputGraphTest, ExpandAndReplaceInputGraphNode) { std::unique_ptr<MyFileNode> myfile(new MyFileNode("multi_files1", 0)); std::vector<std::unique_ptr<File> > objfiles; - std::unique_ptr<MyObjFile> obj1(new MyObjFile(_context, "objfile1")); - std::unique_ptr<MyObjFile> obj2(new MyObjFile(_context, "objfile2")); - objfiles.push_back(std::move(obj1)); - objfiles.push_back(std::move(obj2)); - myfile->addFiles(std::move(objfiles)); - EXPECT_EQ(true, inputGraph().addInputElement(std::move(myfile))); - objfiles.clear(); - - std::unique_ptr<MyExpandFileNode> expandFile(new MyExpandFileNode( - "expand_node", 1, InputElement::ExpandType::ReplaceAndExpand)); - - std::unique_ptr<MyFileNode> filenode1(new MyFileNode("expand_file1", 2)); - std::unique_ptr<MyObjFile> obj3(new MyObjFile(_context, "objfile3")); - objfiles.push_back(std::move(obj3)); - filenode1->addFiles(std::move(objfiles)); - expandFile->addElement(std::move(filenode1)); - objfiles.clear(); - - std::unique_ptr<MyFileNode> filenode2(new MyFileNode("expand_file2", 3)); - std::unique_ptr<MyObjFile> obj4(new MyObjFile(_context, "objfile4")); - objfiles.push_back(std::move(obj4)); - filenode2->addFiles(std::move(objfiles)); - expandFile->addElement(std::move(filenode2)); - objfiles.clear(); - - // Add expand file to InputGraph - EXPECT_EQ(true, inputGraph().addInputElement(std::move(expandFile))); - - std::unique_ptr<MyFileNode> filenode3(new MyFileNode("obj_after_expand", 4)); - std::unique_ptr<MyObjFile> obj5(new MyObjFile(_context, "objfile5")); - std::unique_ptr<MyObjFile> obj6(new MyObjFile(_context, "objfile6")); - objfiles.push_back(std::move(obj5)); - objfiles.push_back(std::move(obj6)); - filenode3->addFiles(std::move(objfiles)); - - // Add an extra obj after the expand node - EXPECT_EQ(true, inputGraph().addInputElement(std::move(filenode3))); - - inputGraph().normalize(); - - ErrorOr<InputElement *> nextElement = inputGraph().getNextInputElement(); - EXPECT_NE(InputGraphError::no_more_elements, nextElement.getError()); - EXPECT_EQ(InputElement::Kind::File, (*nextElement)->kind()); - FileNode *fileNode = llvm::dyn_cast<FileNode>(*nextElement); - EXPECT_EQ("multi_files1", (*fileNode).getUserPath()); - - nextElement = inputGraph().getNextInputElement(); - EXPECT_NE(InputGraphError::no_more_elements, nextElement.getError()); - EXPECT_EQ(InputElement::Kind::File, (*nextElement)->kind()); - fileNode = llvm::dyn_cast<FileNode>(*nextElement); - EXPECT_EQ("expand_file1", (*fileNode).getUserPath()); - - nextElement = inputGraph().getNextInputElement(); - EXPECT_NE(InputGraphError::no_more_elements, nextElement.getError()); - EXPECT_EQ(InputElement::Kind::File, (*nextElement)->kind()); - fileNode = llvm::dyn_cast<FileNode>(*nextElement); - EXPECT_EQ("expand_file2", (*fileNode).getUserPath()); - - nextElement = inputGraph().getNextInputElement(); - EXPECT_NE(InputGraphError::no_more_elements, nextElement.getError()); - EXPECT_EQ(InputElement::Kind::File, (*nextElement)->kind()); - fileNode = llvm::dyn_cast<FileNode>(*nextElement); - EXPECT_EQ("obj_after_expand", (*fileNode).getUserPath()); - - nextElement = inputGraph().getNextInputElement(); - EXPECT_EQ(InputGraphError::no_more_elements, nextElement.getError()); -} - -// Hidden Node tests -TEST_F(InputGraphTest, HiddenNodeTests) { - std::unique_ptr<MyFileNode> myfile(new MyFileNode("multi_files1", 0)); - std::vector<std::unique_ptr<File> > objfiles; - std::unique_ptr<MyObjFile> obj1(new MyObjFile(_context, "objfile1")); - std::unique_ptr<MyObjFile> obj2(new MyObjFile(_context, "objfile2")); + std::unique_ptr<SimpleFile> obj1(new SimpleFile("objfile1")); + std::unique_ptr<SimpleFile> obj2(new SimpleFile("objfile2")); objfiles.push_back(std::move(obj1)); objfiles.push_back(std::move(obj2)); myfile->addFiles(std::move(objfiles)); @@ -563,17 +378,17 @@ TEST_F(InputGraphTest, HiddenNodeTests) { objfiles.clear(); std::unique_ptr<MyExpandFileNode> expandFile(new MyExpandFileNode( - "expand_node", 1, InputElement::ExpandType::ExpandOnly, true)); + "expand_node", 1)); std::unique_ptr<MyFileNode> filenode1(new MyFileNode("expand_file1", 2)); - std::unique_ptr<MyObjFile> obj3(new MyObjFile(_context, "objfile3")); + std::unique_ptr<SimpleFile> obj3(new SimpleFile("objfile3")); objfiles.push_back(std::move(obj3)); filenode1->addFiles(std::move(objfiles)); expandFile->addElement(std::move(filenode1)); objfiles.clear(); std::unique_ptr<MyFileNode> filenode2(new MyFileNode("expand_file2", 3)); - std::unique_ptr<MyObjFile> obj4(new MyObjFile(_context, "objfile4")); + std::unique_ptr<SimpleFile> obj4(new SimpleFile("objfile4")); objfiles.push_back(std::move(obj4)); filenode2->addFiles(std::move(objfiles)); expandFile->addElement(std::move(filenode2)); @@ -583,8 +398,8 @@ TEST_F(InputGraphTest, HiddenNodeTests) { EXPECT_EQ(true, inputGraph().addInputElement(std::move(expandFile))); std::unique_ptr<MyFileNode> filenode3(new MyFileNode("obj_after_expand", 4)); - std::unique_ptr<MyObjFile> obj5(new MyObjFile(_context, "objfile5")); - std::unique_ptr<MyObjFile> obj6(new MyObjFile(_context, "objfile6")); + std::unique_ptr<SimpleFile> obj5(new SimpleFile("objfile5")); + std::unique_ptr<SimpleFile> obj6(new SimpleFile("objfile6")); objfiles.push_back(std::move(obj5)); objfiles.push_back(std::move(obj6)); filenode3->addFiles(std::move(objfiles)); |

