mirror of https://github.com/microsoft/clang.git
Module file extensions: pass a Sema through to the extension writer.
Module file extensions are likely to need access to Sema/Preprocessor/ASTContext, and cannot get it through other sources. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@255065 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
543c2ee4e1
commit
320aee24e0
|
@ -551,7 +551,8 @@ private:
|
|||
void WriteObjCCategories();
|
||||
void WriteLateParsedTemplates(Sema &SemaRef);
|
||||
void WriteOptimizePragmaOptions(Sema &SemaRef);
|
||||
void WriteModuleFileExtension(ModuleFileExtensionWriter &Writer);
|
||||
void WriteModuleFileExtension(Sema &SemaRef,
|
||||
ModuleFileExtensionWriter &Writer);
|
||||
|
||||
unsigned DeclParmVarAbbrev;
|
||||
unsigned DeclContextLexicalAbbrev;
|
||||
|
|
|
@ -25,7 +25,8 @@ namespace clang {
|
|||
|
||||
class ASTReader;
|
||||
class ASTWriter;
|
||||
|
||||
class Sema;
|
||||
|
||||
namespace serialization {
|
||||
class ModuleFile;
|
||||
} // end namespace serialization
|
||||
|
@ -79,7 +80,7 @@ public:
|
|||
/// The default implementation of this function simply returns the
|
||||
/// hash code as given, so the presence/absence of this extension
|
||||
/// does not distinguish module files.
|
||||
virtual llvm::hash_code hashExtension(llvm::hash_code Code) const;
|
||||
virtual llvm::hash_code hashExtension(llvm::hash_code c) const;
|
||||
|
||||
/// Create a new module file extension writer, which will be
|
||||
/// responsible for writing the extension contents into a particular
|
||||
|
@ -120,7 +121,8 @@ public:
|
|||
/// Responsible for writing the contents of the extension into the
|
||||
/// given stream. All of the contents should be written into custom
|
||||
/// records with IDs >= FIRST_EXTENSION_RECORD_ID.
|
||||
virtual void writeExtensionContents(llvm::BitstreamWriter &Stream) = 0;
|
||||
virtual void writeExtensionContents(Sema &SemaRef,
|
||||
llvm::BitstreamWriter &Stream) = 0;
|
||||
};
|
||||
|
||||
/// Abstract base class that reads a module file extension block from
|
||||
|
|
|
@ -19,6 +19,7 @@ using namespace clang::serialization;
|
|||
TestModuleFileExtension::Writer::~Writer() { }
|
||||
|
||||
void TestModuleFileExtension::Writer::writeExtensionContents(
|
||||
Sema &SemaRef,
|
||||
llvm::BitstreamWriter &Stream) {
|
||||
using namespace llvm;
|
||||
|
||||
|
|
|
@ -30,7 +30,8 @@ class TestModuleFileExtension : public ModuleFileExtension {
|
|||
Writer(ModuleFileExtension *Ext) : ModuleFileExtensionWriter(Ext) { }
|
||||
~Writer() override;
|
||||
|
||||
void writeExtensionContents(llvm::BitstreamWriter &Stream) override;
|
||||
void writeExtensionContents(Sema &SemaRef,
|
||||
llvm::BitstreamWriter &Stream) override;
|
||||
};
|
||||
|
||||
class Reader : public ModuleFileExtensionReader {
|
||||
|
|
|
@ -3880,7 +3880,8 @@ void ASTWriter::WriteOptimizePragmaOptions(Sema &SemaRef) {
|
|||
Stream.EmitRecord(OPTIMIZE_PRAGMA_OPTIONS, Record);
|
||||
}
|
||||
|
||||
void ASTWriter::WriteModuleFileExtension(ModuleFileExtensionWriter &Writer) {
|
||||
void ASTWriter::WriteModuleFileExtension(Sema &SemaRef,
|
||||
ModuleFileExtensionWriter &Writer) {
|
||||
// Enter the extension block.
|
||||
Stream.EnterSubblock(EXTENSION_BLOCK_ID, 4);
|
||||
|
||||
|
@ -3908,7 +3909,7 @@ void ASTWriter::WriteModuleFileExtension(ModuleFileExtensionWriter &Writer) {
|
|||
Stream.EmitRecordWithBlob(Abbrev, Record, Buffer);
|
||||
|
||||
// Emit the contents of the extension block.
|
||||
Writer.writeExtensionContents(Stream);
|
||||
Writer.writeExtensionContents(SemaRef, Stream);
|
||||
|
||||
// Exit the extension block.
|
||||
Stream.ExitBlock();
|
||||
|
@ -4563,7 +4564,7 @@ uint64_t ASTWriter::WriteASTCore(Sema &SemaRef, StringRef isysroot,
|
|||
|
||||
// Write the module file extension blocks.
|
||||
for (const auto &ExtWriter : ModuleFileExtensionWriters)
|
||||
WriteModuleFileExtension(*ExtWriter);
|
||||
WriteModuleFileExtension(SemaRef, *ExtWriter);
|
||||
|
||||
return Signature;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue