@@ -119,9 +119,6 @@ class ASTWriter : public ASTDeserializationListener,
119119 // / The PCM manager which manages memory buffers for pcm files.
120120 InMemoryModuleCache &ModuleCache;
121121
122- // / The ASTContext we're writing.
123- ASTContext *Context = nullptr ;
124-
125122 // / The preprocessor we're writing.
126123 Preprocessor *PP = nullptr ;
127124
@@ -545,7 +542,7 @@ class ASTWriter : public ASTDeserializationListener,
545542 unsigned getSubmoduleID (Module *Mod);
546543
547544 // / Write the given subexpression to the bitstream.
548- void WriteSubStmt (Stmt *S);
545+ void WriteSubStmt (ASTContext &Context, Stmt *S);
549546
550547 void WriteBlockInfoBlock ();
551548 void WriteControlBlock (Preprocessor &PP, StringRef isysroot);
@@ -564,34 +561,36 @@ class ASTWriter : public ASTDeserializationListener,
564561 void WriteHeaderSearch (const HeaderSearch &HS);
565562 void WritePreprocessorDetail (PreprocessingRecord &PPRec,
566563 uint64_t MacroOffsetsBase);
567- void WriteSubmodules (Module *WritingModule);
564+ void WriteSubmodules (Module *WritingModule, ASTContext &Context );
568565
569566 void WritePragmaDiagnosticMappings (const DiagnosticsEngine &Diag,
570567 bool isModule);
571568
572569 unsigned TypeExtQualAbbrev = 0 ;
573570 void WriteTypeAbbrevs ();
574- void WriteType (QualType T);
571+ void WriteType (ASTContext &Context, QualType T);
575572
576573 bool isLookupResultExternal (StoredDeclsList &Result, DeclContext *DC);
577574
578- void GenerateNameLookupTable (const DeclContext *DC,
575+ void GenerateNameLookupTable (ASTContext &Context, const DeclContext *DC,
579576 llvm::SmallVectorImpl<char > &LookupTable);
580577 uint64_t WriteDeclContextLexicalBlock (ASTContext &Context,
581578 const DeclContext *DC);
582579 uint64_t WriteDeclContextVisibleBlock (ASTContext &Context, DeclContext *DC);
583580 void WriteTypeDeclOffsets ();
584581 void WriteFileDeclIDsMap ();
585- void WriteComments ();
582+ void WriteComments (ASTContext &Context );
586583 void WriteSelectors (Sema &SemaRef);
587584 void WriteReferencedSelectorsPool (Sema &SemaRef);
588585 void WriteIdentifierTable (Preprocessor &PP, IdentifierResolver &IdResolver,
589586 bool IsModule);
590587 void WriteDeclAndTypes (ASTContext &Context);
591588 void PrepareWritingSpecialDecls (Sema &SemaRef);
592589 void WriteSpecialDeclRecords (Sema &SemaRef);
593- void WriteDeclUpdatesBlocks (RecordDataImpl &OffsetsRecord);
594- void WriteDeclContextVisibleUpdate (const DeclContext *DC);
590+ void WriteDeclUpdatesBlocks (ASTContext &Context,
591+ RecordDataImpl &OffsetsRecord);
592+ void WriteDeclContextVisibleUpdate (ASTContext &Context,
593+ const DeclContext *DC);
595594 void WriteFPPragmaOptions (const FPOptionsOverride &Opts);
596595 void WriteOpenCLExtensions (Sema &SemaRef);
597596 void WriteCUDAPragmas (Sema &SemaRef);
@@ -653,11 +652,6 @@ class ASTWriter : public ASTDeserializationListener,
653652 bool GeneratingReducedBMI = false );
654653 ~ASTWriter () override ;
655654
656- ASTContext &getASTContext () const {
657- assert (Context && " requested AST context when not writing AST" );
658- return *Context;
659- }
660-
661655 const LangOptions &getLangOpts () const ;
662656
663657 // / Get a timestamp for output into the AST file. The actual timestamp
@@ -723,10 +717,10 @@ class ASTWriter : public ASTDeserializationListener,
723717 uint32_t getMacroDirectivesOffset (const IdentifierInfo *Name);
724718
725719 // / Emit a reference to a type.
726- void AddTypeRef (QualType T, RecordDataImpl &Record);
720+ void AddTypeRef (ASTContext &Context, QualType T, RecordDataImpl &Record);
727721
728722 // / Force a type to be emitted and get its ID.
729- serialization::TypeID GetOrCreateTypeID (QualType T);
723+ serialization::TypeID GetOrCreateTypeID (ASTContext &Context, QualType T);
730724
731725 // / Find the first local declaration of a given local redeclarable
732726 // / decl.
0 commit comments