21#include "llvm/Bitstream/BitstreamWriter.h"
27 StringRef isysroot, std::shared_ptr<PCHBuffer> Buffer,
28 ArrayRef<std::shared_ptr<ModuleFileExtension>> Extensions,
29 bool AllowASTWithErrors,
bool IncludeTimestamps,
30 bool BuildingImplicitModule,
bool ShouldCacheASTInMemory,
31 bool GeneratingReducedBMI)
32 : PP(PP), Subject(&PP), OutputFile(OutputFile), isysroot(isysroot.str()),
33 Buffer(
std::move(Buffer)), Stream(this->Buffer->
Data),
34 Writer(Stream, this->Buffer->
Data, ModuleCache, Extensions,
35 IncludeTimestamps, BuildingImplicitModule, GeneratingReducedBMI),
36 AllowASTWithErrors(AllowASTWithErrors),
37 ShouldCacheASTInMemory(ShouldCacheASTInMemory) {
38 this->Buffer->IsComplete =
false;
53 "emitting module but current module doesn't exist");
76 if (hasErrors && !AllowASTWithErrors)
83 if (AllowASTWithErrors)
86 Buffer->Signature = Writer.
WriteAST(Subject, OutputFile,
Module, isysroot,
87 ShouldCacheASTInMemory);
89 Buffer->IsComplete =
true;
100void PCHGenerator::anchor() {}
104 StringRef OutputFile,
105 bool GeneratingReducedBMI)
107 PP, ModuleCache, OutputFile,
llvm::StringRef(),
112 GeneratingReducedBMI) {}
117 "CXX20ModulesGenerator should only be used with C++20 Named modules.");
135 auto OS = std::make_unique<llvm::raw_fd_ostream>(
getOutputFile(), EC);
146void CXX20ModulesGenerator::anchor() {}
148void ReducedBMIGenerator::anchor() {}
Defines the clang::ASTContext interface.
Defines the clang::Preprocessor interface.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Module * getCurrentNamedModule() const
Get module under construction, nullptr if this is not a C++20 module.
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
ASTFileSignature WriteAST(llvm::PointerUnion< Sema *, Preprocessor * > Subject, StringRef OutputFile, Module *WritingModule, StringRef isysroot, bool ShouldCacheASTInMemory=false)
Write a precompiled header or a module with the AST produced by the Sema object, or a dependency scan...
CXX20ModulesGenerator(Preprocessor &PP, InMemoryModuleCache &ModuleCache, StringRef OutputFile, bool GeneratingReducedBMI)
void HandleTranslationUnit(ASTContext &Ctx) override
HandleTranslationUnit - This method is called when the ASTs for entire translation unit have been par...
virtual Module * getEmittingModule(ASTContext &Ctx) override
Concrete class used by the front-end to report problems and issues.
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
bool hasErrorOccurred() const
DiagnosticConsumer * getClient()
In-memory cache for modules.
bool isCompilingModule() const
Are we compiling a module?
std::string CurrentModule
The name of the current module, of which the main source file is a part.
An abstract superclass that describes a custom extension to the module/precompiled header file format...
Describes a module or submodule.
bool isNamedModuleUnit() const
Is this a C++20 named module unit.
AST and semantic-analysis consumer that generates a precompiled header from the parsed source code.
ASTMutationListener * GetASTMutationListener() override
If the consumer is interested in entities getting modified after their initial creation,...
void InitializeSema(Sema &S) override
Initialize the semantic consumer with the Sema instance being used to perform semantic analysis on th...
PCHBuffer * getBufferPtr()
Preprocessor & getPreprocessor()
virtual Module * getEmittingModule(ASTContext &Ctx)
StringRef getOutputFile() const
ASTDeserializationListener * GetASTDeserializationListener() override
If the consumer is interested in entities being deserialized from AST files, it should return a point...
void HandleTranslationUnit(ASTContext &Ctx) override
HandleTranslationUnit - This method is called when the ASTs for entire translation unit have been par...
PCHGenerator(Preprocessor &PP, InMemoryModuleCache &ModuleCache, StringRef OutputFile, StringRef isysroot, std::shared_ptr< PCHBuffer > Buffer, ArrayRef< std::shared_ptr< ModuleFileExtension > > Extensions, bool AllowASTWithErrors=false, bool IncludeTimestamps=true, bool BuildingImplicitModule=false, bool ShouldCacheASTInMemory=false, bool GeneratingReducedBMI=false)
DiagnosticsEngine & getDiagnostics() const
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
ModuleLoader & getModuleLoader() const
Retrieve the module loader associated with this preprocessor.
HeaderSearch & getHeaderSearchInfo() const
const LangOptions & getLangOpts() const
DiagnosticsEngine & getDiagnostics() const
Sema - This implements semantic analysis and AST building for C.
Encodes a location in the source.
The JSON file list parser is used to communicate input to InstallAPI.
Diagnostic wrappers for TextAPI types for error reporting.
llvm::SmallVector< char, 0 > Data