clang 8.0.0

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
18 #include "clang/AST/ASTMutationListener.h"
19 #include "clang/AST/Decl.h"
20 #include "clang/AST/DeclarationName.h"
21 #include "clang/AST/NestedNameSpecifier.h"
22 #include "clang/AST/OpenMPClause.h"
23 #include "clang/AST/TemplateBase.h"
24 #include "clang/AST/TemplateName.h"
25 #include "clang/AST/Type.h"
26 #include "clang/AST/TypeLoc.h"
27 #include "clang/Basic/LLVM.h"
28 #include "clang/Basic/SourceLocation.h"
29 #include "clang/Sema/SemaConsumer.h"
30 #include "clang/Serialization/ASTBitCodes.h"
31 #include "clang/Serialization/ASTDeserializationListener.h"
32 #include "clang/Serialization/PCHContainerOperations.h"
33 #include "llvm/ADT/ArrayRef.h"
34 #include "llvm/ADT/DenseMap.h"
35 #include "llvm/ADT/DenseSet.h"
36 #include "llvm/ADT/MapVector.h"
37 #include "llvm/ADT/SetVector.h"
38 #include "llvm/ADT/SmallVector.h"
39 #include "llvm/ADT/StringRef.h"
40 #include "llvm/Bitcode/BitstreamWriter.h"
41 #include <cassert>
42 #include <cstddef>
43 #include <cstdint>
44 #include <ctime>
45 #include <memory>
46 #include <queue>
47 #include <string>
48 #include <utility>
49 #include <vector>
50
51 namespace llvm {
52
53 class APFloat;
54 class APInt;
55 class APSInt;
56
57 } // namespace llvm
58
59 namespace clang {
60
61 class ASTContext;
62 class ASTReader;
63 class ASTUnresolvedSet;
64 class Attr;
65 class CXXBaseSpecifier;
66 class CXXCtorInitializer;
67 class CXXRecordDecl;
68 class CXXTemporary;
69 class FileEntry;
70 class FPOptions;
71 class FunctionDecl;
72 class HeaderSearch;
73 class HeaderSearchOptions;
74 class IdentifierResolver;
75 class LangOptions;
76 class MacroDefinitionRecord;
77 class MacroInfo;
78 class MemoryBufferCache;
79 class Module;
80 class ModuleFileExtension;
81 class ModuleFileExtensionWriter;
82 class NamedDecl;
83 class NestedNameSpecifier;
84 class ObjCInterfaceDecl;
85 class PreprocessingRecord;
86 class Preprocessor;
87 struct QualifierInfo;
88 class RecordDecl;
89 class Sema;
90 class SourceManager;
91 class Stmt;
92 struct StoredDeclsList;
93 class SwitchCase;
94 class TemplateParameterList;
95 class Token;
96 class TypeSourceInfo;
97
98 /// 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.
104 class ASTWriter : public ASTDeserializationListener,
105 public ASTMutationListener {
106 public:
107 friend class ASTDeclWriter;
108 friend class ASTRecordWriter;
109 friend class ASTStmtWriter;
110 friend class ASTTypeWriter;
111
112 using RecordData = SmallVector<uint64_t, 64>;
113 using RecordDataImpl = SmallVectorImpl<uint64_t>;
114 using RecordDataRef = ArrayRef<uint64_t>;
115
116 private:
117 /// 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,
127 serialization::UnsafeQualTypeDenseMapInfo>;
128
129 /// 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 /// The PCM manager which manages memory buffers for pcm files.
136 MemoryBufferCache &PCMCache;
137
138 /// The ASTContext we're writing.
139 ASTContext *Context = nullptr;
140
141 /// The preprocessor we're writing.
142 Preprocessor *PP = nullptr;
143
144 /// The reader of existing AST files, if we're chaining.
145 ASTReader *Chain = nullptr;
146
147 /// The module we're currently writing, if any.
148 Module *WritingModule = nullptr;
149
150 /// The base directory for any relative paths we emit.
151 std::string BaseDirectory;
152
153 /// 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 /// Indicates when the AST writing is actively performing
160 /// serialization, rather than just queueing updates.
161 bool WritingAST = false;
162
163 /// Indicates that we are done serializing the collection of decls
164 /// and types to emit.
165 bool DoneWritingDeclsAndTypes = false;
166
167 /// Indicates that the AST contained compiler errors.
168 bool ASTHasCompilerErrors = false;
169
170 /// 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 /// 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 /// The declarations and types to emit.
199 std::queue<DeclOrType> DeclTypesToEmit;
200
201 /// The first ID number we can use for our own declarations.
202 serialization::DeclID FirstDeclID = serialization::NUM_PREDEF_DECL_IDS;
203
204 /// The decl ID that will be assigned to the next new decl.
205 serialization::DeclID NextDeclID = FirstDeclID;
206
207 /// 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 /// Offset of each declaration in the bitstream, indexed by
216 /// the declaration's ID.
217 std::vector<serialization::DeclOffset> DeclOffsets;
218
219 /// Sorted (by file offset) vector of pairs of file offset/DeclID.
220 using LocDeclIDsTy =
221 SmallVector<std::pair<unsigned, serialization::DeclID>, 64>;
222 struct DeclIDInFileInfo {
223 LocDeclIDsTy DeclIDs;
224
225 /// 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 /// 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 /// The first ID number we can use for our own types.
238 serialization::TypeID FirstTypeID = serialization::NUM_PREDEF_TYPE_IDS;
239
240 /// The type ID that will be assigned to the next new type.
241 serialization::TypeID NextTypeID = FirstTypeID;
242
243 /// 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 /// Offset of each type in the bitstream, indexed by
255 /// the type's ID.
256 std::vector<uint32_t> TypeOffsets;
257
258 /// The first ID number we can use for our own identifiers.
259 serialization::IdentID FirstIdentID = serialization::NUM_PREDEF_IDENT_IDS;
260
261 /// The identifier ID that will be assigned to the next new identifier.
262 serialization::IdentID NextIdentID = FirstIdentID;
263
264 /// 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 /// The first ID number we can use for our own macros.
273 serialization::MacroID FirstMacroID = serialization::NUM_PREDEF_MACRO_IDS;
274
275 /// The identifier ID that will be assigned to the next new identifier.
276 serialization::MacroID NextMacroID = FirstMacroID;
277
278 /// 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;
284 serialization::MacroID ID;
285 };
286
287 /// 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 /// Set of parent Stmts for the currently serializing sub-stmt.
296 llvm::DenseSet<Stmt *> ParentStmts;
297
298 /// 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 /// Offsets of each of the identifier IDs into the identifier
305 /// table.
306 std::vector<uint32_t> IdentifierOffsets;
307
308 /// The first ID number we can use for our own submodules.
309 serialization::SubmoduleID FirstSubmoduleID =
310 serialization::NUM_PREDEF_SUBMODULE_IDS;
311
312 /// The submodule ID that will be assigned to the next new submodule.
313 serialization::SubmoduleID NextSubmoduleID = FirstSubmoduleID;
314
315 /// The first ID number we can use for our own selectors.
316 serialization::SelectorID FirstSelectorID =
317 serialization::NUM_PREDEF_SELECTOR_IDS;
318
319 /// The selector ID that will be assigned to the next new selector.
320 serialization::SelectorID NextSelectorID = FirstSelectorID;
321
322 /// Map that provides the ID numbers of each Selector.
323 llvm::MapVector<Selector, serialization::SelectorID> SelectorIDs;
324
325 /// 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 /// 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 /// 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
376 using UpdateRecord = SmallVector<DeclUpdate, 1>;
377 using DeclUpdateMap = llvm::MapVector<const Decl *, UpdateRecord>;
378
379 /// 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 /// Map of first declarations from a chained PCH that point to the
386 /// most recent declarations in another PCH.
387 FirstLatestDeclMap FirstLatestDecls;
388
389 /// 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 /// 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.
410 llvm::SmallSetVector<const DeclContext *, 16> UpdatedDeclContexts;
411
412 /// 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 /// The set of Objective-C class that have categories we
418 /// should serialize.
419 llvm::SetVector<ObjCInterfaceDecl *> ObjCClassesWithCategories;
420
421 /// The set of declarations that may have redeclaration chains that
422 /// need to be serialized.
423 llvm::SmallVector<const Decl *, 16> Redeclarations;
424
425 /// A cache of the first local declaration for "interesting"
426 /// redeclaration chains.
427 llvm::DenseMap<const Decl *, const Decl *> FirstLocalDeclCache;
428
429 /// Mapping from SwitchCase statements to IDs.
430 llvm::DenseMap<SwitchCase *, unsigned> SwitchCaseIDs;
431
432 /// The number of statements written to the AST file.
433 unsigned NumStatements = 0;
434
435 /// The number of macros written to the AST file.
436 unsigned NumMacros = 0;
437
438 /// The number of lexical declcontexts written to the AST
439 /// file.
440 unsigned NumLexicalDeclContexts = 0;
441
442 /// The number of visible declcontexts written to the AST
443 /// file.
444 unsigned NumVisibleDeclContexts = 0;
445
446 /// 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 /// A list of the module file extension writers.
451 std::vector<std::unique_ptr<ModuleFileExtensionWriter>>
452 ModuleFileExtensionWriters;
453
454 /// Retrieve or create a submodule ID for this module.
455 unsigned getSubmoduleID(Module *Mod);
456
457 /// 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 /// 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 /// 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 /// 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 /// Emit a token.
577 void AddToken(const Token &Tok, RecordDataImpl &Record);
578
579 /// Emit a source location.
580 void AddSourceLocation(SourceLocation Loc, RecordDataImpl &Record);
581
582 /// Emit a source range.
583 void AddSourceRange(SourceRange Range, RecordDataImpl &Record);
584
585 /// Emit a reference to an identifier.
586 void AddIdentifierRef(const IdentifierInfo *II, RecordDataImpl &Record);
587
588 /// Get the unique number used to refer to the given selector.
589 serialization::SelectorID getSelectorRef(Selector Sel);
590
591 /// Get the unique number used to refer to the given identifier.
592 serialization::IdentID getIdentifierRef(const IdentifierInfo *II);
593
594 /// Get the unique number used to refer to the given macro.
595 serialization::MacroID getMacroRef(MacroInfo *MI, const IdentifierInfo *Name);
596
597 /// Determine the ID of an already-emitted macro.
598 serialization::MacroID getMacroID(MacroInfo *MI);
599
600 uint64_t getMacroDirectivesOffset(const IdentifierInfo *Name);
601
602 /// Emit a reference to a type.
603 void AddTypeRef(QualType T, RecordDataImpl &Record);
604
605 /// Force a type to be emitted and get its ID.
606 serialization::TypeID GetOrCreateTypeID(QualType T);
607
608 /// Determine the type ID of an already-emitted type.
609 serialization::TypeID getTypeID(QualType T) const;
610
611 /// Find the first local declaration of a given local redeclarable
612 /// decl.
613 const Decl *getFirstLocalDecl(const Decl *D);
614
615 /// 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() ||
623 I->second >= serialization::NUM_PREDEF_DECL_IDS);
624 };
625
626 /// Emit a reference to a declaration.
627 void AddDeclRef(const Decl *D, RecordDataImpl &Record);
628
629 /// Force a declaration to be emitted and get its ID.
630 serialization::DeclID GetDeclRef(const Decl *D);
631
632 /// 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 /// Add a string to the given record.
639 void AddString(StringRef Str, RecordDataImpl &Record);
640
641 /// 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 /// Add a path to the given record.
646 void AddPath(StringRef Path, RecordDataImpl &Record);
647
648 /// Emit the current record with the given path as a blob.
649 void EmitRecordWithPath(unsigned Abbrev, RecordDataRef Record,
650 StringRef Path);
651
652 /// Add a version tuple to the given record
653 void AddVersionTuple(const VersionTuple &Version, RecordDataImpl &Record);
654
655 /// 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 /// 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 /// 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 /// Record an ID for the given switch-case statement.
669 unsigned RecordSwitchCaseID(SwitchCase *S);
670
671 /// 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 /// An object for streaming information to a record.
747 class ASTRecordWriter {
748 ASTWriter *Writer;
749 ASTWriter::RecordDataImpl *Record;
750
751 /// Statements that we've encountered while serializing a
752 /// declaration or type.
753 SmallVector<Stmt *, 16> StmtsToEmit;
754
755 /// 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 /// 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.
778 ASTRecordWriter(ASTWriter &Writer, ASTWriter::RecordDataImpl &Record)
779 : Writer(&Writer), Record(&Record) {}
780
781 /// Construct a ASTRecordWriter that uses the same encoding scheme as another
782 /// ASTRecordWriter.
783 ASTRecordWriter(ASTRecordWriter &Parent, ASTWriter::RecordDataImpl &Record)
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 /// Extract the underlying record storage.
791 ASTWriter::RecordDataImpl &getRecordData() const { return *Record; }
792
793 /// 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 /// 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 /// 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 /// 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 /// 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 /// Add a definition for the given function to the queue of statements
843 /// to emit.
844 void AddFunctionDefinition(const FunctionDecl *FD);
845
846 /// Emit a source location.
847 void AddSourceLocation(SourceLocation Loc) {
848 return Writer->AddSourceLocation(Loc, *Record);
849 }
850
851 /// Emit a source range.
852 void AddSourceRange(SourceRange Range) {
853 return Writer->AddSourceRange(Range, *Record);
854 }
855
856 /// Emit an integral value.
857 void AddAPInt(const llvm::APInt &Value);
858
859 /// Emit a signed integral value.
860 void AddAPSInt(const llvm::APSInt &Value);
861
862 /// Emit a floating-point value.
863 void AddAPFloat(const llvm::APFloat &Value);
864
865 /// Emit a reference to an identifier.
866 void AddIdentifierRef(const IdentifierInfo *II) {
867 return Writer->AddIdentifierRef(II, *Record);
868 }
869
870 /// Emit a Selector (which is a smart pointer reference).
871 void AddSelectorRef(Selector S);
872
873 /// Emit a CXXTemporary.
874 void AddCXXTemporary(const CXXTemporary *Temp);
875
876 /// Emit a C++ base specifier.
877 void AddCXXBaseSpecifier(const CXXBaseSpecifier &Base);
878
879 /// Emit a set of C++ base specifiers.
880 void AddCXXBaseSpecifiers(ArrayRef<CXXBaseSpecifier> Bases);
881
882 /// Emit a reference to a type.
883 void AddTypeRef(QualType T) {
884 return Writer->AddTypeRef(T, *Record);
885 }
886
887 /// Emits a reference to a declarator info.
888 void AddTypeSourceInfo(TypeSourceInfo *TInfo);
889
890 /// Emits source location information for a type. Does not emit the type.
891 void AddTypeLoc(TypeLoc TL);
892
893 /// Emits a template argument location info.
894 void AddTemplateArgumentLocInfo(TemplateArgument::ArgKind Kind,
895 const TemplateArgumentLocInfo &Arg);
896
897 /// Emits a template argument location.
898 void AddTemplateArgumentLoc(const TemplateArgumentLoc &Arg);
899
900 /// Emits an AST template argument list info.
901 void AddASTTemplateArgumentListInfo(
902 const ASTTemplateArgumentListInfo *ASTTemplArgList);
903
904 /// Emit a reference to a declaration.
905 void AddDeclRef(const Decl *D) {
906 return Writer->AddDeclRef(D, *Record);
907 }
908
909 /// 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 /// Emit a nested name specifier.
919 void AddNestedNameSpecifier(NestedNameSpecifier *NNS);
920
921 /// Emit a nested name specifier with source-location information.
922 void AddNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS);
923
924 /// Emit a template name.
925 void AddTemplateName(TemplateName Name);
926
927 /// Emit a template argument.
928 void AddTemplateArgument(const TemplateArgument &Arg);
929
930 /// Emit a template parameter list.
931 void AddTemplateParameterList(const TemplateParameterList *TemplateParams);
932
933 /// Emit a template argument list.
934 void AddTemplateArgumentList(const TemplateArgumentList *TemplateArgs);
935
936 /// Emit a UnresolvedSet structure.
937 void AddUnresolvedSet(const ASTUnresolvedSet &Set);
938
939 /// Emit a CXXCtorInitializer array.
940 void AddCXXCtorInitializers(ArrayRef<CXXCtorInitializer *> CtorInits);
941
942 void AddCXXDefinitionData(const CXXRecordDecl *D);
943
944 /// Emit a string.
945 void AddString(StringRef Str) {
946 return Writer->AddString(Str, *Record);
947 }
948
949 /// Emit a path.
950 void AddPath(StringRef Path) {
951 return Writer->AddPath(Path, *Record);
952 }
953
954 /// Emit a version tuple.
955 void AddVersionTuple(const VersionTuple &Version) {
956 return Writer->AddVersionTuple(Version, *Record);
957 }
958
959 // Emit an attribute.
960 void AddAttr(const Attr *A);
961
962 /// Emit a list of attributes.
963 void AddAttributes(ArrayRef<const Attr*> Attrs);
964 };
965
966 /// AST and semantic-analysis consumer that generates a
967 /// precompiled header from the parsed source code.
968 class PCHGenerator : public SemaConsumer {
969 const Preprocessor &PP;
970 std::string OutputFile;
971 std::string isysroot;
972 Sema *SemaPtr;
973 std::shared_ptr<PCHBuffer> Buffer;
974 llvm::BitstreamWriter Stream;
975 ASTWriter Writer;
976 bool AllowASTWithErrors;
977
978 protected:
979 ASTWriter &getWriter() { return Writer; }
980 const ASTWriter &getWriter() const { return Writer; }
981 SmallVectorImpl<char> &getPCH() const { return Buffer->Data; }
982
983 public:
984 PCHGenerator(const Preprocessor &PP, StringRef OutputFile, StringRef isysroot,
985 std::shared_ptr<PCHBuffer> Buffer,
986 ArrayRef<std::shared_ptr<ModuleFileExtension>> Extensions,
987 bool AllowASTWithErrors = false, bool IncludeTimestamps = true);
988 ~PCHGenerator() override;
989
990 void InitializeSema(Sema &S) override { SemaPtr = &S; }
991 void HandleTranslationUnit(ASTContext &Ctx) override;
992 ASTMutationListener *GetASTMutationListener() override;
993 ASTDeserializationListener *GetASTDeserializationListener() override;
994 bool hasEmittedPCH() const { return Buffer->IsComplete; }
995 };
996
997 class OMPClauseWriter : public OMPClauseVisitor<OMPClauseWriter> {
998 ASTRecordWriter &Record;
999
1000 public:
1001 OMPClauseWriter(ASTRecordWriter &Record) : Record(Record) {}
1002 #define OPENMP_CLAUSE(Name, Class) void Visit##Class(Class *S);
1003 #include "clang/Basic/OpenMPKinds.def"
1004 void writeClause(OMPClause *C);
1005 void VisitOMPClauseWithPreInit(OMPClauseWithPreInit *C);
1006 void VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *C);
1007 };
1008
1009 } // namespace clang
1010
1011 #endif // LLVM_CLANG_SERIALIZATION_ASTWRITER_H
clang::ASTWriter::getDeclEnumAbbrev
unsigned getDeclEnumAbbrev() const
Definition: ASTWriter.h:689
clang::Builtin::ID
ID
Definition: Builtins.h:49
SemaConsumer.h
clang::FunctionDecl
Represents a function declaration or definition.
Definition: Decl.h:1738
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
clang::Selector
Smart pointer class that efficiently represents Objective-C method names.
Definition: IdentifierTable.h:673
clang::SourceLocation::getRawEncoding
unsigned getRawEncoding() const
When a SourceLocation itself cannot be used, this returns an (opaque) 32-bit integer encoding for it...
Definition: SourceLocation.h:146
clang::QualType
A (possibly-)qualified type.
Definition: Type.h:638
ASTDeserializationListener.h
llvm
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
Definition: Dominators.h:30
clang::serialization::UnsafeQualTypeDenseMapInfo
A structure for putting "fast"-unqualified QualTypes into a DenseMap.
Definition: ASTBitCodes.h:115
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:1029
clang::Stmt
Stmt - This represents one statement.
Definition: Stmt.h:66
Base
Type.h
C Language Family Type Representation.
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:990
clang::serialization::NUM_PREDEF_SELECTOR_IDS
const unsigned int NUM_PREDEF_SELECTOR_IDS
The number of predefined selector IDs.
Definition: ASTBitCodes.h:157
clang::Decl
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:87
llvm::DenseSet
Definition: Sema.h:66
clang::ASTRecordWriter::operator[]
uint64_t & operator[](size_t N)
Definition: ASTWriter.h:802
clang::Type
The base class of the type hierarchy.
Definition: Type.h:1407
clang::VarTemplateDecl
Declaration of a variable template.
Definition: DeclTemplate.h:2862
clang::TypeSourceInfo
A container of type source information.
Definition: Decl.h:87
clang::FPOptions
Floating point control options.
Definition: LangOptions.h:307
clang::ASTWriter::AddTypeRef
void AddTypeRef(QualType T, RecordDataImpl &Record)
Emit a reference to a type.
Definition: ASTWriter.cpp:5471
clang::ASTWriter::getDeclRefExprAbbrev
unsigned getDeclRefExprAbbrev() const
Definition: ASTWriter.h:693
clang::ASTRecordWriter::Emit
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
Value
Value
Definition: UninitializedValues.cpp:102
clang::VarDecl
Represents a variable declaration or definition.
Definition: Decl.h:813
clang::MemoryBufferCache
Manage memory buffers across multiple users.
Definition: MemoryBufferCache.h:32
clang::serialization::NUM_PREDEF_DECL_IDS
const unsigned int NUM_PREDEF_DECL_IDS
The number of declaration IDs that are predefined.
Definition: ASTBitCodes.h:1277
clang::VarTemplateSpecializationDecl
Represents a variable template specialization, which refers to a variable template with a given set o...
Definition: DeclTemplate.h:2475
clang::ASTTemplateArgumentListInfo
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
Definition: TemplateBase.h:604
clang::TemplateParameterList
Stores a list of template parameters for a TemplateDecl and its derived classes.
Definition: DeclTemplate.h:68
clang::PCHGenerator::getPCH
SmallVectorImpl< char > & getPCH() const
Definition: ASTWriter.h:981
clang::ParmVarDecl
Represents a parameter to a function.
Definition: Decl.h:1550
clang::PCHGenerator::getWriter
const ASTWriter & getWriter() const
Definition: ASTWriter.h:980
clang::ASTRecordWriter::AddString
void AddString(StringRef Str)
Emit a string.
Definition: ASTWriter.h:945
clang::ASTRecordWriter::AddSourceRange
void AddSourceRange(SourceRange Range)
Emit a source range.
Definition: ASTWriter.h:852
clang::ASTWriter::AddIdentifierRef
void AddIdentifierRef(const IdentifierInfo *II, RecordDataImpl &Record)
Emit a reference to an identifier.
Definition: ASTWriter.cpp:5345
clang::PCHGenerator::hasEmittedPCH
bool hasEmittedPCH() const
Definition: ASTWriter.h:994
clang::TypeLoc
Base wrapper for a particular "section" of type source info.
Definition: TypeLoc.h:57
clang::RecordDecl
Represents a struct/union/class.
Definition: Decl.h:3593
clang::ClassTemplateSpecializationDecl
Represents a class template specialization, which refers to a class template with a given set of temp...
Definition: DeclTemplate.h:1648
clang::IdentifierInfo
One of these records is kept for each identifier that is lexed.
Definition: IdentifierTable.h:58
clang::ASTRecordWriter::ASTRecordWriter
ASTRecordWriter(ASTRecordWriter &Parent, ASTWriter::RecordDataImpl &Record)
Construct a ASTRecordWriter that uses the same encoding scheme as another ASTRecordWriter.
Definition: ASTWriter.h:783
clang::ASTRecordWriter::AddTypeRef
void AddTypeRef(QualType T)
Emit a reference to a type.
Definition: ASTWriter.h:883
clang::ASTContext
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:155
clang::NestedNameSpecifierLoc
A C++ nested-name-specifier augmented with source location information.
Definition: NestedNameSpecifier.h:237
clang::MacroDefinitionRecord
Record the location of a macro definition.
Definition: PreprocessingRecord.h:149
clang::FieldDecl
Represents a member of a struct/union/class.
Definition: Decl.h:2579
clang::Token
Token - This structure provides full information about a lexed token.
Definition: Token.h:35
clang::ASTWriter::getChain
ASTReader * getChain() const
Definition: ASTWriter.h:699
clang::serialization::MacroID
uint32_t MacroID
An ID number that refers to a macro in an AST file.
Definition: ASTBitCodes.h:141
clang::ASTFileSignature
The signature of a module, which is a hash of the AST content.
Definition: Module.h:55
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:50
clang::diff::Delete
Definition: ASTDiff.h:30
clang::Module
Describes a module or submodule.
Definition: Module.h:65
llvm::SmallVectorImpl
Definition: LLVM.h:37
clang::ASTWriter::getDeclFieldAbbrev
unsigned getDeclFieldAbbrev() const
Definition: ASTWriter.h:688
clang::ASTRecordWriter::AddIdentifierRef
void AddIdentifierRef(const IdentifierInfo *II)
Emit a reference to an identifier.
Definition: ASTWriter.h:866
clang::SemaConsumer
An abstract interface that should be implemented by clients that read ASTs and then require further s...
Definition: SemaConsumer.h:26
clang::ASTRecordWriter::getRecordData
ASTWriter::RecordDataImpl & getRecordData() const
Extract the underlying record storage.
Definition: ASTWriter.h:791
clang::ASTRecordWriter::append
void append(InputIterator begin, InputIterator end)
Definition: ASTWriter.h:797
clang::ASTWriter::getIntegerLiteralAbbrev
unsigned getIntegerLiteralAbbrev() const
Definition: ASTWriter.h:695
clang::PreprocessingRecord
A record of the steps taken while preprocessing a source file, including the various preprocessing di...
Definition: PreprocessingRecord.h:309
clang::format::Tok
const FormatToken & Tok
Definition: BreakableToken.h:244
LLVM.h
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
clang::DiagnosticsEngine
Concrete class used by the front-end to report problems and issues.
Definition: Diagnostic.h:149
clang::ASTWriter::AddSourceRange
void AddSourceRange(SourceRange Range, RecordDataImpl &Record)
Emit a source range.
Definition: ASTWriter.cpp:5325
clang::ASTWriter::hasChain
bool hasChain() const
Definition: ASTWriter.h:698
clang::ASTWriter::getCharacterLiteralAbbrev
unsigned getCharacterLiteralAbbrev() const
Definition: ASTWriter.h:694
clang::QualType::getAsOpaquePtr
void * getAsOpaquePtr() const
Definition: Type.h:683
clang::ObjCInterfaceDecl
Represents an ObjC class declaration.
Definition: DeclObjC.h:1172
TemplateName.h
llvm::ArrayRef
Definition: LLVM.h:32
ASTMutationListener.h
clang::HeaderSearch
Encapsulates the information needed to find the file referenced by a #include or #include_next, (sub-)framework lookup, etc.
Definition: HeaderSearch.h:148
clang::ASTWriter::getTypeFunctionProtoAbbrev
unsigned getTypeFunctionProtoAbbrev() const
Definition: ASTWriter.h:680
Parent
NodeId Parent
Definition: ASTDiff.cpp:192
clang::Sema
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:278
clang::ASTStmtWriter
Definition: ASTWriterStmt.cpp:31
clang::ASTWriter::AddPath
void AddPath(StringRef Path, RecordDataImpl &Record)
Add a path to the given record.
Definition: ASTWriter.cpp:4522
Offset
unsigned Offset
Definition: Format.cpp:1631
clang::ValueDecl
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:637
clang::Expr
This represents one expression.
Definition: Expr.h:106
clang::CXXDestructorDecl
Represents a C++ destructor within a class.
Definition: DeclCXX.h:2706
clang::TemplateArgument::ArgKind
ArgKind
The kind of template argument we&#39;re storing.
Definition: TemplateBase.h:54
clang::ASTWriter::getDeclRecordAbbrev
unsigned getDeclRecordAbbrev() const
Definition: ASTWriter.h:685
clang::IdentifierResolver
IdentifierResolver - Keeps track of shadowed decls on enclosing scopes.
Definition: IdentifierResolver.h:39
clang::ASTMutationListener
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
Definition: ASTMutationListener.h:47
clang::SwitchCase
Definition: Stmt.h:1349
clang::OMPClauseWriter::OMPClauseWriter
OMPClauseWriter(ASTRecordWriter &Record)
Definition: ASTWriter.h:1001
clang::ASTWriter::getDeclTypedefAbbrev
unsigned getDeclTypedefAbbrev() const
Definition: ASTWriter.h:686
clang::TemplateName
Represents a C++ template name within the type system.
Definition: TemplateName.h:179
TypeLoc.h
Defines the clang::TypeLoc interface and its subclasses.
clang::ASTWriter::AddString
void AddString(StringRef Str, RecordDataImpl &Record)
Add a string to the given record.
Definition: ASTWriter.cpp:4499
ASTBitCodes.h
clang::ASTRecordWriter::AddPath
void AddPath(StringRef Path)
Emit a path.
Definition: ASTWriter.h:950
clang::ASTRecordWriter::AddDeclRef
void AddDeclRef(const Decl *D)
Emit a reference to a declaration.
Definition: ASTWriter.h:905
clang::ASTRecordWriter::AddStmt
void AddStmt(Stmt *S)
Add the given statement or expression to the queue of statements to emit.
Definition: ASTWriter.h:838
clang::ASTRecordWriter::empty
bool empty() const
Definition: ASTWriter.h:800
clang::ModuleFileExtensionWriter
Abstract base class that writes a module file extension block into a module file. ...
Definition: ModuleFileExtension.h:105
clang::ASTDeserializationListener
Definition: ASTDeserializationListener.h:31
OpenMPClause.h
This file defines OpenMP AST classes for clauses.
clang::ASTWriter::AddSourceLocation
void AddSourceLocation(SourceLocation Loc, RecordDataImpl &Record)
Emit a source location.
Definition: ASTWriter.cpp:5320
clang::ASTRecordWriter::push_back
void push_back(uint64_t N)
Minimal vector-like interface.
Definition: ASTWriter.h:795
clang::serialization::NUM_PREDEF_IDENT_IDS
const unsigned int NUM_PREDEF_IDENT_IDS
The number of predefined identifier IDs.
Definition: ASTBitCodes.h:138
clang::serialization::SubmoduleID
uint32_t SubmoduleID
An ID number that refers to a submodule in a module file.
Definition: ASTBitCodes.h:172
clang::QualifierInfo
A struct with extended info about a syntactic name qualifier, to be used for the case of out-of-line ...
Definition: Decl.h:662
Kind
Kind
Definition: ChrootChecker.cpp:29
clang::SourceLocation
Encodes a location in the source.
Definition: SourceLocation.h:88
clang::ASTWriter::getDeclVarAbbrev
unsigned getDeclVarAbbrev() const
Definition: ASTWriter.h:687
clang::CXXTemporary
Represents a C++ temporary.
Definition: ExprCXX.h:1185
clang::ASTRecordWriter::AddOffset
void AddOffset(uint64_t BitOffset)
Add a bit offset into the record.
Definition: ASTWriter.h:826
clang::TagDecl
Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:3064
clang::FileEntry
Cached information about one file (either on disk or in the virtual file system). ...
Definition: FileManager.h:60
llvm::SmallSetVector
Definition: ExternalSemaSource.h:24
DeclarationName.h
clang::NestedNameSpecifier
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
Definition: NestedNameSpecifier.h:49
clang::ObjCCategoryDecl
ObjCCategoryDecl - Represents a category declaration.
Definition: DeclObjC.h:2280
clang::ASTWriter::getDeclCXXMethodAbbrev
unsigned getDeclCXXMethodAbbrev() const
Definition: ASTWriter.h:691
clang::ASTTypeWriter
Definition: ASTWriter.cpp:138
llvm::SmallVector
Definition: LLVM.h:36
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:695
clang::serialization::TypeID
uint32_t TypeID
An ID number that refers to a type in an AST file.
Definition: ASTBitCodes.h:86
clang::ASTWriter::AddVersionTuple
void AddVersionTuple(const VersionTuple &Version, RecordDataImpl &Record)
Add a version tuple to the given record.
Definition: ASTWriter.cpp:4535
clang::ASTRecordWriter::AddSourceLocation
void AddSourceLocation(SourceLocation Loc)
Emit a source location.
Definition: ASTWriter.h:847
clang::ASTWriter::AddDeclRef
void AddDeclRef(const Decl *D, RecordDataImpl &Record)
Emit a reference to a declaration.
Definition: ASTWriter.cpp:5511
clang::StoredDeclsList
An array of decls optimized for the common case of only containing one entry.
Definition: DeclContextInternals.h:35
clang::serialization::PreprocessedEntityID
uint32_t PreprocessedEntityID
An ID number that refers to an entity in the detailed preprocessing record.
Definition: ASTBitCodes.h:169
clang::ASTWriter::getExprImplicitCastAbbrev
unsigned getExprImplicitCastAbbrev() const
Definition: ASTWriter.h:696
clang::ASTWriter::getTypeExtQualAbbrev
unsigned getTypeExtQualAbbrev() const
Definition: ASTWriter.h:676
clang::DeclarationNameLoc
DeclarationNameLoc - Additional source/type location info for a declaration name. ...
Definition: DeclarationName.h:651
NestedNameSpecifier.h
clang::OMPClauseWriter
Definition: ASTWriter.h:997
clang::TemplateArgument
Represents a template argument.
Definition: TemplateBase.h:51
clang::serialization::SelectorID
uint32_t SelectorID
An ID number that refers to an ObjC selector in an AST file.
Definition: ASTBitCodes.h:154
Decl.h
clang
Dataflow Directional Tag Classes.
Definition: CFGReachabilityAnalysis.h:22
clang::DeclContext
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1262
clang::ASTReader
Reads an AST files chain containing the contents of a translation unit.
Definition: ASTReader.h:355
clang::index::SymbolKind::Module
OMPClause
clang::DeclarationName
The name of a declaration.
Definition: DeclarationName.h:146
OMPClauseVisitor
Definition: OpenMPClause.h:5343
clang::DeclarationNameInfo
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
Definition: DeclarationName.h:691
clang::ASTWriter::getDeclParmVarAbbrev
unsigned getDeclParmVarAbbrev() const
Definition: ASTWriter.h:684
clang::serialization::DeclID
uint32_t DeclID
An ID number that refers to a declaration in an AST file.
Definition: ASTBitCodes.h:69
clang::ASTRecordWriter::AddVersionTuple
void AddVersionTuple(const VersionTuple &Version)
Emit a version tuple.
Definition: ASTWriter.h:955
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:618
clang::MacroInfo
Encapsulates the data about a macro definition (e.g.
Definition: MacroInfo.h:40
clang::TemplateArgumentLoc
Location wrapper for a TemplateArgument.
Definition: TemplateBase.h:450
TemplateBase.h
clang::serialization::IdentID
uint32_t IdentID
An ID number that refers to an identifier in an AST file.
Definition: ASTBitCodes.h:135
clang::ASTUnresolvedSet
An UnresolvedSet-like class which uses the ASTContext&#39;s allocator.
Definition: ASTUnresolvedSet.h:30
clang::serialization::NUM_PREDEF_MACRO_IDS
const unsigned int NUM_PREDEF_MACRO_IDS
The number of predefined macro IDs.
Definition: ASTBitCodes.h:151
clang::ASTRecordWriter::EmitStmt
uint64_t EmitStmt(unsigned Code, unsigned Abbrev=0)
Emit the record to the stream, preceded by its substatements.
Definition: ASTWriter.h:817
clang::CXXBaseSpecifier
Represents a base class of a C++ class.
Definition: DeclCXX.h:192
PCHContainerOperations.h
clang::TemplateArgumentList
A template argument list.
Definition: DeclTemplate.h:210
SourceLocation.h
Defines the clang::SourceLocation class and associated facilities.
clang::CXXRecordDecl
Represents a C++ struct/union/class.
Definition: DeclCXX.h:300
clang::ASTRecordWriter
An object for streaming information to a record.
Definition: ASTWriter.h:747
clang::TemplateArgumentLocInfo
Location information for a TemplateArgument.
Definition: TemplateBase.h:393
clang::ClassTemplateDecl
Declaration of a class template.
Definition: DeclTemplate.h:2049
clang::ASTWriter
Writes an AST file containing the contents of a translation unit.
Definition: ASTWriter.h:104
clang::ASTDeclWriter
Definition: ASTWriterDecl.cpp:35
clang::HeaderSearchOptions
HeaderSearchOptions - Helper class for storing options related to the initialization of the HeaderSea...
Definition: HeaderSearchOptions.h:67
getKind
static Decl::Kind getKind(const Decl *D)
Definition: DeclBase.cpp:954
clang::ASTRecordWriter::size
size_t size() const
Definition: ASTWriter.h:801
clang::PCHGenerator
AST and semantic-analysis consumer that generates a precompiled header from the parsed source code...
Definition: ASTWriter.h:968
OMPClauseWithPreInit
clang::SourceRange
A trivial tuple used to represent a source range.
Definition: SourceLocation.h:198
clang::NamedDecl
This represents a decl that may have a name.
Definition: Decl.h:249
clang::PCHGenerator::getWriter
ASTWriter & getWriter()
Definition: ASTWriter.h:979
clang::ASTWriter::getDeclObjCIvarAbbrev
unsigned getDeclObjCIvarAbbrev() const
Definition: ASTWriter.h:690
clang::ASTRecordWriter::ASTRecordWriter
ASTRecordWriter(ASTWriter &Writer, ASTWriter::RecordDataImpl &Record)
Construct a ASTRecordWriter that uses the default encoding scheme.
Definition: ASTWriter.h:778
clang::SourceManager
This class handles loading and caching of source files into memory.
Definition: SourceManager.h:582
clang::FunctionTemplateDecl
Declaration of a template function.
Definition: DeclTemplate.h:969
clang::serialization::TypeIdx
A type index; the type ID with the qualifier bits removed.
Definition: ASTBitCodes.h:89
clang::Attr
Attr - This represents one attribute.
Definition: Attr.h:44
clang::serialization::NUM_PREDEF_SUBMODULE_IDS
const unsigned int NUM_PREDEF_SUBMODULE_IDS
The number of predefined submodule IDs.
Definition: ASTBitCodes.h:175
clang::Preprocessor
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
Definition: Preprocessor.h:125