13#ifndef LLVM_CLANG_FRONTEND_UTILS_H
14#define LLVM_CLANG_FRONTEND_UTILS_H
20#include "llvm/ADT/ArrayRef.h"
21#include "llvm/ADT/IntrusiveRefCntPtr.h"
22#include "llvm/ADT/StringMap.h"
23#include "llvm/ADT/StringRef.h"
24#include "llvm/ADT/StringSet.h"
25#include "llvm/Support/FileCollector.h"
26#include "llvm/Support/VirtualFileSystem.h"
30#include <system_error>
75 virtual bool sawDependency(StringRef Filename,
bool FromModule,
bool IsSystem,
76 bool IsModuleFile,
bool IsDirectModuleImport,
88 bool IsSystem,
bool IsModuleFile,
89 bool IsDirectModuleImport,
bool IsMissing);
97 llvm::StringSet<> Seen;
98 std::vector<std::string> Dependencies;
115 bool sawDependency(StringRef Filename,
bool FromModule,
bool IsSystem,
116 bool IsModuleFile,
bool IsDirectModuleImport,
117 bool IsMissing)
final;
125 std::string OutputFile;
126 std::vector<std::string> Targets;
127 bool IncludeSystemHeaders;
129 bool AddMissingHeaderDeps;
130 bool SeenMissingHeader;
133 unsigned InputFileIndex;
140 bool HasErrors =
false;
141 llvm::StringSet<> Seen;
142 llvm::vfs::YAMLVFSWriter VFSWriter;
143 llvm::FileCollector::PathCanonicalizer Canonicalizer;
145 std::error_code copyToRoot(StringRef Src, StringRef Dst = {});
150 : DestDir(
std::move(DestDir)), Canonicalizer(
std::move(VFS)) {}
154 virtual bool insertSeen(StringRef Filename) {
return Seen.insert(Filename).second; }
155 virtual void addFile(StringRef Filename, StringRef FileDst = {});
158 VFSWriter.addFileMapping(VPath, RPath);
186 const DependencyOutputOptions &DepOpts,
187 bool ShowAllHeaders =
false,
188 StringRef OutputPath = {},
189 bool ShowDepth =
true,
bool MSStyle =
false);
Defines the Diagnostic-related interfaces.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Reads an AST files chain containing the contents of a translation unit.
CodeGenOptions - Track various options which control how the code is optimized and passed to the back...
CompilerInstance - Helper class for managing a single instance of the Clang compiler.
Helper class for holding the data necessary to invoke the compiler.
An interface for collecting the dependencies of a compilation.
bool addDependency(StringRef Filename)
Return true if the filename was added to the list of dependencies, false otherwise.
virtual void attachToPreprocessor(Preprocessor &PP)
virtual void maybeAddDependency(StringRef Filename, bool FromModule, bool IsSystem, bool IsModuleFile, bool IsDirectModuleImport, bool IsMissing)
Add a dependency Filename if it has not been seen before and sawDependency() returns true.
ArrayRef< std::string > getDependencies() const
virtual void finishedMainFile(DiagnosticsEngine &Diags)
Called when the end of the main file is reached.
virtual void attachToASTReader(ASTReader &R)
virtual ~DependencyCollector()
virtual bool sawDependency(StringRef Filename, bool FromModule, bool IsSystem, bool IsModuleFile, bool IsDirectModuleImport, bool IsMissing)
Called when a new file is seen.
virtual bool needSystemDependencies()
Return true if system files should be passed to sawDependency().
void outputDependencyFile(llvm::raw_ostream &OS)
void attachToPreprocessor(Preprocessor &PP) override
void finishedMainFile(DiagnosticsEngine &Diags) override
Called when the end of the main file is reached.
bool needSystemDependencies() final
Return true if system files should be passed to sawDependency().
bool sawDependency(StringRef Filename, bool FromModule, bool IsSystem, bool IsModuleFile, bool IsDirectModuleImport, bool IsMissing) final
Called when a new file is seen.
DependencyFileGenerator(const DependencyOutputOptions &Opts)
DependencyOutputOptions - Options for controlling the compiler dependency file generation.
Concrete class used by the front-end to report problems and issues.
An abstract interface that should be implemented by external AST sources that also provide informatio...
FrontendOptions - Options for controlling the behavior of the frontend.
void attachToASTReader(ASTReader &R) override
~ModuleDependencyCollector() override
virtual void addFileMapping(StringRef VPath, StringRef RPath)
ModuleDependencyCollector(std::string DestDir, IntrusiveRefCntPtr< llvm::vfs::FileSystem > VFS)
void attachToPreprocessor(Preprocessor &PP) override
virtual void addFile(StringRef Filename, StringRef FileDst={})
virtual bool insertSeen(StringRef Filename)
virtual void writeFileMap()
This abstract interface provides operations for unwrapping containers for serialized ASTs (precompile...
PreprocessorOptions - This class is used for passing the various options used in preprocessor initial...
PreprocessorOutputOptions - Options for controlling the C preprocessor output (e.g....
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
The JSON file list parser is used to communicate input to InstallAPI.
void InitializePreprocessor(Preprocessor &PP, const PreprocessorOptions &PPOpts, const PCHContainerReader &PCHContainerRdr, const FrontendOptions &FEOpts, const CodeGenOptions &CodeGenOpts)
InitializePreprocessor - Initialize the preprocessor getting it and the environment ready to process ...
IntrusiveRefCntPtr< ExternalSemaSource > createChainedIncludesSource(CompilerInstance &CI, IntrusiveRefCntPtr< ASTReader > &OutReader)
The ChainedIncludesSource class converts headers to chained PCHs in memory, mainly for testing.
ModuleFileDepsKind
ModuleFileDepsKind - Whether to include module file dependencies.
void DoPrintPreprocessedInput(Preprocessor &PP, raw_ostream *OS, const PreprocessorOutputOptions &Opts)
DoPrintPreprocessedInput - Implement -E mode.
DependencyOutputFormat
DependencyOutputFormat - Format for the compiler dependency file.
void AttachHeaderIncludeGen(Preprocessor &PP, const DependencyOutputOptions &DepOpts, bool ShowAllHeaders=false, StringRef OutputPath={}, bool ShowDepth=true, bool MSStyle=false)
AttachHeaderIncludeGen - Create a header include list generator, and attach it to the given preproces...
void AttachDependencyGraphGen(Preprocessor &PP, StringRef OutputFile, StringRef SysRoot)
AttachDependencyGraphGen - Create a dependency graph generator, and attach it to the given preprocess...