diff options
| -rw-r--r-- | lld/include/lld/Core/InputGraph.h | 12 | ||||
| -rw-r--r-- | lld/include/lld/Core/LinkingContext.h | 2 | ||||
| -rw-r--r-- | lld/lib/Core/InputGraph.cpp | 6 | ||||
| -rw-r--r-- | lld/lib/Core/Resolver.cpp | 11 | ||||
| -rw-r--r-- | lld/lib/Driver/Driver.cpp | 6 | ||||
| -rw-r--r-- | lld/lib/Driver/WinLinkDriver.cpp | 6 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp | 3 | ||||
| -rw-r--r-- | lld/unittests/DriverTests/DriverTest.h | 6 | ||||
| -rw-r--r-- | lld/unittests/DriverTests/InputGraphTest.cpp | 54 |
9 files changed, 53 insertions, 53 deletions
diff --git a/lld/include/lld/Core/InputGraph.h b/lld/include/lld/Core/InputGraph.h index 42e703a017c..b1deb49fb4f 100644 --- a/lld/include/lld/Core/InputGraph.h +++ b/lld/include/lld/Core/InputGraph.h @@ -54,12 +54,12 @@ public: /// \brief Initialize the inputgraph InputGraph() : _nextElementIndex(0), _currentInputElement(nullptr) {} - /// nextFile returns the next file that needs to be processed by the resolver. - /// When there are no more files to be processed, an appropriate - /// InputGraphError is returned. Ordinals are assigned to files returned by - /// nextFile, which means ordinals would be assigned in the way files are - /// resolved. - ErrorOr<File &> nextFile(); + /// getNextFile returns the next file that needs to be processed by + /// the resolver. When there are no more files to be processed, an + /// appropriate InputGraphError is returned. Ordinals are assigned + /// to files returned by getNextFile, which means ordinals would be + /// assigned in the way files are resolved. + ErrorOr<File &> getNextFile(); /// Notifies the current input element of Resolver made some progress on /// resolving undefined symbols using the current file. Group (representing diff --git a/lld/include/lld/Core/LinkingContext.h b/lld/include/lld/Core/LinkingContext.h index cd413389fa0..0c6e2014479 100644 --- a/lld/include/lld/Core/LinkingContext.h +++ b/lld/include/lld/Core/LinkingContext.h @@ -217,7 +217,7 @@ public: void setInputGraph(std::unique_ptr<InputGraph> inputGraph) { _inputGraph = std::move(inputGraph); } - InputGraph &inputGraph() const { return *_inputGraph; } + InputGraph &getInputGraph() const { return *_inputGraph; } /// This method adds undefined symbols specified by the -u option to the to /// the list of undefined symbols known to the linker. This option essentially diff --git a/lld/lib/Core/InputGraph.cpp b/lld/lib/Core/InputGraph.cpp index 730a958158e..39d2b193b7c 100644 --- a/lld/lib/Core/InputGraph.cpp +++ b/lld/lib/Core/InputGraph.cpp @@ -15,9 +15,9 @@ using namespace lld; -ErrorOr<File &> InputGraph::nextFile() { - // When nextFile() is called for the first time, _currentInputElement is not - // initialized. Initialize it with the first element of the input graph. +ErrorOr<File &> InputGraph::getNextFile() { + // When getNextFile() is called for the first time, _currentInputElement is + // not initialized. Initialize it with the first element of the input graph. if (_currentInputElement == nullptr) { ErrorOr<InputElement *> elem = getNextInputElement(); if (elem.getError() == InputGraphError::no_more_elements) diff --git a/lld/lib/Core/Resolver.cpp b/lld/lib/Core/Resolver.cpp index 69688fe78ff..1b40bd37dcc 100644 --- a/lld/lib/Core/Resolver.cpp +++ b/lld/lib/Core/Resolver.cpp @@ -65,7 +65,7 @@ void Resolver::handleFile(const File &file) { // Notify the input file manager of the fact that we have made some progress // on linking using the current input file. It may want to know the fact for // --start-group/--end-group. - _context.inputGraph().notifyProgress(); + _context.getInputGraph().notifyProgress(); } void Resolver::forEachUndefines(UndefCallback callback, @@ -260,19 +260,18 @@ void Resolver::addAtoms(const std::vector<const DefinedAtom *> &newAtoms) { doDefinedAtom(*newAtom); } -// Keep adding atoms until _context.nextFile() returns an error. This function -// is where undefined atoms are resolved. +// Keep adding atoms until _context.getNextFile() returns an error. This +// function is where undefined atoms are resolved. bool Resolver::resolveUndefines() { ScopedTask task(getDefaultDomain(), "resolveUndefines"); for (;;) { - ErrorOr<File &> file = _context.inputGraph().nextFile(); + ErrorOr<File &> file = _context.getInputGraph().getNextFile(); error_code ec = file.getError(); if (ec == InputGraphError::no_more_files) return true; if (!file) { - llvm::errs() << "Error occurred in nextFile: " - << ec.message() << "\n"; + llvm::errs() << "Error occurred in getNextFile: " << ec.message() << "\n"; return false; } diff --git a/lld/lib/Driver/Driver.cpp b/lld/lib/Driver/Driver.cpp index 0e05725f1e7..1122ae9bc54 100644 --- a/lld/lib/Driver/Driver.cpp +++ b/lld/lib/Driver/Driver.cpp @@ -44,7 +44,7 @@ bool Driver::link(LinkingContext &context, raw_ostream &diagnostics) { args[numArgs + 1] = 0; llvm::cl::ParseCommandLineOptions(numArgs + 1, args); } - InputGraph &inputGraph = context.inputGraph(); + InputGraph &inputGraph = context.getInputGraph(); if (!inputGraph.size()) return false; @@ -95,8 +95,8 @@ bool Driver::link(LinkingContext &context, raw_ostream &diagnostics) { context.createImplicitFiles(implicitFiles); if (implicitFiles.size()) fileNode->addFiles(std::move(implicitFiles)); - context.inputGraph().insertElementAt(std::move(fileNode), - InputGraph::Position::BEGIN); + context.getInputGraph().insertElementAt(std::move(fileNode), + InputGraph::Position::BEGIN); // Do core linking. ScopedTask resolveTask(getDefaultDomain(), "Resolve"); diff --git a/lld/lib/Driver/WinLinkDriver.cpp b/lld/lib/Driver/WinLinkDriver.cpp index 2ab1a7f6a94..8ae776b39af 100644 --- a/lld/lib/Driver/WinLinkDriver.cpp +++ b/lld/lib/Driver/WinLinkDriver.cpp @@ -531,7 +531,7 @@ static bool createManifest(PECOFFLinkingContext &ctx, raw_ostream &diag) { return false; std::unique_ptr<InputElement> inputElement( new PECOFFFileNode(ctx, ctx.allocate(resourceFilePath))); - ctx.inputGraph().addInputElement(std::move(inputElement)); + ctx.getInputGraph().addInputElement(std::move(inputElement)); return true; } return createSideBySideManifestFile(ctx, diag); @@ -1241,14 +1241,14 @@ bool WinLinkDriver::parse(int argc, const char *argv[], if (isReadingDirectiveSection) if (file->parse(ctx, diag)) return false; - ctx.inputGraph().addInputElement(std::move(file)); + ctx.getInputGraph().addInputElement(std::move(file)); } // Add the library group to the input graph. if (!isReadingDirectiveSection) { auto group = std::unique_ptr<Group>(new PECOFFGroup(ctx)); ctx.setLibraryGroup(group.get()); - ctx.inputGraph().addInputElement(std::move(group)); + ctx.getInputGraph().addInputElement(std::move(group)); } // Add the library files to the library group. diff --git a/lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp b/lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp index 780dc233230..404f24d9ff6 100644 --- a/lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp +++ b/lld/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp @@ -108,7 +108,8 @@ bool PECOFFLinkingContext::createImplicitFiles( std::unique_ptr<File> linkerGeneratedSymFile( new pecoff::LinkerGeneratedSymbolFile(*this)); fileNode->appendInputFile(std::move(linkerGeneratedSymFile)); - inputGraph().insertElementAt(std::move(fileNode), InputGraph::Position::END); + getInputGraph().insertElementAt(std::move(fileNode), + InputGraph::Position::END); return true; } diff --git a/lld/unittests/DriverTests/DriverTest.h b/lld/unittests/DriverTests/DriverTest.h index a8f0d486189..dcc451ea75e 100644 --- a/lld/unittests/DriverTests/DriverTest.h +++ b/lld/unittests/DriverTests/DriverTest.h @@ -29,11 +29,11 @@ protected: std::string &errorMessage() { return _errorMessage; } // Convenience method for getting number of input files. - int inputFileCount() { return linkingContext()->inputGraph().size(); } + int inputFileCount() { return linkingContext()->getInputGraph().size(); } // Convenience method for getting i'th input files name. std::string inputFile(int index) { - const InputElement &inputElement = linkingContext()->inputGraph()[index]; + const InputElement &inputElement = linkingContext()->getInputGraph()[index]; if (inputElement.kind() == InputElement::Kind::File) return *cast<FileNode>(&inputElement)->getPath(*linkingContext()); llvm_unreachable("not handling other types of input files"); @@ -41,7 +41,7 @@ protected: // Convenience method for getting i'th input files name. std::string inputFile(int index1, int index2) { - Group *group = dyn_cast<Group>(&linkingContext()->inputGraph()[index1]); + Group *group = dyn_cast<Group>(&linkingContext()->getInputGraph()[index1]); if (!group) llvm_unreachable("not handling other types of input files"); FileNode *file = dyn_cast<FileNode>(group->elements()[index2].get()); diff --git a/lld/unittests/DriverTests/InputGraphTest.cpp b/lld/unittests/DriverTests/InputGraphTest.cpp index a5cfef1d80a..e584895a2a3 100644 --- a/lld/unittests/DriverTests/InputGraphTest.cpp +++ b/lld/unittests/DriverTests/InputGraphTest.cpp @@ -64,8 +64,8 @@ public: _ctx.setInputGraph(std::unique_ptr<InputGraph>(new InputGraph())); } - InputGraph &inputGraph() { return _ctx.inputGraph(); } - int inputFileCount() { return _ctx.inputGraph().size(); } + InputGraph &getInputGraph() { return _ctx.getInputGraph(); } + int inputFileCount() { return _ctx.getInputGraph().size(); } protected: MyLinkingContext _ctx; @@ -75,20 +75,20 @@ protected: TEST_F(InputGraphTest, Basic) { EXPECT_EQ(0, inputFileCount()); - ErrorOr<InputElement *> nextElement = inputGraph().getNextInputElement(); + ErrorOr<InputElement *> nextElement = getInputGraph().getNextInputElement(); EXPECT_EQ(InputGraphError::no_more_elements, nextElement.getError()); } TEST_F(InputGraphTest, AddAFile) { std::unique_ptr<MyFileNode> myfile(new MyFileNode("file1")); - EXPECT_EQ(true, inputGraph().addInputElement(std::move(myfile))); + EXPECT_EQ(true, getInputGraph().addInputElement(std::move(myfile))); EXPECT_EQ(1, inputFileCount()); - ErrorOr<InputElement *> nextElement = inputGraph().getNextInputElement(); + ErrorOr<InputElement *> nextElement = getInputGraph().getNextInputElement(); EXPECT_NE(InputGraphError::no_more_elements, nextElement.getError()); EXPECT_EQ(InputElement::Kind::File, (*nextElement)->kind()); FileNode *fileNode = dyn_cast<FileNode>(*nextElement); EXPECT_EQ("file1", fileNode->getUserPath()); - nextElement = inputGraph().getNextInputElement(); + nextElement = getInputGraph().getNextInputElement(); EXPECT_EQ(InputGraphError::no_more_elements, nextElement.getError()); } @@ -100,9 +100,9 @@ TEST_F(InputGraphTest, AddAFileWithLLDFiles) { 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))); + EXPECT_EQ(true, getInputGraph().addInputElement(std::move(myfile))); EXPECT_EQ(1, inputFileCount()); - ErrorOr<InputElement *> nextElement = inputGraph().getNextInputElement(); + ErrorOr<InputElement *> nextElement = getInputGraph().getNextInputElement(); EXPECT_NE(InputGraphError::no_more_elements, nextElement.getError()); EXPECT_EQ(InputElement::Kind::File, (*nextElement)->kind()); FileNode *fileNode = dyn_cast<FileNode>(*nextElement); @@ -126,7 +126,7 @@ TEST_F(InputGraphTest, AddAFileWithLLDFiles) { EXPECT_NE(InputGraphError::no_more_files, objfile.getError()); EXPECT_EQ("objfile1", (*objfile).path()); - nextElement = inputGraph().getNextInputElement(); + nextElement = getInputGraph().getNextInputElement(); EXPECT_EQ(InputGraphError::no_more_elements, nextElement.getError()); } @@ -138,7 +138,7 @@ TEST_F(InputGraphTest, AddNodeWithFilesAndGroup) { 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))); + EXPECT_EQ(true, getInputGraph().addInputElement(std::move(myfile))); // Create a group node with two elements // an file node which looks like an archive and @@ -170,11 +170,11 @@ TEST_F(InputGraphTest, AddNodeWithFilesAndGroup) { EXPECT_EQ(true, mygroup->addFile(std::move(mygroupobjfile_2))); // Add the group to the InputGraph. - EXPECT_EQ(true, inputGraph().addInputElement(std::move(mygroup))); + EXPECT_EQ(true, getInputGraph().addInputElement(std::move(mygroup))); EXPECT_EQ(2, inputFileCount()); - ErrorOr<InputElement *> nextElement = inputGraph().getNextInputElement(); + ErrorOr<InputElement *> nextElement = getInputGraph().getNextInputElement(); EXPECT_NE(InputGraphError::no_more_elements, nextElement.getError()); EXPECT_EQ(InputElement::Kind::File, (*nextElement)->kind()); FileNode *fileNode = dyn_cast<FileNode>(*nextElement); @@ -192,7 +192,7 @@ TEST_F(InputGraphTest, AddNodeWithFilesAndGroup) { objfile = fileNode->getNextFile(); EXPECT_EQ(InputGraphError::no_more_files, objfile.getError()); - nextElement = inputGraph().getNextInputElement(); + nextElement = getInputGraph().getNextInputElement(); Group *group = dyn_cast<Group>(*nextElement); assert(group); @@ -212,7 +212,7 @@ TEST_F(InputGraphTest, AddNodeWithFilesAndGroup) { EXPECT_NE(InputGraphError::no_more_files, objfile.getError()); EXPECT_EQ("group_objfile2", (*objfile).path()); - nextElement = inputGraph().getNextInputElement(); + nextElement = getInputGraph().getNextInputElement(); EXPECT_EQ(InputGraphError::no_more_elements, nextElement.getError()); } @@ -225,7 +225,7 @@ TEST_F(InputGraphTest, AddNodeWithGroupIteration) { 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))); + EXPECT_EQ(true, getInputGraph().addInputElement(std::move(myfile))); // Create a group node with two elements // an file node which looks like an archive and @@ -257,11 +257,11 @@ TEST_F(InputGraphTest, AddNodeWithGroupIteration) { EXPECT_EQ(true, mygroup->addFile(std::move(mygroupobjfile_2))); // Add the group to the InputGraph. - EXPECT_EQ(true, inputGraph().addInputElement(std::move(mygroup))); + EXPECT_EQ(true, getInputGraph().addInputElement(std::move(mygroup))); EXPECT_EQ(2, inputFileCount()); - ErrorOr<InputElement *> nextElement = inputGraph().getNextInputElement(); + ErrorOr<InputElement *> nextElement = getInputGraph().getNextInputElement(); EXPECT_NE(InputGraphError::no_more_elements, nextElement.getError()); EXPECT_EQ(InputElement::Kind::File, (*nextElement)->kind()); FileNode *fileNode = dyn_cast<FileNode>(*nextElement); @@ -279,7 +279,7 @@ TEST_F(InputGraphTest, AddNodeWithGroupIteration) { objfile = fileNode->getNextFile(); EXPECT_EQ(InputGraphError::no_more_files, objfile.getError()); - nextElement = inputGraph().getNextInputElement(); + nextElement = getInputGraph().getNextInputElement(); Group *group = dyn_cast<Group>(*nextElement); assert(group); @@ -327,7 +327,7 @@ TEST_F(InputGraphTest, ExpandAndReplaceInputGraphNode) { 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))); + EXPECT_EQ(true, getInputGraph().addInputElement(std::move(myfile))); objfiles.clear(); std::unique_ptr<MyExpandFileNode> expandFile( @@ -348,7 +348,7 @@ TEST_F(InputGraphTest, ExpandAndReplaceInputGraphNode) { objfiles.clear(); // Add expand file to InputGraph - EXPECT_EQ(true, inputGraph().addInputElement(std::move(expandFile))); + EXPECT_EQ(true, getInputGraph().addInputElement(std::move(expandFile))); std::unique_ptr<MyFileNode> filenode3(new MyFileNode("obj_after_expand")); std::unique_ptr<SimpleFile> obj5(new SimpleFile("objfile5")); @@ -358,34 +358,34 @@ TEST_F(InputGraphTest, ExpandAndReplaceInputGraphNode) { filenode3->addFiles(std::move(objfiles)); // Add an extra obj after the expand node - EXPECT_EQ(true, inputGraph().addInputElement(std::move(filenode3))); + EXPECT_EQ(true, getInputGraph().addInputElement(std::move(filenode3))); - inputGraph().normalize(); + getInputGraph().normalize(); - ErrorOr<InputElement *> nextElement = inputGraph().getNextInputElement(); + ErrorOr<InputElement *> nextElement = getInputGraph().getNextInputElement(); EXPECT_NE(InputGraphError::no_more_elements, nextElement.getError()); EXPECT_EQ(InputElement::Kind::File, (*nextElement)->kind()); FileNode *fileNode = dyn_cast<FileNode>(*nextElement); EXPECT_EQ("multi_files1", (*fileNode).getUserPath()); - nextElement = inputGraph().getNextInputElement(); + nextElement = getInputGraph().getNextInputElement(); EXPECT_NE(InputGraphError::no_more_elements, nextElement.getError()); EXPECT_EQ(InputElement::Kind::File, (*nextElement)->kind()); fileNode = dyn_cast<FileNode>(*nextElement); EXPECT_EQ("expand_file1", (*fileNode).getUserPath()); - nextElement = inputGraph().getNextInputElement(); + nextElement = getInputGraph().getNextInputElement(); EXPECT_NE(InputGraphError::no_more_elements, nextElement.getError()); EXPECT_EQ(InputElement::Kind::File, (*nextElement)->kind()); fileNode = dyn_cast<FileNode>(*nextElement); EXPECT_EQ("expand_file2", (*fileNode).getUserPath()); - nextElement = inputGraph().getNextInputElement(); + nextElement = getInputGraph().getNextInputElement(); EXPECT_NE(InputGraphError::no_more_elements, nextElement.getError()); EXPECT_EQ(InputElement::Kind::File, (*nextElement)->kind()); fileNode = dyn_cast<FileNode>(*nextElement); EXPECT_EQ("obj_after_expand", (*fileNode).getUserPath()); - nextElement = inputGraph().getNextInputElement(); + nextElement = getInputGraph().getNextInputElement(); EXPECT_EQ(InputGraphError::no_more_elements, nextElement.getError()); } |

