clang  6.0.0svn
ASTWriter.h
Go to the documentation of this file.
1 //===- ASTWriter.h - AST File Writer ----------------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines the ASTWriter class, which writes an AST file
11 // containing a serialized representation of a translation unit.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_CLANG_SERIALIZATION_ASTWRITER_H
16 #define LLVM_CLANG_SERIALIZATION_ASTWRITER_H
17 
19 #include "clang/AST/Decl.h"
22 #include "clang/AST/TemplateBase.h"
23 #include "clang/AST/TemplateName.h"
24 #include "clang/AST/Type.h"
25 #include "clang/AST/TypeLoc.h"
26 #include "clang/Basic/LLVM.h"
32 #include "llvm/ADT/ArrayRef.h"
33 #include "llvm/ADT/DenseMap.h"
34 #include "llvm/ADT/DenseSet.h"
35 #include "llvm/ADT/MapVector.h"
36 #include "llvm/ADT/SetVector.h"
37 #include "llvm/ADT/SmallVector.h"
38 #include "llvm/ADT/StringRef.h"
39 #include "llvm/Bitcode/BitstreamWriter.h"
40 #include <cassert>
41 #include <cstddef>
42 #include <cstdint>
43 #include <ctime>
44 #include <memory>
45 #include <queue>
46 #include <string>
47 #include <utility>
48 #include <vector>
49 
50 namespace llvm {
51 
52 class APFloat;
53 class APInt;
54 class APSInt;
55 
56 } // namespace llvm
57 
58 namespace clang {
59 
60 class ASTContext;
61 class ASTReader;
62 class ASTUnresolvedSet;
63 class Attr;
64 class CXXBaseSpecifier;
65 class CXXCtorInitializer;
66 class CXXRecordDecl;
67 class CXXTemporary;
68 class FileEntry;
69 class FPOptions;
70 class FunctionDecl;
71 class HeaderSearch;
72 class HeaderSearchOptions;
73 class IdentifierResolver;
74 class LangOptions;
75 class MacroDefinitionRecord;
76 class MacroInfo;
77 class MemoryBufferCache;
78 class Module;
79 class ModuleFileExtension;
80 class ModuleFileExtensionWriter;
81 class NamedDecl;
82 class NestedNameSpecifier;
83 class ObjCInterfaceDecl;
84 class PreprocessingRecord;
85 class Preprocessor;
86 struct QualifierInfo;
87 class RecordDecl;
88 class Sema;
89 class SourceManager;
90 class Stmt;
91 struct StoredDeclsList;
92 class SwitchCase;
93 class TemplateParameterList;
94 class Token;
95 class TypeSourceInfo;
96 class VersionTuple;
97 
98 /// \brief Writes an AST file containing the contents of a translation unit.
99 ///
100 /// The ASTWriter class produces a bitstream containing the serialized
101 /// representation of a given abstract syntax tree and its supporting
102 /// data structures. This bitstream can be de-serialized via an
103 /// instance of the ASTReader class.
105  public ASTMutationListener {
106 public:
107  friend class ASTDeclWriter;
108  friend class ASTRecordWriter;
109  friend class ASTStmtWriter;
110  friend class ASTTypeWriter;
111 
115 
116 private:
117  /// \brief Map that provides the ID numbers of each type within the
118  /// output stream, plus those deserialized from a chained PCH.
119  ///
120  /// The ID numbers of types are consecutive (in order of discovery)
121  /// and start at 1. 0 is reserved for NULL. When types are actually
122  /// stored in the stream, the ID number is shifted by 2 bits to
123  /// allow for the const/volatile qualifiers.
124  ///
125  /// Keys in the map never have const/volatile qualifiers.
126  using TypeIdxMap = llvm::DenseMap<QualType, serialization::TypeIdx,
128 
129  /// \brief The bitstream writer used to emit this precompiled header.
130  llvm::BitstreamWriter &Stream;
131 
132  /// The buffer associated with the bitstream.
133  const SmallVectorImpl<char> &Buffer;
134 
135  /// \brief The PCM manager which manages memory buffers for pcm files.
136  MemoryBufferCache &PCMCache;
137 
138  /// \brief The ASTContext we're writing.
139  ASTContext *Context = nullptr;
140 
141  /// \brief The preprocessor we're writing.
142  Preprocessor *PP = nullptr;
143 
144  /// \brief The reader of existing AST files, if we're chaining.
145  ASTReader *Chain = nullptr;
146 
147  /// \brief The module we're currently writing, if any.
148  Module *WritingModule = nullptr;
149 
150  /// \brief The base directory for any relative paths we emit.
151  std::string BaseDirectory;
152 
153  /// \brief Indicates whether timestamps should be written to the produced
154  /// module file. This is the case for files implicitly written to the
155  /// module cache, where we need the timestamps to determine if the module
156  /// file is up to date, but not otherwise.
157  bool IncludeTimestamps;
158 
159  /// \brief Indicates when the AST writing is actively performing
160  /// serialization, rather than just queueing updates.
161  bool WritingAST = false;
162 
163  /// \brief Indicates that we are done serializing the collection of decls
164  /// and types to emit.
165  bool DoneWritingDeclsAndTypes = false;
166 
167  /// \brief Indicates that the AST contained compiler errors.
168  bool ASTHasCompilerErrors = false;
169 
170  /// \brief Mapping from input file entries to the index into the
171  /// offset table where information about that input file is stored.
172  llvm::DenseMap<const FileEntry *, uint32_t> InputFileIDs;
173 
174  /// \brief Stores a declaration or a type to be written to the AST file.
175  class DeclOrType {
176  public:
177  DeclOrType(Decl *D) : Stored(D), IsType(false) {}
178  DeclOrType(QualType T) : Stored(T.getAsOpaquePtr()), IsType(true) {}
179 
180  bool isType() const { return IsType; }
181  bool isDecl() const { return !IsType; }
182 
183  QualType getType() const {
184  assert(isType() && "Not a type!");
185  return QualType::getFromOpaquePtr(Stored);
186  }
187 
188  Decl *getDecl() const {
189  assert(isDecl() && "Not a decl!");
190  return static_cast<Decl *>(Stored);
191  }
192 
193  private:
194  void *Stored;
195  bool IsType;
196  };
197 
198  /// \brief The declarations and types to emit.
199  std::queue<DeclOrType> DeclTypesToEmit;
200 
201  /// \brief The first ID number we can use for our own declarations.
203 
204  /// \brief The decl ID that will be assigned to the next new decl.
205  serialization::DeclID NextDeclID = FirstDeclID;
206 
207  /// \brief Map that provides the ID numbers of each declaration within
208  /// the output stream, as well as those deserialized from a chained PCH.
209  ///
210  /// The ID numbers of declarations are consecutive (in order of
211  /// discovery) and start at 2. 1 is reserved for the translation
212  /// unit, while 0 is reserved for NULL.
213  llvm::DenseMap<const Decl *, serialization::DeclID> DeclIDs;
214 
215  /// \brief Offset of each declaration in the bitstream, indexed by
216  /// the declaration's ID.
217  std::vector<serialization::DeclOffset> DeclOffsets;
218 
219  /// \brief Sorted (by file offset) vector of pairs of file offset/DeclID.
220  using LocDeclIDsTy =
222  struct DeclIDInFileInfo {
223  LocDeclIDsTy DeclIDs;
224 
225  /// \brief Set when the DeclIDs vectors from all files are joined, this
226  /// indicates the index that this particular vector has in the global one.
227  unsigned FirstDeclIndex;
228  };
229  using FileDeclIDsTy = llvm::DenseMap<FileID, DeclIDInFileInfo *>;
230 
231  /// \brief Map from file SLocEntries to info about the file-level declarations
232  /// that it contains.
233  FileDeclIDsTy FileDeclIDs;
234 
235  void associateDeclWithFile(const Decl *D, serialization::DeclID);
236 
237  /// \brief The first ID number we can use for our own types.
239 
240  /// \brief The type ID that will be assigned to the next new type.
241  serialization::TypeID NextTypeID = FirstTypeID;
242 
243  /// \brief Map that provides the ID numbers of each type within the
244  /// output stream, plus those deserialized from a chained PCH.
245  ///
246  /// The ID numbers of types are consecutive (in order of discovery)
247  /// and start at 1. 0 is reserved for NULL. When types are actually
248  /// stored in the stream, the ID number is shifted by 2 bits to
249  /// allow for the const/volatile qualifiers.
250  ///
251  /// Keys in the map never have const/volatile qualifiers.
252  TypeIdxMap TypeIdxs;
253 
254  /// \brief Offset of each type in the bitstream, indexed by
255  /// the type's ID.
256  std::vector<uint32_t> TypeOffsets;
257 
258  /// \brief The first ID number we can use for our own identifiers.
260 
261  /// \brief The identifier ID that will be assigned to the next new identifier.
262  serialization::IdentID NextIdentID = FirstIdentID;
263 
264  /// \brief Map that provides the ID numbers of each identifier in
265  /// the output stream.
266  ///
267  /// The ID numbers for identifiers are consecutive (in order of
268  /// discovery), starting at 1. An ID of zero refers to a NULL
269  /// IdentifierInfo.
270  llvm::MapVector<const IdentifierInfo *, serialization::IdentID> IdentifierIDs;
271 
272  /// \brief The first ID number we can use for our own macros.
274 
275  /// \brief The identifier ID that will be assigned to the next new identifier.
276  serialization::MacroID NextMacroID = FirstMacroID;
277 
278  /// \brief Map that provides the ID numbers of each macro.
279  llvm::DenseMap<MacroInfo *, serialization::MacroID> MacroIDs;
280 
281  struct MacroInfoToEmitData {
282  const IdentifierInfo *Name;
283  MacroInfo *MI;
285  };
286 
287  /// \brief The macro infos to emit.
288  std::vector<MacroInfoToEmitData> MacroInfosToEmit;
289 
290  llvm::DenseMap<const IdentifierInfo *, uint64_t> IdentMacroDirectivesOffsetMap;
291 
292  /// @name FlushStmt Caches
293  /// @{
294 
295  /// \brief Set of parent Stmts for the currently serializing sub-stmt.
296  llvm::DenseSet<Stmt *> ParentStmts;
297 
298  /// \brief Offsets of sub-stmts already serialized. The offset points
299  /// just after the stmt record.
300  llvm::DenseMap<Stmt *, uint64_t> SubStmtEntries;
301 
302  /// @}
303 
304  /// \brief Offsets of each of the identifier IDs into the identifier
305  /// table.
306  std::vector<uint32_t> IdentifierOffsets;
307 
308  /// \brief The first ID number we can use for our own submodules.
309  serialization::SubmoduleID FirstSubmoduleID =
311 
312  /// \brief The submodule ID that will be assigned to the next new submodule.
313  serialization::SubmoduleID NextSubmoduleID = FirstSubmoduleID;
314 
315  /// \brief The first ID number we can use for our own selectors.
316  serialization::SelectorID FirstSelectorID =
318 
319  /// \brief The selector ID that will be assigned to the next new selector.
320  serialization::SelectorID NextSelectorID = FirstSelectorID;
321 
322  /// \brief Map that provides the ID numbers of each Selector.
323  llvm::MapVector<Selector, serialization::SelectorID> SelectorIDs;
324 
325  /// \brief Offset of each selector within the method pool/selector
326  /// table, indexed by the Selector ID (-1).
327  std::vector<uint32_t> SelectorOffsets;
328 
329  /// \brief Mapping from macro definitions (as they occur in the preprocessing
330  /// record) to the macro IDs.
331  llvm::DenseMap<const MacroDefinitionRecord *,
332  serialization::PreprocessedEntityID> MacroDefinitions;
333 
334  /// \brief Cache of indices of anonymous declarations within their lexical
335  /// contexts.
336  llvm::DenseMap<const Decl *, unsigned> AnonymousDeclarationNumbers;
337 
338  /// An update to a Decl.
339  class DeclUpdate {
340  /// A DeclUpdateKind.
341  unsigned Kind;
342  union {
343  const Decl *Dcl;
344  void *Type;
345  unsigned Loc;
346  unsigned Val;
347  Module *Mod;
348  const Attr *Attribute;
349  };
350 
351  public:
352  DeclUpdate(unsigned Kind) : Kind(Kind), Dcl(nullptr) {}
353  DeclUpdate(unsigned Kind, const Decl *Dcl) : Kind(Kind), Dcl(Dcl) {}
354  DeclUpdate(unsigned Kind, QualType Type)
355  : Kind(Kind), Type(Type.getAsOpaquePtr()) {}
356  DeclUpdate(unsigned Kind, SourceLocation Loc)
357  : Kind(Kind), Loc(Loc.getRawEncoding()) {}
358  DeclUpdate(unsigned Kind, unsigned Val) : Kind(Kind), Val(Val) {}
359  DeclUpdate(unsigned Kind, Module *M) : Kind(Kind), Mod(M) {}
360  DeclUpdate(unsigned Kind, const Attr *Attribute)
361  : Kind(Kind), Attribute(Attribute) {}
362 
363  unsigned getKind() const { return Kind; }
364  const Decl *getDecl() const { return Dcl; }
365  QualType getType() const { return QualType::getFromOpaquePtr(Type); }
366 
367  SourceLocation getLoc() const {
368  return SourceLocation::getFromRawEncoding(Loc);
369  }
370 
371  unsigned getNumber() const { return Val; }
372  Module *getModule() const { return Mod; }
373  const Attr *getAttr() const { return Attribute; }
374  };
375 
377  using DeclUpdateMap = llvm::MapVector<const Decl *, UpdateRecord>;
378 
379  /// \brief Mapping from declarations that came from a chained PCH to the
380  /// record containing modifications to them.
381  DeclUpdateMap DeclUpdates;
382 
383  using FirstLatestDeclMap = llvm::DenseMap<Decl *, Decl *>;
384 
385  /// \brief Map of first declarations from a chained PCH that point to the
386  /// most recent declarations in another PCH.
387  FirstLatestDeclMap FirstLatestDecls;
388 
389  /// \brief Declarations encountered that might be external
390  /// definitions.
391  ///
392  /// We keep track of external definitions and other 'interesting' declarations
393  /// as we are emitting declarations to the AST file. The AST file contains a
394  /// separate record for these declarations, which are provided to the AST
395  /// consumer by the AST reader. This is behavior is required to properly cope with,
396  /// e.g., tentative variable definitions that occur within
397  /// headers. The declarations themselves are stored as declaration
398  /// IDs, since they will be written out to an EAGERLY_DESERIALIZED_DECLS
399  /// record.
400  SmallVector<uint64_t, 16> EagerlyDeserializedDecls;
401  SmallVector<uint64_t, 16> ModularCodegenDecls;
402 
403  /// \brief DeclContexts that have received extensions since their serialized
404  /// form.
405  ///
406  /// For namespaces, when we're chaining and encountering a namespace, we check
407  /// if its primary namespace comes from the chain. If it does, we add the
408  /// primary to this set, so that we can write out lexical content updates for
409  /// it.
411 
412  /// \brief Keeps track of declarations that we must emit, even though we're
413  /// not guaranteed to be able to find them by walking the AST starting at the
414  /// translation unit.
415  SmallVector<const Decl *, 16> DeclsToEmitEvenIfUnreferenced;
416 
417  /// \brief The set of Objective-C class that have categories we
418  /// should serialize.
419  llvm::SetVector<ObjCInterfaceDecl *> ObjCClassesWithCategories;
420 
421  /// \brief The set of declarations that may have redeclaration chains that
422  /// need to be serialized.
424 
425  /// \brief A cache of the first local declaration for "interesting"
426  /// redeclaration chains.
427  llvm::DenseMap<const Decl *, const Decl *> FirstLocalDeclCache;
428 
429  /// \brief Mapping from SwitchCase statements to IDs.
430  llvm::DenseMap<SwitchCase *, unsigned> SwitchCaseIDs;
431 
432  /// \brief The number of statements written to the AST file.
433  unsigned NumStatements = 0;
434 
435  /// \brief The number of macros written to the AST file.
436  unsigned NumMacros = 0;
437 
438  /// \brief The number of lexical declcontexts written to the AST
439  /// file.
440  unsigned NumLexicalDeclContexts = 0;
441 
442  /// \brief The number of visible declcontexts written to the AST
443  /// file.
444  unsigned NumVisibleDeclContexts = 0;
445 
446  /// \brief A mapping from each known submodule to its ID number, which will
447  /// be a positive integer.
448  llvm::DenseMap<Module *, unsigned> SubmoduleIDs;
449 
450  /// \brief A list of the module file extension writers.
451  std::vector<std::unique_ptr<ModuleFileExtensionWriter>>
452  ModuleFileExtensionWriters;
453 
454  /// \brief Retrieve or create a submodule ID for this module.
455  unsigned getSubmoduleID(Module *Mod);
456 
457  /// \brief Write the given subexpression to the bitstream.
458  void WriteSubStmt(Stmt *S);
459 
460  void WriteBlockInfoBlock();
461  void WriteControlBlock(Preprocessor &PP, ASTContext &Context,
462  StringRef isysroot, const std::string &OutputFile);
463 
464  /// Write out the signature and diagnostic options, and return the signature.
465  ASTFileSignature writeUnhashedControlBlock(Preprocessor &PP,
466  ASTContext &Context);
467 
468  /// Calculate hash of the pcm content.
469  static ASTFileSignature createSignature(StringRef Bytes);
470 
471  void WriteInputFiles(SourceManager &SourceMgr, HeaderSearchOptions &HSOpts,
472  bool Modules);
473  void WriteSourceManagerBlock(SourceManager &SourceMgr,
474  const Preprocessor &PP);
475  void WritePreprocessor(const Preprocessor &PP, bool IsModule);
476  void WriteHeaderSearch(const HeaderSearch &HS);
477  void WritePreprocessorDetail(PreprocessingRecord &PPRec);
478  void WriteSubmodules(Module *WritingModule);
479 
480  void WritePragmaDiagnosticMappings(const DiagnosticsEngine &Diag,
481  bool isModule);
482 
483  unsigned TypeExtQualAbbrev = 0;
484  unsigned TypeFunctionProtoAbbrev = 0;
485  void WriteTypeAbbrevs();
486  void WriteType(QualType T);
487 
488  bool isLookupResultExternal(StoredDeclsList &Result, DeclContext *DC);
489  bool isLookupResultEntirelyExternal(StoredDeclsList &Result, DeclContext *DC);
490 
491  void GenerateNameLookupTable(const DeclContext *DC,
492  llvm::SmallVectorImpl<char> &LookupTable);
493  uint64_t WriteDeclContextLexicalBlock(ASTContext &Context, DeclContext *DC);
494  uint64_t WriteDeclContextVisibleBlock(ASTContext &Context, DeclContext *DC);
495  void WriteTypeDeclOffsets();
496  void WriteFileDeclIDsMap();
497  void WriteComments();
498  void WriteSelectors(Sema &SemaRef);
499  void WriteReferencedSelectorsPool(Sema &SemaRef);
500  void WriteIdentifierTable(Preprocessor &PP, IdentifierResolver &IdResolver,
501  bool IsModule);
502  void WriteDeclUpdatesBlocks(RecordDataImpl &OffsetsRecord);
503  void WriteDeclContextVisibleUpdate(const DeclContext *DC);
504  void WriteFPPragmaOptions(const FPOptions &Opts);
505  void WriteOpenCLExtensions(Sema &SemaRef);
506  void WriteOpenCLExtensionTypes(Sema &SemaRef);
507  void WriteOpenCLExtensionDecls(Sema &SemaRef);
508  void WriteCUDAPragmas(Sema &SemaRef);
509  void WriteObjCCategories();
510  void WriteLateParsedTemplates(Sema &SemaRef);
511  void WriteOptimizePragmaOptions(Sema &SemaRef);
512  void WriteMSStructPragmaOptions(Sema &SemaRef);
513  void WriteMSPointersToMembersPragmaOptions(Sema &SemaRef);
514  void WritePackPragmaOptions(Sema &SemaRef);
515  void WriteModuleFileExtension(Sema &SemaRef,
516  ModuleFileExtensionWriter &Writer);
517 
518  unsigned DeclParmVarAbbrev = 0;
519  unsigned DeclContextLexicalAbbrev = 0;
520  unsigned DeclContextVisibleLookupAbbrev = 0;
521  unsigned UpdateVisibleAbbrev = 0;
522  unsigned DeclRecordAbbrev = 0;
523  unsigned DeclTypedefAbbrev = 0;
524  unsigned DeclVarAbbrev = 0;
525  unsigned DeclFieldAbbrev = 0;
526  unsigned DeclEnumAbbrev = 0;
527  unsigned DeclObjCIvarAbbrev = 0;
528  unsigned DeclCXXMethodAbbrev = 0;
529 
530  unsigned DeclRefExprAbbrev = 0;
531  unsigned CharacterLiteralAbbrev = 0;
532  unsigned IntegerLiteralAbbrev = 0;
533  unsigned ExprImplicitCastAbbrev = 0;
534 
535  void WriteDeclAbbrevs();
536  void WriteDecl(ASTContext &Context, Decl *D);
537 
538  ASTFileSignature WriteASTCore(Sema &SemaRef, StringRef isysroot,
539  const std::string &OutputFile,
540  Module *WritingModule);
541 
542 public:
543  /// \brief Create a new precompiled header writer that outputs to
544  /// the given bitstream.
545  ASTWriter(llvm::BitstreamWriter &Stream, SmallVectorImpl<char> &Buffer,
546  MemoryBufferCache &PCMCache,
547  ArrayRef<std::shared_ptr<ModuleFileExtension>> Extensions,
548  bool IncludeTimestamps = true);
549  ~ASTWriter() override;
550 
551  const LangOptions &getLangOpts() const;
552 
553  /// \brief Get a timestamp for output into the AST file. The actual timestamp
554  /// of the specified file may be ignored if we have been instructed to not
555  /// include timestamps in the output file.
556  time_t getTimestampForOutput(const FileEntry *E) const;
557 
558  /// \brief Write a precompiled header for the given semantic analysis.
559  ///
560  /// \param SemaRef a reference to the semantic analysis object that processed
561  /// the AST to be written into the precompiled header.
562  ///
563  /// \param WritingModule The module that we are writing. If null, we are
564  /// writing a precompiled header.
565  ///
566  /// \param isysroot if non-empty, write a relocatable file whose headers
567  /// are relative to the given system root. If we're writing a module, its
568  /// build directory will be used in preference to this if both are available.
569  ///
570  /// \return the module signature, which eventually will be a hash of
571  /// the module but currently is merely a random 32-bit number.
572  ASTFileSignature WriteAST(Sema &SemaRef, const std::string &OutputFile,
573  Module *WritingModule, StringRef isysroot,
574  bool hasErrors = false);
575 
576  /// \brief Emit a token.
577  void AddToken(const Token &Tok, RecordDataImpl &Record);
578 
579  /// \brief Emit a source location.
580  void AddSourceLocation(SourceLocation Loc, RecordDataImpl &Record);
581 
582  /// \brief Emit a source range.
583  void AddSourceRange(SourceRange Range, RecordDataImpl &Record);
584 
585  /// \brief Emit a reference to an identifier.
586  void AddIdentifierRef(const IdentifierInfo *II, RecordDataImpl &Record);
587 
588  /// \brief Get the unique number used to refer to the given selector.
589  serialization::SelectorID getSelectorRef(Selector Sel);
590 
591  /// \brief Get the unique number used to refer to the given identifier.
592  serialization::IdentID getIdentifierRef(const IdentifierInfo *II);
593 
594  /// \brief Get the unique number used to refer to the given macro.
595  serialization::MacroID getMacroRef(MacroInfo *MI, const IdentifierInfo *Name);
596 
597  /// \brief Determine the ID of an already-emitted macro.
598  serialization::MacroID getMacroID(MacroInfo *MI);
599 
600  uint64_t getMacroDirectivesOffset(const IdentifierInfo *Name);
601 
602  /// \brief Emit a reference to a type.
603  void AddTypeRef(QualType T, RecordDataImpl &Record);
604 
605  /// \brief Force a type to be emitted and get its ID.
606  serialization::TypeID GetOrCreateTypeID(QualType T);
607 
608  /// \brief Determine the type ID of an already-emitted type.
609  serialization::TypeID getTypeID(QualType T) const;
610 
611  /// \brief Find the first local declaration of a given local redeclarable
612  /// decl.
613  const Decl *getFirstLocalDecl(const Decl *D);
614 
615  /// \brief Is this a local declaration (that is, one that will be written to
616  /// our AST file)? This is the case for declarations that are neither imported
617  /// from another AST file nor predefined.
618  bool IsLocalDecl(const Decl *D) {
619  if (D->isFromASTFile())
620  return false;
621  auto I = DeclIDs.find(D);
622  return (I == DeclIDs.end() ||
624  };
625 
626  /// \brief Emit a reference to a declaration.
627  void AddDeclRef(const Decl *D, RecordDataImpl &Record);
628 
629  /// \brief Force a declaration to be emitted and get its ID.
630  serialization::DeclID GetDeclRef(const Decl *D);
631 
632  /// \brief Determine the declaration ID of an already-emitted
633  /// declaration.
634  serialization::DeclID getDeclID(const Decl *D);
635 
636  unsigned getAnonymousDeclarationNumber(const NamedDecl *D);
637 
638  /// \brief Add a string to the given record.
639  void AddString(StringRef Str, RecordDataImpl &Record);
640 
641  /// \brief Convert a path from this build process into one that is appropriate
642  /// for emission in the module file.
643  bool PreparePathForOutput(SmallVectorImpl<char> &Path);
644 
645  /// \brief Add a path to the given record.
646  void AddPath(StringRef Path, RecordDataImpl &Record);
647 
648  /// \brief Emit the current record with the given path as a blob.
649  void EmitRecordWithPath(unsigned Abbrev, RecordDataRef Record,
650  StringRef Path);
651 
652  /// \brief Add a version tuple to the given record
653  void AddVersionTuple(const VersionTuple &Version, RecordDataImpl &Record);
654 
655  /// \brief Retrieve or create a submodule ID for this module, or return 0 if
656  /// the submodule is neither local (a submodle of the currently-written module)
657  /// nor from an imported module.
658  unsigned getLocalOrImportedSubmoduleID(Module *Mod);
659 
660  /// \brief Note that the identifier II occurs at the given offset
661  /// within the identifier table.
662  void SetIdentifierOffset(const IdentifierInfo *II, uint32_t Offset);
663 
664  /// \brief Note that the selector Sel occurs at the given offset
665  /// within the method pool/selector table.
666  void SetSelectorOffset(Selector Sel, uint32_t Offset);
667 
668  /// \brief Record an ID for the given switch-case statement.
669  unsigned RecordSwitchCaseID(SwitchCase *S);
670 
671  /// \brief Retrieve the ID for the given switch-case statement.
672  unsigned getSwitchCaseID(SwitchCase *S);
673 
674  void ClearSwitchCaseIDs();
675 
676  unsigned getTypeExtQualAbbrev() const {
677  return TypeExtQualAbbrev;
678  }
679 
680  unsigned getTypeFunctionProtoAbbrev() const {
681  return TypeFunctionProtoAbbrev;
682  }
683 
684  unsigned getDeclParmVarAbbrev() const { return DeclParmVarAbbrev; }
685  unsigned getDeclRecordAbbrev() const { return DeclRecordAbbrev; }
686  unsigned getDeclTypedefAbbrev() const { return DeclTypedefAbbrev; }
687  unsigned getDeclVarAbbrev() const { return DeclVarAbbrev; }
688  unsigned getDeclFieldAbbrev() const { return DeclFieldAbbrev; }
689  unsigned getDeclEnumAbbrev() const { return DeclEnumAbbrev; }
690  unsigned getDeclObjCIvarAbbrev() const { return DeclObjCIvarAbbrev; }
691  unsigned getDeclCXXMethodAbbrev() const { return DeclCXXMethodAbbrev; }
692 
693  unsigned getDeclRefExprAbbrev() const { return DeclRefExprAbbrev; }
694  unsigned getCharacterLiteralAbbrev() const { return CharacterLiteralAbbrev; }
695  unsigned getIntegerLiteralAbbrev() const { return IntegerLiteralAbbrev; }
696  unsigned getExprImplicitCastAbbrev() const { return ExprImplicitCastAbbrev; }
697 
698  bool hasChain() const { return Chain; }
699  ASTReader *getChain() const { return Chain; }
700 
701 private:
702  // ASTDeserializationListener implementation
703  void ReaderInitialized(ASTReader *Reader) override;
704  void IdentifierRead(serialization::IdentID ID, IdentifierInfo *II) override;
705  void MacroRead(serialization::MacroID ID, MacroInfo *MI) override;
706  void TypeRead(serialization::TypeIdx Idx, QualType T) override;
707  void SelectorRead(serialization::SelectorID ID, Selector Sel) override;
708  void MacroDefinitionRead(serialization::PreprocessedEntityID ID,
709  MacroDefinitionRecord *MD) override;
710  void ModuleRead(serialization::SubmoduleID ID, Module *Mod) override;
711 
712  // ASTMutationListener implementation.
713  void CompletedTagDefinition(const TagDecl *D) override;
714  void AddedVisibleDecl(const DeclContext *DC, const Decl *D) override;
715  void AddedCXXImplicitMember(const CXXRecordDecl *RD, const Decl *D) override;
716  void AddedCXXTemplateSpecialization(
717  const ClassTemplateDecl *TD,
718  const ClassTemplateSpecializationDecl *D) override;
719  void AddedCXXTemplateSpecialization(
720  const VarTemplateDecl *TD,
721  const VarTemplateSpecializationDecl *D) override;
722  void AddedCXXTemplateSpecialization(const FunctionTemplateDecl *TD,
723  const FunctionDecl *D) override;
724  void ResolvedExceptionSpec(const FunctionDecl *FD) override;
725  void DeducedReturnType(const FunctionDecl *FD, QualType ReturnType) override;
726  void ResolvedOperatorDelete(const CXXDestructorDecl *DD,
727  const FunctionDecl *Delete,
728  Expr *ThisArg) override;
729  void CompletedImplicitDefinition(const FunctionDecl *D) override;
730  void InstantiationRequested(const ValueDecl *D) override;
731  void VariableDefinitionInstantiated(const VarDecl *D) override;
732  void FunctionDefinitionInstantiated(const FunctionDecl *D) override;
733  void DefaultArgumentInstantiated(const ParmVarDecl *D) override;
734  void DefaultMemberInitializerInstantiated(const FieldDecl *D) override;
735  void AddedObjCCategoryToInterface(const ObjCCategoryDecl *CatD,
736  const ObjCInterfaceDecl *IFD) override;
737  void DeclarationMarkedUsed(const Decl *D) override;
738  void DeclarationMarkedOpenMPThreadPrivate(const Decl *D) override;
739  void DeclarationMarkedOpenMPDeclareTarget(const Decl *D,
740  const Attr *Attr) override;
741  void RedefinedHiddenDefinition(const NamedDecl *D, Module *M) override;
742  void AddedAttributeToRecord(const Attr *Attr,
743  const RecordDecl *Record) override;
744 };
745 
746 /// \brief An object for streaming information to a record.
748  ASTWriter *Writer;
750 
751  /// \brief Statements that we've encountered while serializing a
752  /// declaration or type.
753  SmallVector<Stmt *, 16> StmtsToEmit;
754 
755  /// \brief Indices of record elements that describe offsets within the
756  /// bitcode. These will be converted to offsets relative to the current
757  /// record when emitted.
758  SmallVector<unsigned, 8> OffsetIndices;
759 
760  /// \brief Flush all of the statements and expressions that have
761  /// been added to the queue via AddStmt().
762  void FlushStmts();
763  void FlushSubStmts();
764 
765  void PrepareToEmit(uint64_t MyOffset) {
766  // Convert offsets into relative form.
767  for (unsigned I : OffsetIndices) {
768  auto &StoredOffset = (*Record)[I];
769  assert(StoredOffset < MyOffset && "invalid offset");
770  if (StoredOffset)
771  StoredOffset = MyOffset - StoredOffset;
772  }
773  OffsetIndices.clear();
774  }
775 
776 public:
777  /// Construct a ASTRecordWriter that uses the default encoding scheme.
779  : Writer(&Writer), Record(&Record) {}
780 
781  /// Construct a ASTRecordWriter that uses the same encoding scheme as another
782  /// ASTRecordWriter.
784  : Writer(Parent.Writer), Record(&Record) {}
785 
786  /// Copying an ASTRecordWriter is almost certainly a bug.
787  ASTRecordWriter(const ASTRecordWriter &) = delete;
788  ASTRecordWriter &operator=(const ASTRecordWriter &) = delete;
789 
790  /// \brief Extract the underlying record storage.
791  ASTWriter::RecordDataImpl &getRecordData() const { return *Record; }
792 
793  /// \brief Minimal vector-like interface.
794  /// @{
795  void push_back(uint64_t N) { Record->push_back(N); }
796  template<typename InputIterator>
797  void append(InputIterator begin, InputIterator end) {
798  Record->append(begin, end);
799  }
800  bool empty() const { return Record->empty(); }
801  size_t size() const { return Record->size(); }
802  uint64_t &operator[](size_t N) { return (*Record)[N]; }
803  /// @}
804 
805  /// \brief Emit the record to the stream, followed by its substatements, and
806  /// return its offset.
807  // FIXME: Allow record producers to suggest Abbrevs.
808  uint64_t Emit(unsigned Code, unsigned Abbrev = 0) {
809  uint64_t Offset = Writer->Stream.GetCurrentBitNo();
810  PrepareToEmit(Offset);
811  Writer->Stream.EmitRecord(Code, *Record, Abbrev);
812  FlushStmts();
813  return Offset;
814  }
815 
816  /// \brief Emit the record to the stream, preceded by its substatements.
817  uint64_t EmitStmt(unsigned Code, unsigned Abbrev = 0) {
818  FlushSubStmts();
819  PrepareToEmit(Writer->Stream.GetCurrentBitNo());
820  Writer->Stream.EmitRecord(Code, *Record, Abbrev);
821  return Writer->Stream.GetCurrentBitNo();
822  }
823 
824  /// \brief Add a bit offset into the record. This will be converted into an
825  /// offset relative to the current record when emitted.
826  void AddOffset(uint64_t BitOffset) {
827  OffsetIndices.push_back(Record->size());
828  Record->push_back(BitOffset);
829  }
830 
831  /// \brief Add the given statement or expression to the queue of
832  /// statements to emit.
833  ///
834  /// This routine should be used when emitting types and declarations
835  /// that have expressions as part of their formulation. Once the
836  /// type or declaration has been written, Emit() will write
837  /// the corresponding statements just after the record.
838  void AddStmt(Stmt *S) {
839  StmtsToEmit.push_back(S);
840  }
841 
842  /// \brief Add a definition for the given function to the queue of statements
843  /// to emit.
844  void AddFunctionDefinition(const FunctionDecl *FD);
845 
846  /// \brief Emit a source location.
848  return Writer->AddSourceLocation(Loc, *Record);
849  }
850 
851  /// \brief Emit a source range.
853  return Writer->AddSourceRange(Range, *Record);
854  }
855 
856  /// \brief Emit an integral value.
857  void AddAPInt(const llvm::APInt &Value);
858 
859  /// \brief Emit a signed integral value.
860  void AddAPSInt(const llvm::APSInt &Value);
861 
862  /// \brief Emit a floating-point value.
863  void AddAPFloat(const llvm::APFloat &Value);
864 
865  /// \brief Emit a reference to an identifier.
867  return Writer->AddIdentifierRef(II, *Record);
868  }
869 
870  /// \brief Emit a Selector (which is a smart pointer reference).
871  void AddSelectorRef(Selector S);
872 
873  /// \brief Emit a CXXTemporary.
874  void AddCXXTemporary(const CXXTemporary *Temp);
875 
876  /// \brief Emit a C++ base specifier.
877  void AddCXXBaseSpecifier(const CXXBaseSpecifier &Base);
878 
879  /// \brief Emit a set of C++ base specifiers.
880  void AddCXXBaseSpecifiers(ArrayRef<CXXBaseSpecifier> Bases);
881 
882  /// \brief Emit a reference to a type.
884  return Writer->AddTypeRef(T, *Record);
885  }
886 
887  /// \brief Emits a reference to a declarator info.
888  void AddTypeSourceInfo(TypeSourceInfo *TInfo);
889 
890  /// \brief Emits a type with source-location information.
891  void AddTypeLoc(TypeLoc TL);
892 
893  /// \brief Emits a template argument location info.
894  void AddTemplateArgumentLocInfo(TemplateArgument::ArgKind Kind,
895  const TemplateArgumentLocInfo &Arg);
896 
897  /// \brief Emits a template argument location.
898  void AddTemplateArgumentLoc(const TemplateArgumentLoc &Arg);
899 
900  /// \brief Emits an AST template argument list info.
901  void AddASTTemplateArgumentListInfo(
902  const ASTTemplateArgumentListInfo *ASTTemplArgList);
903 
904  /// \brief Emit a reference to a declaration.
905  void AddDeclRef(const Decl *D) {
906  return Writer->AddDeclRef(D, *Record);
907  }
908 
909  /// \brief Emit a declaration name.
910  void AddDeclarationName(DeclarationName Name);
911 
912  void AddDeclarationNameLoc(const DeclarationNameLoc &DNLoc,
913  DeclarationName Name);
914  void AddDeclarationNameInfo(const DeclarationNameInfo &NameInfo);
915 
916  void AddQualifierInfo(const QualifierInfo &Info);
917 
918  /// \brief Emit a nested name specifier.
919  void AddNestedNameSpecifier(NestedNameSpecifier *NNS);
920 
921  /// \brief Emit a nested name specifier with source-location information.
922  void AddNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS);
923 
924  /// \brief Emit a template name.
925  void AddTemplateName(TemplateName Name);
926 
927  /// \brief Emit a template argument.
928  void AddTemplateArgument(const TemplateArgument &Arg);
929 
930  /// \brief Emit a template parameter list.
931  void AddTemplateParameterList(const TemplateParameterList *TemplateParams);
932 
933  /// \brief Emit a template argument list.
934  void AddTemplateArgumentList(const TemplateArgumentList *TemplateArgs);
935 
936  /// \brief Emit a UnresolvedSet structure.
937  void AddUnresolvedSet(const ASTUnresolvedSet &Set);
938 
939  /// \brief Emit a CXXCtorInitializer array.
940  void AddCXXCtorInitializers(ArrayRef<CXXCtorInitializer *> CtorInits);
941 
942  void AddCXXDefinitionData(const CXXRecordDecl *D);
943 
944  /// \brief Emit a string.
945  void AddString(StringRef Str) {
946  return Writer->AddString(Str, *Record);
947  }
948 
949  /// \brief Emit a path.
950  void AddPath(StringRef Path) {
951  return Writer->AddPath(Path, *Record);
952  }
953 
954  /// \brief Emit a version tuple.
955  void AddVersionTuple(const VersionTuple &Version) {
956  return Writer->AddVersionTuple(Version, *Record);
957  }
958 
959  /// \brief Emit a list of attributes.
960  void AddAttributes(ArrayRef<const Attr*> Attrs);
961 };
962 
963 /// \brief AST and semantic-analysis consumer that generates a
964 /// precompiled header from the parsed source code.
965 class PCHGenerator : public SemaConsumer {
966  const Preprocessor &PP;
967  std::string OutputFile;
968  std::string isysroot;
969  Sema *SemaPtr;
970  std::shared_ptr<PCHBuffer> Buffer;
971  llvm::BitstreamWriter Stream;
972  ASTWriter Writer;
973  bool AllowASTWithErrors;
974 
975 protected:
976  ASTWriter &getWriter() { return Writer; }
977  const ASTWriter &getWriter() const { return Writer; }
978  SmallVectorImpl<char> &getPCH() const { return Buffer->Data; }
979 
980 public:
981  PCHGenerator(const Preprocessor &PP, StringRef OutputFile, StringRef isysroot,
982  std::shared_ptr<PCHBuffer> Buffer,
983  ArrayRef<std::shared_ptr<ModuleFileExtension>> Extensions,
984  bool AllowASTWithErrors = false, bool IncludeTimestamps = true);
985  ~PCHGenerator() override;
986 
987  void InitializeSema(Sema &S) override { SemaPtr = &S; }
988  void HandleTranslationUnit(ASTContext &Ctx) override;
989  ASTMutationListener *GetASTMutationListener() override;
990  ASTDeserializationListener *GetASTDeserializationListener() override;
991  bool hasEmittedPCH() const { return Buffer->IsComplete; }
992 };
993 
994 } // namespace clang
995 
996 #endif // LLVM_CLANG_SERIALIZATION_ASTWRITER_H
unsigned getDeclEnumAbbrev() const
Definition: ASTWriter.h:689
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
Definition: Decl.h:1698
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.
Smart pointer class that efficiently represents Objective-C method names.
unsigned getRawEncoding() const
When a SourceLocation itself cannot be used, this returns an (opaque) 32-bit integer encoding for it...
A (possibly-)qualified type.
Definition: Type.h:653
Represents a version number in the form major[.minor[.subminor[.build]]].
Definition: VersionTuple.h:26
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
Definition: Dominators.h:26
A structure for putting "fast"-unqualified QualTypes into a DenseMap.
Definition: ASTBitCodes.h:115
const unsigned NUM_PREDEF_TYPE_IDS
The number of predefined type IDs that are reserved for the PREDEF_TYPE_* constants.
Definition: ASTBitCodes.h:928
Stmt - This represents one statement.
Definition: Stmt.h:66
C Language Family Type Representation.
void InitializeSema(Sema &S) override
Initialize the semantic consumer with the Sema instance being used to perform semantic analysis on th...
Definition: ASTWriter.h:987
const unsigned int NUM_PREDEF_SELECTOR_IDS
The number of predefined selector IDs.
Definition: ASTBitCodes.h:157
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:86
uint64_t & operator[](size_t N)
Definition: ASTWriter.h:802
The base class of the type hierarchy.
Definition: Type.h:1353
Declaration of a variable template.
A container of type source information.
Definition: Decl.h:86
Floating point control options.
Definition: LangOptions.h:208
void AddTypeRef(QualType T, RecordDataImpl &Record)
Emit a reference to a type.
Definition: ASTWriter.cpp:5420
unsigned getDeclRefExprAbbrev() const
Definition: ASTWriter.h:693
uint64_t Emit(unsigned Code, unsigned Abbrev=0)
Emit the record to the stream, followed by its substatements, and return its offset.
Definition: ASTWriter.h:808
VarDecl - An instance of this class is created to represent a variable declaration or definition...
Definition: Decl.h:807
Manage memory buffers across multiple users.
const unsigned int NUM_PREDEF_DECL_IDS
The number of declaration IDs that are predefined.
Definition: ASTBitCodes.h:1173
Represents a variable template specialization, which refers to a variable template with a given set o...
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
Definition: TemplateBase.h:595
Stores a list of template parameters for a TemplateDecl and its derived classes.
Definition: DeclTemplate.h:68
SmallVectorImpl< char > & getPCH() const
Definition: ASTWriter.h:978
ParmVarDecl - Represents a parameter to a function.
Definition: Decl.h:1514
const ASTWriter & getWriter() const
Definition: ASTWriter.h:977
void AddString(StringRef Str)
Emit a string.
Definition: ASTWriter.h:945
void AddSourceRange(SourceRange Range)
Emit a source range.
Definition: ASTWriter.h:852
void AddIdentifierRef(const IdentifierInfo *II, RecordDataImpl &Record)
Emit a reference to an identifier.
Definition: ASTWriter.cpp:5293
bool hasEmittedPCH() const
Definition: ASTWriter.h:991
Base wrapper for a particular "section" of type source info.
Definition: TypeLoc.h:56
RecordDecl - Represents a struct/union/class.
Definition: Decl.h:3482
Represents a class template specialization, which refers to a class template with a given set of temp...
One of these records is kept for each identifier that is lexed.
ASTRecordWriter(ASTRecordWriter &Parent, ASTWriter::RecordDataImpl &Record)
Construct a ASTRecordWriter that uses the same encoding scheme as another ASTRecordWriter.
Definition: ASTWriter.h:783
void AddTypeRef(QualType T)
Emit a reference to a type.
Definition: ASTWriter.h:883
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:149
A C++ nested-name-specifier augmented with source location information.
Record the location of a macro definition.
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
Definition: Decl.h:2461
Token - This structure provides full information about a lexed token.
Definition: Token.h:35
ASTReader * getChain() const
Definition: ASTWriter.h:699
uint32_t MacroID
An ID number that refers to a macro in an AST file.
Definition: ASTBitCodes.h:141
The signature of a module, which is a hash of the AST content.
Definition: Module.h:55
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:48
Describes a module or submodule.
Definition: Module.h:65
unsigned getDeclFieldAbbrev() const
Definition: ASTWriter.h:688
void AddIdentifierRef(const IdentifierInfo *II)
Emit a reference to an identifier.
Definition: ASTWriter.h:866
An abstract interface that should be implemented by clients that read ASTs and then require further s...
Definition: SemaConsumer.h:26
ASTWriter::RecordDataImpl & getRecordData() const
Extract the underlying record storage.
Definition: ASTWriter.h:791
void append(InputIterator begin, InputIterator end)
Definition: ASTWriter.h:797
unsigned getIntegerLiteralAbbrev() const
Definition: ASTWriter.h:695
A record of the steps taken while preprocessing a source file, including the various preprocessing di...
uint32_t Offset
Definition: CacheTokens.cpp:43
const FormatToken & Tok
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
Concrete class used by the front-end to report problems and issues.
Definition: Diagnostic.h:147
void AddSourceRange(SourceRange Range, RecordDataImpl &Record)
Emit a source range.
Definition: ASTWriter.cpp:5273
bool hasChain() const
Definition: ASTWriter.h:698
unsigned getCharacterLiteralAbbrev() const
Definition: ASTWriter.h:694
void * getAsOpaquePtr() const
Definition: Type.h:699
Represents an ObjC class declaration.
Definition: DeclObjC.h:1191
Encapsulates the information needed to find the file referenced by a #include or #include_next, (sub-)framework lookup, etc.
Definition: HeaderSearch.h:148
unsigned getTypeFunctionProtoAbbrev() const
Definition: ASTWriter.h:680
NodeId Parent
Definition: ASTDiff.cpp:192
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:274
void AddPath(StringRef Path, RecordDataImpl &Record)
Add a path to the given record.
Definition: ASTWriter.cpp:4478
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Definition: Decl.h:628
Expr - This represents one expression.
Definition: Expr.h:106
const FunctionProtoType * T
Represents a C++ destructor within a class.
Definition: DeclCXX.h:2620
ArgKind
The kind of template argument we&#39;re storing.
Definition: TemplateBase.h:54
unsigned getDeclRecordAbbrev() const
Definition: ASTWriter.h:685
IdentifierResolver - Keeps track of shadowed decls on enclosing scopes.
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
unsigned getDeclTypedefAbbrev() const
Definition: ASTWriter.h:686
Represents a C++ template name within the type system.
Definition: TemplateName.h:178
Defines the clang::TypeLoc interface and its subclasses.
void AddString(StringRef Str, RecordDataImpl &Record)
Add a string to the given record.
Definition: ASTWriter.cpp:4455
void AddPath(StringRef Path)
Emit a path.
Definition: ASTWriter.h:950
void AddDeclRef(const Decl *D)
Emit a reference to a declaration.
Definition: ASTWriter.h:905
void AddStmt(Stmt *S)
Add the given statement or expression to the queue of statements to emit.
Definition: ASTWriter.h:838
bool empty() const
Definition: ASTWriter.h:800
Abstract base class that writes a module file extension block into a module file. ...
void AddSourceLocation(SourceLocation Loc, RecordDataImpl &Record)
Emit a source location.
Definition: ASTWriter.cpp:5268
void push_back(uint64_t N)
Minimal vector-like interface.
Definition: ASTWriter.h:795
const unsigned int NUM_PREDEF_IDENT_IDS
The number of predefined identifier IDs.
Definition: ASTBitCodes.h:138
uint32_t SubmoduleID
An ID number that refers to a submodule in a module file.
Definition: ASTBitCodes.h:172
QualifierInfo - A struct with extended info about a syntactic name qualifier, to be used for the case...
Definition: Decl.h:653
Kind
Encodes a location in the source.
unsigned getDeclVarAbbrev() const
Definition: ASTWriter.h:687
Represents a C++ temporary.
Definition: ExprCXX.h:1164
void AddOffset(uint64_t BitOffset)
Add a bit offset into the record.
Definition: ASTWriter.h:826
TagDecl - Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:2938
Cached information about one file (either on disk or in the virtual file system). ...
Definition: FileManager.h:59
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
ObjCCategoryDecl - Represents a category declaration.
Definition: DeclObjC.h:2299
unsigned getDeclCXXMethodAbbrev() const
Definition: ASTWriter.h:691
bool isFromASTFile() const
Determine whether this declaration came from an AST file (such as a precompiled header or module) rat...
Definition: DeclBase.h:694
uint32_t TypeID
An ID number that refers to a type in an AST file.
Definition: ASTBitCodes.h:86
void AddVersionTuple(const VersionTuple &Version, RecordDataImpl &Record)
Add a version tuple to the given record.
Definition: ASTWriter.cpp:4491
void AddSourceLocation(SourceLocation Loc)
Emit a source location.
Definition: ASTWriter.h:847
void AddDeclRef(const Decl *D, RecordDataImpl &Record)
Emit a reference to a declaration.
Definition: ASTWriter.cpp:5460
An array of decls optimized for the common case of only containing one entry.
uint32_t PreprocessedEntityID
An ID number that refers to an entity in the detailed preprocessing record.
Definition: ASTBitCodes.h:169
unsigned getExprImplicitCastAbbrev() const
Definition: ASTWriter.h:696
unsigned getTypeExtQualAbbrev() const
Definition: ASTWriter.h:676
DeclarationNameLoc - Additional source/type location info for a declaration name. ...
Represents a template argument.
Definition: TemplateBase.h:51
uint32_t SelectorID
An ID number that refers to an ObjC selector in an AST file.
Definition: ASTBitCodes.h:154
Dataflow Directional Tag Classes.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1252
Reads an AST files chain containing the contents of a translation unit.
Definition: ASTReader.h:358
DeclarationName - The name of a declaration.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
unsigned getDeclParmVarAbbrev() const
Definition: ASTWriter.h:684
uint32_t DeclID
An ID number that refers to a declaration in an AST file.
Definition: ASTBitCodes.h:69
void AddVersionTuple(const VersionTuple &Version)
Emit a version tuple.
Definition: ASTWriter.h:955
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:618
Encapsulates the data about a macro definition (e.g.
Definition: MacroInfo.h:40
Location wrapper for a TemplateArgument.
Definition: TemplateBase.h:450
uint32_t IdentID
An ID number that refers to an identifier in an AST file.
Definition: ASTBitCodes.h:135
An UnresolvedSet-like class which uses the ASTContext&#39;s allocator.
const unsigned int NUM_PREDEF_MACRO_IDS
The number of predefined macro IDs.
Definition: ASTBitCodes.h:151
uint64_t EmitStmt(unsigned Code, unsigned Abbrev=0)
Emit the record to the stream, preceded by its substatements.
Definition: ASTWriter.h:817
Represents a base class of a C++ class.
Definition: DeclCXX.h:191
A template argument list.
Definition: DeclTemplate.h:210
Defines the clang::SourceLocation class and associated facilities.
Represents a C++ struct/union/class.
Definition: DeclCXX.h:299
An object for streaming information to a record.
Definition: ASTWriter.h:747
Location information for a TemplateArgument.
Definition: TemplateBase.h:393
Declaration of a class template.
Writes an AST file containing the contents of a translation unit.
Definition: ASTWriter.h:104
HeaderSearchOptions - Helper class for storing options related to the initialization of the HeaderSea...
static Decl::Kind getKind(const Decl *D)
Definition: DeclBase.cpp:915
size_t size() const
Definition: ASTWriter.h:801
AST and semantic-analysis consumer that generates a precompiled header from the parsed source code...
Definition: ASTWriter.h:965
A trivial tuple used to represent a source range.
NamedDecl - This represents a decl with a name.
Definition: Decl.h:245
ASTWriter & getWriter()
Definition: ASTWriter.h:976
unsigned getDeclObjCIvarAbbrev() const
Definition: ASTWriter.h:690
ASTRecordWriter(ASTWriter &Writer, ASTWriter::RecordDataImpl &Record)
Construct a ASTRecordWriter that uses the default encoding scheme.
Definition: ASTWriter.h:778
This class handles loading and caching of source files into memory.
Declaration of a template function.
Definition: DeclTemplate.h:958
A type index; the type ID with the qualifier bits removed.
Definition: ASTBitCodes.h:89
Attr - This represents one attribute.
Definition: Attr.h:43
const unsigned int NUM_PREDEF_SUBMODULE_IDS
The number of predefined submodule IDs.
Definition: ASTBitCodes.h:175
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
Definition: Preprocessor.h:127