[lld] r205589 - Rename getInputGraph() and getNextFile().
Rui Ueyama
ruiu at google.com
Thu Apr 3 17:14:05 PDT 2014
Author: ruiu
Date: Thu Apr 3 19:14:04 2014
New Revision: 205589
URL: http://llvm.org/viewvc/llvm-project?rev=205589&view=rev
Log:
Rename getInputGraph() and getNextFile().
Seems getSomething() is more common naming scheme than just a noun
to get something, so renaming these members.
Differential Revision: http://llvm-reviews.chandlerc.com/D3285
Modified:
lld/trunk/include/lld/Core/InputGraph.h
lld/trunk/include/lld/Core/LinkingContext.h
lld/trunk/lib/Core/InputGraph.cpp
lld/trunk/lib/Core/Resolver.cpp
lld/trunk/lib/Driver/Driver.cpp
lld/trunk/lib/Driver/WinLinkDriver.cpp
lld/trunk/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp
lld/trunk/unittests/DriverTests/DriverTest.h
lld/trunk/unittests/DriverTests/InputGraphTest.cpp
Modified: lld/trunk/include/lld/Core/InputGraph.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/InputGraph.h?rev=205589&r1=205588&r2=205589&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/InputGraph.h (original)
+++ lld/trunk/include/lld/Core/InputGraph.h Thu Apr 3 19:14:04 2014
@@ -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
Modified: lld/trunk/include/lld/Core/LinkingContext.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/LinkingContext.h?rev=205589&r1=205588&r2=205589&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/LinkingContext.h (original)
+++ lld/trunk/include/lld/Core/LinkingContext.h Thu Apr 3 19:14:04 2014
@@ -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
Modified: lld/trunk/lib/Core/InputGraph.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/InputGraph.cpp?rev=205589&r1=205588&r2=205589&view=diff
==============================================================================
--- lld/trunk/lib/Core/InputGraph.cpp (original)
+++ lld/trunk/lib/Core/InputGraph.cpp Thu Apr 3 19:14:04 2014
@@ -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)
Modified: lld/trunk/lib/Core/Resolver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/Resolver.cpp?rev=205589&r1=205588&r2=205589&view=diff
==============================================================================
--- lld/trunk/lib/Core/Resolver.cpp (original)
+++ lld/trunk/lib/Core/Resolver.cpp Thu Apr 3 19:14:04 2014
@@ -65,7 +65,7 @@ void Resolver::handleFile(const File &fi
// 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::vecto
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;
}
Modified: lld/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/Driver.cpp?rev=205589&r1=205588&r2=205589&view=diff
==============================================================================
--- lld/trunk/lib/Driver/Driver.cpp (original)
+++ lld/trunk/lib/Driver/Driver.cpp Thu Apr 3 19:14:04 2014
@@ -44,7 +44,7 @@ bool Driver::link(LinkingContext &contex
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 &contex
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");
Modified: lld/trunk/lib/Driver/WinLinkDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkDriver.cpp?rev=205589&r1=205588&r2=205589&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkDriver.cpp (original)
+++ lld/trunk/lib/Driver/WinLinkDriver.cpp Thu Apr 3 19:14:04 2014
@@ -531,7 +531,7 @@ static bool createManifest(PECOFFLinking
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, cons
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.
Modified: lld/trunk/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp?rev=205589&r1=205588&r2=205589&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/PECOFFLinkingContext.cpp Thu Apr 3 19:14:04 2014
@@ -108,7 +108,8 @@ bool PECOFFLinkingContext::createImplici
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;
}
Modified: lld/trunk/unittests/DriverTests/DriverTest.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/unittests/DriverTests/DriverTest.h?rev=205589&r1=205588&r2=205589&view=diff
==============================================================================
--- lld/trunk/unittests/DriverTests/DriverTest.h (original)
+++ lld/trunk/unittests/DriverTests/DriverTest.h Thu Apr 3 19:14:04 2014
@@ -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());
Modified: lld/trunk/unittests/DriverTests/InputGraphTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/unittests/DriverTests/InputGraphTest.cpp?rev=205589&r1=205588&r2=205589&view=diff
==============================================================================
--- lld/trunk/unittests/DriverTests/InputGraphTest.cpp (original)
+++ lld/trunk/unittests/DriverTests/InputGraphTest.cpp Thu Apr 3 19:14:04 2014
@@ -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, AddAFileWithLLDFi
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, AddAFileWithLLDFi
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, AddNodeWithFilesA
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, AddNodeWithFilesA
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, AddNodeWithFilesA
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, AddNodeWithFilesA
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, AddNodeWithGroupI
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, AddNodeWithGroupI
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, AddNodeWithGroupI
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, ExpandAndReplaceI
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, ExpandAndReplaceI
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, ExpandAndReplaceI
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());
}
More information about the llvm-commits
mailing list