clang  13.0.0git
ASTWriter.h
Go to the documentation of this file.
1 //===- ASTWriter.h - AST File Writer ----------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines the ASTWriter class, which writes an AST file
10 // containing a serialized representation of a translation unit.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_CLANG_SERIALIZATION_ASTWRITER_H
15 #define LLVM_CLANG_SERIALIZATION_ASTWRITER_H
16 
18 #include "clang/AST/Decl.h"
19 #include "clang/AST/Type.h"
20 #include "clang/Basic/LLVM.h"
22 #include "clang/Sema/Sema.h"
27 #include "llvm/ADT/ArrayRef.h"
28 #include "llvm/ADT/DenseMap.h"
29 #include "llvm/ADT/DenseSet.h"
30 #include "llvm/ADT/MapVector.h"
31 #include "llvm/ADT/STLExtras.h"
32 #include "llvm/ADT/SetVector.h"
33 #include "llvm/ADT/SmallVector.h"
34 #include "llvm/ADT/StringRef.h"
35 #include "llvm/Bitstream/BitstreamWriter.h"
36 #include <cassert>
37 #include <cstddef>
38 #include <cstdint>
39 #include <ctime>
40 #include <memory>
41 #include <queue>
42 #include <string>
43 #include <utility>
44 #include <vector>
45 
46 namespace llvm {
47 
48 class APFloat;
49 class APInt;
50 class APSInt;
51 
52 } // namespace llvm
53 
54 namespace clang {
55 
56 class ASTContext;
57 class ASTReader;
58 class ASTUnresolvedSet;
59 class Attr;
60 class CXXBaseSpecifier;
61 class CXXCtorInitializer;
62 class CXXRecordDecl;
63 class CXXTemporary;
64 class FileEntry;
65 class FPOptions;
66 class FPOptionsOverride;
67 class FunctionDecl;
68 class HeaderSearch;
69 class HeaderSearchOptions;
70 class IdentifierResolver;
71 class LangOptions;
72 class MacroDefinitionRecord;
73 class MacroInfo;
74 class Module;
75 class InMemoryModuleCache;
76 class ModuleFileExtension;
77 class ModuleFileExtensionWriter;
78 class NamedDecl;
79 class ObjCInterfaceDecl;
80 class PreprocessingRecord;
81 class Preprocessor;
82 struct QualifierInfo;
83 class RecordDecl;
84 class Sema;
85 class SourceManager;
86 class Stmt;
87 class StoredDeclsList;
88 class SwitchCase;
89 class TemplateParameterList;
90 class Token;
91 class TypeSourceInfo;
92 
93 /// Writes an AST file containing the contents of a translation unit.
94 ///
95 /// The ASTWriter class produces a bitstream containing the serialized
96 /// representation of a given abstract syntax tree and its supporting
97 /// data structures. This bitstream can be de-serialized via an
98 /// instance of the ASTReader class.
100  public ASTMutationListener {
101 public:
102  friend class ASTDeclWriter;
103  friend class ASTRecordWriter;
104 
108 
109 private:
110  /// Map that provides the ID numbers of each type within the
111  /// output stream, plus those deserialized from a chained PCH.
112  ///
113  /// The ID numbers of types are consecutive (in order of discovery)
114  /// and start at 1. 0 is reserved for NULL. When types are actually
115  /// stored in the stream, the ID number is shifted by 2 bits to
116  /// allow for the const/volatile qualifiers.
117  ///
118  /// Keys in the map never have const/volatile qualifiers.
119  using TypeIdxMap = llvm::DenseMap<QualType, serialization::TypeIdx,
121 
122  /// The bitstream writer used to emit this precompiled header.
123  llvm::BitstreamWriter &Stream;
124 
125  /// The buffer associated with the bitstream.
126  const SmallVectorImpl<char> &Buffer;
127 
128  /// The PCM manager which manages memory buffers for pcm files.
129  InMemoryModuleCache &ModuleCache;
130 
131  /// The ASTContext we're writing.
132  ASTContext *Context = nullptr;
133 
134  /// The preprocessor we're writing.
135  Preprocessor *PP = nullptr;
136 
137  /// The reader of existing AST files, if we're chaining.
138  ASTReader *Chain = nullptr;
139 
140  /// The module we're currently writing, if any.
141  Module *WritingModule = nullptr;
142 
143  /// The offset of the first bit inside the AST_BLOCK.
144  uint64_t ASTBlockStartOffset = 0;
145 
146  /// The range representing all the AST_BLOCK.
147  std::pair<uint64_t, uint64_t> ASTBlockRange;
148 
149  /// The base directory for any relative paths we emit.
150  std::string BaseDirectory;
151 
152  /// Indicates whether timestamps should be written to the produced
153  /// module file. This is the case for files implicitly written to the
154  /// module cache, where we need the timestamps to determine if the module
155  /// file is up to date, but not otherwise.
156  bool IncludeTimestamps;
157 
158  /// Indicates when the AST writing is actively performing
159  /// serialization, rather than just queueing updates.
160  bool WritingAST = false;
161 
162  /// Indicates that we are done serializing the collection of decls
163  /// and types to emit.
164  bool DoneWritingDeclsAndTypes = false;
165 
166  /// Indicates that the AST contained compiler errors.
167  bool ASTHasCompilerErrors = false;
168 
169  /// Mapping from input file entries to the index into the
170  /// offset table where information about that input file is stored.
171  llvm::DenseMap<const FileEntry *, uint32_t> InputFileIDs;
172 
173  /// Stores a declaration or a type to be written to the AST file.
174  class DeclOrType {
175  public:
176  DeclOrType(Decl *D) : Stored(D), IsType(false) {}
177  DeclOrType(QualType T) : Stored(T.getAsOpaquePtr()), IsType(true) {}
178 
179  bool isType() const { return IsType; }
180  bool isDecl() const { return !IsType; }
181 
182  QualType getType() const {
183  assert(isType() && "Not a type!");
184  return QualType::getFromOpaquePtr(Stored);
185  }
186 
187  Decl *getDecl() const {
188  assert(isDecl() && "Not a decl!");
189  return static_cast<Decl *>(Stored);
190  }
191 
192  private:
193  void *Stored;
194  bool IsType;
195  };
196 
197  /// The declarations and types to emit.
198  std::queue<DeclOrType> DeclTypesToEmit;
199 
200  /// The first ID number we can use for our own declarations.
202 
203  /// The decl ID that will be assigned to the next new decl.
204  serialization::DeclID NextDeclID = FirstDeclID;
205 
206  /// Map that provides the ID numbers of each declaration within
207  /// the output stream, as well as those deserialized from a chained PCH.
208  ///
209  /// The ID numbers of declarations are consecutive (in order of
210  /// discovery) and start at 2. 1 is reserved for the translation
211  /// unit, while 0 is reserved for NULL.
212  llvm::DenseMap<const Decl *, serialization::DeclID> DeclIDs;
213 
214  /// Offset of each declaration in the bitstream, indexed by
215  /// the declaration's ID.
216  std::vector<serialization::DeclOffset> DeclOffsets;
217 
218  /// The offset of the DECLTYPES_BLOCK. The offsets in DeclOffsets
219  /// are relative to this value.
220  uint64_t DeclTypesBlockStartOffset = 0;
221 
222  /// Sorted (by file offset) vector of pairs of file offset/DeclID.
223  using LocDeclIDsTy =
225  struct DeclIDInFileInfo {
226  LocDeclIDsTy DeclIDs;
227 
228  /// Set when the DeclIDs vectors from all files are joined, this
229  /// indicates the index that this particular vector has in the global one.
230  unsigned FirstDeclIndex;
231  };
232  using FileDeclIDsTy =
233  llvm::DenseMap<FileID, std::unique_ptr<DeclIDInFileInfo>>;
234 
235  /// Map from file SLocEntries to info about the file-level declarations
236  /// that it contains.
237  FileDeclIDsTy FileDeclIDs;
238 
239  void associateDeclWithFile(const Decl *D, serialization::DeclID);
240 
241  /// The first ID number we can use for our own types.
243 
244  /// The type ID that will be assigned to the next new type.
245  serialization::TypeID NextTypeID = FirstTypeID;
246 
247  /// Map that provides the ID numbers of each type within the
248  /// output stream, plus those deserialized from a chained PCH.
249  ///
250  /// The ID numbers of types are consecutive (in order of discovery)
251  /// and start at 1. 0 is reserved for NULL. When types are actually
252  /// stored in the stream, the ID number is shifted by 2 bits to
253  /// allow for the const/volatile qualifiers.
254  ///
255  /// Keys in the map never have const/volatile qualifiers.
256  TypeIdxMap TypeIdxs;
257 
258  /// Offset of each type in the bitstream, indexed by
259  /// the type's ID.
260  std::vector<serialization::UnderalignedInt64> TypeOffsets;
261 
262  /// The first ID number we can use for our own identifiers.
264 
265  /// The identifier ID that will be assigned to the next new identifier.
266  serialization::IdentID NextIdentID = FirstIdentID;
267 
268  /// Map that provides the ID numbers of each identifier in
269  /// the output stream.
270  ///
271  /// The ID numbers for identifiers are consecutive (in order of
272  /// discovery), starting at 1. An ID of zero refers to a NULL
273  /// IdentifierInfo.
274  llvm::MapVector<const IdentifierInfo *, serialization::IdentID> IdentifierIDs;
275 
276  /// The first ID number we can use for our own macros.
278 
279  /// The identifier ID that will be assigned to the next new identifier.
280  serialization::MacroID NextMacroID = FirstMacroID;
281 
282  /// Map that provides the ID numbers of each macro.
283  llvm::DenseMap<MacroInfo *, serialization::MacroID> MacroIDs;
284 
285  struct MacroInfoToEmitData {
286  const IdentifierInfo *Name;
287  MacroInfo *MI;
289  };
290 
291  /// The macro infos to emit.
292  std::vector<MacroInfoToEmitData> MacroInfosToEmit;
293 
294  llvm::DenseMap<const IdentifierInfo *, uint32_t>
295  IdentMacroDirectivesOffsetMap;
296 
297  /// @name FlushStmt Caches
298  /// @{
299 
300  /// Set of parent Stmts for the currently serializing sub-stmt.
301  llvm::DenseSet<Stmt *> ParentStmts;
302 
303  /// Offsets of sub-stmts already serialized. The offset points
304  /// just after the stmt record.
305  llvm::DenseMap<Stmt *, uint64_t> SubStmtEntries;
306 
307  /// @}
308 
309  /// Offsets of each of the identifier IDs into the identifier
310  /// table.
311  std::vector<uint32_t> IdentifierOffsets;
312 
313  /// The first ID number we can use for our own submodules.
314  serialization::SubmoduleID FirstSubmoduleID =
316 
317  /// The submodule ID that will be assigned to the next new submodule.
318  serialization::SubmoduleID NextSubmoduleID = FirstSubmoduleID;
319 
320  /// The first ID number we can use for our own selectors.
321  serialization::SelectorID FirstSelectorID =
323 
324  /// The selector ID that will be assigned to the next new selector.
325  serialization::SelectorID NextSelectorID = FirstSelectorID;
326 
327  /// Map that provides the ID numbers of each Selector.
328  llvm::MapVector<Selector, serialization::SelectorID> SelectorIDs;
329 
330  /// Offset of each selector within the method pool/selector
331  /// table, indexed by the Selector ID (-1).
332  std::vector<uint32_t> SelectorOffsets;
333 
334  /// Mapping from macro definitions (as they occur in the preprocessing
335  /// record) to the macro IDs.
336  llvm::DenseMap<const MacroDefinitionRecord *,
337  serialization::PreprocessedEntityID> MacroDefinitions;
338 
339  /// Cache of indices of anonymous declarations within their lexical
340  /// contexts.
341  llvm::DenseMap<const Decl *, unsigned> AnonymousDeclarationNumbers;
342 
343  /// An update to a Decl.
344  class DeclUpdate {
345  /// A DeclUpdateKind.
346  unsigned Kind;
347  union {
348  const Decl *Dcl;
349  void *Type;
350  unsigned Loc;
351  unsigned Val;
352  Module *Mod;
353  const Attr *Attribute;
354  };
355 
356  public:
357  DeclUpdate(unsigned Kind) : Kind(Kind), Dcl(nullptr) {}
358  DeclUpdate(unsigned Kind, const Decl *Dcl) : Kind(Kind), Dcl(Dcl) {}
359  DeclUpdate(unsigned Kind, QualType Type)
360  : Kind(Kind), Type(Type.getAsOpaquePtr()) {}
361  DeclUpdate(unsigned Kind, SourceLocation Loc)
362  : Kind(Kind), Loc(Loc.getRawEncoding()) {}
363  DeclUpdate(unsigned Kind, unsigned Val) : Kind(Kind), Val(Val) {}
364  DeclUpdate(unsigned Kind, Module *M) : Kind(Kind), Mod(M) {}
365  DeclUpdate(unsigned Kind, const Attr *Attribute)
366  : Kind(Kind), Attribute(Attribute) {}
367 
368  unsigned getKind() const { return Kind; }
369  const Decl *getDecl() const { return Dcl; }
370  QualType getType() const { return QualType::getFromOpaquePtr(Type); }
371 
372  SourceLocation getLoc() const {
374  }
375 
376  unsigned getNumber() const { return Val; }
377  Module *getModule() const { return Mod; }
378  const Attr *getAttr() const { return Attribute; }
379  };
380 
381  using UpdateRecord = SmallVector<DeclUpdate, 1>;
382  using DeclUpdateMap = llvm::MapVector<const Decl *, UpdateRecord>;
383 
384  /// Mapping from declarations that came from a chained PCH to the
385  /// record containing modifications to them.
386  DeclUpdateMap DeclUpdates;
387 
388  using FirstLatestDeclMap = llvm::DenseMap<Decl *, Decl *>;
389 
390  /// Map of first declarations from a chained PCH that point to the
391  /// most recent declarations in another PCH.
392  FirstLatestDeclMap FirstLatestDecls;
393 
394  /// Declarations encountered that might be external
395  /// definitions.
396  ///
397  /// We keep track of external definitions and other 'interesting' declarations
398  /// as we are emitting declarations to the AST file. The AST file contains a
399  /// separate record for these declarations, which are provided to the AST
400  /// consumer by the AST reader. This is behavior is required to properly cope with,
401  /// e.g., tentative variable definitions that occur within
402  /// headers. The declarations themselves are stored as declaration
403  /// IDs, since they will be written out to an EAGERLY_DESERIALIZED_DECLS
404  /// record.
405  SmallVector<uint64_t, 16> EagerlyDeserializedDecls;
406  SmallVector<uint64_t, 16> ModularCodegenDecls;
407 
408  /// DeclContexts that have received extensions since their serialized
409  /// form.
410  ///
411  /// For namespaces, when we're chaining and encountering a namespace, we check
412  /// if its primary namespace comes from the chain. If it does, we add the
413  /// primary to this set, so that we can write out lexical content updates for
414  /// it.
416 
417  /// Keeps track of declarations that we must emit, even though we're
418  /// not guaranteed to be able to find them by walking the AST starting at the
419  /// translation unit.
420  SmallVector<const Decl *, 16> DeclsToEmitEvenIfUnreferenced;
421 
422  /// The set of Objective-C class that have categories we
423  /// should serialize.
424  llvm::SetVector<ObjCInterfaceDecl *> ObjCClassesWithCategories;
425 
426  /// The set of declarations that may have redeclaration chains that
427  /// need to be serialized.
429 
430  /// A cache of the first local declaration for "interesting"
431  /// redeclaration chains.
432  llvm::DenseMap<const Decl *, const Decl *> FirstLocalDeclCache;
433 
434  /// Mapping from SwitchCase statements to IDs.
435  llvm::DenseMap<SwitchCase *, unsigned> SwitchCaseIDs;
436 
437  /// The number of statements written to the AST file.
438  unsigned NumStatements = 0;
439 
440  /// The number of macros written to the AST file.
441  unsigned NumMacros = 0;
442 
443  /// The number of lexical declcontexts written to the AST
444  /// file.
445  unsigned NumLexicalDeclContexts = 0;
446 
447  /// The number of visible declcontexts written to the AST
448  /// file.
449  unsigned NumVisibleDeclContexts = 0;
450 
451  /// A mapping from each known submodule to its ID number, which will
452  /// be a positive integer.
453  llvm::DenseMap<Module *, unsigned> SubmoduleIDs;
454 
455  /// A list of the module file extension writers.
456  std::vector<std::unique_ptr<ModuleFileExtensionWriter>>
457  ModuleFileExtensionWriters;
458 
459  /// Retrieve or create a submodule ID for this module.
460  unsigned getSubmoduleID(Module *Mod);
461 
462  /// Write the given subexpression to the bitstream.
463  void WriteSubStmt(Stmt *S);
464 
465  void WriteBlockInfoBlock();
466  void WriteControlBlock(Preprocessor &PP, ASTContext &Context,
467  StringRef isysroot, const std::string &OutputFile);
468 
469  /// Write out the signature and diagnostic options, and return the signature.
470  ASTFileSignature writeUnhashedControlBlock(Preprocessor &PP,
471  ASTContext &Context);
472 
473  /// Calculate hash of the pcm content.
474  static std::pair<ASTFileSignature, ASTFileSignature>
475  createSignature(StringRef AllBytes, StringRef ASTBlockBytes);
476 
477  void WriteInputFiles(SourceManager &SourceMgr, HeaderSearchOptions &HSOpts,
478  bool Modules);
479  void WriteSourceManagerBlock(SourceManager &SourceMgr,
480  const Preprocessor &PP);
481  void WritePreprocessor(const Preprocessor &PP, bool IsModule);
482  void WriteHeaderSearch(const HeaderSearch &HS);
483  void WritePreprocessorDetail(PreprocessingRecord &PPRec,
484  uint64_t MacroOffsetsBase);
485  void WriteSubmodules(Module *WritingModule);
486 
487  void WritePragmaDiagnosticMappings(const DiagnosticsEngine &Diag,
488  bool isModule);
489 
490  unsigned TypeExtQualAbbrev = 0;
491  unsigned TypeFunctionProtoAbbrev = 0;
492  void WriteTypeAbbrevs();
493  void WriteType(QualType T);
494 
495  bool isLookupResultExternal(StoredDeclsList &Result, DeclContext *DC);
496  bool isLookupResultEntirelyExternal(StoredDeclsList &Result, DeclContext *DC);
497 
498  void GenerateNameLookupTable(const DeclContext *DC,
499  llvm::SmallVectorImpl<char> &LookupTable);
500  uint64_t WriteDeclContextLexicalBlock(ASTContext &Context, DeclContext *DC);
501  uint64_t WriteDeclContextVisibleBlock(ASTContext &Context, DeclContext *DC);
502  void WriteTypeDeclOffsets();
503  void WriteFileDeclIDsMap();
504  void WriteComments();
505  void WriteSelectors(Sema &SemaRef);
506  void WriteReferencedSelectorsPool(Sema &SemaRef);
507  void WriteIdentifierTable(Preprocessor &PP, IdentifierResolver &IdResolver,
508  bool IsModule);
509  void WriteDeclUpdatesBlocks(RecordDataImpl &OffsetsRecord);
510  void WriteDeclContextVisibleUpdate(const DeclContext *DC);
511  void WriteFPPragmaOptions(const FPOptionsOverride &Opts);
512  void WriteOpenCLExtensions(Sema &SemaRef);
513  void WriteOpenCLExtensionTypes(Sema &SemaRef);
514  void WriteOpenCLExtensionDecls(Sema &SemaRef);
515  void WriteCUDAPragmas(Sema &SemaRef);
516  void WriteObjCCategories();
517  void WriteLateParsedTemplates(Sema &SemaRef);
518  void WriteOptimizePragmaOptions(Sema &SemaRef);
519  void WriteMSStructPragmaOptions(Sema &SemaRef);
520  void WriteMSPointersToMembersPragmaOptions(Sema &SemaRef);
521  void WritePackPragmaOptions(Sema &SemaRef);
522  void WriteFloatControlPragmaOptions(Sema &SemaRef);
523  void WriteModuleFileExtension(Sema &SemaRef,
524  ModuleFileExtensionWriter &Writer);
525 
526  unsigned DeclParmVarAbbrev = 0;
527  unsigned DeclContextLexicalAbbrev = 0;
528  unsigned DeclContextVisibleLookupAbbrev = 0;
529  unsigned UpdateVisibleAbbrev = 0;
530  unsigned DeclRecordAbbrev = 0;
531  unsigned DeclTypedefAbbrev = 0;
532  unsigned DeclVarAbbrev = 0;
533  unsigned DeclFieldAbbrev = 0;
534  unsigned DeclEnumAbbrev = 0;
535  unsigned DeclObjCIvarAbbrev = 0;
536  unsigned DeclCXXMethodAbbrev = 0;
537 
538  unsigned DeclRefExprAbbrev = 0;
539  unsigned CharacterLiteralAbbrev = 0;
540  unsigned IntegerLiteralAbbrev = 0;
541  unsigned ExprImplicitCastAbbrev = 0;
542 
543  void WriteDeclAbbrevs();
544  void WriteDecl(ASTContext &Context, Decl *D);
545 
546  ASTFileSignature WriteASTCore(Sema &SemaRef, StringRef isysroot,
547  const std::string &OutputFile,
548  Module *WritingModule);
549 
550 public:
551  /// Create a new precompiled header writer that outputs to
552  /// the given bitstream.
553  ASTWriter(llvm::BitstreamWriter &Stream, SmallVectorImpl<char> &Buffer,
554  InMemoryModuleCache &ModuleCache,
555  ArrayRef<std::shared_ptr<ModuleFileExtension>> Extensions,
556  bool IncludeTimestamps = true);
557  ~ASTWriter() override;
558 
560  assert(Context && "requested AST context when not writing AST");
561  return *Context;
562  }
563 
564  const LangOptions &getLangOpts() const;
565 
566  /// Get a timestamp for output into the AST file. The actual timestamp
567  /// of the specified file may be ignored if we have been instructed to not
568  /// include timestamps in the output file.
569  time_t getTimestampForOutput(const FileEntry *E) const;
570 
571  /// Write a precompiled header for the given semantic analysis.
572  ///
573  /// \param SemaRef a reference to the semantic analysis object that processed
574  /// the AST to be written into the precompiled header.
575  ///
576  /// \param WritingModule The module that we are writing. If null, we are
577  /// writing a precompiled header.
578  ///
579  /// \param isysroot if non-empty, write a relocatable file whose headers
580  /// are relative to the given system root. If we're writing a module, its
581  /// build directory will be used in preference to this if both are available.
582  ///
583  /// \return the module signature, which eventually will be a hash of
584  /// the module but currently is merely a random 32-bit number.
585  ASTFileSignature WriteAST(Sema &SemaRef, const std::string &OutputFile,
586  Module *WritingModule, StringRef isysroot,
587  bool hasErrors = false,
588  bool ShouldCacheASTInMemory = false);
589 
590  /// Emit a token.
591  void AddToken(const Token &Tok, RecordDataImpl &Record);
592 
593  /// Emit a AlignPackInfo.
594  void AddAlignPackInfo(const Sema::AlignPackInfo &Info,
595  RecordDataImpl &Record);
596 
597  /// Emit a source location.
599 
600  /// Emit a source range.
601  void AddSourceRange(SourceRange Range, RecordDataImpl &Record);
602 
603  /// Emit a reference to an identifier.
604  void AddIdentifierRef(const IdentifierInfo *II, RecordDataImpl &Record);
605 
606  /// Get the unique number used to refer to the given selector.
608 
609  /// Get the unique number used to refer to the given identifier.
611 
612  /// Get the unique number used to refer to the given macro.
614 
615  /// Determine the ID of an already-emitted macro.
617 
618  uint32_t getMacroDirectivesOffset(const IdentifierInfo *Name);
619 
620  /// Emit a reference to a type.
621  void AddTypeRef(QualType T, RecordDataImpl &Record);
622 
623  /// Force a type to be emitted and get its ID.
625 
626  /// Determine the type ID of an already-emitted type.
628 
629  /// Find the first local declaration of a given local redeclarable
630  /// decl.
631  const Decl *getFirstLocalDecl(const Decl *D);
632 
633  /// Is this a local declaration (that is, one that will be written to
634  /// our AST file)? This is the case for declarations that are neither imported
635  /// from another AST file nor predefined.
636  bool IsLocalDecl(const Decl *D) {
637  if (D->isFromASTFile())
638  return false;
639  auto I = DeclIDs.find(D);
640  return (I == DeclIDs.end() ||
642  };
643 
644  /// Emit a reference to a declaration.
645  void AddDeclRef(const Decl *D, RecordDataImpl &Record);
646 
647  /// Force a declaration to be emitted and get its ID.
649 
650  /// Determine the declaration ID of an already-emitted
651  /// declaration.
653 
654  unsigned getAnonymousDeclarationNumber(const NamedDecl *D);
655 
656  /// Add a string to the given record.
657  void AddString(StringRef Str, RecordDataImpl &Record);
658 
659  /// Convert a path from this build process into one that is appropriate
660  /// for emission in the module file.
662 
663  /// Add a path to the given record.
664  void AddPath(StringRef Path, RecordDataImpl &Record);
665 
666  /// Emit the current record with the given path as a blob.
667  void EmitRecordWithPath(unsigned Abbrev, RecordDataRef Record,
668  StringRef Path);
669 
670  /// Add a version tuple to the given record
671  void AddVersionTuple(const VersionTuple &Version, RecordDataImpl &Record);
672 
673  /// Retrieve or create a submodule ID for this module, or return 0 if
674  /// the submodule is neither local (a submodle of the currently-written module)
675  /// nor from an imported module.
676  unsigned getLocalOrImportedSubmoduleID(Module *Mod);
677 
678  /// Note that the identifier II occurs at the given offset
679  /// within the identifier table.
680  void SetIdentifierOffset(const IdentifierInfo *II, uint32_t Offset);
681 
682  /// Note that the selector Sel occurs at the given offset
683  /// within the method pool/selector table.
684  void SetSelectorOffset(Selector Sel, uint32_t Offset);
685 
686  /// Record an ID for the given switch-case statement.
687  unsigned RecordSwitchCaseID(SwitchCase *S);
688 
689  /// Retrieve the ID for the given switch-case statement.
690  unsigned getSwitchCaseID(SwitchCase *S);
691 
692  void ClearSwitchCaseIDs();
693 
694  unsigned getTypeExtQualAbbrev() const {
695  return TypeExtQualAbbrev;
696  }
697 
698  unsigned getTypeFunctionProtoAbbrev() const {
699  return TypeFunctionProtoAbbrev;
700  }
701 
702  unsigned getDeclParmVarAbbrev() const { return DeclParmVarAbbrev; }
703  unsigned getDeclRecordAbbrev() const { return DeclRecordAbbrev; }
704  unsigned getDeclTypedefAbbrev() const { return DeclTypedefAbbrev; }
705  unsigned getDeclVarAbbrev() const { return DeclVarAbbrev; }
706  unsigned getDeclFieldAbbrev() const { return DeclFieldAbbrev; }
707  unsigned getDeclEnumAbbrev() const { return DeclEnumAbbrev; }
708  unsigned getDeclObjCIvarAbbrev() const { return DeclObjCIvarAbbrev; }
709  unsigned getDeclCXXMethodAbbrev() const { return DeclCXXMethodAbbrev; }
710 
711  unsigned getDeclRefExprAbbrev() const { return DeclRefExprAbbrev; }
712  unsigned getCharacterLiteralAbbrev() const { return CharacterLiteralAbbrev; }
713  unsigned getIntegerLiteralAbbrev() const { return IntegerLiteralAbbrev; }
714  unsigned getExprImplicitCastAbbrev() const { return ExprImplicitCastAbbrev; }
715 
716  bool hasChain() const { return Chain; }
717  ASTReader *getChain() const { return Chain; }
718 
719 private:
720  // ASTDeserializationListener implementation
721  void ReaderInitialized(ASTReader *Reader) override;
722  void IdentifierRead(serialization::IdentID ID, IdentifierInfo *II) override;
723  void MacroRead(serialization::MacroID ID, MacroInfo *MI) override;
724  void TypeRead(serialization::TypeIdx Idx, QualType T) override;
725  void SelectorRead(serialization::SelectorID ID, Selector Sel) override;
726  void MacroDefinitionRead(serialization::PreprocessedEntityID ID,
727  MacroDefinitionRecord *MD) override;
728  void ModuleRead(serialization::SubmoduleID ID, Module *Mod) override;
729 
730  // ASTMutationListener implementation.
731  void CompletedTagDefinition(const TagDecl *D) override;
732  void AddedVisibleDecl(const DeclContext *DC, const Decl *D) override;
733  void AddedCXXImplicitMember(const CXXRecordDecl *RD, const Decl *D) override;
734  void AddedCXXTemplateSpecialization(
735  const ClassTemplateDecl *TD,
736  const ClassTemplateSpecializationDecl *D) override;
737  void AddedCXXTemplateSpecialization(
738  const VarTemplateDecl *TD,
739  const VarTemplateSpecializationDecl *D) override;
740  void AddedCXXTemplateSpecialization(const FunctionTemplateDecl *TD,
741  const FunctionDecl *D) override;
742  void ResolvedExceptionSpec(const FunctionDecl *FD) override;
743  void DeducedReturnType(const FunctionDecl *FD, QualType ReturnType) override;
744  void ResolvedOperatorDelete(const CXXDestructorDecl *DD,
745  const FunctionDecl *Delete,
746  Expr *ThisArg) override;
747  void CompletedImplicitDefinition(const FunctionDecl *D) override;
748  void InstantiationRequested(const ValueDecl *D) override;
749  void VariableDefinitionInstantiated(const VarDecl *D) override;
750  void FunctionDefinitionInstantiated(const FunctionDecl *D) override;
751  void DefaultArgumentInstantiated(const ParmVarDecl *D) override;
752  void DefaultMemberInitializerInstantiated(const FieldDecl *D) override;
753  void AddedObjCCategoryToInterface(const ObjCCategoryDecl *CatD,
754  const ObjCInterfaceDecl *IFD) override;
755  void DeclarationMarkedUsed(const Decl *D) override;
756  void DeclarationMarkedOpenMPThreadPrivate(const Decl *D) override;
757  void DeclarationMarkedOpenMPDeclareTarget(const Decl *D,
758  const Attr *Attr) override;
759  void DeclarationMarkedOpenMPAllocate(const Decl *D, const Attr *A) override;
760  void RedefinedHiddenDefinition(const NamedDecl *D, Module *M) override;
761  void AddedAttributeToRecord(const Attr *Attr,
762  const RecordDecl *Record) override;
763 };
764 
765 /// AST and semantic-analysis consumer that generates a
766 /// precompiled header from the parsed source code.
767 class PCHGenerator : public SemaConsumer {
768  const Preprocessor &PP;
769  std::string OutputFile;
770  std::string isysroot;
771  Sema *SemaPtr;
772  std::shared_ptr<PCHBuffer> Buffer;
773  llvm::BitstreamWriter Stream;
774  ASTWriter Writer;
775  bool AllowASTWithErrors;
776  bool ShouldCacheASTInMemory;
777 
778 protected:
779  ASTWriter &getWriter() { return Writer; }
780  const ASTWriter &getWriter() const { return Writer; }
781  SmallVectorImpl<char> &getPCH() const { return Buffer->Data; }
782 
783 public:
784  PCHGenerator(const Preprocessor &PP, InMemoryModuleCache &ModuleCache,
785  StringRef OutputFile, StringRef isysroot,
786  std::shared_ptr<PCHBuffer> Buffer,
787  ArrayRef<std::shared_ptr<ModuleFileExtension>> Extensions,
788  bool AllowASTWithErrors = false, bool IncludeTimestamps = true,
789  bool ShouldCacheASTInMemory = false);
790  ~PCHGenerator() override;
791 
792  void InitializeSema(Sema &S) override { SemaPtr = &S; }
793  void HandleTranslationUnit(ASTContext &Ctx) override;
796  bool hasEmittedPCH() const { return Buffer->IsComplete; }
797 };
798 
799 } // namespace clang
800 
801 #endif // LLVM_CLANG_SERIALIZATION_ASTWRITER_H
clang::ASTWriter::getCharacterLiteralAbbrev
unsigned getCharacterLiteralAbbrev() const
Definition: ASTWriter.h:712
clang::ObjCInterfaceDecl
Represents an ObjC class declaration.
Definition: DeclObjC.h:1148
llvm
Specialize PointerLikeTypeTraits to allow LazyGenerationalUpdatePtr to be placed into a PointerUnion.
Definition: Dominators.h:30
clang::ASTWriter::getDeclRefExprAbbrev
unsigned getDeclRefExprAbbrev() const
Definition: ASTWriter.h:711
clang::serialization::TypeIdx
A type index; the type ID with the qualifier bits removed.
Definition: ASTBitCodes.h:88
clang::serialization::NUM_PREDEF_SELECTOR_IDS
const unsigned int NUM_PREDEF_SELECTOR_IDS
The number of predefined selector IDs.
Definition: ASTBitCodes.h:156
clang::interp::APInt
llvm::APInt APInt
Definition: Integral.h:27
clang::SourceRange
A trivial tuple used to represent a source range.
Definition: SourceLocation.h:212
string
string(SUBSTRING ${CMAKE_CURRENT_BINARY_DIR} 0 ${PATH_LIB_START} PATH_HEAD) string(SUBSTRING $
Definition: CMakeLists.txt:22
clang::DeclContext
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1347
clang::PCHGenerator::InitializeSema
void InitializeSema(Sema &S) override
Initialize the semantic consumer with the Sema instance being used to perform semantic analysis on th...
Definition: ASTWriter.h:792
clang::ASTWriter::getSwitchCaseID
unsigned getSwitchCaseID(SwitchCase *S)
Retrieve the ID for the given switch-case statement.
Definition: ASTWriterStmt.cpp:2575
Diag
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
Definition: LiteralSupport.cpp:78
llvm::SmallVector< uint64_t, 64 >
clang::SourceLocation
Encodes a location in the source.
Definition: SourceLocation.h:89
clang::NamedDecl
This represents a decl that may have a name.
Definition: Decl.h:223
clang::serialization::IdentID
uint32_t IdentID
An ID number that refers to an identifier in an AST file.
Definition: ASTBitCodes.h:134
clang::ASTWriter::getFirstLocalDecl
const Decl * getFirstLocalDecl(const Decl *D)
Find the first local declaration of a given local redeclarable decl.
Definition: ASTWriterDecl.cpp:1762
clang::QualType
A (possibly-)qualified type.
Definition: Type.h:661
clang::FieldDecl
Represents a member of a struct/union/class.
Definition: Decl.h:2792
clang::ParmVarDecl
Represents a parameter to a function.
Definition: Decl.h:1630
clang::ASTWriter::PreparePathForOutput
bool PreparePathForOutput(SmallVectorImpl< char > &Path)
Convert a path from this build process into one that is appropriate for emission in the module file.
Definition: ASTWriter.cpp:4259
clang::MacroInfo
Encapsulates the data about a macro definition (e.g.
Definition: MacroInfo.h:39
ASTDeserializationListener.h
clang::ASTWriter::getMacroRef
serialization::MacroID getMacroRef(MacroInfo *MI, const IdentifierInfo *Name)
Get the unique number used to refer to the given macro.
Definition: ASTWriter.cpp:5128
clang::VarTemplateSpecializationDecl
Represents a variable template specialization, which refers to a variable template with a given set o...
Definition: DeclTemplate.h:2659
clang::Token
Token - This structure provides full information about a lexed token.
Definition: Token.h:34
clang::ASTWriter::IsLocalDecl
bool IsLocalDecl(const Decl *D)
Is this a local declaration (that is, one that will be written to our AST file)? This is the case for...
Definition: ASTWriter.h:636
clang::serialization::MacroID
uint32_t MacroID
An ID number that refers to a macro in an AST file.
Definition: ASTBitCodes.h:140
Decl.h
Offset
unsigned Offset
Definition: Format.cpp:2164
clang::PCHGenerator::getWriter
const ASTWriter & getWriter() const
Definition: ASTWriter.h:780
clang::CodeGen::AlignmentSource::Decl
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
clang::ASTWriter::AddIdentifierRef
void AddIdentifierRef(const IdentifierInfo *II, RecordDataImpl &Record)
Emit a reference to an identifier.
Definition: ASTWriter.cpp:5114
APSInt
llvm::APSInt APSInt
Definition: ByteCodeEmitter.cpp:18
clang::ASTWriter::getDeclVarAbbrev
unsigned getDeclVarAbbrev() const
Definition: ASTWriter.h:705
clang::FunctionTemplateDecl
Declaration of a template function.
Definition: DeclTemplate.h:973
clang::ASTWriter::getTypeFunctionProtoAbbrev
unsigned getTypeFunctionProtoAbbrev() const
Definition: ASTWriter.h:698
clang::serialization::SubmoduleID
uint32_t SubmoduleID
An ID number that refers to a submodule in a module file.
Definition: ASTBitCodes.h:171
clang::SemaConsumer
An abstract interface that should be implemented by clients that read ASTs and then require further s...
Definition: SemaConsumer.h:25
clang::PCHGenerator::PCHGenerator
PCHGenerator(const Preprocessor &PP, InMemoryModuleCache &ModuleCache, StringRef OutputFile, StringRef isysroot, std::shared_ptr< PCHBuffer > Buffer, ArrayRef< std::shared_ptr< ModuleFileExtension >> Extensions, bool AllowASTWithErrors=false, bool IncludeTimestamps=true, bool ShouldCacheASTInMemory=false)
Definition: GeneratePCH.cpp:23
clang::Module
Describes a module or submodule.
Definition: Module.h:96
clang::SourceLocation::getFromRawEncoding
static SourceLocation getFromRawEncoding(unsigned Encoding)
Turn a raw encoding of a SourceLocation object into a real SourceLocation.
Definition: SourceLocation.h:154
clang::serialization::NUM_PREDEF_DECL_IDS
const unsigned int NUM_PREDEF_DECL_IDS
The number of declaration IDs that are predefined.
Definition: ASTBitCodes.h:1207
clang::ASTWriter::getTypeID
serialization::TypeID getTypeID(QualType T) const
Determine the type ID of an already-emitted type.
Definition: ASTWriter.cpp:5267
clang::ASTWriter::EmitRecordWithPath
void EmitRecordWithPath(unsigned Abbrev, RecordDataRef Record, StringRef Path)
Emit the current record with the given path as a blob.
Definition: ASTWriter.cpp:4283
clang::serialization::UnsafeQualTypeDenseMapInfo
A structure for putting "fast"-unqualified QualTypes into a DenseMap.
Definition: ASTBitCodes.h:114
clang::ASTWriter::getLocalOrImportedSubmoduleID
unsigned getLocalOrImportedSubmoduleID(Module *Mod)
Retrieve or create a submodule ID for this module, or return 0 if the submodule is neither local (a s...
Definition: ASTWriter.cpp:2479
clang::ASTWriter::AddVersionTuple
void AddVersionTuple(const VersionTuple &Version, RecordDataImpl &Record)
Add a version tuple to the given record.
Definition: ASTWriter.cpp:4290
clang::ASTWriter::AddDeclRef
void AddDeclRef(const Decl *D, RecordDataImpl &Record)
Emit a reference to a declaration.
Definition: ASTWriter.cpp:5280
clang::ASTWriter::GetOrCreateTypeID
serialization::TypeID GetOrCreateTypeID(QualType T)
Force a type to be emitted and get its ID.
Definition: ASTWriter.cpp:5244
clang::index::SymbolKind::Module
@ Module
clang::ASTContext
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:187
clang::ASTWriter::getExprImplicitCastAbbrev
unsigned getExprImplicitCastAbbrev() const
Definition: ASTWriter.h:714
clang::ASTWriter::ASTWriter
ASTWriter(llvm::BitstreamWriter &Stream, SmallVectorImpl< char > &Buffer, InMemoryModuleCache &ModuleCache, ArrayRef< std::shared_ptr< ModuleFileExtension >> Extensions, bool IncludeTimestamps=true)
Create a new precompiled header writer that outputs to the given bitstream.
Definition: ASTWriter.cpp:4325
clang::Sema::AlignPackInfo
Definition: Sema.h:489
clang::ASTMutationListener
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
Definition: ASTMutationListener.h:46
clang::PCHGenerator::getWriter
ASTWriter & getWriter()
Definition: ASTWriter.h:779
clang::serialization::NUM_PREDEF_TYPE_IDS
const unsigned NUM_PREDEF_TYPE_IDS
The number of predefined type IDs that are reserved for the PREDEF_TYPE_* constants.
Definition: ASTBitCodes.h:1090
clang::serialization::NUM_PREDEF_SUBMODULE_IDS
const unsigned int NUM_PREDEF_SUBMODULE_IDS
The number of predefined submodule IDs.
Definition: ASTBitCodes.h:174
clang::CXXDestructorDecl
Represents a C++ destructor within a class.
Definition: DeclCXX.h:2657
clang::MacroDefinitionRecord
Record the location of a macro definition.
Definition: PreprocessingRecord.h:148
clang::PCHGenerator::~PCHGenerator
~PCHGenerator() override
Definition: GeneratePCH.cpp:38
Type.h
clang::ASTWriter::ClearSwitchCaseIDs
void ClearSwitchCaseIDs()
Definition: ASTWriterStmt.cpp:2581
clang::VarDecl
Represents a variable declaration or definition.
Definition: Decl.h:844
clang::TagDecl
Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:3285
clang::ASTWriter::RecordSwitchCaseID
unsigned RecordSwitchCaseID(SwitchCase *S)
Record an ID for the given switch-case statement.
Definition: ASTWriterStmt.cpp:2567
clang::serialization::TypeID
uint32_t TypeID
An ID number that refers to a type in an AST file.
Definition: ASTBitCodes.h:85
clang::serialization::NUM_PREDEF_IDENT_IDS
const unsigned int NUM_PREDEF_IDENT_IDS
The number of predefined identifier IDs.
Definition: ASTBitCodes.h:137
llvm::DenseSet
Definition: Sema.h:75
clang::SwitchCase
Definition: Stmt.h:1521
clang::ASTFileSignature
The signature of a module, which is a hash of the AST content.
Definition: Module.h:56
clang::ASTWriter::getAnonymousDeclarationNumber
unsigned getAnonymousDeclarationNumber(const NamedDecl *D)
Definition: ASTWriter.cpp:5372
clang::ASTWriter
Writes an AST file containing the contents of a translation unit.
Definition: ASTWriter.h:99
clang::ASTWriter::getDeclParmVarAbbrev
unsigned getDeclParmVarAbbrev() const
Definition: ASTWriter.h:702
getKind
static Decl::Kind getKind(const Decl *D)
Definition: DeclBase.cpp:994
Sema.h
clang::FileEntry
Cached information about one file (either on disk or in the virtual file system).
Definition: FileEntry.h:331
clang::serialization::PreprocessedEntityID
uint32_t PreprocessedEntityID
An ID number that refers to an entity in the detailed preprocessing record.
Definition: ASTBitCodes.h:168
clang::ASTWriter::getTypeExtQualAbbrev
unsigned getTypeExtQualAbbrev() const
Definition: ASTWriter.h:694
clang::ObjCCategoryDecl
ObjCCategoryDecl - Represents a category declaration.
Definition: DeclObjC.h:2264
clang::ASTWriter::~ASTWriter
~ASTWriter() override
clang::ASTWriter::getASTContext
ASTContext & getASTContext() const
Definition: ASTWriter.h:559
clang::diff::Delete
@ Delete
Definition: ASTDiff.h:29
ASTBitCodes.h
clang::CXXRecordDecl
Represents a C++ struct/union/class.
Definition: DeclCXX.h:254
SourceLocation.h
clang::Decl::isFromASTFile
bool isFromASTFile() const
Determine whether this declaration came from an AST file (such as a precompiled header or module) rat...
Definition: DeclBase.h:716
clang::ASTWriter::getIntegerLiteralAbbrev
unsigned getIntegerLiteralAbbrev() const
Definition: ASTWriter.h:713
clang::ASTDeserializationListener
Definition: ASTDeserializationListener.h:30
clang::ClassTemplateDecl
Declaration of a class template.
Definition: DeclTemplate.h:2242
clang::ValueDecl
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:644
clang::ASTWriter::RecordDataImpl
SmallVectorImpl< uint64_t > RecordDataImpl
Definition: ASTWriter.h:106
clang::ASTWriter::getDeclID
serialization::DeclID getDeclID(const Decl *D)
Determine the declaration ID of an already-emitted declaration.
Definition: ASTWriter.cpp:5313
clang::ASTWriter::AddAlignPackInfo
void AddAlignPackInfo(const Sema::AlignPackInfo &Info, RecordDataImpl &Record)
Emit a AlignPackInfo.
Definition: ASTWriter.cpp:5094
clang::PCHGenerator::getPCH
SmallVectorImpl< char > & getPCH() const
Definition: ASTWriter.h:781
llvm::ArrayRef
Definition: LLVM.h:34
clang::Decl
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:89
clang::ASTWriter::hasChain
bool hasChain() const
Definition: ASTWriter.h:716
ASTMutationListener.h
clang::ASTWriter::AddSourceLocation
void AddSourceLocation(SourceLocation Loc, RecordDataImpl &Record)
Emit a source location.
Definition: ASTWriter.cpp:5100
clang::ASTWriter::getIdentifierRef
serialization::IdentID getIdentifierRef(const IdentifierInfo *II)
Get the unique number used to refer to the given identifier.
Definition: ASTWriter.cpp:5118
clang::Sema
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:352
LLVM.h
clang::serialization::NUM_PREDEF_MACRO_IDS
const unsigned int NUM_PREDEF_MACRO_IDS
The number of predefined macro IDs.
Definition: ASTBitCodes.h:150
clang::ASTWriter::getDeclObjCIvarAbbrev
unsigned getDeclObjCIvarAbbrev() const
Definition: ASTWriter.h:708
clang::PCHGenerator::GetASTMutationListener
ASTMutationListener * GetASTMutationListener() override
If the consumer is interested in entities getting modified after their initial creation,...
Definition: GeneratePCH.cpp:77
clang::ASTRecordWriter
An object for streaming information to a record.
Definition: ASTRecordWriter.h:26
clang::PCHGenerator::HandleTranslationUnit
void HandleTranslationUnit(ASTContext &Ctx) override
HandleTranslationUnit - This method is called when the ASTs for entire translation unit have been par...
Definition: GeneratePCH.cpp:41
clang::ASTWriter::getSelectorRef
serialization::SelectorID getSelectorRef(Selector Sel)
Get the unique number used to refer to the given selector.
Definition: ASTWriter.cpp:5160
clang::PCHGenerator::GetASTDeserializationListener
ASTDeserializationListener * GetASTDeserializationListener() override
If the consumer is interested in entities being deserialized from AST files, it should return a point...
Definition: GeneratePCH.cpp:81
clang::IdentifierInfo
One of these records is kept for each identifier that is lexed.
Definition: IdentifierTable.h:59
clang::ASTWriter::getMacroDirectivesOffset
uint32_t getMacroDirectivesOffset(const IdentifierInfo *Name)
Definition: ASTWriter.cpp:5152
PCHContainerOperations.h
clang::ASTWriter::getLangOpts
const LangOptions & getLangOpts() const
Definition: ASTWriter.cpp:4340
clang::QualType::getFromOpaquePtr
static QualType getFromOpaquePtr(const void *Ptr)
Definition: Type.h:708
clang::LangOptions
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:58
clang::ASTWriter::WriteAST
ASTFileSignature WriteAST(Sema &SemaRef, const std::string &OutputFile, Module *WritingModule, StringRef isysroot, bool hasErrors=false, bool ShouldCacheASTInMemory=false)
Write a precompiled header for the given semantic analysis.
Definition: ASTWriter.cpp:4349
clang::ObjCPropertyAttribute::Kind
Kind
Definition: DeclObjCCommon.h:22
clang::ASTReader
Reads an AST files chain containing the contents of a translation unit.
Definition: ASTReader.h:342
clang::Builtin::ID
ID
Definition: Builtins.h:47
clang::ASTWriter::getTimestampForOutput
time_t getTimestampForOutput(const FileEntry *E) const
Get a timestamp for output into the AST file.
Definition: ASTWriter.cpp:4345
clang::ASTWriter::getMacroID
serialization::MacroID getMacroID(MacroInfo *MI)
Determine the ID of an already-emitted macro.
Definition: ASTWriter.cpp:5144
clang::ASTWriter::getChain
ASTReader * getChain() const
Definition: ASTWriter.h:717
clang
Dataflow Directional Tag Classes.
Definition: CalledOnceCheck.h:17
clang::Selector
Smart pointer class that efficiently represents Objective-C method names.
Definition: IdentifierTable.h:684
clang::ASTWriter::SetSelectorOffset
void SetSelectorOffset(Selector Sel, uint32_t Offset)
Note that the selector Sel occurs at the given offset within the method pool/selector table.
Definition: ASTWriter.cpp:4315
clang::ASTWriter::RecordDataRef
ArrayRef< uint64_t > RecordDataRef
Definition: ASTWriter.h:107
clang::ASTWriter::getDeclRecordAbbrev
unsigned getDeclRecordAbbrev() const
Definition: ASTWriter.h:703
clang::ASTWriter::AddTypeRef
void AddTypeRef(QualType T, RecordDataImpl &Record)
Emit a reference to a type.
Definition: ASTWriter.cpp:5240
clang::Attr
Attr - This represents one attribute.
Definition: Attr.h:46
clang::InMemoryModuleCache
In-memory cache for modules.
Definition: InMemoryModuleCache.h:30
clang::ASTWriter::GetDeclRef
serialization::DeclID GetDeclRef(const Decl *D)
Force a declaration to be emitted and get its ID.
Definition: ASTWriter.cpp:5284
clang::ASTWriter::AddSourceRange
void AddSourceRange(SourceRange Range, RecordDataImpl &Record)
Emit a source range.
Definition: ASTWriter.cpp:5105
clang::PCHGenerator
AST and semantic-analysis consumer that generates a precompiled header from the parsed source code.
Definition: ASTWriter.h:767
clang::QualType::getAsOpaquePtr
void * getAsOpaquePtr() const
Definition: Type.h:706
llvm::SmallVectorImpl
Definition: LLVM.h:39
clang::ASTWriter::AddPath
void AddPath(StringRef Path, RecordDataImpl &Record)
Add a path to the given record.
Definition: ASTWriter.cpp:4277
clang::ASTWriter::getDeclEnumAbbrev
unsigned getDeclEnumAbbrev() const
Definition: ASTWriter.h:707
clang::VarTemplateDecl
Declaration of a variable template.
Definition: DeclTemplate.h:3074
llvm::SmallSetVector
Definition: ExternalSemaSource.h:23
clang::PCHGenerator::hasEmittedPCH
bool hasEmittedPCH() const
Definition: ASTWriter.h:796
clang::Expr
This represents one expression.
Definition: Expr.h:109
clang::Preprocessor
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
Definition: Preprocessor.h:129
clang::serialization::DeclID
uint32_t DeclID
An ID number that refers to a declaration in an AST file.
Definition: ASTBitCodes.h:68
clang::ASTWriter::getDeclFieldAbbrev
unsigned getDeclFieldAbbrev() const
Definition: ASTWriter.h:706
clang::ClassTemplateSpecializationDecl
Represents a class template specialization, which refers to a class template with a given set of temp...
Definition: DeclTemplate.h:1798
clang::ASTDeclWriter
Definition: ASTWriterDecl.cpp:34
clang::serialization::SelectorID
uint32_t SelectorID
An ID number that refers to an ObjC selector in an AST file.
Definition: ASTBitCodes.h:153
SemaConsumer.h
clang::ASTWriter::AddToken
void AddToken(const Token &Tok, RecordDataImpl &Record)
Emit a token.
Definition: ASTWriter.cpp:4241
clang::FunctionDecl
Represents a function declaration or definition.
Definition: Decl.h:1821
clang::RecordDecl
Represents a struct/union/class.
Definition: Decl.h:3816
clang::ASTWriter::getDeclCXXMethodAbbrev
unsigned getDeclCXXMethodAbbrev() const
Definition: ASTWriter.h:709
clang::ASTWriter::AddString
void AddString(StringRef Str, RecordDataImpl &Record)
Add a string to the given record.
Definition: ASTWriter.cpp:4254
clang::ASTWriter::SetIdentifierOffset
void SetIdentifierOffset(const IdentifierInfo *II, uint32_t Offset)
Note that the identifier II occurs at the given offset within the identifier table.
Definition: ASTWriter.cpp:4305
clang::ASTWriter::getDeclTypedefAbbrev
unsigned getDeclTypedefAbbrev() const
Definition: ASTWriter.h:704
Type
MatchType Type
Definition: ASTMatchFinder.cpp:70