10 #ifndef LLVM_CLANG_PCH_CONTAINER_OPERATIONS_H
11 #define LLVM_CLANG_PCH_CONTAINER_OPERATIONS_H
14 #include "llvm/ADT/SmallVector.h"
15 #include "llvm/ADT/StringMap.h"
16 #include "llvm/Support/MemoryBuffer.h"
20 class raw_pwrite_stream;
23 using llvm::StringRef;
29 class DiagnosticsEngine;
30 class CompilerInstance;
49 virtual std::unique_ptr<ASTConsumer>
51 const std::string &MainFileName,
52 const std::string &OutputFileName,
53 std::unique_ptr<llvm::raw_pwrite_stream> OS,
54 std::shared_ptr<PCHBuffer>
Buffer)
const = 0;
72 StringRef getFormat()
const override {
return "raw"; }
76 std::unique_ptr<ASTConsumer>
78 const std::string &MainFileName,
79 const std::string &OutputFileName,
80 std::unique_ptr<llvm::raw_pwrite_stream> OS,
81 std::shared_ptr<PCHBuffer>
Buffer)
const override;
86 StringRef getFormat()
const override {
return "raw"; }
89 StringRef ExtractPCH(llvm::MemoryBufferRef
Buffer)
const override;
94 llvm::StringMap<std::unique_ptr<PCHContainerWriter>> Writers;
95 llvm::StringMap<std::unique_ptr<PCHContainerReader>> Readers;
101 Writers[Writer->getFormat()] = std::move(Writer);
104 Readers[Reader->getFormat()] = std::move(Reader);
107 return Writers[Format].get();
110 return Readers[Format].get();
virtual StringRef ExtractPCH(llvm::MemoryBufferRef Buffer) const =0
Returns the serialized AST inside the PCH container Buffer.
Defines the clang::Module class, which describes a module in the source code.
std::unique_ptr< llvm::MemoryBuffer > Buffer
A registry of PCHContainerWriter and -Reader objects for different formats.
The signature of a module, which is a hash of the AST content.
This abstract interface provides operations for creating containers for serialized ASTs (precompiled ...
const PCHContainerWriter * getWriterOrNull(StringRef Format)
This abstract interface provides operations for unwrapping containers for serialized ASTs (precompile...
void registerReader(std::unique_ptr< PCHContainerReader > Reader)
virtual StringRef getFormat() const =0
const PCHContainerReader & getRawReader()
ASTFileSignature Signature
CompilerInstance - Helper class for managing a single instance of the Clang compiler.
const PCHContainerReader * getReaderOrNull(StringRef Format)
virtual ~PCHContainerReader()=0
virtual StringRef getFormat() const =0
Equivalent to the format passed to -fmodule-format=.
PCHContainerOperations()
Automatically registers a RawPCHContainerWriter and RawPCHContainerReader.
virtual std::unique_ptr< ASTConsumer > CreatePCHContainerGenerator(CompilerInstance &CI, const std::string &MainFileName, const std::string &OutputFileName, std::unique_ptr< llvm::raw_pwrite_stream > OS, std::shared_ptr< PCHBuffer > Buffer) const =0
Return an ASTConsumer that can be chained with a PCHGenerator that produces a wrapper file format con...
Implements read operations for a raw pass-through PCH container.
llvm::SmallVector< char, 0 > Data
void registerWriter(std::unique_ptr< PCHContainerWriter > Writer)
virtual ~PCHContainerWriter()=0
Implements write operations for a raw pass-through PCH container.