9#ifndef LLVM_CLANG_SERIALIZATION_PCHCONTAINEROPERATIONS_H
10#define LLVM_CLANG_SERIALIZATION_PCHCONTAINEROPERATIONS_H
13#include "llvm/ADT/SmallVector.h"
14#include "llvm/ADT/StringMap.h"
15#include "llvm/Support/MemoryBufferRef.h"
19class raw_pwrite_stream;
25class CompilerInstance;
44 virtual std::unique_ptr<ASTConsumer>
46 const std::string &MainFileName,
47 const std::string &OutputFileName,
48 std::unique_ptr<llvm::raw_pwrite_stream> OS,
49 std::shared_ptr<PCHBuffer> Buffer)
const = 0;
62 virtual llvm::StringRef
ExtractPCH(llvm::MemoryBufferRef Buffer)
const = 0;
67 llvm::StringRef getFormat()
const override {
return "raw"; }
71 std::unique_ptr<ASTConsumer>
73 const std::string &MainFileName,
74 const std::string &OutputFileName,
75 std::unique_ptr<llvm::raw_pwrite_stream> OS,
76 std::shared_ptr<PCHBuffer> Buffer)
const override;
83 llvm::StringRef ExtractPCH(llvm::MemoryBufferRef Buffer)
const override;
88 llvm::StringMap<std::unique_ptr<PCHContainerWriter>> Writers;
89 llvm::StringMap<PCHContainerReader *> Readers;
97 Writers[Writer->getFormat()] = std::move(Writer);
100 assert(!Reader->getFormats().empty() &&
101 "PCHContainerReader must handle >=1 format");
102 for (llvm::StringRef Fmt : Reader->getFormats())
103 Readers[Fmt] = Reader.get();
104 OwnedReaders.push_back(std::move(Reader));
107 return Writers[Format].get();
110 return Readers[Format];
Defines the clang::Module class, which describes a module in the source code.
CompilerInstance - Helper class for managing a single instance of the Clang compiler.
A registry of PCHContainerWriter and -Reader objects for different formats.
void registerReader(std::unique_ptr< PCHContainerReader > Reader)
PCHContainerOperations()
Automatically registers a RawPCHContainerWriter and RawPCHContainerReader.
const PCHContainerReader * getReaderOrNull(llvm::StringRef Format)
const PCHContainerWriter * getWriterOrNull(llvm::StringRef Format)
void registerWriter(std::unique_ptr< PCHContainerWriter > Writer)
const PCHContainerReader & getRawReader()
This abstract interface provides operations for unwrapping containers for serialized ASTs (precompile...
virtual llvm::ArrayRef< llvm::StringRef > getFormats() const =0
Equivalent to the format passed to -fmodule-format=.
virtual llvm::StringRef ExtractPCH(llvm::MemoryBufferRef Buffer) const =0
Returns the serialized AST inside the PCH container Buffer.
virtual ~PCHContainerReader()=0
This abstract interface provides operations for creating containers for serialized ASTs (precompiled ...
virtual ~PCHContainerWriter()=0
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...
virtual llvm::StringRef getFormat() const =0
Implements read operations for a raw pass-through PCH container.
Implements write operations for a raw pass-through PCH container.
The JSON file list parser is used to communicate input to InstallAPI.
Diagnostic wrappers for TextAPI types for error reporting.
The signature of a module, which is a hash of the AST content.
llvm::SmallVector< char, 0 > Data
ASTFileSignature Signature