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), OutputFile(OutputFile), isysroot(isysroot.str()),
33 SemaPtr(nullptr), 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");
65 if (hasErrors && !AllowASTWithErrors)
72 if (AllowASTWithErrors)
76 assert(SemaPtr &&
"No Sema?");
77 Buffer->Signature = Writer.
WriteAST(*SemaPtr, OutputFile,
Module, isysroot,
78 ShouldCacheASTInMemory);
80 Buffer->IsComplete =
true;
91void PCHGenerator::anchor() {}
96 bool GeneratingReducedBMI)
98 PP, ModuleCache, OutputFile,
llvm::StringRef(),
103 GeneratingReducedBMI) {}
108 "CXX20ModulesGenerator should only be used with C++20 Named modules.");
126 auto OS = std::make_unique<llvm::raw_fd_ostream>(
getOutputFile(), EC);
137void CXX20ModulesGenerator::anchor() {}
139void 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(Sema &SemaRef, StringRef OutputFile, Module *WritingModule, StringRef isysroot, bool ShouldCacheASTInMemory=false)
Write a precompiled header for the given semantic analysis.
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
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,...
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
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