[cfe-commits] r49518 - /cfe/trunk/Driver/PrintPreprocessedOutput.cpp
Chris Lattner
sabre at nondot.org
Thu Apr 10 23:14:11 PDT 2008
Author: lattner
Date: Fri Apr 11 01:14:11 2008
New Revision: 49518
URL: http://llvm.org/viewvc/llvm-project?rev=49518&view=rev
Log:
Fix rdar://5843510 don't assert and die when an invalid output
file is specified, print a happy little error message.
Modified:
cfe/trunk/Driver/PrintPreprocessedOutput.cpp
Modified: cfe/trunk/Driver/PrintPreprocessedOutput.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/PrintPreprocessedOutput.cpp?rev=49518&r1=49517&r2=49518&view=diff
==============================================================================
--- cfe/trunk/Driver/PrintPreprocessedOutput.cpp (original)
+++ cfe/trunk/Driver/PrintPreprocessedOutput.cpp Fri Apr 11 01:14:11 2008
@@ -60,8 +60,14 @@
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 @@
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
}
More information about the cfe-commits
mailing list