diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-11-11 21:43:12 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-11-11 21:43:12 +0000 |
commit | 89d1fdff65aa4faeaeb48b7eb80f44486b2dc9af (patch) | |
tree | f2c3130d73aaabe3cfcf79d7d6bce9d25554af16 /clang/lib/Frontend/DependencyFile.cpp | |
parent | fd84d6d8086b2929019e9821bfebea50fec9ffa1 (diff) | |
download | bcm5719-llvm-89d1fdff65aa4faeaeb48b7eb80f44486b2dc9af.tar.gz bcm5719-llvm-89d1fdff65aa4faeaeb48b7eb80f44486b2dc9af.zip |
Add DependencyOutputOptions to wrap -M... options, and propogate to
CompilerInvocation and clang-cc.
llvm-svn: 86880
Diffstat (limited to 'clang/lib/Frontend/DependencyFile.cpp')
-rw-r--r-- | clang/lib/Frontend/DependencyFile.cpp | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/clang/lib/Frontend/DependencyFile.cpp b/clang/lib/Frontend/DependencyFile.cpp index 81d1179f28e..9c311fac629 100644 --- a/clang/lib/Frontend/DependencyFile.cpp +++ b/clang/lib/Frontend/DependencyFile.cpp @@ -12,12 +12,14 @@ //===----------------------------------------------------------------------===// #include "clang/Frontend/Utils.h" -#include "clang/Basic/SourceManager.h" #include "clang/Basic/FileManager.h" -#include "clang/Lex/Preprocessor.h" -#include "clang/Lex/PPCallbacks.h" -#include "clang/Lex/DirectoryLookup.h" #include "clang/Basic/SourceLocation.h" +#include "clang/Basic/SourceManager.h" +#include "clang/Frontend/DependencyOutputOptions.h" +#include "clang/Frontend/FrontendDiagnostic.h" +#include "clang/Lex/DirectoryLookup.h" +#include "clang/Lex/PPCallbacks.h" +#include "clang/Lex/Preprocessor.h" #include "llvm/ADT/StringSet.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/raw_ostream.h" @@ -42,11 +44,10 @@ private: public: DependencyFileCallback(const Preprocessor *_PP, llvm::raw_ostream *_OS, - const std::vector<std::string> &_Targets, - bool _IncludeSystemHeaders, - bool _PhonyTarget) - : PP(_PP), Targets(_Targets), OS(_OS), - IncludeSystemHeaders(_IncludeSystemHeaders), PhonyTarget(_PhonyTarget) {} + const DependencyOutputOptions &Opts) + : PP(_PP), Targets(Opts.Targets), OS(_OS), + IncludeSystemHeaders(Opts.IncludeSystemHeaders), + PhonyTarget(Opts.UsePhonyTargets) {} ~DependencyFileCallback() { OutputDependencyFile(); @@ -59,18 +60,23 @@ public: }; } +void clang::AttachDependencyFileGen(Preprocessor *PP, + const DependencyOutputOptions &Opts) { + if (Opts.Targets.empty()) { + 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) + << Opts.OutputFile << Err; + return; + } -void clang::AttachDependencyFileGen(Preprocessor *PP, llvm::raw_ostream *OS, - std::vector<std::string> &Targets, - bool IncludeSystemHeaders, - bool PhonyTarget) { - assert(!Targets.empty() && "Target required for dependency generation"); - - DependencyFileCallback *PPDep = - new DependencyFileCallback(PP, OS, Targets, IncludeSystemHeaders, - PhonyTarget); - PP->setPPCallbacks(PPDep); + assert(!PP->getPPCallbacks() && "Preprocessor callbacks already registered!"); + PP->setPPCallbacks(new DependencyFileCallback(PP, OS, Opts)); } /// FileMatchesDepCriteria - Determine whether the given Filename should be |