21#include "llvm/Bitstream/BitstreamWriter.h"
27 StringRef isysroot, std::shared_ptr<PCHBuffer> Buffer,
29 ArrayRef<std::shared_ptr<ModuleFileExtension>> Extensions,
30 bool AllowASTWithErrors,
bool IncludeTimestamps,
31 bool BuildingImplicitModule,
bool ShouldCacheASTInMemory,
32 bool GeneratingReducedBMI)
33 : PP(PP), Subject(&PP), OutputFile(OutputFile), isysroot(isysroot.str()),
34 Buffer(
std::move(Buffer)), Stream(this->Buffer->
Data),
35 Writer(Stream, this->Buffer->
Data, ModCache, CodeGenOpts, Extensions,
36 IncludeTimestamps, BuildingImplicitModule, GeneratingReducedBMI),
37 AllowASTWithErrors(AllowASTWithErrors),
38 ShouldCacheASTInMemory(ShouldCacheASTInMemory) {
39 this->Buffer->IsComplete =
false;
54 "emitting module but current module doesn't exist");
77 if (hasErrors && !AllowASTWithErrors)
84 if (AllowASTWithErrors)
87 Buffer->Signature = Writer.
WriteAST(Subject, OutputFile,
Module, isysroot,
88 ShouldCacheASTInMemory);
90 Buffer->IsComplete =
true;
101void PCHGenerator::anchor() {}
105 StringRef OutputFile,
107 bool GeneratingReducedBMI,
108 bool AllowASTWithErrors)
110 PP, ModCache, OutputFile,
llvm::StringRef(),
113 AllowASTWithErrors,
false,
115 GeneratingReducedBMI) {}
120 "CXX20ModulesGenerator should only be used with C++20 Named modules.");
131 auto OS = std::make_unique<llvm::raw_fd_ostream>(
getOutputFile(), EC);
142void CXX20ModulesGenerator::anchor() {}
144void 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, ModuleCache &ModCache, StringRef OutputFile, const CodeGenOptions &CodeGenOpts, bool GeneratingReducedBMI, bool AllowASTWithErrors)
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
CodeGenOptions - Track various options which control how the code is optimized and passed to the back...
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()
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.
The module cache used for compiling modules implicitly.
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()
virtual Module * getEmittingModule(ASTContext &Ctx)
StringRef getOutputFile() const
PCHGenerator(Preprocessor &PP, ModuleCache &ModCache, StringRef OutputFile, StringRef isysroot, std::shared_ptr< PCHBuffer > Buffer, const CodeGenOptions &CodeGenOpts, ArrayRef< std::shared_ptr< ModuleFileExtension > > Extensions, bool AllowASTWithErrors=false, bool IncludeTimestamps=true, bool BuildingImplicitModule=false, bool ShouldCacheASTInMemory=false, bool GeneratingReducedBMI=false)
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...
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