[cfe-commits] r86881 - in /cfe/trunk: include/clang/Frontend/Utils.h lib/Frontend/DependencyFile.cpp tools/clang-cc/clang-cc.cpp

Daniel Dunbar daniel at zuster.org
Wed Nov 11 13:44:00 PST 2009


Author: ddunbar
Date: Wed Nov 11 15:44:00 2009
New Revision: 86881

URL: http://llvm.org/viewvc/llvm-project?rev=86881&view=rev
Log:
Sink AttachDependencyFileGen into CreatePreprocessor.

Modified:
    cfe/trunk/include/clang/Frontend/Utils.h
    cfe/trunk/lib/Frontend/DependencyFile.cpp
    cfe/trunk/tools/clang-cc/clang-cc.cpp

Modified: cfe/trunk/include/clang/Frontend/Utils.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/Utils.h?rev=86881&r1=86880&r2=86881&view=diff

==============================================================================
--- cfe/trunk/include/clang/Frontend/Utils.h (original)
+++ cfe/trunk/include/clang/Frontend/Utils.h Wed Nov 11 15:44:00 2009
@@ -78,12 +78,12 @@
 
 /// 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(Preprocessor& PP, llvm::raw_fd_ostream* OS);
+void CacheTokens(Preprocessor &PP, llvm::raw_fd_ostream* OS);
 
 }  // end namespace clang
 

Modified: cfe/trunk/lib/Frontend/DependencyFile.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/DependencyFile.cpp?rev=86881&r1=86880&r2=86881&view=diff

==============================================================================
--- cfe/trunk/lib/Frontend/DependencyFile.cpp (original)
+++ cfe/trunk/lib/Frontend/DependencyFile.cpp Wed Nov 11 15:44:00 2009
@@ -60,23 +60,23 @@
 };
 }
 
-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

Modified: cfe/trunk/tools/clang-cc/clang-cc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/clang-cc.cpp?rev=86881&r1=86880&r2=86881&view=diff

==============================================================================
--- cfe/trunk/tools/clang-cc/clang-cc.cpp (original)
+++ cfe/trunk/tools/clang-cc/clang-cc.cpp Wed Nov 11 15:44:00 2009
@@ -376,8 +376,10 @@
 
 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 @@
 
   InitializePreprocessor(*PP, PPOpts);
 
+  // Handle generating dependencies, if requested.
+  if (!DepOpts.OutputFile.empty())
+    AttachDependencyFileGen(*PP, DepOpts);
+
   return PP;
 }
 
@@ -1207,12 +1213,9 @@
     // 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))





More information about the cfe-commits mailing list