14 #ifndef LLVM_CLANG_FRONTEND_UTILS_H 15 #define LLVM_CLANG_FRONTEND_UTILS_H 19 #include "llvm/ADT/ArrayRef.h" 20 #include "llvm/ADT/IntrusiveRefCntPtr.h" 21 #include "llvm/ADT/StringMap.h" 22 #include "llvm/ADT/StringRef.h" 23 #include "llvm/ADT/StringSet.h" 24 #include "llvm/Option/OptSpecifier.h" 25 #include "llvm/Support/VirtualFileSystem.h" 29 #include <system_error> 48 class CompilerInstance;
49 class CompilerInvocation;
50 class DependencyOutputOptions;
51 class DiagnosticsEngine;
52 class ExternalSemaSource;
53 class FrontendOptions;
55 class HeaderSearchOptions;
57 class PCHContainerReader;
59 class PreprocessorOptions;
60 class PreprocessorOutputOptions;
64 const HeaderSearchOptions &HSOpts,
65 const LangOptions &Lang,
66 const llvm::Triple &triple);
71 const PCHContainerReader &PCHContainerRdr,
72 const FrontendOptions &FEOpts);
76 const PreprocessorOutputOptions &Opts);
88 virtual void attachToASTReader(
ASTReader &R);
95 virtual bool sawDependency(StringRef
Filename,
bool FromModule,
96 bool IsSystem,
bool IsModuleFile,
bool IsMissing);
107 void maybeAddDependency(StringRef Filename,
bool FromModule,
bool IsSystem,
108 bool IsModuleFile,
bool IsMissing);
111 llvm::StringSet<> Seen;
112 std::vector<std::string> Dependencies;
135 bool HasErrors =
false;
136 llvm::StringSet<> Seen;
137 llvm::vfs::YAMLVFSWriter VFSWriter;
138 llvm::StringMap<std::string> SymLinkMap;
141 std::error_code copyToRoot(StringRef Src, StringRef Dst = {});
145 : DestDir(
std::move(DestDir)) {}
150 void addFile(StringRef
Filename, StringRef FileDst = {});
153 VFSWriter.addFileMapping(VPath, RPath);
157 void attachToASTReader(
ASTReader &R)
override;
182 bool ShowAllHeaders =
false,
183 StringRef OutputPath = {},
184 bool ShowDepth =
true,
bool MSStyle =
false);
210 llvm::opt::OptSpecifier Id,
int Default,
216 llvm::opt::OptSpecifier Id, uint64_t Default,
220 llvm::opt::OptSpecifier Id,
234 #endif // LLVM_CLANG_FRONTEND_UTILS_H IntrusiveRefCntPtr< ExternalSemaSource > createChainedIncludesSource(CompilerInstance &CI, IntrusiveRefCntPtr< ExternalSemaSource > &Reader)
The ChainedIncludesSource class converts headers to chained PCHs in memory, mainly for testing...
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
An interface for collecting the dependencies of a compilation.
virtual bool needSystemDependencies()
Return true if system files should be passed to sawDependency().
std::unique_ptr< CompilerInvocation > createInvocationFromCommandLine(ArrayRef< const char *> Args, IntrusiveRefCntPtr< DiagnosticsEngine > Diags=IntrusiveRefCntPtr< DiagnosticsEngine >(), IntrusiveRefCntPtr< llvm::vfs::FileSystem > VFS=nullptr)
createInvocationFromCommandLine - Construct a compiler invocation object for a command line argument ...
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
Concrete class used by the front-end to report problems and issues.
Defines the Diagnostic-related interfaces.
ModuleDependencyCollector(std::string DestDir)
Builds a depdenency file when attached to a Preprocessor (for includes) and ASTReader (for module imp...
uint64_t getLastArgUInt64Value(const llvm::opt::ArgList &Args, llvm::opt::OptSpecifier Id, uint64_t Default, DiagnosticsEngine &Diags)
void DoPrintPreprocessedInput(Preprocessor &PP, raw_ostream *OS, const PreprocessorOutputOptions &Opts)
DoPrintPreprocessedInput - Implement -E mode.
ArrayRef< std::string > getDependencies() const
void addFileMapping(StringRef VPath, StringRef RPath)
virtual void finishedMainFile()
Called when the end of the main file is reached.
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...
Collects the dependencies for imported modules into a directory.
void ApplyHeaderSearchOptions(HeaderSearch &HS, const HeaderSearchOptions &HSOpts, const LangOptions &Lang, const llvm::Triple &triple)
Apply the header search options to get given HeaderSearch object.
CompilerInstance - Helper class for managing a single instance of the Clang compiler.
void AttachDependencyGraphGen(Preprocessor &PP, StringRef OutputFile, StringRef SysRoot)
AttachDependencyGraphGen - Create a dependency graph generator, and attach it to the given preprocess...
DependencyOutputOptions - Options for controlling the compiler dependency file generation.
Dataflow Directional Tag Classes.
bool FrontendTimesIsEnabled
If the user specifies the -ftime-report argument on an Clang command line then the value of this bool...
Reads an AST files chain containing the contents of a translation unit.
~ModuleDependencyCollector() override
int getLastArgIntValue(const llvm::opt::ArgList &Args, llvm::opt::OptSpecifier Id, int Default, DiagnosticsEngine &Diags)
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 ...
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
bool insertSeen(StringRef Filename)