summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-04-11 06:14:11 +0000
committerChris Lattner <sabre@nondot.org>2008-04-11 06:14:11 +0000
commit47fb9efa5d3530be3a40cb4e9aac24e1e8de7491 (patch)
treed989a3e9ff3aa0f466786f47558e8c5cc87693a6 /clang
parent90bde997b3f2e5e20452dc01c6617833ce8697d5 (diff)
downloadbcm5719-llvm-47fb9efa5d3530be3a40cb4e9aac24e1e8de7491.tar.gz
bcm5719-llvm-47fb9efa5d3530be3a40cb4e9aac24e1e8de7491.zip
Fix rdar://5843510 don't assert and die when an invalid output
file is specified, print a happy little error message. llvm-svn: 49518
Diffstat (limited to 'clang')
-rw-r--r--clang/Driver/PrintPreprocessedOutput.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/clang/Driver/PrintPreprocessedOutput.cpp b/clang/Driver/PrintPreprocessedOutput.cpp
index 68a2f954ed9..105e99e9c48 100644
--- a/clang/Driver/PrintPreprocessedOutput.cpp
+++ b/clang/Driver/PrintPreprocessedOutput.cpp
@@ -60,8 +60,14 @@ static void InitOutputBuffer(const std::string& Output) {
if (!Output.size() || Output == "-")
OutputFILE = stdout;
else {
- OutputFILE = fopen(Output.c_str(), "w+");
OutputFilename = Output;
+ OutputFILE = fopen(Output.c_str(), "w+");
+
+ if (OutputFILE == 0) {
+ fprintf(stderr, "Error opening output file '%s'.\n", Output.c_str());
+ exit(1);
+ }
+
}
assert(OutputFILE && "failed to open output file");
@@ -73,11 +79,13 @@ static void InitOutputBuffer(const std::string& Output) {
if (!Output.size() || Output == "-")
OutputFD = STDOUT_FILENO;
else {
- OutputFD = open(Output.c_str(), O_WRONLY|O_CREAT|O_TRUNC, 0644);
OutputFilename = Output;
+ OutputFD = open(Output.c_str(), O_WRONLY|O_CREAT|O_TRUNC, 0644);
+ if (OutputFD < 0) {
+ fprintf(stderr, "Error opening output file '%s'.\n", Output.c_str());
+ exit(1);
+ }
}
-
- assert(OutputFD >= 0 && "failed to open output file");
#endif
}
OpenPOWER on IntegriCloud