diff options
Diffstat (limited to 'include/clang/Frontend/Utils.h')
-rw-r--r-- | include/clang/Frontend/Utils.h | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/include/clang/Frontend/Utils.h b/include/clang/Frontend/Utils.h index a5f667ef7c7d..cf943a5960bd 100644 --- a/include/clang/Frontend/Utils.h +++ b/include/clang/Frontend/Utils.h @@ -20,6 +20,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/ADT/StringSet.h" #include "llvm/Option/OptSpecifier.h" +#include <utility> namespace llvm { class raw_fd_ostream; @@ -73,12 +74,12 @@ void DoPrintPreprocessedInput(Preprocessor &PP, raw_ostream* OS, /// An interface for collecting the dependencies of a compilation. Users should /// use \c attachToPreprocessor and \c attachToASTReader to get all of the /// dependencies. -// FIXME: Migrate DependencyFileGen, DependencyGraphGen, ModuleDepCollectory to -// use this interface. +/// FIXME: Migrate DependencyFileGen and DependencyGraphGen to use this +/// interface. class DependencyCollector { public: - void attachToPreprocessor(Preprocessor &PP); - void attachToASTReader(ASTReader &R); + virtual void attachToPreprocessor(Preprocessor &PP); + virtual void attachToASTReader(ASTReader &R); llvm::ArrayRef<std::string> getDependencies() const { return Dependencies; } /// Called when a new file is seen. Return true if \p Filename should be added @@ -118,39 +119,43 @@ public: /// Collects the dependencies for imported modules into a directory. Users /// should attach to the AST reader whenever a module is loaded. -class ModuleDependencyCollector { +class ModuleDependencyCollector : public DependencyCollector { std::string DestDir; - bool HasErrors; + bool HasErrors = false; llvm::StringSet<> Seen; vfs::YAMLVFSWriter VFSWriter; + llvm::StringMap<std::string> SymLinkMap; + + bool getRealPath(StringRef SrcPath, SmallVectorImpl<char> &Result); + std::error_code copyToRoot(StringRef Src); public: StringRef getDest() { return DestDir; } bool insertSeen(StringRef Filename) { return Seen.insert(Filename).second; } - void setHasErrors() { HasErrors = true; } + void addFile(StringRef Filename); void addFileMapping(StringRef VPath, StringRef RPath) { VFSWriter.addFileMapping(VPath, RPath); } - void attachToASTReader(ASTReader &R); + void attachToPreprocessor(Preprocessor &PP) override; + void attachToASTReader(ASTReader &R) override; + void writeFileMap(); bool hasErrors() { return HasErrors; } ModuleDependencyCollector(std::string DestDir) - : DestDir(DestDir), HasErrors(false) {} + : DestDir(std::move(DestDir)) {} ~ModuleDependencyCollector() { writeFileMap(); } }; /// AttachDependencyGraphGen - Create a dependency graph generator, and attach /// it to the given preprocessor. - void AttachDependencyGraphGen(Preprocessor &PP, StringRef OutputFile, - StringRef SysRoot); +void AttachDependencyGraphGen(Preprocessor &PP, StringRef OutputFile, + StringRef SysRoot); /// AttachHeaderIncludeGen - Create a header include list generator, and attach /// it to the given preprocessor. /// -/// \param ExtraHeaders - If not empty, will write the header filenames, just -/// like they were included during a regular preprocessing. Useful for -/// implicit include dependencies, like sanitizer blacklists. +/// \param DepOpts - Options controlling the output. /// \param ShowAllHeaders - If true, show all header information instead of just /// headers following the predefines buffer. This is useful for making sure /// includes mentioned on the command line are also reported, but differs from @@ -160,7 +165,7 @@ public: /// \param ShowDepth - Whether to indent to show the nesting of the includes. /// \param MSStyle - Whether to print in cl.exe /showIncludes style. void AttachHeaderIncludeGen(Preprocessor &PP, - const std::vector<std::string> &ExtraHeaders, + const DependencyOutputOptions &DepOpts, bool ShowAllHeaders = false, StringRef OutputPath = "", bool ShowDepth = true, bool MSStyle = false); |