]> granicus.if.org Git - clang/commitdiff
clang-cc: Move output file initialization closer to use.
authorDaniel Dunbar <daniel@zuster.org>
Fri, 13 Nov 2009 10:18:59 +0000 (10:18 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Fri, 13 Nov 2009 10:18:59 +0000 (10:18 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@87102 91177308-0d34-0410-b5e6-96231b3b80d8

tools/clang-cc/clang-cc.cpp

index 7cdf2ac8b016f2d8a1af78e56eb83447b4c0e091..93384390e1ab851f95bdc8750763c02663a06397 100644 (file)
@@ -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;