r255065 - Module file extensions: pass a Sema through to the extension writer.

Douglas Gregor via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 8 14:43:32 PST 2015


Author: dgregor
Date: Tue Dec  8 16:43:32 2015
New Revision: 255065

URL: http://llvm.org/viewvc/llvm-project?rev=255065&view=rev
Log:
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.

Modified:
    cfe/trunk/include/clang/Serialization/ASTWriter.h
    cfe/trunk/include/clang/Serialization/ModuleFileExtension.h
    cfe/trunk/lib/Frontend/TestModuleFileExtension.cpp
    cfe/trunk/lib/Frontend/TestModuleFileExtension.h
    cfe/trunk/lib/Serialization/ASTWriter.cpp

Modified: cfe/trunk/include/clang/Serialization/ASTWriter.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTWriter.h?rev=255065&r1=255064&r2=255065&view=diff
==============================================================================
--- cfe/trunk/include/clang/Serialization/ASTWriter.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTWriter.h Tue Dec  8 16:43:32 2015
@@ -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;

Modified: cfe/trunk/include/clang/Serialization/ModuleFileExtension.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ModuleFileExtension.h?rev=255065&r1=255064&r2=255065&view=diff
==============================================================================
--- cfe/trunk/include/clang/Serialization/ModuleFileExtension.h (original)
+++ cfe/trunk/include/clang/Serialization/ModuleFileExtension.h Tue Dec  8 16:43:32 2015
@@ -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

Modified: cfe/trunk/lib/Frontend/TestModuleFileExtension.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/TestModuleFileExtension.cpp?rev=255065&r1=255064&r2=255065&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/TestModuleFileExtension.cpp (original)
+++ cfe/trunk/lib/Frontend/TestModuleFileExtension.cpp Tue Dec  8 16:43:32 2015
@@ -19,6 +19,7 @@ using namespace clang::serialization;
 TestModuleFileExtension::Writer::~Writer() { }
 
 void TestModuleFileExtension::Writer::writeExtensionContents(
+       Sema &SemaRef,
        llvm::BitstreamWriter &Stream) {
   using namespace llvm;
 

Modified: cfe/trunk/lib/Frontend/TestModuleFileExtension.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/TestModuleFileExtension.h?rev=255065&r1=255064&r2=255065&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/TestModuleFileExtension.h (original)
+++ cfe/trunk/lib/Frontend/TestModuleFileExtension.h Tue Dec  8 16:43:32 2015
@@ -30,7 +30,8 @@ class TestModuleFileExtension : public M
     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 {

Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=255065&r1=255064&r2=255065&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Tue Dec  8 16:43:32 2015
@@ -3880,7 +3880,8 @@ void ASTWriter::WriteOptimizePragmaOptio
   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
   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 &S
 
   // Write the module file extension blocks.
   for (const auto &ExtWriter : ModuleFileExtensionWriters)
-    WriteModuleFileExtension(*ExtWriter);
+    WriteModuleFileExtension(SemaRef, *ExtWriter);
 
   return Signature;
 }




More information about the cfe-commits mailing list