summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-11-20 22:32:38 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-11-20 22:32:38 +0000
commit2eaef18e76e402c20f6f8da6dd8f41f42dec45ab (patch)
treea17900750f0a9508aca26280d5547a63731dfe39 /clang
parent32164f4bdb81cfd6aea0d933328346b15db8e41e (diff)
downloadbcm5719-llvm-2eaef18e76e402c20f6f8da6dd8f41f42dec45ab.tar.gz
bcm5719-llvm-2eaef18e76e402c20f6f8da6dd8f41f42dec45ab.zip
Fix refactoro, clang-cc wasn't properly reporting errors when opening an output file failed.
llvm-svn: 89502
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Frontend/CompilerInstance.cpp10
-rw-r--r--clang/test/Frontend/output-failures.c4
2 files changed, 9 insertions, 5 deletions
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp
index 0365761c840..872b7713f32 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -321,7 +321,7 @@ CompilerInstance::createOutputFile(llvm::StringRef OutputPath,
&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 @@ CompilerInstance::createOutputFile(llvm::StringRef OutputPath,
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
diff --git a/clang/test/Frontend/output-failures.c b/clang/test/Frontend/output-failures.c
new file mode 100644
index 00000000000..a8687c754a0
--- /dev/null
+++ b/clang/test/Frontend/output-failures.c
@@ -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{{.*}}'
OpenPOWER on IntegriCloud