aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-11-13 10:18:59 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-11-13 10:18:59 +0000
commit84c639a1a8fa3d45e8106b0ec492cc0ded08fcd1 (patch)
tree8e7e95200c4020fd31d679038293d2a3b474d93b
parent3d0dab330beb7ab5e0450a56f0c5c45fda06a0e3 (diff)
clang-cc: Move output file initialization closer to use.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@87102 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--tools/clang-cc/clang-cc.cpp25
1 files changed, 12 insertions, 13 deletions
diff --git a/tools/clang-cc/clang-cc.cpp b/tools/clang-cc/clang-cc.cpp
index 7cdf2ac8b0..93384390e1 100644
--- a/tools/clang-cc/clang-cc.cpp
+++ b/tools/clang-cc/clang-cc.cpp
@@ -426,24 +426,12 @@ static void ProcessInputFile(CompilerInstance &CI, const std::string &InFile,
case DumpTokens:
case RunPreprocessorOnly:
case ParseNoop:
- break; // No setup.
-
case GeneratePTH:
- if (FEOpts.OutputFile.empty() || FEOpts.OutputFile == "-") {
- // FIXME: Don't fail this way.
- // FIXME: Verify that we can actually seek in the given file.
- llvm::errs() << "ERROR: PTH requires an seekable file for output!\n";
- ::exit(1);
- }
- OS.reset(ComputeOutFile(CI.getFrontendOpts(), InFile, 0, true, OutPath));
- break;
-
case PrintPreprocessedInput:
case ParsePrintCallbacks:
case RewriteMacros:
case RewriteTest:
- OS.reset(ComputeOutFile(CI.getFrontendOpts(), InFile, 0, true, OutPath));
- break;
+ break; // No setup.
}
// Check if we want a fix-it rewriter.
@@ -531,6 +519,13 @@ static void ProcessInputFile(CompilerInstance &CI, const std::string &InFile,
}
case GeneratePTH:
+ if (FEOpts.OutputFile.empty() || FEOpts.OutputFile == "-") {
+ // FIXME: Don't fail this way.
+ // FIXME: Verify that we can actually seek in the given file.
+ llvm::errs() << "ERROR: PTH requires an seekable file for output!\n";
+ ::exit(1);
+ }
+ OS.reset(ComputeOutFile(CI.getFrontendOpts(), InFile, 0, true, OutPath));
CacheTokens(PP, static_cast<llvm::raw_fd_ostream*>(OS.get()));
break;
@@ -539,18 +534,22 @@ static void ProcessInputFile(CompilerInstance &CI, const std::string &InFile,
break;
case ParsePrintCallbacks:
+ OS.reset(ComputeOutFile(CI.getFrontendOpts(), InFile, 0, true, OutPath));
ParseFile(PP, CreatePrintParserActionsAction(PP, OS.get()));
break;
case PrintPreprocessedInput:
+ OS.reset(ComputeOutFile(CI.getFrontendOpts(), InFile, 0, true, OutPath));
DoPrintPreprocessedInput(PP, OS.get(), CI.getPreprocessorOutputOpts());
break;
case RewriteMacros:
+ OS.reset(ComputeOutFile(CI.getFrontendOpts(), InFile, 0, true, OutPath));
RewriteMacrosInInput(PP, OS.get());
break;
case RewriteTest:
+ OS.reset(ComputeOutFile(CI.getFrontendOpts(), InFile, 0, true, OutPath));
DoRewriteTest(PP, OS.get());
break;