Sink AttachDependencyFileGen into CreatePreprocessor.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86881 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/Frontend/Utils.h b/include/clang/Frontend/Utils.h
index 859f06a..5526dfd 100644
--- a/include/clang/Frontend/Utils.h
+++ b/include/clang/Frontend/Utils.h
@@ -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
diff --git a/lib/Frontend/DependencyFile.cpp b/lib/Frontend/DependencyFile.cpp
index 9c311fa..c7f9359 100644
--- a/lib/Frontend/DependencyFile.cpp
+++ b/lib/Frontend/DependencyFile.cpp
@@ -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
diff --git a/tools/clang-cc/clang-cc.cpp b/tools/clang-cc/clang-cc.cpp
index 85a1192..f6e6557 100644
--- a/tools/clang-cc/clang-cc.cpp
+++ b/tools/clang-cc/clang-cc.cpp
@@ -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))