]> granicus.if.org Git - clang/commitdiff
Sink AttachDependencyFileGen into CreatePreprocessor.
authorDaniel Dunbar <daniel@zuster.org>
Wed, 11 Nov 2009 21:44:00 +0000 (21:44 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Wed, 11 Nov 2009 21:44:00 +0000 (21:44 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86881 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Frontend/Utils.h
lib/Frontend/DependencyFile.cpp
tools/clang-cc/clang-cc.cpp

index 859f06a434bb6562c4e621ad57083b84437ab928..5526dfdb324fcb479266b60a9ff379da30ea89c4 100644 (file)
@@ -78,12 +78,12 @@ bool CheckDiagnostics(Preprocessor &PP);
 
 /// AttachDependencyFileGen - Create a dependency file generator, and attach
 /// it to the given preprocessor.  This takes ownership of the output stream.
-void AttachDependencyFileGen(Preprocessor *PP,
+void AttachDependencyFileGen(Preprocessor &PP,
                              const DependencyOutputOptions &Opts);
 
 /// CacheTokens - Cache tokens for use with PCH. Note that this requires
 /// a seekable stream.
-void CacheTokens(PreprocessorPP, llvm::raw_fd_ostream* OS);
+void CacheTokens(Preprocessor &PP, llvm::raw_fd_ostream* OS);
 
 }  // end namespace clang
 
index 9c311fac629b85e707ad3241cc5493da961adbe0..c7f93595e1ea3704b17714f37d591f586e035d0a 100644 (file)
@@ -60,23 +60,23 @@ public:
 };
 }
 
-void clang::AttachDependencyFileGen(Preprocessor *PP,
+void clang::AttachDependencyFileGen(Preprocessor &PP,
                                     const DependencyOutputOptions &Opts) {
   if (Opts.Targets.empty()) {
-    PP->getDiagnostics().Report(diag::err_fe_dependency_file_requires_MT);
+    PP.getDiagnostics().Report(diag::err_fe_dependency_file_requires_MT);
     return;
   }
 
   std::string Err;
   llvm::raw_ostream *OS(new llvm::raw_fd_ostream(Opts.OutputFile.c_str(), Err));
   if (!Err.empty()) {
-    PP->getDiagnostics().Report(diag::err_fe_error_opening)
+    PP.getDiagnostics().Report(diag::err_fe_error_opening)
       << Opts.OutputFile << Err;
     return;
   }
 
-  assert(!PP->getPPCallbacks() && "Preprocessor callbacks already registered!");
-  PP->setPPCallbacks(new DependencyFileCallback(PP, OS, Opts));
+  assert(!PP.getPPCallbacks() && "Preprocessor callbacks already registered!");
+  PP.setPPCallbacks(new DependencyFileCallback(&PP, OS, Opts));
 }
 
 /// FileMatchesDepCriteria - Determine whether the given Filename should be
index 85a11923e12fc2e5ad949cd884636cf00ca06491..f6e65572096951e786b178abe083fc5f7294bc92 100644 (file)
@@ -376,8 +376,10 @@ std::string GetBuiltinIncludePath(const char *Argv0) {
 
 static Preprocessor *
 CreatePreprocessor(Diagnostic &Diags, const LangOptions &LangInfo,
-                   const PreprocessorOptions &PPOpts, TargetInfo &Target,
-                   SourceManager &SourceMgr, HeaderSearch &HeaderInfo) {
+                   const PreprocessorOptions &PPOpts,
+                   const DependencyOutputOptions &DepOpts,
+                   TargetInfo &Target, SourceManager &SourceMgr,
+                   HeaderSearch &HeaderInfo) {
   PTHManager *PTHMgr = 0;
   if (!TokenCache.empty() && !PPOpts.getImplicitPTHInclude().empty()) {
     fprintf(stderr, "error: cannot use both -token-cache and -include-pth "
@@ -411,6 +413,10 @@ CreatePreprocessor(Diagnostic &Diags, const LangOptions &LangInfo,
 
   InitializePreprocessor(*PP, PPOpts);
 
+  // Handle generating dependencies, if requested.
+  if (!DepOpts.OutputFile.empty())
+    AttachDependencyFileGen(*PP, DepOpts);
+
   return PP;
 }
 
@@ -1207,12 +1213,9 @@ int main(int argc, char **argv) {
     // Set up the preprocessor with these options.
     llvm::OwningPtr<Preprocessor>
       PP(CreatePreprocessor(Diags, CompOpts.getLangOpts(),
-                            CompOpts.getPreprocessorOpts(), *Target, SourceMgr,
-                            HeaderInfo));
-
-    // Handle generating dependencies, if requested.
-    if (!CompOpts.getDependencyOutputOpts().OutputFile.empty())
-      AttachDependencyFileGen(PP.get(), CompOpts.getDependencyOutputOpts());
+                            CompOpts.getPreprocessorOpts(),
+                            CompOpts.getDependencyOutputOpts(),
+                            *Target, SourceMgr, HeaderInfo));
 
     if (CompOpts.getPreprocessorOpts().getImplicitPCHInclude().empty()) {
       if (InitializeSourceManager(*PP.get(), InFile))