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/Option/OptSpecifier.h" 26 #include "llvm/Support/VirtualFileSystem.h" 30 #include <system_error> 43 class CompilerInstance;
44 class CompilerInvocation;
45 class DiagnosticsEngine;
46 class ExternalSemaSource;
47 class FrontendOptions;
49 class HeaderSearchOptions;
51 class PCHContainerReader;
53 class PreprocessorOptions;
54 class PreprocessorOutputOptions;
58 const HeaderSearchOptions &HSOpts,
59 const LangOptions &Lang,
60 const llvm::Triple &triple);
65 const PCHContainerReader &PCHContainerRdr,
66 const FrontendOptions &FEOpts);
70 const PreprocessorOutputOptions &Opts);
81 virtual void attachToASTReader(
ASTReader &R);
88 virtual bool sawDependency(StringRef
Filename,
bool FromModule,
89 bool IsSystem,
bool IsModuleFile,
bool IsMissing);
99 virtual void maybeAddDependency(StringRef Filename,
bool FromModule,
100 bool IsSystem,
bool IsModuleFile,
106 bool addDependency(StringRef Filename);
109 llvm::StringSet<> Seen;
110 std::vector<std::string> Dependencies;
127 bool sawDependency(StringRef
Filename,
bool FromModule,
bool IsSystem,
128 bool IsModuleFile,
bool IsMissing)
final override;
131 void outputDependencyFile(llvm::raw_ostream &OS);
136 std::string OutputFile;
137 std::vector<std::string> Targets;
138 bool IncludeSystemHeaders;
140 bool AddMissingHeaderDeps;
141 bool SeenMissingHeader;
142 bool IncludeModuleFiles;
144 unsigned InputFileIndex;
151 bool HasErrors =
false;
152 llvm::StringSet<> Seen;
153 llvm::vfs::YAMLVFSWriter VFSWriter;
154 llvm::StringMap<std::string> SymLinkMap;
157 std::error_code copyToRoot(StringRef Src, StringRef Dst = {});
161 : DestDir(
std::move(DestDir)) {}
166 virtual void addFile(StringRef
Filename, StringRef FileDst = {});
169 VFSWriter.addFileMapping(VPath, RPath);
173 void attachToASTReader(
ASTReader &R)
override;
175 virtual void writeFileMap();
198 bool ShowAllHeaders =
false,
199 StringRef OutputPath = {},
200 bool ShowDepth =
true,
bool MSStyle =
false);
225 bool ShouldRecoverOnErrors =
false,
226 std::vector<std::string> *CC1Args =
nullptr);
236 #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)
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...
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
std::unique_ptr< CompilerInvocation > createInvocationFromCommandLine(ArrayRef< const char *> Args, IntrusiveRefCntPtr< DiagnosticsEngine > Diags=IntrusiveRefCntPtr< DiagnosticsEngine >(), IntrusiveRefCntPtr< llvm::vfs::FileSystem > VFS=nullptr, bool ShouldRecoverOnErrors=false, std::vector< std::string > *CC1Args=nullptr)
createInvocationFromCommandLine - Construct a compiler invocation object for a command line argument ...
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.