Simplify FileNode.
authorRui Ueyama <ruiu@google.com>
Thu, 15 Jan 2015 07:15:36 +0000 (07:15 +0000)
committerRui Ueyama <ruiu@google.com>
Thu, 15 Jan 2015 07:15:36 +0000 (07:15 +0000)
The member function was defined to allow subclasses to customize
error message. But since we only have one FileNode type, there's
no actual need for that.

llvm-svn: 226139

lld/include/lld/Core/InputGraph.h
lld/lib/Driver/Driver.cpp

index 3d44bd4..1df63e1 100644 (file)
@@ -149,12 +149,6 @@ public:
     return a->kind() == InputElement::Kind::File;
   }
 
-  /// \brief create an error string for printing purposes
-  virtual std::string errStr(std::error_code errc) {
-    std::string msg = errc.message();
-    return (Twine("Cannot open ") + _path + ": " + msg).str();
-  }
-
   /// \brief Get the list of files
   File *getFile() { return _file.get(); }
 
index dabcdf0..f059c0e 100644 (file)
@@ -94,10 +94,12 @@ bool Driver::link(LinkingContext &context, raw_ostream &diagnostics) {
       llvm::raw_string_ostream stream(buf);
 
       if (std::error_code ec = ie->parse(context, stream)) {
-        if (FileNode *fileNode = dyn_cast<FileNode>(ie.get()))
-          stream << fileNode->errStr(ec) << "\n";
-        else
+        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;
       }