[lld] r208109 - Don't return value rather than always returning true.

Rui Ueyama ruiu at google.com
Tue May 6 10:33:14 PDT 2014


Author: ruiu
Date: Tue May  6 12:33:14 2014
New Revision: 208109

URL: http://llvm.org/viewvc/llvm-project?rev=208109&view=rev
Log:
Don't return value rather than always returning true.

addInputElement() never fails, and no one checks its return value
except tests. Let's simplify the signature.

Modified:
    lld/trunk/include/lld/Core/InputGraph.h
    lld/trunk/lib/Core/InputGraph.cpp
    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=208109&r1=208108&r2=208109&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/InputGraph.h (original)
+++ lld/trunk/include/lld/Core/InputGraph.h Tue May  6 12:33:14 2014
@@ -68,7 +68,7 @@ public:
   void notifyProgress();
 
   /// \brief Adds a node into the InputGraph
-  bool addInputElement(std::unique_ptr<InputElement>);
+  void addInputElement(std::unique_ptr<InputElement>);
 
   /// Normalize the InputGraph. It visits all nodes in the tree to replace a
   /// node with its children if it's shouldExpand() returns true.

Modified: lld/trunk/lib/Core/InputGraph.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/InputGraph.cpp?rev=208109&r1=208108&r2=208109&view=diff
==============================================================================
--- lld/trunk/lib/Core/InputGraph.cpp (original)
+++ lld/trunk/lib/Core/InputGraph.cpp Tue May  6 12:33:14 2014
@@ -44,9 +44,8 @@ ErrorOr<File &> InputGraph::getNextFile(
 
 void InputGraph::notifyProgress() { _currentInputElement->notifyProgress(); }
 
-bool InputGraph::addInputElement(std::unique_ptr<InputElement> ie) {
+void InputGraph::addInputElement(std::unique_ptr<InputElement> ie) {
   _inputArgs.push_back(std::move(ie));
-  return true;
 }
 
 bool InputGraph::dump(raw_ostream &diagnostics) {

Modified: lld/trunk/unittests/DriverTests/InputGraphTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/unittests/DriverTests/InputGraphTest.cpp?rev=208109&r1=208108&r2=208109&view=diff
==============================================================================
--- lld/trunk/unittests/DriverTests/InputGraphTest.cpp (original)
+++ lld/trunk/unittests/DriverTests/InputGraphTest.cpp Tue May  6 12:33:14 2014
@@ -81,7 +81,7 @@ TEST_F(InputGraphTest, Basic) {
 
 TEST_F(InputGraphTest, AddAFile) {
   std::unique_ptr<MyFileNode> myfile(new MyFileNode("file1"));
-  EXPECT_EQ(true, getInputGraph().addInputElement(std::move(myfile)));
+  getInputGraph().addInputElement(std::move(myfile));
   EXPECT_EQ(1, inputFileCount());
   ErrorOr<InputElement *> nextElement = getInputGraph().getNextInputElement();
   EXPECT_NE(InputGraphError::no_more_elements, nextElement.getError());
@@ -98,7 +98,7 @@ TEST_F(InputGraphTest, AddAFileWithLLDFi
   objfiles.push_back(std::move(obj1));
   objfiles.push_back(std::move(obj2));
   myfile->addFiles(std::move(objfiles));
-  EXPECT_EQ(true, getInputGraph().addInputElement(std::move(myfile)));
+  getInputGraph().addInputElement(std::move(myfile));
   EXPECT_EQ(1, inputFileCount());
   ErrorOr<InputElement *> nextElement = getInputGraph().getNextInputElement();
   EXPECT_NE(InputGraphError::no_more_elements, nextElement.getError());
@@ -134,7 +134,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, getInputGraph().addInputElement(std::move(myfile)));
+  getInputGraph().addInputElement(std::move(myfile));
 
   // Create a group node with two elements
   // an file node which looks like an archive and
@@ -166,7 +166,7 @@ TEST_F(InputGraphTest, AddNodeWithFilesA
   EXPECT_EQ(true, mygroup->addFile(std::move(mygroupobjfile_2)));
 
   // Add the group to the InputGraph.
-  EXPECT_EQ(true, getInputGraph().addInputElement(std::move(mygroup)));
+  getInputGraph().addInputElement(std::move(mygroup));
 
   EXPECT_EQ(2, inputFileCount());
 
@@ -219,7 +219,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, getInputGraph().addInputElement(std::move(myfile)));
+  getInputGraph().addInputElement(std::move(myfile));
 
   // Create a group node with two elements
   // an file node which looks like an archive and
@@ -251,7 +251,7 @@ TEST_F(InputGraphTest, AddNodeWithGroupI
   EXPECT_EQ(true, mygroup->addFile(std::move(mygroupobjfile_2)));
 
   // Add the group to the InputGraph.
-  EXPECT_EQ(true, getInputGraph().addInputElement(std::move(mygroup)));
+  getInputGraph().addInputElement(std::move(mygroup));
 
   EXPECT_EQ(2, inputFileCount());
 
@@ -319,7 +319,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, getInputGraph().addInputElement(std::move(myfile)));
+  getInputGraph().addInputElement(std::move(myfile));
   objfiles.clear();
 
   std::unique_ptr<MyExpandFileNode> expandFile(
@@ -340,7 +340,7 @@ TEST_F(InputGraphTest, ExpandAndReplaceI
   objfiles.clear();
 
   // Add expand file to InputGraph
-  EXPECT_EQ(true, getInputGraph().addInputElement(std::move(expandFile)));
+  getInputGraph().addInputElement(std::move(expandFile));
 
   std::unique_ptr<MyFileNode> filenode3(new MyFileNode("obj_after_expand"));
   std::unique_ptr<SimpleFile> obj5(new SimpleFile("objfile5"));
@@ -350,7 +350,7 @@ TEST_F(InputGraphTest, ExpandAndReplaceI
   filenode3->addFiles(std::move(objfiles));
 
   // Add an extra obj after the expand node
-  EXPECT_EQ(true, getInputGraph().addInputElement(std::move(filenode3)));
+  getInputGraph().addInputElement(std::move(filenode3));
 
   getInputGraph().normalize();
 





More information about the llvm-commits mailing list