Modernize raw_fd_ostream's constructor a bit.
[oota-llvm.git] / tools / opt / opt.cpp
index abcf6910b289e2853468d1022e1ee7ab22f7f5ce..d6b450d03ed6e687f5b0f106ea094ce79e833613 100644 (file)
@@ -385,11 +385,10 @@ int main(int argc, char **argv) {
     if (OutputFilename.empty())
       OutputFilename = "-";
 
-    std::string ErrorInfo;
-    Out.reset(new tool_output_file(OutputFilename.c_str(), ErrorInfo,
-                                   sys::fs::F_None));
-    if (!ErrorInfo.empty()) {
-      errs() << ErrorInfo << '\n';
+    std::error_code EC;
+    Out.reset(new tool_output_file(OutputFilename, EC, sys::fs::F_None));
+    if (EC) {
+      errs() << EC.message() << '\n';
       return 1;
     }
   }
@@ -470,11 +469,10 @@ int main(int argc, char **argv) {
       if (OutputFilename.empty())
         OutputFilename = "-";
 
-      std::string ErrorInfo;
-      Out.reset(new tool_output_file(OutputFilename.c_str(), ErrorInfo,
-                                     sys::fs::F_None));
-      if (!ErrorInfo.empty()) {
-        errs() << ErrorInfo << '\n';
+      std::error_code EC;
+      Out.reset(new tool_output_file(OutputFilename, EC, sys::fs::F_None));
+      if (EC) {
+        errs() << EC.message() << '\n';
         return 1;
       }
     }