[cfe-commits] r89502 - in /cfe/trunk: lib/Frontend/CompilerInstance.cpp test/Frontend/output-failures.c

Daniel Dunbar daniel at zuster.org
Fri Nov 20 14:32:38 PST 2009


Author: ddunbar
Date: Fri Nov 20 16:32:38 2009
New Revision: 89502

URL: http://llvm.org/viewvc/llvm-project?rev=89502&view=rev
Log:
Fix refactoro, clang-cc wasn't properly reporting errors when opening an output file failed.

Added:
    cfe/trunk/test/Frontend/output-failures.c
Modified:
    cfe/trunk/lib/Frontend/CompilerInstance.cpp

Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=89502&r1=89501&r2=89502&view=diff

==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Fri Nov 20 16:32:38 2009
@@ -321,7 +321,7 @@
                                               &OutputPathName);
   if (!OS) {
     // FIXME: Don't fail this way.
-    llvm::errs() << "ERROR: " << Error << "\n";
+    llvm::errs() << "error: " << Error << "\n";
     ::exit(1);
   }
 
@@ -353,16 +353,16 @@
     OutFile = "-";
   }
 
-  llvm::raw_fd_ostream *OS =
+  llvm::OwningPtr<llvm::raw_fd_ostream> OS(
     new llvm::raw_fd_ostream(OutFile.c_str(), Error,
-                             (Binary ? llvm::raw_fd_ostream::F_Binary : 0));
-  if (!OS)
+                             (Binary ? llvm::raw_fd_ostream::F_Binary : 0)));
+  if (!Error.empty())
     return 0;
 
   if (ResultPathName)
     *ResultPathName = OutFile;
 
-  return OS;
+  return OS.take();
 }
 
 // Initialization Utilities

Added: cfe/trunk/test/Frontend/output-failures.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/output-failures.c?rev=89502&view=auto

==============================================================================
--- cfe/trunk/test/Frontend/output-failures.c (added)
+++ cfe/trunk/test/Frontend/output-failures.c Fri Nov 20 16:32:38 2009
@@ -0,0 +1,4 @@
+// RUN: not clang-cc -emit-llvm -o %S/doesnotexist/somename %s 2> %t
+// RUN: FileCheck -check-prefix=OUTPUTFAIL -input-file=%t %s
+
+// OUTPUTFAIL: Error opening output file '{{.*}}doesnotexist{{.*}}'





More information about the cfe-commits mailing list