13 #ifndef LLVM_CLANG_FRONTEND_UTILS_H 14 #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 DiagnosticsEngine;
51 class ExternalSemaSource;
52 class FrontendOptions;
54 class HeaderSearchOptions;
56 class PCHContainerReader;
58 class PreprocessorOptions;
59 class PreprocessorOutputOptions;
63 const HeaderSearchOptions &HSOpts,
64 const LangOptions &Lang,
65 const llvm::Triple &triple);
70 const PCHContainerReader &PCHContainerRdr,
71 const FrontendOptions &FEOpts);
75 const PreprocessorOutputOptions &Opts);
86 virtual void attachToASTReader(
ASTReader &R);
93 virtual bool sawDependency(StringRef
Filename,
bool FromModule,
94 bool IsSystem,
bool IsModuleFile,
bool IsMissing);
105 void maybeAddDependency(StringRef Filename,
bool FromModule,
bool IsSystem,
106 bool IsModuleFile,
bool IsMissing);
111 bool addDependency(StringRef Filename);
114 llvm::StringSet<> Seen;
115 std::vector<std::string> Dependencies;
132 bool sawDependency(StringRef
Filename,
bool FromModule,
bool IsSystem,
133 bool IsModuleFile,
bool IsMissing)
final override;
136 void outputDependencyFile(llvm::raw_ostream &OS);
141 std::string OutputFile;
142 std::vector<std::string> Targets;
143 bool IncludeSystemHeaders;
145 bool AddMissingHeaderDeps;
146 bool SeenMissingHeader;
147 bool IncludeModuleFiles;
149 unsigned InputFileIndex;
156 bool HasErrors =
false;
157 llvm::StringSet<> Seen;
158 llvm::vfs::YAMLVFSWriter VFSWriter;
159 llvm::StringMap<std::string> SymLinkMap;
162 std::error_code copyToRoot(StringRef Src, StringRef Dst = {});
166 : DestDir(
std::move(DestDir)) {}
171 virtual void addFile(StringRef
Filename, StringRef FileDst = {});
174 VFSWriter.addFileMapping(VPath, RPath);
178 void attachToASTReader(
ASTReader &R)
override;
180 virtual void writeFileMap();
203 bool ShowAllHeaders =
false,
204 StringRef OutputPath = {},
205 bool ShowDepth =
true,
bool MSStyle =
false);
231 llvm::opt::OptSpecifier Id,
int Default,
237 llvm::opt::OptSpecifier Id, uint64_t Default,
241 llvm::opt::OptSpecifier Id,
255 #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...
Specialize PointerLikeTypeTraits to allow LazyGenerationalUpdatePtr to be placed into a PointerUnion...
An interface for collecting the dependencies of a compilation.
virtual bool insertSeen(StringRef Filename)
virtual bool needSystemDependencies()
Return true if system files should be passed to sawDependency().
virtual void addFileMapping(StringRef VPath, StringRef RPath)
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 dependency 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 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.
virtual void finishedMainFile(DiagnosticsEngine &Diags)
Called when the end of the main file is reached.
bool needSystemDependencies() final override
Return true if system files should be passed to sawDependency().
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 ...
DependencyOutputFormat
DependencyOutputFormat - Format for the compiler dependency file.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.