1 //===--- ASTWriter.h - AST File Writer --------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the ASTWriter class, which writes an AST file
11 // containing a serialized representation of a translation unit.
13 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_CLANG_FRONTEND_AST_WRITER_H
15 #define LLVM_CLANG_FRONTEND_AST_WRITER_H
17 #include "clang/AST/Decl.h"
18 #include "clang/AST/DeclarationName.h"
19 #include "clang/AST/TemplateBase.h"
20 #include "clang/AST/ASTMutationListener.h"
21 #include "clang/Serialization/ASTBitCodes.h"
22 #include "clang/Serialization/ASTDeserializationListener.h"
23 #include "clang/Sema/SemaConsumer.h"
24 #include "llvm/ADT/SmallPtrSet.h"
25 #include "llvm/ADT/SmallVector.h"
26 #include "llvm/ADT/DenseMap.h"
27 #include "llvm/Bitcode/BitstreamWriter.h"
35 class BitstreamWriter;
41 class ASTSerializationListener;
42 class NestedNameSpecifier;
43 class CXXBaseSpecifier;
44 class CXXCtorInitializer;
47 class MacroDefinition;
48 class MemorizeStatCalls;
49 class OpaqueValueExpr;
52 class PreprocessedEntity;
53 class PreprocessingRecord;
61 /// \brief Writes an AST file containing the contents of a translation unit.
63 /// The ASTWriter class produces a bitstream containing the serialized
64 /// representation of a given abstract syntax tree and its supporting
65 /// data structures. This bitstream can be de-serialized via an
66 /// instance of the ASTReader class.
67 class ASTWriter : public ASTDeserializationListener,
68 public ASTMutationListener {
70 typedef llvm::SmallVector<uint64_t, 64> RecordData;
71 typedef llvm::SmallVectorImpl<uint64_t> RecordDataImpl;
73 friend class ASTDeclWriter;
75 /// \brief The bitstream writer used to emit this precompiled header.
76 llvm::BitstreamWriter &Stream;
78 /// \brief The reader of existing AST files, if we're chaining.
81 /// \brief A listener object that receives notifications when certain
82 /// entities are serialized.
83 ASTSerializationListener *SerializationListener;
85 /// \brief Stores a declaration or a type to be written to the AST file.
88 DeclOrType(Decl *D) : Stored(D), IsType(false) { }
89 DeclOrType(QualType T) : Stored(T.getAsOpaquePtr()), IsType(true) { }
91 bool isType() const { return IsType; }
92 bool isDecl() const { return !IsType; }
94 QualType getType() const {
95 assert(isType() && "Not a type!");
96 return QualType::getFromOpaquePtr(Stored);
99 Decl *getDecl() const {
100 assert(isDecl() && "Not a decl!");
101 return static_cast<Decl *>(Stored);
109 /// \brief The declarations and types to emit.
110 std::queue<DeclOrType> DeclTypesToEmit;
112 /// \brief The first ID number we can use for our own declarations.
113 serialization::DeclID FirstDeclID;
115 /// \brief The decl ID that will be assigned to the next new decl.
116 serialization::DeclID NextDeclID;
118 /// \brief Map that provides the ID numbers of each declaration within
119 /// the output stream, as well as those deserialized from a chained PCH.
121 /// The ID numbers of declarations are consecutive (in order of
122 /// discovery) and start at 2. 1 is reserved for the translation
123 /// unit, while 0 is reserved for NULL.
124 llvm::DenseMap<const Decl *, serialization::DeclID> DeclIDs;
126 /// \brief Offset of each declaration in the bitstream, indexed by
127 /// the declaration's ID.
128 std::vector<uint32_t> DeclOffsets;
130 /// \brief The first ID number we can use for our own types.
131 serialization::TypeID FirstTypeID;
133 /// \brief The type ID that will be assigned to the next new type.
134 serialization::TypeID NextTypeID;
136 /// \brief Map that provides the ID numbers of each type within the
137 /// output stream, plus those deserialized from a chained PCH.
139 /// The ID numbers of types are consecutive (in order of discovery)
140 /// and start at 1. 0 is reserved for NULL. When types are actually
141 /// stored in the stream, the ID number is shifted by 2 bits to
142 /// allow for the const/volatile qualifiers.
144 /// Keys in the map never have const/volatile qualifiers.
145 serialization::TypeIdxMap TypeIdxs;
147 /// \brief Offset of each type in the bitstream, indexed by
149 std::vector<uint32_t> TypeOffsets;
151 /// \brief The first ID number we can use for our own identifiers.
152 serialization::IdentID FirstIdentID;
154 /// \brief The identifier ID that will be assigned to the next new identifier.
155 serialization::IdentID NextIdentID;
157 /// \brief Map that provides the ID numbers of each identifier in
158 /// the output stream.
160 /// The ID numbers for identifiers are consecutive (in order of
161 /// discovery), starting at 1. An ID of zero refers to a NULL
163 llvm::DenseMap<const IdentifierInfo *, serialization::IdentID> IdentifierIDs;
165 /// \brief Offsets of each of the identifier IDs into the identifier
167 std::vector<uint32_t> IdentifierOffsets;
169 /// \brief The first ID number we can use for our own selectors.
170 serialization::SelectorID FirstSelectorID;
172 /// \brief The selector ID that will be assigned to the next new identifier.
173 serialization::SelectorID NextSelectorID;
175 /// \brief Map that provides the ID numbers of each Selector.
176 llvm::DenseMap<Selector, serialization::SelectorID> SelectorIDs;
178 /// \brief Offset of each selector within the method pool/selector
179 /// table, indexed by the Selector ID (-1).
180 std::vector<uint32_t> SelectorOffsets;
182 /// \brief Offsets of each of the macro identifiers into the
185 /// For each identifier that is associated with a macro, this map
186 /// provides the offset into the bitstream where that macro is
188 llvm::DenseMap<const IdentifierInfo *, uint64_t> MacroOffsets;
190 /// \brief The set of identifiers that had macro definitions at some point.
191 std::vector<const IdentifierInfo *> DeserializedMacroNames;
193 /// \brief The first ID number we can use for our own macro definitions.
194 serialization::MacroID FirstMacroID;
196 /// \brief The decl ID that will be assigned to the next new macro definition.
197 serialization::MacroID NextMacroID;
199 /// \brief Mapping from macro definitions (as they occur in the preprocessing
200 /// record) to the macro IDs.
201 llvm::DenseMap<const MacroDefinition *, serialization::MacroID>
204 /// \brief Mapping from the macro definition indices in \c MacroDefinitions
205 /// to the corresponding offsets within the preprocessor block.
206 std::vector<uint32_t> MacroDefinitionOffsets;
208 typedef llvm::SmallVector<uint64_t, 2> UpdateRecord;
209 typedef llvm::DenseMap<const Decl *, UpdateRecord> DeclUpdateMap;
210 /// \brief Mapping from declarations that came from a chained PCH to the
211 /// record containing modifications to them.
212 DeclUpdateMap DeclUpdates;
214 typedef llvm::DenseMap<Decl *, Decl *> FirstLatestDeclMap;
215 /// \brief Map of first declarations from a chained PCH that point to the
216 /// most recent declarations in another PCH.
217 FirstLatestDeclMap FirstLatestDecls;
219 /// \brief Declarations encountered that might be external
222 /// We keep track of external definitions (as well as tentative
223 /// definitions) as we are emitting declarations to the AST
224 /// file. The AST file contains a separate record for these external
225 /// definitions, which are provided to the AST consumer by the AST
226 /// reader. This is behavior is required to properly cope with,
227 /// e.g., tentative variable definitions that occur within
228 /// headers. The declarations themselves are stored as declaration
229 /// IDs, since they will be written out to an EXTERNAL_DEFINITIONS
231 llvm::SmallVector<uint64_t, 16> ExternalDefinitions;
233 /// \brief DeclContexts that have received extensions since their serialized
236 /// For namespaces, when we're chaining and encountering a namespace, we check if
237 /// its primary namespace comes from the chain. If it does, we add the primary
238 /// to this set, so that we can write out lexical content updates for it.
239 llvm::SmallPtrSet<const DeclContext *, 16> UpdatedDeclContexts;
241 typedef llvm::SmallPtrSet<const Decl *, 16> DeclsToRewriteTy;
242 /// \brief Decls that will be replaced in the current dependent AST file.
243 DeclsToRewriteTy DeclsToRewrite;
245 /// \brief Decls that have been replaced in the current dependent AST file.
247 /// When a decl changes fundamentally after being deserialized (this shouldn't
248 /// happen, but the ObjC AST nodes are designed this way), it will be
249 /// serialized again. In this case, it is registered here, so that the reader
250 /// knows to read the updated version.
251 llvm::SmallVector<std::pair<serialization::DeclID, uint64_t>, 16>
254 /// \brief Statements that we've encountered while serializing a
255 /// declaration or type.
256 llvm::SmallVector<Stmt *, 16> StmtsToEmit;
258 /// \brief Statements collection to use for ASTWriter::AddStmt().
259 /// It will point to StmtsToEmit unless it is overriden.
260 llvm::SmallVector<Stmt *, 16> *CollectedStmts;
262 /// \brief Mapping from SwitchCase statements to IDs.
263 std::map<SwitchCase *, unsigned> SwitchCaseIDs;
265 /// \brief Mapping from OpaqueValueExpr expressions to IDs.
266 llvm::DenseMap<OpaqueValueExpr *, unsigned> OpaqueValues;
268 /// \brief The number of statements written to the AST file.
269 unsigned NumStatements;
271 /// \brief The number of macros written to the AST file.
274 /// \brief The number of lexical declcontexts written to the AST
276 unsigned NumLexicalDeclContexts;
278 /// \brief The number of visible declcontexts written to the AST
280 unsigned NumVisibleDeclContexts;
282 /// \brief The offset of each CXXBaseSpecifier set within the AST.
283 llvm::SmallVector<uint32_t, 4> CXXBaseSpecifiersOffsets;
285 /// \brief The first ID number we can use for our own base specifiers.
286 serialization::CXXBaseSpecifiersID FirstCXXBaseSpecifiersID;
288 /// \brief The base specifiers ID that will be assigned to the next new
289 /// set of C++ base specifiers.
290 serialization::CXXBaseSpecifiersID NextCXXBaseSpecifiersID;
292 /// \brief A set of C++ base specifiers that is queued to be written into the
294 struct QueuedCXXBaseSpecifiers {
295 QueuedCXXBaseSpecifiers() : ID(), Bases(), BasesEnd() { }
297 QueuedCXXBaseSpecifiers(serialization::CXXBaseSpecifiersID ID,
298 CXXBaseSpecifier const *Bases,
299 CXXBaseSpecifier const *BasesEnd)
300 : ID(ID), Bases(Bases), BasesEnd(BasesEnd) { }
302 serialization::CXXBaseSpecifiersID ID;
303 CXXBaseSpecifier const * Bases;
304 CXXBaseSpecifier const * BasesEnd;
307 /// \brief Queue of C++ base specifiers to be written to the AST file,
308 /// in the order they should be written.
309 llvm::SmallVector<QueuedCXXBaseSpecifiers, 2> CXXBaseSpecifiersToWrite;
311 /// \brief Write the given subexpression to the bitstream.
312 void WriteSubStmt(Stmt *S);
314 void WriteBlockInfoBlock();
315 void WriteMetadata(ASTContext &Context, const char *isysroot,
316 const std::string &OutputFile);
317 void WriteLanguageOptions(const LangOptions &LangOpts);
318 void WriteStatCache(MemorizeStatCalls &StatCalls);
319 void WriteSourceManagerBlock(SourceManager &SourceMgr,
320 const Preprocessor &PP,
321 const char* isysroot);
322 void WritePreprocessor(const Preprocessor &PP);
323 void WriteHeaderSearch(HeaderSearch &HS, const char* isysroot);
324 void WritePreprocessorDetail(PreprocessingRecord &PPRec);
325 void WritePragmaDiagnosticMappings(const Diagnostic &Diag);
326 void WriteCXXBaseSpecifiersOffsets();
327 void WriteType(QualType T);
328 uint64_t WriteDeclContextLexicalBlock(ASTContext &Context, DeclContext *DC);
329 uint64_t WriteDeclContextVisibleBlock(ASTContext &Context, DeclContext *DC);
330 void WriteTypeDeclOffsets();
331 void WriteSelectors(Sema &SemaRef);
332 void WriteReferencedSelectorsPool(Sema &SemaRef);
333 void WriteIdentifierTable(Preprocessor &PP);
334 void WriteAttributes(const AttrVec &Attrs, RecordDataImpl &Record);
335 void WriteDeclUpdatesBlocks();
336 void WriteDeclReplacementsBlock();
337 void WriteDeclContextVisibleUpdate(const DeclContext *DC);
338 void WriteFPPragmaOptions(const FPOptions &Opts);
339 void WriteOpenCLExtensions(Sema &SemaRef);
341 unsigned DeclParmVarAbbrev;
342 unsigned DeclContextLexicalAbbrev;
343 unsigned DeclContextVisibleLookupAbbrev;
344 unsigned UpdateVisibleAbbrev;
345 unsigned DeclRefExprAbbrev;
346 unsigned CharacterLiteralAbbrev;
347 unsigned DeclRecordAbbrev;
348 unsigned IntegerLiteralAbbrev;
349 unsigned DeclTypedefAbbrev;
350 unsigned DeclVarAbbrev;
351 unsigned DeclFieldAbbrev;
352 unsigned DeclEnumAbbrev;
353 unsigned DeclObjCIvarAbbrev;
355 void WriteDeclsBlockAbbrevs();
356 void WriteDecl(ASTContext &Context, Decl *D);
358 void WriteASTCore(Sema &SemaRef, MemorizeStatCalls *StatCalls,
359 const char* isysroot, const std::string &OutputFile);
360 void WriteASTChain(Sema &SemaRef, MemorizeStatCalls *StatCalls,
361 const char* isysroot);
364 /// \brief Create a new precompiled header writer that outputs to
365 /// the given bitstream.
366 ASTWriter(llvm::BitstreamWriter &Stream);
368 /// \brief Set the listener that will receive notification of serialization
370 void SetSerializationListener(ASTSerializationListener *Listener) {
371 SerializationListener = Listener;
374 /// \brief Write a precompiled header for the given semantic analysis.
376 /// \param SemaRef a reference to the semantic analysis object that processed
377 /// the AST to be written into the precompiled header.
379 /// \param StatCalls the object that cached all of the stat() calls made while
380 /// searching for source files and headers.
382 /// \param isysroot if non-NULL, write a relocatable PCH file whose headers
383 /// are relative to the given system root.
385 /// \param PPRec Record of the preprocessing actions that occurred while
386 /// preprocessing this file, e.g., macro expansions
387 void WriteAST(Sema &SemaRef, MemorizeStatCalls *StatCalls,
388 const std::string &OutputFile,
389 const char* isysroot);
391 /// \brief Emit a source location.
392 void AddSourceLocation(SourceLocation Loc, RecordDataImpl &Record);
394 /// \brief Emit a source range.
395 void AddSourceRange(SourceRange Range, RecordDataImpl &Record);
397 /// \brief Emit an integral value.
398 void AddAPInt(const llvm::APInt &Value, RecordDataImpl &Record);
400 /// \brief Emit a signed integral value.
401 void AddAPSInt(const llvm::APSInt &Value, RecordDataImpl &Record);
403 /// \brief Emit a floating-point value.
404 void AddAPFloat(const llvm::APFloat &Value, RecordDataImpl &Record);
406 /// \brief Emit a reference to an identifier.
407 void AddIdentifierRef(const IdentifierInfo *II, RecordDataImpl &Record);
409 /// \brief Emit a Selector (which is a smart pointer reference).
410 void AddSelectorRef(Selector, RecordDataImpl &Record);
412 /// \brief Emit a CXXTemporary.
413 void AddCXXTemporary(const CXXTemporary *Temp, RecordDataImpl &Record);
415 /// \brief Emit a set of C++ base specifiers to the record.
416 void AddCXXBaseSpecifiersRef(CXXBaseSpecifier const *Bases,
417 CXXBaseSpecifier const *BasesEnd,
418 RecordDataImpl &Record);
420 /// \brief Get the unique number used to refer to the given selector.
421 serialization::SelectorID getSelectorRef(Selector Sel);
423 /// \brief Get the unique number used to refer to the given identifier.
424 serialization::IdentID getIdentifierRef(const IdentifierInfo *II);
426 /// \brief Retrieve the offset of the macro definition for the given
429 /// The identifier must refer to a macro.
430 uint64_t getMacroOffset(const IdentifierInfo *II) {
431 assert(MacroOffsets.find(II) != MacroOffsets.end() &&
432 "Identifier does not name a macro");
433 return MacroOffsets[II];
436 /// \brief Retrieve the ID number corresponding to the given macro
438 serialization::MacroID getMacroDefinitionID(MacroDefinition *MD);
440 /// \brief Emit a reference to a type.
441 void AddTypeRef(QualType T, RecordDataImpl &Record);
443 /// \brief Force a type to be emitted and get its ID.
444 serialization::TypeID GetOrCreateTypeID(QualType T);
446 /// \brief Determine the type ID of an already-emitted type.
447 serialization::TypeID getTypeID(QualType T) const;
449 /// \brief Force a type to be emitted and get its index.
450 serialization::TypeIdx GetOrCreateTypeIdx(QualType T);
452 /// \brief Determine the type index of an already-emitted type.
453 serialization::TypeIdx getTypeIdx(QualType T) const;
455 /// \brief Emits a reference to a declarator info.
456 void AddTypeSourceInfo(TypeSourceInfo *TInfo, RecordDataImpl &Record);
458 /// \brief Emits a type with source-location information.
459 void AddTypeLoc(TypeLoc TL, RecordDataImpl &Record);
461 /// \brief Emits a template argument location info.
462 void AddTemplateArgumentLocInfo(TemplateArgument::ArgKind Kind,
463 const TemplateArgumentLocInfo &Arg,
464 RecordDataImpl &Record);
466 /// \brief Emits a template argument location.
467 void AddTemplateArgumentLoc(const TemplateArgumentLoc &Arg,
468 RecordDataImpl &Record);
470 /// \brief Emit a reference to a declaration.
471 void AddDeclRef(const Decl *D, RecordDataImpl &Record);
474 /// \brief Force a declaration to be emitted and get its ID.
475 serialization::DeclID GetDeclRef(const Decl *D);
477 /// \brief Determine the declaration ID of an already-emitted
479 serialization::DeclID getDeclID(const Decl *D);
481 /// \brief Emit a declaration name.
482 void AddDeclarationName(DeclarationName Name, RecordDataImpl &Record);
483 void AddDeclarationNameLoc(const DeclarationNameLoc &DNLoc,
484 DeclarationName Name, RecordDataImpl &Record);
485 void AddDeclarationNameInfo(const DeclarationNameInfo &NameInfo,
486 RecordDataImpl &Record);
488 void AddQualifierInfo(const QualifierInfo &Info, RecordDataImpl &Record);
490 /// \brief Emit a nested name specifier.
491 void AddNestedNameSpecifier(NestedNameSpecifier *NNS, RecordDataImpl &Record);
493 /// \brief Emit a nested name specifier with source-location information.
494 void AddNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS,
495 RecordDataImpl &Record);
497 /// \brief Emit a template name.
498 void AddTemplateName(TemplateName Name, RecordDataImpl &Record);
500 /// \brief Emit a template argument.
501 void AddTemplateArgument(const TemplateArgument &Arg, RecordDataImpl &Record);
503 /// \brief Emit a template parameter list.
504 void AddTemplateParameterList(const TemplateParameterList *TemplateParams,
505 RecordDataImpl &Record);
507 /// \brief Emit a template argument list.
508 void AddTemplateArgumentList(const TemplateArgumentList *TemplateArgs,
509 RecordDataImpl &Record);
511 /// \brief Emit a UnresolvedSet structure.
512 void AddUnresolvedSet(const UnresolvedSetImpl &Set, RecordDataImpl &Record);
514 /// \brief Emit a C++ base specifier.
515 void AddCXXBaseSpecifier(const CXXBaseSpecifier &Base, RecordDataImpl &Record);
517 /// \brief Emit a CXXCtorInitializer array.
518 void AddCXXCtorInitializers(
519 const CXXCtorInitializer * const *CtorInitializers,
520 unsigned NumCtorInitializers,
521 RecordDataImpl &Record);
523 void AddCXXDefinitionData(const CXXRecordDecl *D, RecordDataImpl &Record);
525 /// \brief Add a string to the given record.
526 void AddString(llvm::StringRef Str, RecordDataImpl &Record);
528 /// \brief Add a version tuple to the given record
529 void AddVersionTuple(const VersionTuple &Version, RecordDataImpl &Record);
531 /// \brief Mark a declaration context as needing an update.
532 void AddUpdatedDeclContext(const DeclContext *DC) {
533 UpdatedDeclContexts.insert(DC);
536 void RewriteDecl(const Decl *D) {
537 DeclsToRewrite.insert(D);
538 // Reset the flag, so that we don't add this decl multiple times.
539 const_cast<Decl *>(D)->setChangedSinceDeserialization(false);
542 /// \brief Note that the identifier II occurs at the given offset
543 /// within the identifier table.
544 void SetIdentifierOffset(const IdentifierInfo *II, uint32_t Offset);
546 /// \brief Note that the selector Sel occurs at the given offset
547 /// within the method pool/selector table.
548 void SetSelectorOffset(Selector Sel, uint32_t Offset);
550 /// \brief Add the given statement or expression to the queue of
551 /// statements to emit.
553 /// This routine should be used when emitting types and declarations
554 /// that have expressions as part of their formulation. Once the
555 /// type or declaration has been written, call FlushStmts() to write
556 /// the corresponding statements just after the type or
558 void AddStmt(Stmt *S) {
559 CollectedStmts->push_back(S);
562 /// \brief Flush all of the statements and expressions that have
563 /// been added to the queue via AddStmt().
566 /// \brief Flush all of the C++ base specifier sets that have been added
567 /// via \c AddCXXBaseSpecifiersRef().
568 void FlushCXXBaseSpecifiers();
570 /// \brief Record an ID for the given switch-case statement.
571 unsigned RecordSwitchCaseID(SwitchCase *S);
573 /// \brief Retrieve the ID for the given switch-case statement.
574 unsigned getSwitchCaseID(SwitchCase *S);
576 void ClearSwitchCaseIDs();
578 /// \brief Retrieve the ID for the given opaque value expression.
579 unsigned getOpaqueValueID(OpaqueValueExpr *e);
581 unsigned getDeclParmVarAbbrev() const { return DeclParmVarAbbrev; }
582 unsigned getDeclRefExprAbbrev() const { return DeclRefExprAbbrev; }
583 unsigned getCharacterLiteralAbbrev() const { return CharacterLiteralAbbrev; }
584 unsigned getDeclRecordAbbrev() const { return DeclRecordAbbrev; }
585 unsigned getIntegerLiteralAbbrev() const { return IntegerLiteralAbbrev; }
586 unsigned getDeclTypedefAbbrev() const { return DeclTypedefAbbrev; }
587 unsigned getDeclVarAbbrev() const { return DeclVarAbbrev; }
588 unsigned getDeclFieldAbbrev() const { return DeclFieldAbbrev; }
589 unsigned getDeclEnumAbbrev() const { return DeclEnumAbbrev; }
590 unsigned getDeclObjCIvarAbbrev() const { return DeclObjCIvarAbbrev; }
592 bool hasChain() const { return Chain; }
594 // ASTDeserializationListener implementation
595 void ReaderInitialized(ASTReader *Reader);
596 void IdentifierRead(serialization::IdentID ID, IdentifierInfo *II);
597 void TypeRead(serialization::TypeIdx Idx, QualType T);
598 void DeclRead(serialization::DeclID ID, const Decl *D);
599 void SelectorRead(serialization::SelectorID ID, Selector Sel);
600 void MacroDefinitionRead(serialization::MacroID ID, MacroDefinition *MD);
602 // ASTMutationListener implementation.
603 virtual void CompletedTagDefinition(const TagDecl *D);
604 virtual void AddedVisibleDecl(const DeclContext *DC, const Decl *D);
605 virtual void AddedCXXImplicitMember(const CXXRecordDecl *RD, const Decl *D);
606 virtual void AddedCXXTemplateSpecialization(const ClassTemplateDecl *TD,
607 const ClassTemplateSpecializationDecl *D);
608 virtual void AddedCXXTemplateSpecialization(const FunctionTemplateDecl *TD,
609 const FunctionDecl *D);
610 virtual void CompletedImplicitDefinition(const FunctionDecl *D);
611 virtual void StaticDataMemberInstantiated(const VarDecl *D);
614 /// \brief AST and semantic-analysis consumer that generates a
615 /// precompiled header from the parsed source code.
616 class PCHGenerator : public SemaConsumer {
617 const Preprocessor &PP;
618 std::string OutputFile;
619 const char *isysroot;
620 llvm::raw_ostream *Out;
622 MemorizeStatCalls *StatCalls; // owned by the FileManager
623 std::vector<unsigned char> Buffer;
624 llvm::BitstreamWriter Stream;
629 ASTWriter &getWriter() { return Writer; }
630 const ASTWriter &getWriter() const { return Writer; }
633 PCHGenerator(const Preprocessor &PP, const std::string &OutputFile, bool Chaining,
634 const char *isysroot, llvm::raw_ostream *Out);
635 virtual void InitializeSema(Sema &S) { SemaPtr = &S; }
636 virtual void HandleTranslationUnit(ASTContext &Ctx);
637 virtual ASTMutationListener *GetASTMutationListener();
638 virtual ASTSerializationListener *GetASTSerializationListener();
639 virtual ASTDeserializationListener *GetASTDeserializationListener();
642 } // end namespace clang