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"
36 class CompilerInstance;
37 class CompilerInvocation;
39 class DependencyOutputOptions;
40 class DiagnosticsEngine;
41 class DiagnosticOptions;
42 class ExternalSemaSource;
45 class HeaderSearchOptions;
46 class IdentifierTable;
48 class PCHContainerReader;
50 class PreprocessorOptions;
51 class PreprocessorOutputOptions;
55 class FrontendOptions;
59 const HeaderSearchOptions &HSOpts,
60 const LangOptions &Lang,
61 const llvm::Triple &triple);
66 const PCHContainerReader &PCHContainerRdr,
67 const FrontendOptions &FEOpts);
71 const PreprocessorOutputOptions &Opts);
88 virtual bool sawDependency(StringRef Filename,
bool FromModule,
89 bool IsSystem,
bool IsModuleFile,
bool IsMissing);
100 bool IsModuleFile,
bool IsMissing);
102 llvm::StringSet<> Seen;
103 std::vector<std::string> Dependencies;
124 llvm::StringSet<> Seen;
129 bool insertSeen(StringRef Filename) {
return Seen.insert(Filename).second; }
139 : DestDir(DestDir), HasErrors(
false) {}
160 StringRef OutputPath =
"",
161 bool ShowDepth =
true,
bool MSStyle =
false);
164 void CacheTokens(Preprocessor &PP, raw_pwrite_stream *OS);
168 IntrusiveRefCntPtr<ExternalSemaSource>
170 IntrusiveRefCntPtr<ExternalSemaSource> &Reader);
179 IntrusiveRefCntPtr<DiagnosticsEngine> Diags =
180 IntrusiveRefCntPtr<DiagnosticsEngine>());
185 llvm::opt::OptSpecifier Id,
int Default,
186 DiagnosticsEngine *Diags =
nullptr);
189 llvm::opt::OptSpecifier Id,
int Default,
195 llvm::opt::OptSpecifier Id, uint64_t Default,
196 DiagnosticsEngine *Diags =
nullptr);
199 llvm::opt::OptSpecifier Id,
void AttachHeaderIncludeGen(Preprocessor &PP, bool ShowAllHeaders=false, StringRef OutputPath="", bool ShowDepth=true, bool MSStyle=false)
llvm::ArrayRef< std::string > getDependencies() const
IntrusiveRefCntPtr< ExternalSemaSource > createChainedIncludesSource(CompilerInstance &CI, IntrusiveRefCntPtr< ExternalSemaSource > &Reader)
virtual bool needSystemDependencies()
Return true if system files should be passed to sawDependency().
void attachToASTReader(ASTReader &R)
void addFileMapping(StringRef VirtualPath, StringRef RealPath)
Concrete class used by the front-end to report problems and issues.
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)
static DependencyFileGenerator * CreateAndAttachToPreprocessor(Preprocessor &PP, const DependencyOutputOptions &Opts)
uint64_t getLastArgUInt64Value(const llvm::opt::ArgList &Args, llvm::opt::OptSpecifier Id, uint64_t Default, DiagnosticsEngine *Diags=nullptr)
void DoPrintPreprocessedInput(Preprocessor &PP, raw_ostream *OS, const PreprocessorOutputOptions &Opts)
DoPrintPreprocessedInput - Implement -E mode.
void maybeAddDependency(StringRef Filename, bool FromModule, bool IsSystem, bool IsModuleFile, bool IsMissing)
void addFileMapping(StringRef VPath, StringRef RPath)
virtual void finishedMainFile()
Called when the end of the main file is reached.
void attachToASTReader(ASTReader &R)
void ApplyHeaderSearchOptions(HeaderSearch &HS, const HeaderSearchOptions &HSOpts, const LangOptions &Lang, const llvm::Triple &triple)
Apply the header search options to get given HeaderSearch object.
void AttachToASTReader(ASTReader &R)
void AttachDependencyGraphGen(Preprocessor &PP, StringRef OutputFile, StringRef SysRoot)
Reads an AST files chain containing the contents of a translation unit.
CompilerInvocation * createInvocationFromCommandLine(ArrayRef< const char * > Args, IntrusiveRefCntPtr< DiagnosticsEngine > Diags=IntrusiveRefCntPtr< DiagnosticsEngine >())
Defines the virtual file system interface vfs::FileSystem.
virtual ~DependencyCollector()
Defines the Diagnostic-related interfaces.
~ModuleDependencyCollector()
void BuryPointer(const void *Ptr)
void attachToPreprocessor(Preprocessor &PP)
int getLastArgIntValue(const llvm::opt::ArgList &Args, llvm::opt::OptSpecifier Id, int Default, DiagnosticsEngine *Diags=nullptr)
void InitializePreprocessor(Preprocessor &PP, const PreprocessorOptions &PPOpts, const PCHContainerReader &PCHContainerRdr, const FrontendOptions &FEOpts)
virtual bool sawDependency(StringRef Filename, bool FromModule, bool IsSystem, bool IsModuleFile, bool IsMissing)
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
bool insertSeen(StringRef Filename)