14 #ifndef LLVM_CLANG_FRONTEND_UTILS_H 15 #define LLVM_CLANG_FRONTEND_UTILS_H 19 #include "llvm/ADT/IntrusiveRefCntPtr.h" 20 #include "llvm/ADT/StringRef.h" 21 #include "llvm/ADT/StringSet.h" 22 #include "llvm/Option/OptSpecifier.h" 37 class CompilerInstance;
38 class CompilerInvocation;
40 class DependencyOutputOptions;
41 class DiagnosticsEngine;
42 class DiagnosticOptions;
43 class ExternalSemaSource;
46 class HeaderSearchOptions;
47 class IdentifierTable;
49 class PCHContainerReader;
51 class PreprocessorOptions;
52 class PreprocessorOutputOptions;
56 class FrontendOptions;
60 const HeaderSearchOptions &HSOpts,
61 const LangOptions &Lang,
62 const llvm::Triple &triple);
67 const PCHContainerReader &PCHContainerRdr,
68 const FrontendOptions &FEOpts);
72 const PreprocessorOutputOptions &Opts);
82 virtual void attachToASTReader(
ASTReader &R);
89 virtual bool sawDependency(StringRef
Filename,
bool FromModule,
90 bool IsSystem,
bool IsModuleFile,
bool IsMissing);
100 void maybeAddDependency(StringRef Filename,
bool FromModule,
bool IsSystem,
101 bool IsModuleFile,
bool IsMissing);
103 llvm::StringSet<> Seen;
104 std::vector<std::string> Dependencies;
124 bool HasErrors =
false;
125 llvm::StringSet<> Seen;
128 llvm::StringMap<std::string> SymLinkMap;
131 std::error_code copyToRoot(StringRef Src, StringRef Dst =
"");
135 void addFile(StringRef
Filename, StringRef FileDst =
"");
141 void attachToASTReader(
ASTReader &R)
override;
146 : DestDir(
std::move(DestDir)) {}
169 bool ShowAllHeaders =
false,
170 StringRef OutputPath =
"",
171 bool ShowDepth =
true,
bool MSStyle =
false);
200 llvm::opt::OptSpecifier Id,
int Default,
206 llvm::opt::OptSpecifier Id, uint64_t Default,
210 llvm::opt::OptSpecifier Id,
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.
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
virtual bool needSystemDependencies()
Return true if system files should be passed to sawDependency().
void addFileMapping(StringRef VirtualPath, StringRef RealPath)
Concrete class used by the front-end to report problems and issues.
Defines the Diagnostic-related interfaces.
void CacheTokens(Preprocessor &PP, raw_pwrite_stream *OS)
Cache tokens for use with PCH. Note that this requires a seekable stream.
ModuleDependencyCollector(std::string DestDir)
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...
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.
void addFileMapping(StringRef VPath, StringRef RPath)
virtual void finishedMainFile()
Called when the end of the main file is reached.
Collects the dependencies for imported modules into a directory.
std::unique_ptr< CompilerInvocation > createInvocationFromCommandLine(ArrayRef< const char *> Args, IntrusiveRefCntPtr< DiagnosticsEngine > Diags=IntrusiveRefCntPtr< DiagnosticsEngine >(), IntrusiveRefCntPtr< vfs::FileSystem > VFS=nullptr)
createInvocationFromCommandLine - Construct a compiler invocation object for a command line argument ...
llvm::ArrayRef< std::string > getDependencies() const
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.
void BuryPointer(std::unique_ptr< T > Ptr)
Dataflow Directional Tag Classes.
Reads an AST files chain containing the contents of a translation unit.
Defines the virtual file system interface vfs::FileSystem.
~ModuleDependencyCollector()
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)