[lld] r207691 - [Driver] Check type of InputElement before request a error message. If the

Simon Atanasyan simon at atanasyan.com
Wed Apr 30 12:04:01 PDT 2014


Author: atanasyan
Date: Wed Apr 30 14:04:01 2014
New Revision: 207691

URL: http://llvm.org/viewvc/llvm-project?rev=207691&view=rev
Log:
[Driver] Check type of InputElement before request a error message. If the
element is a FileNode, request error description. If the element is Group,
print hard coded error message. We need to implement a better diagnostics
here but even current solution is better than a segmentation fault output.

Modified:
    lld/trunk/lib/Driver/Driver.cpp

Modified: lld/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/Driver.cpp?rev=207691&r1=207690&r2=207691&view=diff
==============================================================================
--- lld/trunk/lib/Driver/Driver.cpp (original)
+++ lld/trunk/lib/Driver/Driver.cpp Wed Apr 30 14:04:01 2014
@@ -63,8 +63,13 @@ bool Driver::link(LinkingContext &contex
       llvm::raw_string_ostream stream(buf);
 
       if (error_code ec = ie->parse(context, stream)) {
-        FileNode *fileNode = dyn_cast<FileNode>(ie.get());
-        stream << fileNode->errStr(ec) << "\n";
+        if (FileNode *fileNode = dyn_cast<FileNode>(ie.get()))
+          stream << fileNode->errStr(ec) << "\n";
+        else if (dyn_cast<Group>(ie.get()))
+          // FIXME: We need a better diagnostics here
+          stream << "Cannot parse group input element\n";
+        else
+          llvm_unreachable("Unknown type of input element");
         fail = true;
       }
 





More information about the llvm-commits mailing list