Sink AttachDependencyFileGen into CreatePreprocessor.

llvm-svn: 86881
This commit is contained in:
Daniel Dunbar 2009-11-11 21:44:00 +00:00
parent 89d1fdff65
commit 55b781f85e
3 changed files with 18 additions and 15 deletions

View 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(Preprocessor& PP, llvm::raw_fd_ostream* OS);
void CacheTokens(Preprocessor &PP, llvm::raw_fd_ostream* OS);
} // end namespace clang

View 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

View 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))