Go to the documentation of this file.
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>
37 class CompilerInstance;
38 class CompilerInvocation;
39 class DiagnosticsEngine;
40 class ExternalSemaSource;
41 class FrontendOptions;
42 class PCHContainerReader;
44 class PreprocessorOptions;
45 class PreprocessorOutputOptions;
50 const PCHContainerReader &PCHContainerRdr,
51 const FrontendOptions &FEOpts);
55 const PreprocessorOutputOptions &Opts);
74 bool IsSystem,
bool IsModuleFile,
bool IsMissing);
85 bool IsSystem,
bool IsModuleFile,
94 llvm::StringSet<> Seen;
95 std::vector<std::string> Dependencies;
113 bool IsModuleFile,
bool IsMissing)
final override;
122 std::vector<std::string> Targets;
123 bool IncludeSystemHeaders;
125 bool AddMissingHeaderDeps;
126 bool SeenMissingHeader;
127 bool IncludeModuleFiles;
129 unsigned InputFileIndex;
136 bool HasErrors =
false;
137 llvm::StringSet<> Seen;
138 llvm::vfs::YAMLVFSWriter VFSWriter;
139 llvm::FileCollector::PathCanonicalizer Canonicalizer;
141 std::error_code copyToRoot(StringRef Src, StringRef Dst = {});
145 : DestDir(
std::move(DestDir)) {}
153 VFSWriter.addFileMapping(VPath, RPath);
181 const DependencyOutputOptions &DepOpts,
182 bool ShowAllHeaders =
false,
183 StringRef OutputPath = {},
184 bool ShowDepth =
true,
bool MSStyle =
false);
188 IntrusiveRefCntPtr<ExternalSemaSource>
190 IntrusiveRefCntPtr<ExternalSemaSource> &Reader);
233 std::unique_ptr<CompilerInvocation>
239 #endif // LLVM_CLANG_FRONTEND_UTILS_H
DependencyOutputOptions - Options for controlling the compiler dependency file generation.
bool sawDependency(StringRef Filename, bool FromModule, bool IsSystem, bool IsModuleFile, bool IsMissing) final override
Called when a new file is seen.
void finishedMainFile(DiagnosticsEngine &Diags) override
Called when the end of the main file is reached.
Concrete class used by the front-end to report problems and issues.
std::unique_ptr< CompilerInvocation > createInvocation(ArrayRef< const char * > Args, CreateInvocationOptions Opts={})
Interpret clang arguments in preparation to parse a file.
virtual void writeFileMap()
virtual void attachToPreprocessor(Preprocessor &PP)
virtual void finishedMainFile(DiagnosticsEngine &Diags)
Called when the end of the main file is reached.
bool ProbePrecompiled
Allow the driver to probe the filesystem for PCH files.
DependencyOutputFormat
DependencyOutputFormat - Format for the compiler dependency file.
virtual ~DependencyCollector()
void attachToPreprocessor(Preprocessor &PP) override
IntrusiveRefCntPtr< llvm::vfs::FileSystem > VFS
Used e.g.
~ModuleDependencyCollector() override
void InitializePreprocessor(Preprocessor &PP, const PreprocessorOptions &PPOpts, const PCHContainerReader &PCHContainerRdr, const FrontendOptions &FEOpts)
InitializePreprocessor - Initialize the preprocessor getting it and the environment ready to process ...
void attachToASTReader(ASTReader &R) override
virtual bool sawDependency(StringRef Filename, bool FromModule, bool IsSystem, bool IsModuleFile, bool IsMissing)
Called when a new file is seen.
An interface for collecting the dependencies of a compilation.
Builds a dependency file when attached to a Preprocessor (for includes) and ASTReader (for module imp...
std::vector< std::string > * CC1Args
If set, the target is populated with the cc1 args produced by the driver.
bool needSystemDependencies() final override
Return true if system files should be passed to sawDependency().
Optional inputs to createInvocation.
Collects the dependencies for imported modules into a directory.
virtual bool needSystemDependencies()
Return true if system files should be passed to sawDependency().
virtual bool insertSeen(StringRef Filename)
void DoPrintPreprocessedInput(Preprocessor &PP, raw_ostream *OS, const PreprocessorOutputOptions &Opts)
DoPrintPreprocessedInput - Implement -E mode.
Reads an AST files chain containing the contents of a translation unit.
DependencyFileGenerator(const DependencyOutputOptions &Opts)
virtual void attachToASTReader(ASTReader &R)
IntrusiveRefCntPtr< ExternalSemaSource > createChainedIncludesSource(CompilerInstance &CI, IntrusiveRefCntPtr< ExternalSemaSource > &Reader)
The ChainedIncludesSource class converts headers to chained PCHs in memory, mainly for testing.
void attachToPreprocessor(Preprocessor &PP) override
void outputDependencyFile(llvm::raw_ostream &OS)
virtual void maybeAddDependency(StringRef Filename, bool FromModule, bool IsSystem, bool IsModuleFile, bool IsMissing)
Add a dependency Filename if it has not been seen before and sawDependency() returns true.
ModuleDependencyCollector(std::string DestDir)
ArrayRef< std::string > getDependencies() const
bool RecoverOnError
Whether to attempt to produce a non-null (possibly incorrect) invocation if any errors were encounter...
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
void AttachDependencyGraphGen(Preprocessor &PP, StringRef OutputFile, StringRef SysRoot)
AttachDependencyGraphGen - Create a dependency graph generator, and attach it to the given preprocess...
bool addDependency(StringRef Filename)
Return true if the filename was added to the list of dependencies, false otherwise.
virtual void addFileMapping(StringRef VPath, StringRef RPath)
virtual void addFile(StringRef Filename, StringRef FileDst={})
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...
IntrusiveRefCntPtr< DiagnosticsEngine > Diags
Receives diagnostics encountered while parsing command-line flags.