clang 20.0.0git
ASTReader.h
Go to the documentation of this file.
1//===- ASTReader.h - AST File Reader ----------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file defines the ASTReader class, which reads AST files.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_CLANG_SERIALIZATION_ASTREADER_H
14#define LLVM_CLANG_SERIALIZATION_ASTREADER_H
15
16#include "clang/AST/Type.h"
23#include "clang/Basic/Version.h"
30#include "clang/Sema/Sema.h"
37#include "llvm/ADT/ArrayRef.h"
38#include "llvm/ADT/DenseMap.h"
39#include "llvm/ADT/DenseSet.h"
40#include "llvm/ADT/IntrusiveRefCntPtr.h"
41#include "llvm/ADT/MapVector.h"
42#include "llvm/ADT/PagedVector.h"
43#include "llvm/ADT/STLExtras.h"
44#include "llvm/ADT/SetVector.h"
45#include "llvm/ADT/SmallPtrSet.h"
46#include "llvm/ADT/SmallVector.h"
47#include "llvm/ADT/StringMap.h"
48#include "llvm/ADT/StringRef.h"
49#include "llvm/ADT/iterator.h"
50#include "llvm/ADT/iterator_range.h"
51#include "llvm/Bitstream/BitstreamReader.h"
52#include "llvm/Support/MemoryBuffer.h"
53#include "llvm/Support/SaveAndRestore.h"
54#include "llvm/Support/Timer.h"
55#include "llvm/Support/VersionTuple.h"
56#include <cassert>
57#include <cstddef>
58#include <cstdint>
59#include <ctime>
60#include <deque>
61#include <memory>
62#include <optional>
63#include <set>
64#include <string>
65#include <utility>
66#include <vector>
67
68namespace clang {
69
70class ASTConsumer;
71class ASTContext;
72class ASTDeserializationListener;
73class ASTReader;
74class ASTRecordReader;
75class CXXTemporary;
76class Decl;
77class DeclarationName;
78class DeclaratorDecl;
79class DeclContext;
80class EnumDecl;
81class Expr;
82class FieldDecl;
83class FileEntry;
84class FileManager;
85class FileSystemOptions;
86class FunctionDecl;
87class GlobalModuleIndex;
88struct HeaderFileInfo;
89class HeaderSearchOptions;
90class LangOptions;
91class MacroInfo;
92class InMemoryModuleCache;
93class NamedDecl;
94class NamespaceDecl;
95class ObjCCategoryDecl;
96class ObjCInterfaceDecl;
97class PCHContainerReader;
98class Preprocessor;
99class PreprocessorOptions;
100class Sema;
101class SourceManager;
102class Stmt;
103class SwitchCase;
104class TargetOptions;
105class Token;
106class TypedefNameDecl;
107class ValueDecl;
108class VarDecl;
109
110/// Abstract interface for callback invocations by the ASTReader.
111///
112/// While reading an AST file, the ASTReader will call the methods of the
113/// listener to pass on specific information. Some of the listener methods can
114/// return true to indicate to the ASTReader that the information (and
115/// consequently the AST file) is invalid.
117public:
119
120 /// Receives the full Clang version information.
121 ///
122 /// \returns true to indicate that the version is invalid. Subclasses should
123 /// generally defer to this implementation.
124 virtual bool ReadFullVersionInformation(StringRef FullVersion) {
125 return FullVersion != getClangFullRepositoryVersion();
126 }
127
128 virtual void ReadModuleName(StringRef ModuleName) {}
129 virtual void ReadModuleMapFile(StringRef ModuleMapPath) {}
130
131 /// Receives the language options.
132 ///
133 /// \returns true to indicate the options are invalid or false otherwise.
134 virtual bool ReadLanguageOptions(const LangOptions &LangOpts,
135 StringRef ModuleFilename, bool Complain,
136 bool AllowCompatibleDifferences) {
137 return false;
138 }
139
140 /// Receives the target options.
141 ///
142 /// \returns true to indicate the target options are invalid, or false
143 /// otherwise.
144 virtual bool ReadTargetOptions(const TargetOptions &TargetOpts,
145 StringRef ModuleFilename, bool Complain,
146 bool AllowCompatibleDifferences) {
147 return false;
148 }
149
150 /// Receives the diagnostic options.
151 ///
152 /// \returns true to indicate the diagnostic options are invalid, or false
153 /// otherwise.
154 virtual bool
156 StringRef ModuleFilename, bool Complain) {
157 return false;
158 }
159
160 /// Receives the file system options.
161 ///
162 /// \returns true to indicate the file system options are invalid, or false
163 /// otherwise.
164 virtual bool ReadFileSystemOptions(const FileSystemOptions &FSOpts,
165 bool Complain) {
166 return false;
167 }
168
169 /// Receives the header search options.
170 ///
171 /// \param HSOpts The read header search options. The following fields are
172 /// missing and are reported in ReadHeaderSearchPaths():
173 /// UserEntries, SystemHeaderPrefixes, VFSOverlayFiles.
174 ///
175 /// \returns true to indicate the header search options are invalid, or false
176 /// otherwise.
178 StringRef ModuleFilename,
179 StringRef SpecificModuleCachePath,
180 bool Complain) {
181 return false;
182 }
183
184 /// Receives the header search paths.
185 ///
186 /// \param HSOpts The read header search paths. Only the following fields are
187 /// initialized: UserEntries, SystemHeaderPrefixes,
188 /// VFSOverlayFiles. The rest is reported in
189 /// ReadHeaderSearchOptions().
190 ///
191 /// \returns true to indicate the header search paths are invalid, or false
192 /// otherwise.
193 virtual bool ReadHeaderSearchPaths(const HeaderSearchOptions &HSOpts,
194 bool Complain) {
195 return false;
196 }
197
198 /// Receives the preprocessor options.
199 ///
200 /// \param SuggestedPredefines Can be filled in with the set of predefines
201 /// that are suggested by the preprocessor options. Typically only used when
202 /// loading a precompiled header.
203 ///
204 /// \returns true to indicate the preprocessor options are invalid, or false
205 /// otherwise.
207 StringRef ModuleFilename,
208 bool ReadMacros, bool Complain,
209 std::string &SuggestedPredefines) {
210 return false;
211 }
212
213 /// Receives __COUNTER__ value.
215 unsigned Value) {}
216
217 /// This is called for each AST file loaded.
218 virtual void visitModuleFile(StringRef Filename,
220
221 /// Returns true if this \c ASTReaderListener wants to receive the
222 /// input files of the AST file via \c visitInputFile, false otherwise.
223 virtual bool needsInputFileVisitation() { return false; }
224
225 /// Returns true if this \c ASTReaderListener wants to receive the
226 /// system input files of the AST file via \c visitInputFile, false otherwise.
227 virtual bool needsSystemInputFileVisitation() { return false; }
228
229 /// if \c needsInputFileVisitation returns true, this is called for
230 /// each non-system input file of the AST File. If
231 /// \c needsSystemInputFileVisitation is true, then it is called for all
232 /// system input files as well.
233 ///
234 /// \returns true to continue receiving the next input file, false to stop.
235 virtual bool visitInputFile(StringRef Filename, bool isSystem,
236 bool isOverridden, bool isExplicitModule) {
237 return true;
238 }
239
240 /// Returns true if this \c ASTReaderListener wants to receive the
241 /// imports of the AST file via \c visitImport, false otherwise.
242 virtual bool needsImportVisitation() const { return false; }
243
244 /// If needsImportVisitation returns \c true, this is called for each
245 /// AST file imported by this AST file.
246 virtual void visitImport(StringRef ModuleName, StringRef Filename) {}
247
248 /// Indicates that a particular module file extension has been read.
250 const ModuleFileExtensionMetadata &Metadata) {}
251};
252
253/// Simple wrapper class for chaining listeners.
255 std::unique_ptr<ASTReaderListener> First;
256 std::unique_ptr<ASTReaderListener> Second;
257
258public:
259 /// Takes ownership of \p First and \p Second.
260 ChainedASTReaderListener(std::unique_ptr<ASTReaderListener> First,
261 std::unique_ptr<ASTReaderListener> Second)
262 : First(std::move(First)), Second(std::move(Second)) {}
263
264 std::unique_ptr<ASTReaderListener> takeFirst() { return std::move(First); }
265 std::unique_ptr<ASTReaderListener> takeSecond() { return std::move(Second); }
266
267 bool ReadFullVersionInformation(StringRef FullVersion) override;
268 void ReadModuleName(StringRef ModuleName) override;
269 void ReadModuleMapFile(StringRef ModuleMapPath) override;
270 bool ReadLanguageOptions(const LangOptions &LangOpts,
271 StringRef ModuleFilename, bool Complain,
272 bool AllowCompatibleDifferences) override;
273 bool ReadTargetOptions(const TargetOptions &TargetOpts,
274 StringRef ModuleFilename, bool Complain,
275 bool AllowCompatibleDifferences) override;
277 StringRef ModuleFilename, bool Complain) override;
278 bool ReadFileSystemOptions(const FileSystemOptions &FSOpts,
279 bool Complain) override;
280
282 StringRef ModuleFilename,
283 StringRef SpecificModuleCachePath,
284 bool Complain) override;
286 StringRef ModuleFilename, bool ReadMacros,
287 bool Complain,
288 std::string &SuggestedPredefines) override;
289
290 void ReadCounter(const serialization::ModuleFile &M, unsigned Value) override;
291 bool needsInputFileVisitation() override;
292 bool needsSystemInputFileVisitation() override;
293 void visitModuleFile(StringRef Filename,
295 bool visitInputFile(StringRef Filename, bool isSystem,
296 bool isOverridden, bool isExplicitModule) override;
298 const ModuleFileExtensionMetadata &Metadata) override;
299};
300
301/// ASTReaderListener implementation to validate the information of
302/// the PCH file against an initialized Preprocessor.
304 Preprocessor &PP;
305 ASTReader &Reader;
306
307public:
309 : PP(PP), Reader(Reader) {}
310
311 bool ReadLanguageOptions(const LangOptions &LangOpts,
312 StringRef ModuleFilename, bool Complain,
313 bool AllowCompatibleDifferences) override;
314 bool ReadTargetOptions(const TargetOptions &TargetOpts,
315 StringRef ModuleFilename, bool Complain,
316 bool AllowCompatibleDifferences) override;
318 StringRef ModuleFilename, bool Complain) override;
320 StringRef ModuleFilename, bool ReadMacros,
321 bool Complain,
322 std::string &SuggestedPredefines) override;
324 StringRef ModuleFilename,
325 StringRef SpecificModuleCachePath,
326 bool Complain) override;
327 void ReadCounter(const serialization::ModuleFile &M, unsigned Value) override;
328};
329
330/// ASTReaderListenter implementation to set SuggestedPredefines of
331/// ASTReader which is required to use a pch file. This is the replacement
332/// of PCHValidator or SimplePCHValidator when using a pch file without
333/// validating it.
335 Preprocessor &PP;
336
337public:
339
341 StringRef ModuleFilename, bool ReadMacros,
342 bool Complain,
343 std::string &SuggestedPredefines) override;
344};
345
346namespace serialization {
347
348class ReadMethodPoolVisitor;
349
350namespace reader {
351
353
354/// The on-disk hash table(s) used for DeclContext name lookup.
356
357/// The on-disk hash table(s) used for specialization decls.
359
360} // namespace reader
361
362} // namespace serialization
363
364/// Reads an AST files chain containing the contents of a translation
365/// unit.
366///
367/// The ASTReader class reads bitstreams (produced by the ASTWriter
368/// class) containing the serialized representation of a given
369/// abstract syntax tree and its supporting data structures. An
370/// instance of the ASTReader can be attached to an ASTContext object,
371/// which will provide access to the contents of the AST files.
372///
373/// The AST reader provides lazy de-serialization of declarations, as
374/// required when traversing the AST. Only those AST nodes that are
375/// actually required will be de-serialized.
380 public ExternalSemaSource,
383{
384public:
385 /// Types of AST files.
386 friend class ASTDeclMerger;
387 friend class ASTDeclReader;
389 friend class ASTRecordReader;
390 friend class ASTUnit; // ASTUnit needs to remap source locations.
391 friend class ASTWriter;
392 friend class PCHValidator;
395 friend class TypeLocReader;
396 friend class LocalDeclID;
397
400
401 /// The result of reading the control block of an AST file, which
402 /// can fail for various reasons.
404 /// The control block was read successfully. Aside from failures,
405 /// the AST file is safe to read into the current context.
407
408 /// The AST file itself appears corrupted.
410
411 /// The AST file was missing.
413
414 /// The AST file is out-of-date relative to its input files,
415 /// and needs to be regenerated.
417
418 /// The AST file was written by a different version of Clang.
420
421 /// The AST file was written with a different language/target
422 /// configuration.
424
425 /// The AST file has errors.
427 };
428
435
436private:
438
439 /// The receiver of some callbacks invoked by ASTReader.
440 std::unique_ptr<ASTReaderListener> Listener;
441
442 /// The receiver of deserialization events.
443 ASTDeserializationListener *DeserializationListener = nullptr;
444
445 bool OwnsDeserializationListener = false;
446
447 SourceManager &SourceMgr;
448 FileManager &FileMgr;
449 const PCHContainerReader &PCHContainerRdr;
450 DiagnosticsEngine &Diags;
451 // Sema has duplicate logic, but SemaObj can sometimes be null so ASTReader
452 // has its own version.
453 StackExhaustionHandler StackHandler;
454
455 /// The semantic analysis object that will be processing the
456 /// AST files and the translation unit that uses it.
457 Sema *SemaObj = nullptr;
458
459 /// The preprocessor that will be loading the source file.
460 Preprocessor &PP;
461
462 /// The AST context into which we'll read the AST files.
463 ASTContext *ContextObj = nullptr;
464
465 /// The AST consumer.
466 ASTConsumer *Consumer = nullptr;
467
468 /// The module manager which manages modules and their dependencies
469 ModuleManager ModuleMgr;
470
471 /// A dummy identifier resolver used to merge TU-scope declarations in
472 /// C, for the cases where we don't have a Sema object to provide a real
473 /// identifier resolver.
474 IdentifierResolver DummyIdResolver;
475
476 /// A mapping from extension block names to module file extensions.
477 llvm::StringMap<std::shared_ptr<ModuleFileExtension>> ModuleFileExtensions;
478
479 /// A timer used to track the time spent deserializing.
480 std::unique_ptr<llvm::Timer> ReadTimer;
481
482 /// The location where the module file will be considered as
483 /// imported from. For non-module AST types it should be invalid.
484 SourceLocation CurrentImportLoc;
485
486 /// The module kind that is currently deserializing.
487 std::optional<ModuleKind> CurrentDeserializingModuleKind;
488
489 /// The global module index, if loaded.
490 std::unique_ptr<GlobalModuleIndex> GlobalIndex;
491
492 /// A map of global bit offsets to the module that stores entities
493 /// at those bit offsets.
495
496 /// A map of negated SLocEntryIDs to the modules containing them.
498
501
502 /// A map of reversed (SourceManager::MaxLoadedOffset - SLocOffset)
503 /// SourceLocation offsets to the modules containing them.
504 GlobalSLocOffsetMapType GlobalSLocOffsetMap;
505
506 /// Types that have already been loaded from the chain.
507 ///
508 /// When the pointer at index I is non-NULL, the type with
509 /// ID = (I + 1) << FastQual::Width has already been loaded
510 llvm::PagedVector<QualType> TypesLoaded;
511
512 /// Declarations that have already been loaded from the chain.
513 ///
514 /// When the pointer at index I is non-NULL, the declaration with ID
515 /// = I + 1 has already been loaded.
516 llvm::PagedVector<Decl *> DeclsLoaded;
517
518 using FileOffset = std::pair<ModuleFile *, uint64_t>;
520 using DeclUpdateOffsetsMap = llvm::DenseMap<GlobalDeclID, FileOffsetsTy>;
521
522 /// Declarations that have modifications residing in a later file
523 /// in the chain.
524 DeclUpdateOffsetsMap DeclUpdateOffsets;
525
526 using DelayedNamespaceOffsetMapTy =
527 llvm::DenseMap<GlobalDeclID, std::pair</*LexicalOffset*/ uint64_t,
528 /*VisibleOffset*/ uint64_t>>;
529
530 /// Mapping from global declaration IDs to the lexical and visible block
531 /// offset for delayed namespace in reduced BMI.
532 ///
533 /// We can't use the existing DeclUpdate mechanism since the DeclUpdate
534 /// may only be applied in an outer most read. However, we need to know
535 /// whether or not a DeclContext has external storage during the recursive
536 /// reading. So we need to apply the offset immediately after we read the
537 /// namespace as if it is not delayed.
538 DelayedNamespaceOffsetMapTy DelayedNamespaceOffsetMap;
539
540 /// Mapping from main decl ID to the related decls IDs.
541 ///
542 /// These related decls have to be loaded right after the main decl.
543 /// It is required to have canonical declaration for related decls from the
544 /// same module as the enclosing main decl. Without this, due to lazy
545 /// deserialization, canonical declarations for the main decl and related can
546 /// be selected from different modules.
547 llvm::DenseMap<GlobalDeclID, SmallVector<GlobalDeclID, 4>> RelatedDeclsMap;
548
549 struct PendingUpdateRecord {
550 Decl *D;
551 GlobalDeclID ID;
552
553 // Whether the declaration was just deserialized.
554 bool JustLoaded;
555
556 PendingUpdateRecord(GlobalDeclID ID, Decl *D, bool JustLoaded)
557 : D(D), ID(ID), JustLoaded(JustLoaded) {}
558 };
559
560 /// Declaration updates for already-loaded declarations that we need
561 /// to apply once we finish processing an import.
563
564 enum class PendingFakeDefinitionKind { NotFake, Fake, FakeLoaded };
565
566 /// The DefinitionData pointers that we faked up for class definitions
567 /// that we needed but hadn't loaded yet.
568 llvm::DenseMap<void *, PendingFakeDefinitionKind> PendingFakeDefinitionData;
569
570 /// Exception specification updates that have been loaded but not yet
571 /// propagated across the relevant redeclaration chain. The map key is the
572 /// canonical declaration (used only for deduplication) and the value is a
573 /// declaration that has an exception specification.
574 llvm::SmallMapVector<Decl *, FunctionDecl *, 4> PendingExceptionSpecUpdates;
575
576 /// Deduced return type updates that have been loaded but not yet propagated
577 /// across the relevant redeclaration chain. The map key is the canonical
578 /// declaration and the value is the deduced return type.
579 llvm::SmallMapVector<FunctionDecl *, QualType, 4> PendingDeducedTypeUpdates;
580
581 /// Functions has undededuced return type and we wish we can find the deduced
582 /// return type by iterating the redecls in other modules.
583 llvm::SmallVector<FunctionDecl *, 4> PendingUndeducedFunctionDecls;
584
585 /// Declarations that have been imported and have typedef names for
586 /// linkage purposes.
587 llvm::DenseMap<std::pair<DeclContext *, IdentifierInfo *>, NamedDecl *>
588 ImportedTypedefNamesForLinkage;
589
590 /// Mergeable declaration contexts that have anonymous declarations
591 /// within them, and those anonymous declarations.
592 llvm::DenseMap<Decl*, llvm::SmallVector<NamedDecl*, 2>>
593 AnonymousDeclarationsForMerging;
594
595 /// Map from numbering information for lambdas to the corresponding lambdas.
596 llvm::DenseMap<std::pair<const Decl *, unsigned>, NamedDecl *>
597 LambdaDeclarationsForMerging;
598
599 /// Key used to identify LifetimeExtendedTemporaryDecl for merging,
600 /// containing the lifetime-extending declaration and the mangling number.
601 using LETemporaryKey = std::pair<Decl *, unsigned>;
602
603 /// Map of already deserialiazed temporaries.
604 llvm::DenseMap<LETemporaryKey, LifetimeExtendedTemporaryDecl *>
605 LETemporaryForMerging;
606
607 struct FileDeclsInfo {
608 ModuleFile *Mod = nullptr;
609 ArrayRef<serialization::unaligned_decl_id_t> Decls;
610
611 FileDeclsInfo() = default;
612 FileDeclsInfo(ModuleFile *Mod,
613 ArrayRef<serialization::unaligned_decl_id_t> Decls)
614 : Mod(Mod), Decls(Decls) {}
615 };
616
617 /// Map from a FileID to the file-level declarations that it contains.
618 llvm::DenseMap<FileID, FileDeclsInfo> FileDeclIDs;
619
620 /// An array of lexical contents of a declaration context, as a sequence of
621 /// Decl::Kind, DeclID pairs.
622 using LexicalContents = ArrayRef<serialization::unaligned_decl_id_t>;
623
624 /// Map from a DeclContext to its lexical contents.
625 llvm::DenseMap<const DeclContext*, std::pair<ModuleFile*, LexicalContents>>
626 LexicalDecls;
627
628 /// Map from the TU to its lexical contents from each module file.
629 std::vector<std::pair<ModuleFile*, LexicalContents>> TULexicalDecls;
630
631 /// Map from a DeclContext to its lookup tables.
632 llvm::DenseMap<const DeclContext *,
633 serialization::reader::DeclContextLookupTable> Lookups;
634
635 using SpecLookupTableTy =
636 llvm::DenseMap<const Decl *,
637 serialization::reader::LazySpecializationInfoLookupTable>;
638 /// Map from decls to specialized decls.
639 SpecLookupTableTy SpecializationsLookups;
640 /// Split partial specialization from specialization to speed up lookups.
641 SpecLookupTableTy PartialSpecializationsLookups;
642
643 bool LoadExternalSpecializationsImpl(SpecLookupTableTy &SpecLookups,
644 const Decl *D);
645 bool LoadExternalSpecializationsImpl(SpecLookupTableTy &SpecLookups,
646 const Decl *D,
647 ArrayRef<TemplateArgument> TemplateArgs);
648
649 // Updates for visible decls can occur for other contexts than just the
650 // TU, and when we read those update records, the actual context may not
651 // be available yet, so have this pending map using the ID as a key. It
652 // will be realized when the data is actually loaded.
653 struct UpdateData {
654 ModuleFile *Mod;
655 const unsigned char *Data;
656 };
657 using DeclContextVisibleUpdates = SmallVector<UpdateData, 1>;
658
659 /// Updates to the visible declarations of declaration contexts that
660 /// haven't been loaded yet.
661 llvm::DenseMap<GlobalDeclID, DeclContextVisibleUpdates> PendingVisibleUpdates;
662
663 using SpecializationsUpdate = SmallVector<UpdateData, 1>;
664 using SpecializationsUpdateMap =
665 llvm::DenseMap<GlobalDeclID, SpecializationsUpdate>;
666 SpecializationsUpdateMap PendingSpecializationsUpdates;
667 SpecializationsUpdateMap PendingPartialSpecializationsUpdates;
668
669 /// The set of C++ or Objective-C classes that have forward
670 /// declarations that have not yet been linked to their definitions.
671 llvm::SmallPtrSet<Decl *, 4> PendingDefinitions;
672
673 using PendingBodiesMap =
674 llvm::MapVector<Decl *, uint64_t,
675 llvm::SmallDenseMap<Decl *, unsigned, 4>,
676 SmallVector<std::pair<Decl *, uint64_t>, 4>>;
677
678 /// Functions or methods that have bodies that will be attached.
679 PendingBodiesMap PendingBodies;
680
681 /// Definitions for which we have added merged definitions but not yet
682 /// performed deduplication.
683 llvm::SetVector<NamedDecl *> PendingMergedDefinitionsToDeduplicate;
684
685 /// The duplicated definitions in module units which are pending to be warned.
686 /// We need to delay it to wait for the loading of definitions since we don't
687 /// want to warn for forward declarations.
689 PendingWarningForDuplicatedDefsInModuleUnits;
690
691 /// Read the record that describes the lexical contents of a DC.
692 bool ReadLexicalDeclContextStorage(ModuleFile &M,
693 llvm::BitstreamCursor &Cursor,
694 uint64_t Offset, DeclContext *DC);
695
696 /// Read the record that describes the visible contents of a DC.
697 bool ReadVisibleDeclContextStorage(ModuleFile &M,
698 llvm::BitstreamCursor &Cursor,
699 uint64_t Offset, GlobalDeclID ID);
700
701 bool ReadSpecializations(ModuleFile &M, llvm::BitstreamCursor &Cursor,
702 uint64_t Offset, Decl *D, bool IsPartial);
703 void AddSpecializations(const Decl *D, const unsigned char *Data,
704 ModuleFile &M, bool IsPartial);
705
706 /// A vector containing identifiers that have already been
707 /// loaded.
708 ///
709 /// If the pointer at index I is non-NULL, then it refers to the
710 /// IdentifierInfo for the identifier with ID=I+1 that has already
711 /// been loaded.
712 std::vector<IdentifierInfo *> IdentifiersLoaded;
713
714 /// A vector containing macros that have already been
715 /// loaded.
716 ///
717 /// If the pointer at index I is non-NULL, then it refers to the
718 /// MacroInfo for the identifier with ID=I+1 that has already
719 /// been loaded.
720 std::vector<MacroInfo *> MacrosLoaded;
721
722 using LoadedMacroInfo =
723 std::pair<IdentifierInfo *, serialization::SubmoduleID>;
724
725 /// A set of #undef directives that we have loaded; used to
726 /// deduplicate the same #undef information coming from multiple module
727 /// files.
728 llvm::DenseSet<LoadedMacroInfo> LoadedUndefs;
729
730 using GlobalMacroMapType =
731 ContinuousRangeMap<serialization::MacroID, ModuleFile *, 4>;
732
733 /// Mapping from global macro IDs to the module in which the
734 /// macro resides along with the offset that should be added to the
735 /// global macro ID to produce a local ID.
736 GlobalMacroMapType GlobalMacroMap;
737
738 /// A vector containing submodules that have already been loaded.
739 ///
740 /// This vector is indexed by the Submodule ID (-1). NULL submodule entries
741 /// indicate that the particular submodule ID has not yet been loaded.
742 SmallVector<Module *, 2> SubmodulesLoaded;
743
744 using GlobalSubmoduleMapType =
745 ContinuousRangeMap<serialization::SubmoduleID, ModuleFile *, 4>;
746
747 /// Mapping from global submodule IDs to the module file in which the
748 /// submodule resides along with the offset that should be added to the
749 /// global submodule ID to produce a local ID.
750 GlobalSubmoduleMapType GlobalSubmoduleMap;
751
752 /// A set of hidden declarations.
753 using HiddenNames = SmallVector<Decl *, 2>;
754 using HiddenNamesMapType = llvm::DenseMap<Module *, HiddenNames>;
755
756 /// A mapping from each of the hidden submodules to the deserialized
757 /// declarations in that submodule that could be made visible.
758 HiddenNamesMapType HiddenNamesMap;
759
760 /// A module import, export, or conflict that hasn't yet been resolved.
761 struct UnresolvedModuleRef {
762 /// The file in which this module resides.
764
765 /// The module that is importing or exporting.
766 Module *Mod;
767
768 /// The kind of module reference.
769 enum { Import, Export, Conflict, Affecting } Kind;
770
771 /// The local ID of the module that is being exported.
772 unsigned ID;
773
774 /// Whether this is a wildcard export.
775 LLVM_PREFERRED_TYPE(bool)
776 unsigned IsWildcard : 1;
777
778 /// String data.
779 StringRef String;
780 };
781
782 /// The set of module imports and exports that still need to be
783 /// resolved.
784 SmallVector<UnresolvedModuleRef, 2> UnresolvedModuleRefs;
785
786 /// A vector containing selectors that have already been loaded.
787 ///
788 /// This vector is indexed by the Selector ID (-1). NULL selector
789 /// entries indicate that the particular selector ID has not yet
790 /// been loaded.
791 SmallVector<Selector, 16> SelectorsLoaded;
792
793 using GlobalSelectorMapType =
794 ContinuousRangeMap<serialization::SelectorID, ModuleFile *, 4>;
795
796 /// Mapping from global selector IDs to the module in which the
797 /// global selector ID to produce a local ID.
798 GlobalSelectorMapType GlobalSelectorMap;
799
800 /// The generation number of the last time we loaded data from the
801 /// global method pool for this selector.
802 llvm::DenseMap<Selector, unsigned> SelectorGeneration;
803
804 /// Whether a selector is out of date. We mark a selector as out of date
805 /// if we load another module after the method pool entry was pulled in.
806 llvm::DenseMap<Selector, bool> SelectorOutOfDate;
807
808 struct PendingMacroInfo {
809 ModuleFile *M;
810 /// Offset relative to ModuleFile::MacroOffsetsBase.
811 uint32_t MacroDirectivesOffset;
812
813 PendingMacroInfo(ModuleFile *M, uint32_t MacroDirectivesOffset)
814 : M(M), MacroDirectivesOffset(MacroDirectivesOffset) {}
815 };
816
817 using PendingMacroIDsMap =
818 llvm::MapVector<IdentifierInfo *, SmallVector<PendingMacroInfo, 2>>;
819
820 /// Mapping from identifiers that have a macro history to the global
821 /// IDs have not yet been deserialized to the global IDs of those macros.
822 PendingMacroIDsMap PendingMacroIDs;
823
824 using GlobalPreprocessedEntityMapType =
825 ContinuousRangeMap<unsigned, ModuleFile *, 4>;
826
827 /// Mapping from global preprocessing entity IDs to the module in
828 /// which the preprocessed entity resides along with the offset that should be
829 /// added to the global preprocessing entity ID to produce a local ID.
830 GlobalPreprocessedEntityMapType GlobalPreprocessedEntityMap;
831
832 using GlobalSkippedRangeMapType =
833 ContinuousRangeMap<unsigned, ModuleFile *, 4>;
834
835 /// Mapping from global skipped range base IDs to the module in which
836 /// the skipped ranges reside.
837 GlobalSkippedRangeMapType GlobalSkippedRangeMap;
838
839 /// \name CodeGen-relevant special data
840 /// Fields containing data that is relevant to CodeGen.
841 //@{
842
843 /// The IDs of all declarations that fulfill the criteria of
844 /// "interesting" decls.
845 ///
846 /// This contains the data loaded from all EAGERLY_DESERIALIZED_DECLS blocks
847 /// in the chain. The referenced declarations are deserialized and passed to
848 /// the consumer eagerly.
849 SmallVector<GlobalDeclID, 16> EagerlyDeserializedDecls;
850
851 /// The IDs of all vtables to emit. The referenced declarations are passed
852 /// to the consumers' HandleVTable eagerly after passing
853 /// EagerlyDeserializedDecls.
854 SmallVector<GlobalDeclID, 16> VTablesToEmit;
855
856 /// The IDs of all tentative definitions stored in the chain.
857 ///
858 /// Sema keeps track of all tentative definitions in a TU because it has to
859 /// complete them and pass them on to CodeGen. Thus, tentative definitions in
860 /// the PCH chain must be eagerly deserialized.
861 SmallVector<GlobalDeclID, 16> TentativeDefinitions;
862
863 /// The IDs of all CXXRecordDecls stored in the chain whose VTables are
864 /// used.
865 ///
866 /// CodeGen has to emit VTables for these records, so they have to be eagerly
867 /// deserialized.
868 struct VTableUse {
869 GlobalDeclID ID;
871 bool Used;
872 };
873 SmallVector<VTableUse> VTableUses;
874
875 /// A snapshot of the pending instantiations in the chain.
876 ///
877 /// This record tracks the instantiations that Sema has to perform at the
878 /// end of the TU. It consists of a pair of values for every pending
879 /// instantiation where the first value is the ID of the decl and the second
880 /// is the instantiation location.
881 struct PendingInstantiation {
882 GlobalDeclID ID;
884 };
885 SmallVector<PendingInstantiation, 64> PendingInstantiations;
886
887 //@}
888
889 /// \name DiagnosticsEngine-relevant special data
890 /// Fields containing data that is used for generating diagnostics
891 //@{
892
893 /// A snapshot of Sema's unused file-scoped variable tracking, for
894 /// generating warnings.
895 SmallVector<GlobalDeclID, 16> UnusedFileScopedDecls;
896
897 /// A list of all the delegating constructors we've seen, to diagnose
898 /// cycles.
899 SmallVector<GlobalDeclID, 4> DelegatingCtorDecls;
900
901 /// Method selectors used in a @selector expression. Used for
902 /// implementation of -Wselector.
903 SmallVector<serialization::SelectorID, 64> ReferencedSelectorsData;
904
905 /// A snapshot of Sema's weak undeclared identifier tracking, for
906 /// generating warnings.
907 SmallVector<serialization::IdentifierID, 64> WeakUndeclaredIdentifiers;
908
909 /// The IDs of type aliases for ext_vectors that exist in the chain.
910 ///
911 /// Used by Sema for finding sugared names for ext_vectors in diagnostics.
912 SmallVector<GlobalDeclID, 4> ExtVectorDecls;
913
914 //@}
915
916 /// \name Sema-relevant special data
917 /// Fields containing data that is used for semantic analysis
918 //@{
919
920 /// The IDs of all potentially unused typedef names in the chain.
921 ///
922 /// Sema tracks these to emit warnings.
923 SmallVector<GlobalDeclID, 16> UnusedLocalTypedefNameCandidates;
924
925 /// Our current depth in #pragma cuda force_host_device begin/end
926 /// macros.
927 unsigned ForceHostDeviceDepth = 0;
928
929 /// The IDs of the declarations Sema stores directly.
930 ///
931 /// Sema tracks a few important decls, such as namespace std, directly.
932 SmallVector<GlobalDeclID, 4> SemaDeclRefs;
933
934 /// The IDs of the types ASTContext stores directly.
935 ///
936 /// The AST context tracks a few important types, such as va_list, directly.
937 SmallVector<serialization::TypeID, 16> SpecialTypes;
938
939 /// The IDs of CUDA-specific declarations ASTContext stores directly.
940 ///
941 /// The AST context tracks a few important decls, currently cudaConfigureCall,
942 /// directly.
943 SmallVector<GlobalDeclID, 2> CUDASpecialDeclRefs;
944
945 /// The floating point pragma option settings.
946 SmallVector<uint64_t, 1> FPPragmaOptions;
947
948 /// The pragma clang optimize location (if the pragma state is "off").
949 SourceLocation OptimizeOffPragmaLocation;
950
951 /// The PragmaMSStructKind pragma ms_struct state if set, or -1.
952 int PragmaMSStructState = -1;
953
954 /// The PragmaMSPointersToMembersKind pragma pointers_to_members state.
955 int PragmaMSPointersToMembersState = -1;
956 SourceLocation PointersToMembersPragmaLocation;
957
958 /// The pragma float_control state.
959 std::optional<FPOptionsOverride> FpPragmaCurrentValue;
960 SourceLocation FpPragmaCurrentLocation;
961 struct FpPragmaStackEntry {
962 FPOptionsOverride Value;
963 SourceLocation Location;
964 SourceLocation PushLocation;
965 StringRef SlotLabel;
966 };
968 llvm::SmallVector<std::string, 2> FpPragmaStrings;
969
970 /// The pragma align/pack state.
971 std::optional<Sema::AlignPackInfo> PragmaAlignPackCurrentValue;
972 SourceLocation PragmaAlignPackCurrentLocation;
973 struct PragmaAlignPackStackEntry {
974 Sema::AlignPackInfo Value;
975 SourceLocation Location;
976 SourceLocation PushLocation;
977 StringRef SlotLabel;
978 };
980 llvm::SmallVector<std::string, 2> PragmaAlignPackStrings;
981
982 /// The OpenCL extension settings.
983 OpenCLOptions OpenCLExtensions;
984
985 /// Extensions required by an OpenCL type.
986 llvm::DenseMap<const Type *, std::set<std::string>> OpenCLTypeExtMap;
987
988 /// Extensions required by an OpenCL declaration.
989 llvm::DenseMap<const Decl *, std::set<std::string>> OpenCLDeclExtMap;
990
991 /// A list of the namespaces we've seen.
992 SmallVector<GlobalDeclID, 4> KnownNamespaces;
993
994 /// A list of undefined decls with internal linkage followed by the
995 /// SourceLocation of a matching ODR-use.
996 struct UndefinedButUsedDecl {
997 GlobalDeclID ID;
999 };
1000 SmallVector<UndefinedButUsedDecl, 8> UndefinedButUsed;
1001
1002 /// Delete expressions to analyze at the end of translation unit.
1003 SmallVector<uint64_t, 8> DelayedDeleteExprs;
1004
1005 // A list of late parsed template function data with their module files.
1006 SmallVector<std::pair<ModuleFile *, SmallVector<uint64_t, 1>>, 4>
1007 LateParsedTemplates;
1008
1009 /// The IDs of all decls to be checked for deferred diags.
1010 ///
1011 /// Sema tracks these to emit deferred diags.
1012 llvm::SmallSetVector<GlobalDeclID, 4> DeclsToCheckForDeferredDiags;
1013
1014 /// The IDs of all decls with function effects to be checked.
1015 SmallVector<GlobalDeclID> DeclsWithEffectsToVerify;
1016
1017private:
1018 struct ImportedSubmodule {
1020 SourceLocation ImportLoc;
1021
1022 ImportedSubmodule(serialization::SubmoduleID ID, SourceLocation ImportLoc)
1023 : ID(ID), ImportLoc(ImportLoc) {}
1024 };
1025
1026 /// A list of modules that were imported by precompiled headers or
1027 /// any other non-module AST file and have not yet been made visible. If a
1028 /// module is made visible in the ASTReader, it will be transfered to
1029 /// \c PendingImportedModulesSema.
1030 SmallVector<ImportedSubmodule, 2> PendingImportedModules;
1031
1032 /// A list of modules that were imported by precompiled headers or
1033 /// any other non-module AST file and have not yet been made visible for Sema.
1034 SmallVector<ImportedSubmodule, 2> PendingImportedModulesSema;
1035 //@}
1036
1037 /// The system include root to be used when loading the
1038 /// precompiled header.
1039 std::string isysroot;
1040
1041 /// Whether to disable the normal validation performed on precompiled
1042 /// headers and module files when they are loaded.
1043 DisableValidationForModuleKind DisableValidationKind;
1044
1045 /// Whether to accept an AST file with compiler errors.
1046 bool AllowASTWithCompilerErrors;
1047
1048 /// Whether to accept an AST file that has a different configuration
1049 /// from the current compiler instance.
1050 bool AllowConfigurationMismatch;
1051
1052 /// Whether validate system input files.
1053 bool ValidateSystemInputs;
1054
1055 /// Whether validate headers and module maps using hash based on contents.
1056 bool ValidateASTInputFilesContent;
1057
1058 /// Whether we are allowed to use the global module index.
1059 bool UseGlobalIndex;
1060
1061 /// Whether we have tried loading the global module index yet.
1062 bool TriedLoadingGlobalIndex = false;
1063
1064 ///Whether we are currently processing update records.
1065 bool ProcessingUpdateRecords = false;
1066
1067 using SwitchCaseMapTy = llvm::DenseMap<unsigned, SwitchCase *>;
1068
1069 /// Mapping from switch-case IDs in the chain to switch-case statements
1070 ///
1071 /// Statements usually don't have IDs, but switch cases need them, so that the
1072 /// switch statement can refer to them.
1073 SwitchCaseMapTy SwitchCaseStmts;
1074
1075 SwitchCaseMapTy *CurrSwitchCaseStmts;
1076
1077 /// The number of source location entries de-serialized from
1078 /// the PCH file.
1079 unsigned NumSLocEntriesRead = 0;
1080
1081 /// The number of source location entries in the chain.
1082 unsigned TotalNumSLocEntries = 0;
1083
1084 /// The number of statements (and expressions) de-serialized
1085 /// from the chain.
1086 unsigned NumStatementsRead = 0;
1087
1088 /// The total number of statements (and expressions) stored
1089 /// in the chain.
1090 unsigned TotalNumStatements = 0;
1091
1092 /// The number of macros de-serialized from the chain.
1093 unsigned NumMacrosRead = 0;
1094
1095 /// The total number of macros stored in the chain.
1096 unsigned TotalNumMacros = 0;
1097
1098 /// The number of lookups into identifier tables.
1099 unsigned NumIdentifierLookups = 0;
1100
1101 /// The number of lookups into identifier tables that succeed.
1102 unsigned NumIdentifierLookupHits = 0;
1103
1104 /// The number of selectors that have been read.
1105 unsigned NumSelectorsRead = 0;
1106
1107 /// The number of method pool entries that have been read.
1108 unsigned NumMethodPoolEntriesRead = 0;
1109
1110 /// The number of times we have looked up a selector in the method
1111 /// pool.
1112 unsigned NumMethodPoolLookups = 0;
1113
1114 /// The number of times we have looked up a selector in the method
1115 /// pool and found something.
1116 unsigned NumMethodPoolHits = 0;
1117
1118 /// The number of times we have looked up a selector in the method
1119 /// pool within a specific module.
1120 unsigned NumMethodPoolTableLookups = 0;
1121
1122 /// The number of times we have looked up a selector in the method
1123 /// pool within a specific module and found something.
1124 unsigned NumMethodPoolTableHits = 0;
1125
1126 /// The total number of method pool entries in the selector table.
1127 unsigned TotalNumMethodPoolEntries = 0;
1128
1129 /// Number of lexical decl contexts read/total.
1130 unsigned NumLexicalDeclContextsRead = 0, TotalLexicalDeclContexts = 0;
1131
1132 /// Number of visible decl contexts read/total.
1133 unsigned NumVisibleDeclContextsRead = 0, TotalVisibleDeclContexts = 0;
1134
1135 /// Total size of modules, in bits, currently loaded
1136 uint64_t TotalModulesSizeInBits = 0;
1137
1138 /// Number of Decl/types that are currently deserializing.
1139 unsigned NumCurrentElementsDeserializing = 0;
1140
1141 /// Set true while we are in the process of passing deserialized
1142 /// "interesting" decls to consumer inside FinishedDeserializing().
1143 /// This is used as a guard to avoid recursively repeating the process of
1144 /// passing decls to consumer.
1145 bool PassingDeclsToConsumer = false;
1146
1147 /// The set of identifiers that were read while the AST reader was
1148 /// (recursively) loading declarations.
1149 ///
1150 /// The declarations on the identifier chain for these identifiers will be
1151 /// loaded once the recursive loading has completed.
1152 llvm::MapVector<IdentifierInfo *, SmallVector<GlobalDeclID, 4>>
1153 PendingIdentifierInfos;
1154
1155 /// The set of lookup results that we have faked in order to support
1156 /// merging of partially deserialized decls but that we have not yet removed.
1157 llvm::SmallMapVector<const IdentifierInfo *, SmallVector<NamedDecl *, 2>, 16>
1158 PendingFakeLookupResults;
1159
1160 /// The generation number of each identifier, which keeps track of
1161 /// the last time we loaded information about this identifier.
1162 llvm::DenseMap<const IdentifierInfo *, unsigned> IdentifierGeneration;
1163
1164 /// Contains declarations and definitions that could be
1165 /// "interesting" to the ASTConsumer, when we get that AST consumer.
1166 ///
1167 /// "Interesting" declarations are those that have data that may
1168 /// need to be emitted, such as inline function definitions or
1169 /// Objective-C protocols.
1170 std::deque<Decl *> PotentiallyInterestingDecls;
1171
1172 /// The list of deduced function types that we have not yet read, because
1173 /// they might contain a deduced return type that refers to a local type
1174 /// declared within the function.
1175 SmallVector<std::pair<FunctionDecl *, serialization::TypeID>, 16>
1176 PendingDeducedFunctionTypes;
1177
1178 /// The list of deduced variable types that we have not yet read, because
1179 /// they might contain a deduced type that refers to a local type declared
1180 /// within the variable.
1181 SmallVector<std::pair<VarDecl *, serialization::TypeID>, 16>
1182 PendingDeducedVarTypes;
1183
1184 /// The list of redeclaration chains that still need to be
1185 /// reconstructed, and the local offset to the corresponding list
1186 /// of redeclarations.
1187 SmallVector<std::pair<Decl *, uint64_t>, 16> PendingDeclChains;
1188
1189 /// The list of canonical declarations whose redeclaration chains
1190 /// need to be marked as incomplete once we're done deserializing things.
1191 SmallVector<Decl *, 16> PendingIncompleteDeclChains;
1192
1193 /// The Decl IDs for the Sema/Lexical DeclContext of a Decl that has
1194 /// been loaded but its DeclContext was not set yet.
1195 struct PendingDeclContextInfo {
1196 Decl *D;
1197 GlobalDeclID SemaDC;
1198 GlobalDeclID LexicalDC;
1199 };
1200
1201 /// The set of Decls that have been loaded but their DeclContexts are
1202 /// not set yet.
1203 ///
1204 /// The DeclContexts for these Decls will be set once recursive loading has
1205 /// been completed.
1206 std::deque<PendingDeclContextInfo> PendingDeclContextInfos;
1207
1208 template <typename DeclTy>
1209 using DuplicateObjCDecls = std::pair<DeclTy *, DeclTy *>;
1210
1211 /// When resolving duplicate ivars from Objective-C extensions we don't error
1212 /// out immediately but check if can merge identical extensions. Not checking
1213 /// extensions for equality immediately because ivar deserialization isn't
1214 /// over yet at that point.
1215 llvm::SmallMapVector<DuplicateObjCDecls<ObjCCategoryDecl>,
1217 2>
1218 PendingObjCExtensionIvarRedeclarations;
1219
1220 /// Members that have been added to classes, for which the class has not yet
1221 /// been notified. CXXRecordDecl::addedMember will be called for each of
1222 /// these once recursive deserialization is complete.
1223 SmallVector<std::pair<CXXRecordDecl*, Decl*>, 4> PendingAddedClassMembers;
1224
1225 /// The set of NamedDecls that have been loaded, but are members of a
1226 /// context that has been merged into another context where the corresponding
1227 /// declaration is either missing or has not yet been loaded.
1228 ///
1229 /// We will check whether the corresponding declaration is in fact missing
1230 /// once recursing loading has been completed.
1231 llvm::SmallVector<NamedDecl *, 16> PendingOdrMergeChecks;
1232
1233 using DataPointers =
1234 std::pair<CXXRecordDecl *, struct CXXRecordDecl::DefinitionData *>;
1235 using ObjCInterfaceDataPointers =
1236 std::pair<ObjCInterfaceDecl *,
1237 struct ObjCInterfaceDecl::DefinitionData *>;
1238 using ObjCProtocolDataPointers =
1239 std::pair<ObjCProtocolDecl *, struct ObjCProtocolDecl::DefinitionData *>;
1240
1241 /// Record definitions in which we found an ODR violation.
1242 llvm::SmallDenseMap<CXXRecordDecl *, llvm::SmallVector<DataPointers, 2>, 2>
1243 PendingOdrMergeFailures;
1244
1245 /// C/ObjC record definitions in which we found an ODR violation.
1246 llvm::SmallDenseMap<RecordDecl *, llvm::SmallVector<RecordDecl *, 2>, 2>
1247 PendingRecordOdrMergeFailures;
1248
1249 /// Function definitions in which we found an ODR violation.
1250 llvm::SmallDenseMap<FunctionDecl *, llvm::SmallVector<FunctionDecl *, 2>, 2>
1251 PendingFunctionOdrMergeFailures;
1252
1253 /// Enum definitions in which we found an ODR violation.
1254 llvm::SmallDenseMap<EnumDecl *, llvm::SmallVector<EnumDecl *, 2>, 2>
1255 PendingEnumOdrMergeFailures;
1256
1257 /// ObjCInterfaceDecl in which we found an ODR violation.
1258 llvm::SmallDenseMap<ObjCInterfaceDecl *,
1260 PendingObjCInterfaceOdrMergeFailures;
1261
1262 /// ObjCProtocolDecl in which we found an ODR violation.
1263 llvm::SmallDenseMap<ObjCProtocolDecl *,
1265 PendingObjCProtocolOdrMergeFailures;
1266
1267 /// DeclContexts in which we have diagnosed an ODR violation.
1268 llvm::SmallPtrSet<DeclContext*, 2> DiagnosedOdrMergeFailures;
1269
1270 /// The set of Objective-C categories that have been deserialized
1271 /// since the last time the declaration chains were linked.
1272 llvm::SmallPtrSet<ObjCCategoryDecl *, 16> CategoriesDeserialized;
1273
1274 /// The set of Objective-C class definitions that have already been
1275 /// loaded, for which we will need to check for categories whenever a new
1276 /// module is loaded.
1277 SmallVector<ObjCInterfaceDecl *, 16> ObjCClassesLoaded;
1278
1279 using KeyDeclsMap = llvm::DenseMap<Decl *, SmallVector<GlobalDeclID, 2>>;
1280
1281 /// A mapping from canonical declarations to the set of global
1282 /// declaration IDs for key declaration that have been merged with that
1283 /// canonical declaration. A key declaration is a formerly-canonical
1284 /// declaration whose module did not import any other key declaration for that
1285 /// entity. These are the IDs that we use as keys when finding redecl chains.
1286 KeyDeclsMap KeyDecls;
1287
1288 /// A mapping from DeclContexts to the semantic DeclContext that we
1289 /// are treating as the definition of the entity. This is used, for instance,
1290 /// when merging implicit instantiations of class templates across modules.
1291 llvm::DenseMap<DeclContext *, DeclContext *> MergedDeclContexts;
1292
1293 /// A mapping from canonical declarations of enums to their canonical
1294 /// definitions. Only populated when using modules in C++.
1295 llvm::DenseMap<EnumDecl *, EnumDecl *> EnumDefinitions;
1296
1297 /// A mapping from canonical declarations of records to their canonical
1298 /// definitions. Doesn't cover CXXRecordDecl.
1299 llvm::DenseMap<RecordDecl *, RecordDecl *> RecordDefinitions;
1300
1301 /// When reading a Stmt tree, Stmt operands are placed in this stack.
1302 SmallVector<Stmt *, 16> StmtStack;
1303
1304 /// What kind of records we are reading.
1305 enum ReadingKind {
1306 Read_None, Read_Decl, Read_Type, Read_Stmt
1307 };
1308
1309 /// What kind of records we are reading.
1310 ReadingKind ReadingKind = Read_None;
1311
1312 /// RAII object to change the reading kind.
1313 class ReadingKindTracker {
1314 ASTReader &Reader;
1315 enum ReadingKind PrevKind;
1316
1317 public:
1318 ReadingKindTracker(enum ReadingKind newKind, ASTReader &reader)
1319 : Reader(reader), PrevKind(Reader.ReadingKind) {
1320 Reader.ReadingKind = newKind;
1321 }
1322
1323 ReadingKindTracker(const ReadingKindTracker &) = delete;
1324 ReadingKindTracker &operator=(const ReadingKindTracker &) = delete;
1325 ~ReadingKindTracker() { Reader.ReadingKind = PrevKind; }
1326 };
1327
1328 /// RAII object to mark the start of processing updates.
1329 class ProcessingUpdatesRAIIObj {
1330 ASTReader &Reader;
1331 bool PrevState;
1332
1333 public:
1334 ProcessingUpdatesRAIIObj(ASTReader &reader)
1335 : Reader(reader), PrevState(Reader.ProcessingUpdateRecords) {
1336 Reader.ProcessingUpdateRecords = true;
1337 }
1338
1339 ProcessingUpdatesRAIIObj(const ProcessingUpdatesRAIIObj &) = delete;
1340 ProcessingUpdatesRAIIObj &
1341 operator=(const ProcessingUpdatesRAIIObj &) = delete;
1342 ~ProcessingUpdatesRAIIObj() { Reader.ProcessingUpdateRecords = PrevState; }
1343 };
1344
1345 /// Suggested contents of the predefines buffer, after this
1346 /// PCH file has been processed.
1347 ///
1348 /// In most cases, this string will be empty, because the predefines
1349 /// buffer computed to build the PCH file will be identical to the
1350 /// predefines buffer computed from the command line. However, when
1351 /// there are differences that the PCH reader can work around, this
1352 /// predefines buffer may contain additional definitions.
1353 std::string SuggestedPredefines;
1354
1355 llvm::DenseMap<const Decl *, bool> DefinitionSource;
1356
1357 bool shouldDisableValidationForFile(const serialization::ModuleFile &M) const;
1358
1359 /// Reads a statement from the specified cursor.
1360 Stmt *ReadStmtFromStream(ModuleFile &F);
1361
1362 /// Retrieve the stored information about an input file.
1363 serialization::InputFileInfo getInputFileInfo(ModuleFile &F, unsigned ID);
1364
1365 /// Retrieve the file entry and 'overridden' bit for an input
1366 /// file in the given module file.
1367 serialization::InputFile getInputFile(ModuleFile &F, unsigned ID,
1368 bool Complain = true);
1369
1370 /// The buffer used as the temporary backing storage for resolved paths.
1371 SmallString<0> PathBuf;
1372
1373 /// A wrapper around StringRef that temporarily borrows the underlying buffer.
1374 class TemporarilyOwnedStringRef {
1375 StringRef String;
1376 llvm::SaveAndRestore<SmallString<0>> UnderlyingBuffer;
1377
1378 public:
1379 TemporarilyOwnedStringRef(StringRef S, SmallString<0> &UnderlyingBuffer)
1380 : String(S), UnderlyingBuffer(UnderlyingBuffer, {}) {}
1381
1382 /// Return the wrapped \c StringRef that must be outlived by \c this.
1383 const StringRef *operator->() const & { return &String; }
1384 const StringRef &operator*() const & { return String; }
1385
1386 /// Make it harder to get a \c StringRef that outlives \c this.
1387 const StringRef *operator->() && = delete;
1388 const StringRef &operator*() && = delete;
1389 };
1390
1391public:
1392 /// Get the buffer for resolving paths.
1393 SmallString<0> &getPathBuf() { return PathBuf; }
1394
1395 /// Resolve \c Path in the context of module file \c M. The return value
1396 /// must go out of scope before the next call to \c ResolveImportedPath.
1397 static TemporarilyOwnedStringRef
1398 ResolveImportedPath(SmallString<0> &Buf, StringRef Path, ModuleFile &ModF);
1399 /// Resolve \c Path in the context of the \c Prefix directory. The return
1400 /// value must go out of scope before the next call to \c ResolveImportedPath.
1401 static TemporarilyOwnedStringRef
1402 ResolveImportedPath(SmallString<0> &Buf, StringRef Path, StringRef Prefix);
1403
1404 /// Resolve \c Path in the context of module file \c M.
1405 static std::string ResolveImportedPathAndAllocate(SmallString<0> &Buf,
1406 StringRef Path,
1407 ModuleFile &ModF);
1408 /// Resolve \c Path in the context of the \c Prefix directory.
1409 static std::string ResolveImportedPathAndAllocate(SmallString<0> &Buf,
1410 StringRef Path,
1411 StringRef Prefix);
1412
1413 /// Returns the first key declaration for the given declaration. This
1414 /// is one that is formerly-canonical (or still canonical) and whose module
1415 /// did not import any other key declaration of the entity.
1417 D = D->getCanonicalDecl();
1418 if (D->isFromASTFile())
1419 return D;
1420
1421 auto I = KeyDecls.find(D);
1422 if (I == KeyDecls.end() || I->second.empty())
1423 return D;
1424 return GetExistingDecl(I->second[0]);
1425 }
1426 const Decl *getKeyDeclaration(const Decl *D) {
1427 return getKeyDeclaration(const_cast<Decl*>(D));
1428 }
1429
1430 /// Run a callback on each imported key declaration of \p D.
1431 template <typename Fn>
1432 void forEachImportedKeyDecl(const Decl *D, Fn Visit) {
1433 D = D->getCanonicalDecl();
1434 if (D->isFromASTFile())
1435 Visit(D);
1436
1437 auto It = KeyDecls.find(const_cast<Decl*>(D));
1438 if (It != KeyDecls.end())
1439 for (auto ID : It->second)
1440 Visit(GetExistingDecl(ID));
1441 }
1442
1443 /// Get the loaded lookup tables for \p Primary, if any.
1445 getLoadedLookupTables(DeclContext *Primary) const;
1446
1447 /// Get the loaded specializations lookup tables for \p D,
1448 /// if any.
1450 getLoadedSpecializationsLookupTables(const Decl *D, bool IsPartial);
1451
1452 /// If we have any unloaded specialization for \p D
1453 bool haveUnloadedSpecializations(const Decl *D) const;
1454
1455private:
1456 struct ImportedModule {
1457 ModuleFile *Mod;
1458 ModuleFile *ImportedBy;
1459 SourceLocation ImportLoc;
1460
1461 ImportedModule(ModuleFile *Mod,
1462 ModuleFile *ImportedBy,
1463 SourceLocation ImportLoc)
1464 : Mod(Mod), ImportedBy(ImportedBy), ImportLoc(ImportLoc) {}
1465 };
1466
1467 ASTReadResult ReadASTCore(StringRef FileName, ModuleKind Type,
1468 SourceLocation ImportLoc, ModuleFile *ImportedBy,
1469 SmallVectorImpl<ImportedModule> &Loaded,
1470 off_t ExpectedSize, time_t ExpectedModTime,
1471 ASTFileSignature ExpectedSignature,
1472 unsigned ClientLoadCapabilities);
1473 ASTReadResult ReadControlBlock(ModuleFile &F,
1474 SmallVectorImpl<ImportedModule> &Loaded,
1475 const ModuleFile *ImportedBy,
1476 unsigned ClientLoadCapabilities);
1477 static ASTReadResult
1478 ReadOptionsBlock(llvm::BitstreamCursor &Stream, StringRef Filename,
1479 unsigned ClientLoadCapabilities,
1480 bool AllowCompatibleConfigurationMismatch,
1481 ASTReaderListener &Listener,
1482 std::string &SuggestedPredefines);
1483
1484 /// Read the unhashed control block.
1485 ///
1486 /// This has no effect on \c F.Stream, instead creating a fresh cursor from
1487 /// \c F.Data and reading ahead.
1488 ASTReadResult readUnhashedControlBlock(ModuleFile &F, bool WasImportedBy,
1489 unsigned ClientLoadCapabilities);
1490
1491 static ASTReadResult readUnhashedControlBlockImpl(
1492 ModuleFile *F, llvm::StringRef StreamData, StringRef Filename,
1493 unsigned ClientLoadCapabilities,
1494 bool AllowCompatibleConfigurationMismatch, ASTReaderListener *Listener,
1495 bool ValidateDiagnosticOptions);
1496
1497 llvm::Error ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities);
1498 llvm::Error ReadExtensionBlock(ModuleFile &F);
1499 void ReadModuleOffsetMap(ModuleFile &F) const;
1500 void ParseLineTable(ModuleFile &F, const RecordData &Record);
1501 llvm::Error ReadSourceManagerBlock(ModuleFile &F);
1502 SourceLocation getImportLocation(ModuleFile *F);
1503 ASTReadResult ReadModuleMapFileBlock(RecordData &Record, ModuleFile &F,
1504 const ModuleFile *ImportedBy,
1505 unsigned ClientLoadCapabilities);
1506 llvm::Error ReadSubmoduleBlock(ModuleFile &F,
1507 unsigned ClientLoadCapabilities);
1508 static bool ParseLanguageOptions(const RecordData &Record,
1509 StringRef ModuleFilename, bool Complain,
1510 ASTReaderListener &Listener,
1511 bool AllowCompatibleDifferences);
1512 static bool ParseTargetOptions(const RecordData &Record,
1513 StringRef ModuleFilename, bool Complain,
1514 ASTReaderListener &Listener,
1515 bool AllowCompatibleDifferences);
1516 static bool ParseDiagnosticOptions(const RecordData &Record,
1517 StringRef ModuleFilename, bool Complain,
1518 ASTReaderListener &Listener);
1519 static bool ParseFileSystemOptions(const RecordData &Record, bool Complain,
1520 ASTReaderListener &Listener);
1521 static bool ParseHeaderSearchOptions(const RecordData &Record,
1522 StringRef ModuleFilename, bool Complain,
1523 ASTReaderListener &Listener);
1524 static bool ParseHeaderSearchPaths(const RecordData &Record, bool Complain,
1525 ASTReaderListener &Listener);
1526 static bool ParsePreprocessorOptions(const RecordData &Record,
1527 StringRef ModuleFilename, bool Complain,
1528 ASTReaderListener &Listener,
1529 std::string &SuggestedPredefines);
1530
1531 struct RecordLocation {
1532 ModuleFile *F;
1533 uint64_t Offset;
1534
1535 RecordLocation(ModuleFile *M, uint64_t O) : F(M), Offset(O) {}
1536 };
1537
1538 QualType readTypeRecord(serialization::TypeID ID);
1539 RecordLocation TypeCursorForIndex(serialization::TypeID ID);
1540 void LoadedDecl(unsigned Index, Decl *D);
1541 Decl *ReadDeclRecord(GlobalDeclID ID);
1542 void markIncompleteDeclChain(Decl *D);
1543
1544 /// Returns the most recent declaration of a declaration (which must be
1545 /// of a redeclarable kind) that is either local or has already been loaded
1546 /// merged into its redecl chain.
1547 Decl *getMostRecentExistingDecl(Decl *D);
1548
1549 RecordLocation DeclCursorForID(GlobalDeclID ID, SourceLocation &Location);
1550 void loadDeclUpdateRecords(PendingUpdateRecord &Record);
1551 void loadPendingDeclChain(Decl *D, uint64_t LocalOffset);
1552 void loadObjCCategories(GlobalDeclID ID, ObjCInterfaceDecl *D,
1553 unsigned PreviousGeneration = 0);
1554
1555 RecordLocation getLocalBitOffset(uint64_t GlobalOffset);
1556 uint64_t getGlobalBitOffset(ModuleFile &M, uint64_t LocalOffset);
1557
1558 /// Returns the first preprocessed entity ID that begins or ends after
1559 /// \arg Loc.
1561 findPreprocessedEntity(SourceLocation Loc, bool EndsAfter) const;
1562
1563 /// Find the next module that contains entities and return the ID
1564 /// of the first entry.
1565 ///
1566 /// \param SLocMapI points at a chunk of a module that contains no
1567 /// preprocessed entities or the entities it contains are not the
1568 /// ones we are looking for.
1570 findNextPreprocessedEntity(
1572
1573 /// Returns (ModuleFile, Local index) pair for \p GlobalIndex of a
1574 /// preprocessed entity.
1575 std::pair<ModuleFile *, unsigned>
1576 getModulePreprocessedEntity(unsigned GlobalIndex);
1577
1578 /// Returns (begin, end) pair for the preprocessed entities of a
1579 /// particular module.
1580 llvm::iterator_range<PreprocessingRecord::iterator>
1581 getModulePreprocessedEntities(ModuleFile &Mod) const;
1582
1583 bool canRecoverFromOutOfDate(StringRef ModuleFileName,
1584 unsigned ClientLoadCapabilities);
1585
1586public:
1588 : public llvm::iterator_adaptor_base<
1589 ModuleDeclIterator, const serialization::unaligned_decl_id_t *,
1590 std::random_access_iterator_tag, const Decl *, ptrdiff_t,
1591 const Decl *, const Decl *> {
1592 ASTReader *Reader = nullptr;
1593 ModuleFile *Mod = nullptr;
1594
1595 public:
1596 ModuleDeclIterator() : iterator_adaptor_base(nullptr) {}
1597
1600 : iterator_adaptor_base(Pos), Reader(Reader), Mod(Mod) {}
1601
1602 value_type operator*() const {
1603 LocalDeclID ID = LocalDeclID::get(*Reader, *Mod, *I);
1604 return Reader->GetDecl(Reader->getGlobalDeclID(*Mod, ID));
1605 }
1606
1607 value_type operator->() const { return **this; }
1608
1609 bool operator==(const ModuleDeclIterator &RHS) const {
1610 assert(Reader == RHS.Reader && Mod == RHS.Mod);
1611 return I == RHS.I;
1612 }
1613 };
1614
1615 llvm::iterator_range<ModuleDeclIterator>
1617
1618private:
1619 bool isConsumerInterestedIn(Decl *D);
1620 void PassInterestingDeclsToConsumer();
1621 void PassInterestingDeclToConsumer(Decl *D);
1622 void PassVTableToConsumer(CXXRecordDecl *RD);
1623
1624 void finishPendingActions();
1625 void diagnoseOdrViolations();
1626
1627 void pushExternalDeclIntoScope(NamedDecl *D, DeclarationName Name);
1628
1629 void addPendingDeclContextInfo(Decl *D, GlobalDeclID SemaDC,
1630 GlobalDeclID LexicalDC) {
1631 assert(D);
1632 PendingDeclContextInfo Info = { D, SemaDC, LexicalDC };
1633 PendingDeclContextInfos.push_back(Info);
1634 }
1635
1636 /// Produce an error diagnostic and return true.
1637 ///
1638 /// This routine should only be used for fatal errors that have to
1639 /// do with non-routine failures (e.g., corrupted AST file).
1640 void Error(StringRef Msg) const;
1641 void Error(unsigned DiagID, StringRef Arg1 = StringRef(),
1642 StringRef Arg2 = StringRef(), StringRef Arg3 = StringRef()) const;
1643 void Error(llvm::Error &&Err) const;
1644
1645 /// Translate a \param GlobalDeclID to the index of DeclsLoaded array.
1646 unsigned translateGlobalDeclIDToIndex(GlobalDeclID ID) const;
1647
1648 /// Translate an \param IdentifierID ID to the index of IdentifiersLoaded
1649 /// array and the corresponding module file.
1650 std::pair<ModuleFile *, unsigned>
1651 translateIdentifierIDToIndex(serialization::IdentifierID ID) const;
1652
1653 /// Translate an \param TypeID ID to the index of TypesLoaded
1654 /// array and the corresponding module file.
1655 std::pair<ModuleFile *, unsigned>
1656 translateTypeIDToIndex(serialization::TypeID ID) const;
1657
1658 /// Get a predefined Decl from ASTContext.
1659 Decl *getPredefinedDecl(PredefinedDeclIDs ID);
1660
1661public:
1662 /// Load the AST file and validate its contents against the given
1663 /// Preprocessor.
1664 ///
1665 /// \param PP the preprocessor associated with the context in which this
1666 /// precompiled header will be loaded.
1667 ///
1668 /// \param Context the AST context that this precompiled header will be
1669 /// loaded into, if any.
1670 ///
1671 /// \param PCHContainerRdr the PCHContainerOperations to use for loading and
1672 /// creating modules.
1673 ///
1674 /// \param Extensions the list of module file extensions that can be loaded
1675 /// from the AST files.
1676 ///
1677 /// \param isysroot If non-NULL, the system include path specified by the
1678 /// user. This is only used with relocatable PCH files. If non-NULL,
1679 /// a relocatable PCH file will use the default path "/".
1680 ///
1681 /// \param DisableValidationKind If set, the AST reader will suppress most
1682 /// of its regular consistency checking, allowing the use of precompiled
1683 /// headers and module files that cannot be determined to be compatible.
1684 ///
1685 /// \param AllowASTWithCompilerErrors If true, the AST reader will accept an
1686 /// AST file the was created out of an AST with compiler errors,
1687 /// otherwise it will reject it.
1688 ///
1689 /// \param AllowConfigurationMismatch If true, the AST reader will not check
1690 /// for configuration differences between the AST file and the invocation.
1691 ///
1692 /// \param ValidateSystemInputs If true, the AST reader will validate
1693 /// system input files in addition to user input files. This is only
1694 /// meaningful if \p DisableValidation is false.
1695 ///
1696 /// \param UseGlobalIndex If true, the AST reader will try to load and use
1697 /// the global module index.
1698 ///
1699 /// \param ReadTimer If non-null, a timer used to track the time spent
1700 /// deserializing.
1701 ASTReader(Preprocessor &PP, InMemoryModuleCache &ModuleCache,
1702 ASTContext *Context, const PCHContainerReader &PCHContainerRdr,
1703 ArrayRef<std::shared_ptr<ModuleFileExtension>> Extensions,
1704 StringRef isysroot = "",
1705 DisableValidationForModuleKind DisableValidationKind =
1707 bool AllowASTWithCompilerErrors = false,
1708 bool AllowConfigurationMismatch = false,
1709 bool ValidateSystemInputs = false,
1710 bool ValidateASTInputFilesContent = false,
1711 bool UseGlobalIndex = true,
1712 std::unique_ptr<llvm::Timer> ReadTimer = {});
1713 ASTReader(const ASTReader &) = delete;
1714 ASTReader &operator=(const ASTReader &) = delete;
1715 ~ASTReader() override;
1716
1717 SourceManager &getSourceManager() const { return SourceMgr; }
1718 FileManager &getFileManager() const { return FileMgr; }
1719 DiagnosticsEngine &getDiags() const { return Diags; }
1720
1721 /// Flags that indicate what kind of AST loading failures the client
1722 /// of the AST reader can directly handle.
1723 ///
1724 /// When a client states that it can handle a particular kind of failure,
1725 /// the AST reader will not emit errors when producing that kind of failure.
1727 /// The client can't handle any AST loading failures.
1729
1730 /// The client can handle an AST file that cannot load because it
1731 /// is missing.
1733
1734 /// The client can handle an AST file that cannot load because it
1735 /// is out-of-date relative to its input files.
1737
1738 /// The client can handle an AST file that cannot load because it
1739 /// was built with a different version of Clang.
1741
1742 /// The client can handle an AST file that cannot load because it's
1743 /// compiled configuration doesn't match that of the context it was
1744 /// loaded into.
1746
1747 /// If a module file is marked with errors treat it as out-of-date so the
1748 /// caller can rebuild it.
1751
1752 /// Load the AST file designated by the given file name.
1753 ///
1754 /// \param FileName The name of the AST file to load.
1755 ///
1756 /// \param Type The kind of AST being loaded, e.g., PCH, module, main file,
1757 /// or preamble.
1758 ///
1759 /// \param ImportLoc the location where the module file will be considered as
1760 /// imported from. For non-module AST types it should be invalid.
1761 ///
1762 /// \param ClientLoadCapabilities The set of client load-failure
1763 /// capabilities, represented as a bitset of the enumerators of
1764 /// LoadFailureCapabilities.
1765 ///
1766 /// \param LoadedModuleFile The optional out-parameter refers to the new
1767 /// loaded modules. In case the module specified by FileName is already
1768 /// loaded, the module file pointer referred by NewLoadedModuleFile wouldn't
1769 /// change. Otherwise if the AST file get loaded successfully,
1770 /// NewLoadedModuleFile would refer to the address of the new loaded top level
1771 /// module. The state of NewLoadedModuleFile is unspecified if the AST file
1772 /// isn't loaded successfully.
1774 SourceLocation ImportLoc,
1775 unsigned ClientLoadCapabilities,
1776 ModuleFile **NewLoadedModuleFile = nullptr);
1777
1778 /// Make the entities in the given module and any of its (non-explicit)
1779 /// submodules visible to name lookup.
1780 ///
1781 /// \param Mod The module whose names should be made visible.
1782 ///
1783 /// \param NameVisibility The level of visibility to give the names in the
1784 /// module. Visibility can only be increased over time.
1785 ///
1786 /// \param ImportLoc The location at which the import occurs.
1787 void makeModuleVisible(Module *Mod,
1788 Module::NameVisibilityKind NameVisibility,
1789 SourceLocation ImportLoc);
1790
1791 /// Make the names within this set of hidden names visible.
1792 void makeNamesVisible(const HiddenNames &Names, Module *Owner);
1793
1794 /// Note that MergedDef is a redefinition of the canonical definition
1795 /// Def, so Def should be visible whenever MergedDef is.
1796 void mergeDefinitionVisibility(NamedDecl *Def, NamedDecl *MergedDef);
1797
1798 /// Take the AST callbacks listener.
1799 std::unique_ptr<ASTReaderListener> takeListener() {
1800 return std::move(Listener);
1801 }
1802
1803 /// Set the AST callbacks listener.
1804 void setListener(std::unique_ptr<ASTReaderListener> Listener) {
1805 this->Listener = std::move(Listener);
1806 }
1807
1808 /// Add an AST callback listener.
1809 ///
1810 /// Takes ownership of \p L.
1811 void addListener(std::unique_ptr<ASTReaderListener> L) {
1812 if (Listener)
1813 L = std::make_unique<ChainedASTReaderListener>(std::move(L),
1814 std::move(Listener));
1815 Listener = std::move(L);
1816 }
1817
1818 /// RAII object to temporarily add an AST callback listener.
1820 ASTReader &Reader;
1821 bool Chained = false;
1822
1823 public:
1824 ListenerScope(ASTReader &Reader, std::unique_ptr<ASTReaderListener> L)
1825 : Reader(Reader) {
1826 auto Old = Reader.takeListener();
1827 if (Old) {
1828 Chained = true;
1829 L = std::make_unique<ChainedASTReaderListener>(std::move(L),
1830 std::move(Old));
1831 }
1832 Reader.setListener(std::move(L));
1833 }
1834
1836 auto New = Reader.takeListener();
1837 if (Chained)
1838 Reader.setListener(static_cast<ChainedASTReaderListener *>(New.get())
1839 ->takeSecond());
1840 }
1841 };
1842
1843 /// Set the AST deserialization listener.
1845 bool TakeOwnership = false);
1846
1847 /// Get the AST deserialization listener.
1849 return DeserializationListener;
1850 }
1851
1852 /// Determine whether this AST reader has a global index.
1853 bool hasGlobalIndex() const { return (bool)GlobalIndex; }
1854
1855 /// Return global module index.
1856 GlobalModuleIndex *getGlobalIndex() { return GlobalIndex.get(); }
1857
1858 /// Reset reader for a reload try.
1859 void resetForReload() { TriedLoadingGlobalIndex = false; }
1860
1861 /// Attempts to load the global index.
1862 ///
1863 /// \returns true if loading the global index has failed for any reason.
1864 bool loadGlobalIndex();
1865
1866 /// Determine whether we tried to load the global index, but failed,
1867 /// e.g., because it is out-of-date or does not exist.
1868 bool isGlobalIndexUnavailable() const;
1869
1870 /// Initializes the ASTContext
1871 void InitializeContext();
1872
1873 /// Update the state of Sema after loading some additional modules.
1874 void UpdateSema();
1875
1876 /// Add in-memory (virtual file) buffer.
1878 std::unique_ptr<llvm::MemoryBuffer> Buffer) {
1879 ModuleMgr.addInMemoryBuffer(FileName, std::move(Buffer));
1880 }
1881
1882 /// Finalizes the AST reader's state before writing an AST file to
1883 /// disk.
1884 ///
1885 /// This operation may undo temporary state in the AST that should not be
1886 /// emitted.
1887 void finalizeForWriting();
1888
1889 /// Retrieve the module manager.
1890 ModuleManager &getModuleManager() { return ModuleMgr; }
1891 const ModuleManager &getModuleManager() const { return ModuleMgr; }
1892
1893 /// Retrieve the preprocessor.
1894 Preprocessor &getPreprocessor() const { return PP; }
1895
1896 /// Retrieve the name of the original source file name for the primary
1897 /// module file.
1899 return ModuleMgr.getPrimaryModule().OriginalSourceFileName;
1900 }
1901
1902 /// Retrieve the name of the original source file name directly from
1903 /// the AST file, without actually loading the AST file.
1904 static std::string
1905 getOriginalSourceFile(const std::string &ASTFileName, FileManager &FileMgr,
1906 const PCHContainerReader &PCHContainerRdr,
1907 DiagnosticsEngine &Diags);
1908
1909 /// Read the control block for the named AST file.
1910 ///
1911 /// \returns true if an error occurred, false otherwise.
1912 static bool readASTFileControlBlock(
1913 StringRef Filename, FileManager &FileMgr,
1914 const InMemoryModuleCache &ModuleCache,
1915 const PCHContainerReader &PCHContainerRdr, bool FindModuleFileExtensions,
1916 ASTReaderListener &Listener, bool ValidateDiagnosticOptions,
1917 unsigned ClientLoadCapabilities = ARR_ConfigurationMismatch |
1919
1920 /// Determine whether the given AST file is acceptable to load into a
1921 /// translation unit with the given language and target options.
1922 static bool isAcceptableASTFile(StringRef Filename, FileManager &FileMgr,
1923 const InMemoryModuleCache &ModuleCache,
1924 const PCHContainerReader &PCHContainerRdr,
1925 const LangOptions &LangOpts,
1926 const TargetOptions &TargetOpts,
1927 const PreprocessorOptions &PPOpts,
1928 StringRef ExistingModuleCachePath,
1929 bool RequireStrictOptionMatches = false);
1930
1931 /// Returns the suggested contents of the predefines buffer,
1932 /// which contains a (typically-empty) subset of the predefines
1933 /// build prior to including the precompiled header.
1934 const std::string &getSuggestedPredefines() { return SuggestedPredefines; }
1935
1936 /// Read a preallocated preprocessed entity from the external source.
1937 ///
1938 /// \returns null if an error occurred that prevented the preprocessed
1939 /// entity from being loaded.
1940 PreprocessedEntity *ReadPreprocessedEntity(unsigned Index) override;
1941
1942 /// Returns a pair of [Begin, End) indices of preallocated
1943 /// preprocessed entities that \p Range encompasses.
1944 std::pair<unsigned, unsigned>
1946
1947 /// Optionally returns true or false if the preallocated preprocessed
1948 /// entity with index \p Index came from file \p FID.
1949 std::optional<bool> isPreprocessedEntityInFileID(unsigned Index,
1950 FileID FID) override;
1951
1952 /// Read a preallocated skipped range from the external source.
1953 SourceRange ReadSkippedRange(unsigned Index) override;
1954
1955 /// Read the header file information for the given file entry.
1957
1959
1960 /// Returns the number of source locations found in the chain.
1961 unsigned getTotalNumSLocs() const {
1962 return TotalNumSLocEntries;
1963 }
1964
1965 /// Returns the number of identifiers found in the chain.
1966 unsigned getTotalNumIdentifiers() const {
1967 return static_cast<unsigned>(IdentifiersLoaded.size());
1968 }
1969
1970 /// Returns the number of macros found in the chain.
1971 unsigned getTotalNumMacros() const {
1972 return static_cast<unsigned>(MacrosLoaded.size());
1973 }
1974
1975 /// Returns the number of types found in the chain.
1976 unsigned getTotalNumTypes() const {
1977 return static_cast<unsigned>(TypesLoaded.size());
1978 }
1979
1980 /// Returns the number of declarations found in the chain.
1981 unsigned getTotalNumDecls() const {
1982 return static_cast<unsigned>(DeclsLoaded.size());
1983 }
1984
1985 /// Returns the number of submodules known.
1986 unsigned getTotalNumSubmodules() const {
1987 return static_cast<unsigned>(SubmodulesLoaded.size());
1988 }
1989
1990 /// Returns the number of selectors found in the chain.
1991 unsigned getTotalNumSelectors() const {
1992 return static_cast<unsigned>(SelectorsLoaded.size());
1993 }
1994
1995 /// Returns the number of preprocessed entities known to the AST
1996 /// reader.
1998 unsigned Result = 0;
1999 for (const auto &M : ModuleMgr)
2000 Result += M.NumPreprocessedEntities;
2001 return Result;
2002 }
2003
2004 /// Resolve a type ID into a type, potentially building a new
2005 /// type.
2007
2008 /// Resolve a local type ID within a given AST file into a type.
2010
2011 /// Map a local type ID within a given AST file into a global type ID.
2014
2015 /// Read a type from the current position in the given record, which
2016 /// was read from the given AST file.
2017 QualType readType(ModuleFile &F, const RecordData &Record, unsigned &Idx) {
2018 if (Idx >= Record.size())
2019 return {};
2020
2021 return getLocalType(F, Record[Idx++]);
2022 }
2023
2024 /// Map from a local declaration ID within a given module to a
2025 /// global declaration ID.
2027
2028 /// Returns true if global DeclID \p ID originated from module \p M.
2029 bool isDeclIDFromModule(GlobalDeclID ID, ModuleFile &M) const;
2030
2031 /// Retrieve the module file that owns the given declaration, or NULL
2032 /// if the declaration is not from a module file.
2033 ModuleFile *getOwningModuleFile(const Decl *D) const;
2035
2036 /// Returns the source location for the decl \p ID.
2038
2039 /// Resolve a declaration ID into a declaration, potentially
2040 /// building a new declaration.
2042 Decl *GetExternalDecl(GlobalDeclID ID) override;
2043
2044 /// Resolve a declaration ID into a declaration. Return 0 if it's not
2045 /// been loaded yet.
2047
2048 /// Reads a declaration with the given local ID in the given module.
2050 return GetDecl(getGlobalDeclID(F, LocalID));
2051 }
2052
2053 /// Reads a declaration with the given local ID in the given module.
2054 ///
2055 /// \returns The requested declaration, casted to the given return type.
2056 template <typename T> T *GetLocalDeclAs(ModuleFile &F, LocalDeclID LocalID) {
2057 return cast_or_null<T>(GetLocalDecl(F, LocalID));
2058 }
2059
2060 /// Map a global declaration ID into the declaration ID used to
2061 /// refer to this declaration within the given module fule.
2062 ///
2063 /// \returns the global ID of the given declaration as known in the given
2064 /// module file.
2066 GlobalDeclID GlobalID);
2067
2068 /// Reads a declaration ID from the given position in a record in the
2069 /// given module.
2070 ///
2071 /// \returns The declaration ID read from the record, adjusted to a global ID.
2073 unsigned &Idx);
2074
2075 /// Reads a declaration from the given position in a record in the
2076 /// given module.
2077 Decl *ReadDecl(ModuleFile &F, const RecordDataImpl &R, unsigned &I) {
2078 return GetDecl(ReadDeclID(F, R, I));
2079 }
2080
2081 /// Reads a declaration from the given position in a record in the
2082 /// given module.
2083 ///
2084 /// \returns The declaration read from this location, casted to the given
2085 /// result type.
2086 template <typename T>
2087 T *ReadDeclAs(ModuleFile &F, const RecordDataImpl &R, unsigned &I) {
2088 return cast_or_null<T>(GetDecl(ReadDeclID(F, R, I)));
2089 }
2090
2091 /// If any redeclarations of \p D have been imported since it was
2092 /// last checked, this digs out those redeclarations and adds them to the
2093 /// redeclaration chain for \p D.
2094 void CompleteRedeclChain(const Decl *D) override;
2095
2096 CXXBaseSpecifier *GetExternalCXXBaseSpecifiers(uint64_t Offset) override;
2097
2098 /// Resolve the offset of a statement into a statement.
2099 ///
2100 /// This operation will read a new statement from the external
2101 /// source each time it is called, and is meant to be used via a
2102 /// LazyOffsetPtr (which is used by Decls for the body of functions, etc).
2103 Stmt *GetExternalDeclStmt(uint64_t Offset) override;
2104
2105 /// ReadBlockAbbrevs - Enter a subblock of the specified BlockID with the
2106 /// specified cursor. Read the abbreviations that are at the top of the block
2107 /// and then leave the cursor pointing into the block.
2108 static llvm::Error ReadBlockAbbrevs(llvm::BitstreamCursor &Cursor,
2109 unsigned BlockID,
2110 uint64_t *StartOfBlockOffset = nullptr);
2111
2112 bool LoadExternalSpecializations(const Decl *D, bool OnlyPartial) override;
2113
2114 bool
2116 ArrayRef<TemplateArgument> TemplateArgs) override;
2117
2118 /// Finds all the visible declarations with a given name.
2119 /// The current implementation of this method just loads the entire
2120 /// lookup table as unmaterialized references.
2122 DeclarationName Name) override;
2123
2124 /// Read all of the declarations lexically stored in a
2125 /// declaration context.
2126 ///
2127 /// \param DC The declaration context whose declarations will be
2128 /// read.
2129 ///
2130 /// \param IsKindWeWant A predicate indicating which declaration kinds
2131 /// we are interested in.
2132 ///
2133 /// \param Decls Vector that will contain the declarations loaded
2134 /// from the external source. The caller is responsible for merging
2135 /// these declarations with any declarations already stored in the
2136 /// declaration context.
2137 void
2139 llvm::function_ref<bool(Decl::Kind)> IsKindWeWant,
2140 SmallVectorImpl<Decl *> &Decls) override;
2141
2142 /// Get the decls that are contained in a file in the Offset/Length
2143 /// range. \p Length can be 0 to indicate a point at \p Offset instead of
2144 /// a range.
2145 void FindFileRegionDecls(FileID File, unsigned Offset, unsigned Length,
2146 SmallVectorImpl<Decl *> &Decls) override;
2147
2148 /// Notify ASTReader that we started deserialization of
2149 /// a decl or type so until FinishedDeserializing is called there may be
2150 /// decls that are initializing. Must be paired with FinishedDeserializing.
2151 void StartedDeserializing() override;
2152
2153 /// Notify ASTReader that we finished the deserialization of
2154 /// a decl or type. Must be paired with StartedDeserializing.
2155 void FinishedDeserializing() override;
2156
2157 /// Function that will be invoked when we begin parsing a new
2158 /// translation unit involving this external AST source.
2159 ///
2160 /// This function will provide all of the external definitions to
2161 /// the ASTConsumer.
2162 void StartTranslationUnit(ASTConsumer *Consumer) override;
2163
2164 /// Print some statistics about AST usage.
2165 void PrintStats() override;
2166
2167 /// Dump information about the AST reader to standard error.
2168 void dump();
2169
2170 /// Return the amount of memory used by memory buffers, breaking down
2171 /// by heap-backed versus mmap'ed memory.
2172 void getMemoryBufferSizes(MemoryBufferSizes &sizes) const override;
2173
2174 /// Initialize the semantic source with the Sema instance
2175 /// being used to perform semantic analysis on the abstract syntax
2176 /// tree.
2177 void InitializeSema(Sema &S) override;
2178
2179 /// Inform the semantic consumer that Sema is no longer available.
2180 void ForgetSema() override { SemaObj = nullptr; }
2181
2182 /// Retrieve the IdentifierInfo for the named identifier.
2183 ///
2184 /// This routine builds a new IdentifierInfo for the given identifier. If any
2185 /// declarations with this name are visible from translation unit scope, their
2186 /// declarations will be deserialized and introduced into the declaration
2187 /// chain of the identifier.
2188 IdentifierInfo *get(StringRef Name) override;
2189
2190 /// Retrieve an iterator into the set of all identifiers
2191 /// in all loaded AST files.
2193
2194 /// Load the contents of the global method pool for a given
2195 /// selector.
2196 void ReadMethodPool(Selector Sel) override;
2197
2198 /// Load the contents of the global method pool for a given
2199 /// selector if necessary.
2200 void updateOutOfDateSelector(Selector Sel) override;
2201
2202 /// Load the set of namespaces that are known to the external source,
2203 /// which will be used during typo correction.
2205 SmallVectorImpl<NamespaceDecl *> &Namespaces) override;
2206
2208 llvm::MapVector<NamedDecl *, SourceLocation> &Undefined) override;
2209
2210 void ReadMismatchingDeleteExpressions(llvm::MapVector<
2211 FieldDecl *, llvm::SmallVector<std::pair<SourceLocation, bool>, 4>> &
2212 Exprs) override;
2213
2215 SmallVectorImpl<VarDecl *> &TentativeDefs) override;
2216
2219
2222
2224
2227
2229 llvm::SmallSetVector<Decl *, 4> &Decls) override;
2230
2232 SmallVectorImpl<std::pair<Selector, SourceLocation>> &Sels) override;
2233
2235 SmallVectorImpl<std::pair<IdentifierInfo *, WeakInfo>> &WeakIDs) override;
2236
2238
2240 SmallVectorImpl<std::pair<ValueDecl *,
2241 SourceLocation>> &Pending) override;
2242
2244 llvm::MapVector<const FunctionDecl *, std::unique_ptr<LateParsedTemplate>>
2245 &LPTMap) override;
2246
2247 void AssignedLambdaNumbering(CXXRecordDecl *Lambda) override;
2248
2249 /// Load a selector from disk, registering its ID if it exists.
2250 void LoadSelector(Selector Sel);
2251
2254 const SmallVectorImpl<GlobalDeclID> &DeclIDs,
2255 SmallVectorImpl<Decl *> *Decls = nullptr);
2256
2257 /// Report a diagnostic.
2258 DiagnosticBuilder Diag(unsigned DiagID) const;
2259
2260 /// Report a diagnostic.
2261 DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID) const;
2262
2264 llvm::function_ref<void()> Fn);
2265
2267
2269 unsigned &Idx) {
2271 }
2272
2274 // Note that we are loading an identifier.
2275 Deserializing AnIdentifier(this);
2276
2277 return DecodeIdentifierInfo(ID);
2278 }
2279
2280 IdentifierInfo *getLocalIdentifier(ModuleFile &M, uint64_t LocalID);
2281
2283 uint64_t LocalID);
2284
2285 void resolvePendingMacro(IdentifierInfo *II, const PendingMacroInfo &PMInfo);
2286
2287 /// Retrieve the macro with the given ID.
2289
2290 /// Retrieve the global macro ID corresponding to the given local
2291 /// ID within the given module file.
2293
2294 /// Read the source location entry with index ID.
2295 bool ReadSLocEntry(int ID) override;
2296 /// Get the index ID for the loaded SourceLocation offset.
2297 int getSLocEntryID(SourceLocation::UIntTy SLocOffset) override;
2298 /// Try to read the offset of the SLocEntry at the given index in the given
2299 /// module file.
2301 unsigned Index);
2302
2303 /// Retrieve the module import location and module name for the
2304 /// given source manager entry ID.
2305 std::pair<SourceLocation, StringRef> getModuleImportLoc(int ID) override;
2306
2307 /// Retrieve the global submodule ID given a module and its local ID
2308 /// number.
2310 unsigned LocalID) const;
2311
2312 /// Retrieve the submodule that corresponds to a global submodule ID.
2313 ///
2315
2316 /// Retrieve the module that corresponds to the given module ID.
2317 ///
2318 /// Note: overrides method in ExternalASTSource
2319 Module *getModule(unsigned ID) override;
2320
2321 /// Retrieve the module file with a given local ID within the specified
2322 /// ModuleFile.
2323 ModuleFile *getLocalModuleFile(ModuleFile &M, unsigned ID) const;
2324
2325 /// Get an ID for the given module file.
2326 unsigned getModuleFileID(ModuleFile *M);
2327
2328 /// Return a descriptor for the corresponding module.
2329 std::optional<ASTSourceDescriptor> getSourceDescriptor(unsigned ID) override;
2330
2331 ExtKind hasExternalDefinitions(const Decl *D) override;
2332
2333 /// Retrieve a selector from the given module with its local ID
2334 /// number.
2335 Selector getLocalSelector(ModuleFile &M, unsigned LocalID);
2336
2338
2340 uint32_t GetNumExternalSelectors() override;
2341
2342 Selector ReadSelector(ModuleFile &M, const RecordData &Record, unsigned &Idx) {
2343 return getLocalSelector(M, Record[Idx++]);
2344 }
2345
2346 /// Retrieve the global selector ID that corresponds to this
2347 /// the local selector ID in a given module.
2349 unsigned LocalID) const;
2350
2351 /// Read the contents of a CXXCtorInitializer array.
2352 CXXCtorInitializer **GetExternalCXXCtorInitializers(uint64_t Offset) override;
2353
2354 /// Read a AlignPackInfo from raw form.
2357 }
2358
2360
2361 /// Read a source location from raw form and return it in its
2362 /// originating module file's source location space.
2363 std::pair<SourceLocation, unsigned>
2365 LocSeq *Seq = nullptr) const {
2367 }
2368
2369 /// Read a source location from raw form.
2371 LocSeq *Seq = nullptr) const {
2372 if (!MF.ModuleOffsetMap.empty())
2373 ReadModuleOffsetMap(MF);
2374
2375 auto [Loc, ModuleFileIndex] = ReadUntranslatedSourceLocation(Raw, Seq);
2376 ModuleFile *OwningModuleFile =
2377 ModuleFileIndex == 0 ? &MF : MF.TransitiveImports[ModuleFileIndex - 1];
2378
2379 assert(!SourceMgr.isLoadedSourceLocation(Loc) &&
2380 "Run out source location space");
2381
2382 return TranslateSourceLocation(*OwningModuleFile, Loc);
2383 }
2384
2385 /// Translate a source location from another module file's source
2386 /// location space into ours.
2388 SourceLocation Loc) const {
2389 if (Loc.isInvalid())
2390 return Loc;
2391
2392 // FIXME: TranslateSourceLocation is not re-enterable. It is problematic
2393 // to call TranslateSourceLocation on a translated source location.
2394 // We either need a method to know whether or not a source location is
2395 // translated or refactor the code to make it clear that
2396 // TranslateSourceLocation won't be called with translated source location.
2397
2398 return Loc.getLocWithOffset(ModuleFile.SLocEntryBaseOffset - 2);
2399 }
2400
2401 /// Read a source location.
2403 const RecordDataImpl &Record, unsigned &Idx,
2404 LocSeq *Seq = nullptr) {
2405 return ReadSourceLocation(ModuleFile, Record[Idx++], Seq);
2406 }
2407
2408 /// Read a FileID.
2410 unsigned &Idx) const {
2411 return TranslateFileID(F, FileID::get(Record[Idx++]));
2412 }
2413
2414 /// Translate a FileID from another module file's FileID space into ours.
2416 assert(FID.ID >= 0 && "Reading non-local FileID.");
2417 if (FID.isInvalid())
2418 return FID;
2419 return FileID::get(F.SLocEntryBaseID + FID.ID - 1);
2420 }
2421
2422 /// Read a source range.
2424 unsigned &Idx, LocSeq *Seq = nullptr);
2425
2426 static llvm::BitVector ReadBitVector(const RecordData &Record,
2427 const StringRef Blob);
2428
2429 // Read a string
2430 static std::string ReadString(const RecordDataImpl &Record, unsigned &Idx);
2431 static StringRef ReadStringBlob(const RecordDataImpl &Record, unsigned &Idx,
2432 StringRef &Blob);
2433
2434 // Read a path
2435 std::string ReadPath(ModuleFile &F, const RecordData &Record, unsigned &Idx);
2436
2437 // Read a path
2438 std::string ReadPath(StringRef BaseDirectory, const RecordData &Record,
2439 unsigned &Idx);
2440 std::string ReadPathBlob(StringRef BaseDirectory, const RecordData &Record,
2441 unsigned &Idx, StringRef &Blob);
2442
2443 /// Read a version tuple.
2444 static VersionTuple ReadVersionTuple(const RecordData &Record, unsigned &Idx);
2445
2447 unsigned &Idx);
2448
2449 /// Reads a statement.
2451
2452 /// Reads an expression.
2454
2455 /// Reads a sub-statement operand during statement reading.
2457 assert(ReadingKind == Read_Stmt &&
2458 "Should be called only during statement reading!");
2459 // Subexpressions are stored from last to first, so the next Stmt we need
2460 // is at the back of the stack.
2461 assert(!StmtStack.empty() && "Read too many sub-statements!");
2462 return StmtStack.pop_back_val();
2463 }
2464
2465 /// Reads a sub-expression operand during statement reading.
2466 Expr *ReadSubExpr();
2467
2468 /// Reads a token out of a record.
2469 Token ReadToken(ModuleFile &M, const RecordDataImpl &Record, unsigned &Idx);
2470
2471 /// Reads the macro record located at the given offset.
2472 MacroInfo *ReadMacroRecord(ModuleFile &F, uint64_t Offset);
2473
2474 /// Determine the global preprocessed entity ID that corresponds to
2475 /// the given local ID within the given module.
2477 getGlobalPreprocessedEntityID(ModuleFile &M, unsigned LocalID) const;
2478
2479 /// Add a macro to deserialize its macro directive history.
2480 ///
2481 /// \param II The name of the macro.
2482 /// \param M The module file.
2483 /// \param MacroDirectivesOffset Offset of the serialized macro directive
2484 /// history.
2486 uint32_t MacroDirectivesOffset);
2487
2488 /// Read the set of macros defined by this external macro source.
2489 void ReadDefinedMacros() override;
2490
2491 /// Update an out-of-date identifier.
2492 void updateOutOfDateIdentifier(const IdentifierInfo &II) override;
2493
2494 /// Note that this identifier is up-to-date.
2495 void markIdentifierUpToDate(const IdentifierInfo *II);
2496
2497 /// Load all external visible decls in the given DeclContext.
2498 void completeVisibleDeclsMap(const DeclContext *DC) override;
2499
2500 /// Retrieve the AST context that this AST reader supplements.
2502 assert(ContextObj && "requested AST context when not loading AST");
2503 return *ContextObj;
2504 }
2505
2506 // Contains the IDs for declarations that were requested before we have
2507 // access to a Sema object.
2509
2510 /// Retrieve the semantic analysis object used to analyze the
2511 /// translation unit in which the precompiled header is being
2512 /// imported.
2513 Sema *getSema() { return SemaObj; }
2514
2515 /// Get the identifier resolver used for name lookup / updates
2516 /// in the translation unit scope. We have one of these even if we don't
2517 /// have a Sema object.
2519
2520 /// Retrieve the identifier table associated with the
2521 /// preprocessor.
2523
2524 /// Record that the given ID maps to the given switch-case
2525 /// statement.
2526 void RecordSwitchCaseID(SwitchCase *SC, unsigned ID);
2527
2528 /// Retrieve the switch-case statement with the given ID.
2529 SwitchCase *getSwitchCaseWithID(unsigned ID);
2530
2531 void ClearSwitchCaseIDs();
2532
2533 /// Cursors for comments blocks.
2534 SmallVector<std::pair<llvm::BitstreamCursor,
2536
2537 /// Loads comments ranges.
2538 void ReadComments() override;
2539
2540 /// Visit all the input file infos of the given module file.
2542 serialization::ModuleFile &MF, bool IncludeSystem,
2543 llvm::function_ref<void(const serialization::InputFileInfo &IFI,
2544 bool IsSystem)>
2545 Visitor);
2546
2547 /// Visit all the input files of the given module file.
2549 bool IncludeSystem, bool Complain,
2550 llvm::function_ref<void(const serialization::InputFile &IF,
2551 bool isSystem)> Visitor);
2552
2553 /// Visit all the top-level module maps loaded when building the given module
2554 /// file.
2556 llvm::function_ref<void(FileEntryRef)> Visitor);
2557
2558 bool isProcessingUpdateRecords() { return ProcessingUpdateRecords; }
2559};
2560
2561/// A simple helper class to unpack an integer to bits and consuming
2562/// the bits in order.
2564 constexpr static uint32_t BitsIndexUpbound = 32;
2565
2566public:
2567 BitsUnpacker(uint32_t V) { updateValue(V); }
2568 BitsUnpacker(const BitsUnpacker &) = delete;
2572 ~BitsUnpacker() = default;
2573
2574 void updateValue(uint32_t V) {
2575 Value = V;
2576 CurrentBitsIndex = 0;
2577 }
2578
2579 void advance(uint32_t BitsWidth) { CurrentBitsIndex += BitsWidth; }
2580
2581 bool getNextBit() {
2582 assert(isValid());
2583 return Value & (1 << CurrentBitsIndex++);
2584 }
2585
2586 uint32_t getNextBits(uint32_t Width) {
2587 assert(isValid());
2588 assert(Width < BitsIndexUpbound);
2589 uint32_t Ret = (Value >> CurrentBitsIndex) & ((1 << Width) - 1);
2590 CurrentBitsIndex += Width;
2591 return Ret;
2592 }
2593
2594 bool canGetNextNBits(uint32_t Width) const {
2595 return CurrentBitsIndex + Width < BitsIndexUpbound;
2596 }
2597
2598private:
2599 bool isValid() const { return CurrentBitsIndex < BitsIndexUpbound; }
2600
2601 uint32_t Value;
2602 uint32_t CurrentBitsIndex = ~0;
2603};
2604
2605inline bool shouldSkipCheckingODR(const Decl *D) {
2606 return D->getASTContext().getLangOpts().SkipODRCheckInGMF &&
2608}
2609
2610} // namespace clang
2611
2612#endif // LLVM_CLANG_SERIALIZATION_ASTREADER_H
#define V(N, I)
Definition: ASTContext.h:3443
Defines the Diagnostic-related interfaces.
clang::CharUnits operator*(clang::CharUnits::QuantityType Scale, const clang::CharUnits &CU)
Definition: CharUnits.h:225
const Decl * D
IndirectLocalPath & Path
enum clang::sema::@1718::IndirectLocalPathEntry::EntryKind Kind
StringRef Filename
Definition: Format.cpp:3032
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
llvm::MachO::Record Record
Definition: MachO.h:31
Defines the clang::OpenCLOptions class.
SourceRange Range
Definition: SemaObjC.cpp:758
SourceLocation Loc
Definition: SemaObjC.cpp:759
Defines the clang::SourceLocation class and associated facilities.
Defines a utilitiy for warning once when close to out of stack space.
const char * Data
C Language Family Type Representation.
Defines version macros and version-related utility functions for Clang.
ASTConsumer - This is an abstract interface that should be implemented by clients that read ASTs.
Definition: ASTConsumer.h:34
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:188
const LangOptions & getLangOpts() const
Definition: ASTContext.h:834
An identifier-lookup iterator that enumerates all of the identifiers stored within a set of AST files...
Definition: ASTReader.cpp:8797
Abstract interface for callback invocations by the ASTReader.
Definition: ASTReader.h:116
virtual void ReadModuleMapFile(StringRef ModuleMapPath)
Definition: ASTReader.h:129
virtual bool needsInputFileVisitation()
Returns true if this ASTReaderListener wants to receive the input files of the AST file via visitInpu...
Definition: ASTReader.h:223
virtual bool ReadTargetOptions(const TargetOptions &TargetOpts, StringRef ModuleFilename, bool Complain, bool AllowCompatibleDifferences)
Receives the target options.
Definition: ASTReader.h:144
virtual bool visitInputFile(StringRef Filename, bool isSystem, bool isOverridden, bool isExplicitModule)
if needsInputFileVisitation returns true, this is called for each non-system input file of the AST Fi...
Definition: ASTReader.h:235
virtual bool ReadDiagnosticOptions(IntrusiveRefCntPtr< DiagnosticOptions > DiagOpts, StringRef ModuleFilename, bool Complain)
Receives the diagnostic options.
Definition: ASTReader.h:155
virtual bool ReadHeaderSearchPaths(const HeaderSearchOptions &HSOpts, bool Complain)
Receives the header search paths.
Definition: ASTReader.h:193
virtual bool ReadFileSystemOptions(const FileSystemOptions &FSOpts, bool Complain)
Receives the file system options.
Definition: ASTReader.h:164
virtual bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, StringRef ModuleFilename, bool ReadMacros, bool Complain, std::string &SuggestedPredefines)
Receives the preprocessor options.
Definition: ASTReader.h:206
virtual bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts, StringRef ModuleFilename, StringRef SpecificModuleCachePath, bool Complain)
Receives the header search options.
Definition: ASTReader.h:177
virtual void readModuleFileExtension(const ModuleFileExtensionMetadata &Metadata)
Indicates that a particular module file extension has been read.
Definition: ASTReader.h:249
virtual bool ReadLanguageOptions(const LangOptions &LangOpts, StringRef ModuleFilename, bool Complain, bool AllowCompatibleDifferences)
Receives the language options.
Definition: ASTReader.h:134
virtual void visitImport(StringRef ModuleName, StringRef Filename)
If needsImportVisitation returns true, this is called for each AST file imported by this AST file.
Definition: ASTReader.h:246
virtual void visitModuleFile(StringRef Filename, serialization::ModuleKind Kind)
This is called for each AST file loaded.
Definition: ASTReader.h:218
virtual bool needsImportVisitation() const
Returns true if this ASTReaderListener wants to receive the imports of the AST file via visitImport,...
Definition: ASTReader.h:242
virtual bool ReadFullVersionInformation(StringRef FullVersion)
Receives the full Clang version information.
Definition: ASTReader.h:124
virtual void ReadCounter(const serialization::ModuleFile &M, unsigned Value)
Receives COUNTER value.
Definition: ASTReader.h:214
virtual void ReadModuleName(StringRef ModuleName)
Definition: ASTReader.h:128
virtual bool needsSystemInputFileVisitation()
Returns true if this ASTReaderListener wants to receive the system input files of the AST file via vi...
Definition: ASTReader.h:227
RAII object to temporarily add an AST callback listener.
Definition: ASTReader.h:1819
ListenerScope(ASTReader &Reader, std::unique_ptr< ASTReaderListener > L)
Definition: ASTReader.h:1824
bool operator==(const ModuleDeclIterator &RHS) const
Definition: ASTReader.h:1609
ModuleDeclIterator(ASTReader *Reader, ModuleFile *Mod, const serialization::unaligned_decl_id_t *Pos)
Definition: ASTReader.h:1598
Reads an AST files chain containing the contents of a translation unit.
Definition: ASTReader.h:383
std::optional< bool > isPreprocessedEntityInFileID(unsigned Index, FileID FID) override
Optionally returns true or false if the preallocated preprocessed entity with index Index came from f...
Definition: ASTReader.cpp:6634
PreprocessedEntity * ReadPreprocessedEntity(unsigned Index) override
Read a preallocated preprocessed entity from the external source.
Definition: ASTReader.cpp:6415
void markIdentifierUpToDate(const IdentifierInfo *II)
Note that this identifier is up-to-date.
Definition: ASTReader.cpp:2388
void visitTopLevelModuleMaps(serialization::ModuleFile &MF, llvm::function_ref< void(FileEntryRef)> Visitor)
Visit all the top-level module maps loaded when building the given module file.
void setDeserializationListener(ASTDeserializationListener *Listener, bool TakeOwnership=false)
Set the AST deserialization listener.
Definition: ASTReader.cpp:931
SmallVectorImpl< uint64_t > RecordDataImpl
Definition: ASTReader.h:399
serialization::SubmoduleID getGlobalSubmoduleID(ModuleFile &M, unsigned LocalID) const
Retrieve the global submodule ID given a module and its local ID number.
Definition: ASTReader.cpp:9419
ExtKind hasExternalDefinitions(const Decl *D) override
Definition: ASTReader.cpp:9500
IdentifierTable & getIdentifierTable()
Retrieve the identifier table associated with the preprocessor.
Definition: ASTReader.cpp:9891
SourceLocationEncoding::RawLocEncoding RawLocEncoding
Definition: ASTReader.h:2359
ModuleManager & getModuleManager()
Retrieve the module manager.
Definition: ASTReader.h:1890
ASTReader & operator=(const ASTReader &)=delete
bool isDeclIDFromModule(GlobalDeclID ID, ModuleFile &M) const
Returns true if global DeclID ID originated from module M.
Definition: ASTReader.cpp:7888
bool ReadSLocEntry(int ID) override
Read the source location entry with index ID.
Definition: ASTReader.cpp:1685
void RecordSwitchCaseID(SwitchCase *SC, unsigned ID)
Record that the given ID maps to the given switch-case statement.
Definition: ASTReader.cpp:9897
DiagnosticBuilder Diag(unsigned DiagID) const
Report a diagnostic.
Definition: ASTReader.cpp:9870
unsigned getTotalNumPreprocessedEntities() const
Returns the number of preprocessed entities known to the AST reader.
Definition: ASTReader.h:1997
ASTContext & getContext()
Retrieve the AST context that this AST reader supplements.
Definition: ASTReader.h:2501
Decl * ReadDecl(ModuleFile &F, const RecordDataImpl &R, unsigned &I)
Reads a declaration from the given position in a record in the given module.
Definition: ASTReader.h:2077
ModuleManager::ModuleIterator ModuleIterator
Definition: ASTReader.h:432
static std::string ReadString(const RecordDataImpl &Record, unsigned &Idx)
Definition: ASTReader.cpp:9818
void ReadDeclsToCheckForDeferredDiags(llvm::SmallSetVector< Decl *, 4 > &Decls) override
Read the set of decls to be checked for deferred diags.
Definition: ASTReader.cpp:9115
void InitializeSema(Sema &S) override
Initialize the semantic source with the Sema instance being used to perform semantic analysis on the ...
Definition: ASTReader.cpp:8616
LoadFailureCapabilities
Flags that indicate what kind of AST loading failures the client of the AST reader can directly handl...
Definition: ASTReader.h:1726
@ ARR_Missing
The client can handle an AST file that cannot load because it is missing.
Definition: ASTReader.h:1732
@ ARR_None
The client can't handle any AST loading failures.
Definition: ASTReader.h:1728
@ ARR_ConfigurationMismatch
The client can handle an AST file that cannot load because it's compiled configuration doesn't match ...
Definition: ASTReader.h:1745
@ ARR_OutOfDate
The client can handle an AST file that cannot load because it is out-of-date relative to its input fi...
Definition: ASTReader.h:1736
@ ARR_TreatModuleWithErrorsAsOutOfDate
If a module file is marked with errors treat it as out-of-date so the caller can rebuild it.
Definition: ASTReader.h:1749
@ ARR_VersionMismatch
The client can handle an AST file that cannot load because it was built with a different version of C...
Definition: ASTReader.h:1740
void ReadMismatchingDeleteExpressions(llvm::MapVector< FieldDecl *, llvm::SmallVector< std::pair< SourceLocation, bool >, 4 > > &Exprs) override
Definition: ASTReader.cpp:9045
void FindFileRegionDecls(FileID File, unsigned Offset, unsigned Length, SmallVectorImpl< Decl * > &Decls) override
Get the decls that are contained in a file in the Offset/Length range.
Definition: ASTReader.cpp:8326
std::string ReadPathBlob(StringRef BaseDirectory, const RecordData &Record, unsigned &Idx, StringRef &Blob)
Definition: ASTReader.cpp:9844
SourceRange ReadSkippedRange(unsigned Index) override
Read a preallocated skipped range from the external source.
Definition: ASTReader.cpp:6401
serialization::TypeID getGlobalTypeID(ModuleFile &F, serialization::LocalTypeID LocalID) const
Map a local type ID within a given AST file into a global type ID.
Definition: ASTReader.cpp:7638
const std::string & getSuggestedPredefines()
Returns the suggested contents of the predefines buffer, which contains a (typically-empty) subset of...
Definition: ASTReader.h:1934
void dump()
Dump information about the AST reader to standard error.
Definition: ASTReader.cpp:8583
MacroInfo * ReadMacroRecord(ModuleFile &F, uint64_t Offset)
Reads the macro record located at the given offset.
Definition: ASTReader.cpp:1985
SmallVector< std::pair< llvm::BitstreamCursor, serialization::ModuleFile * >, 8 > CommentsCursors
Cursors for comments blocks.
Definition: ASTReader.h:2535
Selector getLocalSelector(ModuleFile &M, unsigned LocalID)
Retrieve a selector from the given module with its local ID number.
Definition: ASTReader.cpp:9507
void FindExternalLexicalDecls(const DeclContext *DC, llvm::function_ref< bool(Decl::Kind)> IsKindWeWant, SmallVectorImpl< Decl * > &Decls) override
Read all of the declarations lexically stored in a declaration context.
Definition: ASTReader.cpp:8248
ModuleFile * getOwningModuleFile(const Decl *D) const
Retrieve the module file that owns the given declaration, or NULL if the declaration is not from a mo...
Definition: ASTReader.cpp:7908
std::optional< ASTSourceDescriptor > getSourceDescriptor(unsigned ID) override
Return a descriptor for the corresponding module.
Definition: ASTReader.cpp:9482
const serialization::reader::DeclContextLookupTable * getLoadedLookupTables(DeclContext *Primary) const
Get the loaded lookup tables for Primary, if any.
Definition: ASTReader.cpp:8422
T * ReadDeclAs(ModuleFile &F, const RecordDataImpl &R, unsigned &I)
Reads a declaration from the given position in a record in the given module.
Definition: ASTReader.h:2087
QualType getLocalType(ModuleFile &F, serialization::LocalTypeID LocalID)
Resolve a local type ID within a given AST file into a type.
Definition: ASTReader.cpp:7634
void ClearSwitchCaseIDs()
Definition: ASTReader.cpp:9909
Sema::AlignPackInfo ReadAlignPackInfo(uint32_t Raw) const
Read a AlignPackInfo from raw form.
Definition: ASTReader.h:2355
QualType readType(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a type from the current position in the given record, which was read from the given AST file.
Definition: ASTReader.h:2017
SourceLocation ReadSourceLocation(ModuleFile &MF, RawLocEncoding Raw, LocSeq *Seq=nullptr) const
Read a source location from raw form.
Definition: ASTReader.h:2370
void SetGloballyVisibleDecls(IdentifierInfo *II, const SmallVectorImpl< GlobalDeclID > &DeclIDs, SmallVectorImpl< Decl * > *Decls=nullptr)
Set the globally-visible declarations associated with the given identifier.
Definition: ASTReader.cpp:9275
serialization::ModuleKind ModuleKind
Definition: ASTReader.h:430
bool loadGlobalIndex()
Attempts to load the global index.
Definition: ASTReader.cpp:4492
void ReadComments() override
Loads comments ranges.
Definition: ASTReader.cpp:9913
SourceManager & getSourceManager() const
Definition: ASTReader.h:1717
SourceLocation getSourceLocationForDeclID(GlobalDeclID ID)
Returns the source location for the decl ID.
Definition: ASTReader.cpp:7915
void makeModuleVisible(Module *Mod, Module::NameVisibilityKind NameVisibility, SourceLocation ImportLoc)
Make the entities in the given module and any of its (non-explicit) submodules visible to name lookup...
Definition: ASTReader.cpp:4428
unsigned getTotalNumSubmodules() const
Returns the number of submodules known.
Definition: ASTReader.h:1986
ASTReader(const ASTReader &)=delete
bool LoadExternalSpecializations(const Decl *D, bool OnlyPartial) override
Load all the external specializations for the Decl.
Definition: ASTReader.cpp:8197
void finalizeForWriting()
Finalizes the AST reader's state before writing an AST file to disk.
Definition: ASTReader.cpp:5369
Sema * getSema()
Retrieve the semantic analysis object used to analyze the translation unit in which the precompiled h...
Definition: ASTReader.h:2513
static std::string ResolveImportedPathAndAllocate(SmallString< 0 > &Buf, StringRef Path, ModuleFile &ModF)
Resolve Path in the context of module file M.
Definition: ASTReader.cpp:2835
static StringRef ReadStringBlob(const RecordDataImpl &Record, unsigned &Idx, StringRef &Blob)
Definition: ASTReader.cpp:9825
unsigned getTotalNumIdentifiers() const
Returns the number of identifiers found in the chain.
Definition: ASTReader.h:1966
CXXCtorInitializer ** GetExternalCXXCtorInitializers(uint64_t Offset) override
Read the contents of a CXXCtorInitializer array.
Definition: ASTReader.cpp:7791
void visitInputFileInfos(serialization::ModuleFile &MF, bool IncludeSystem, llvm::function_ref< void(const serialization::InputFileInfo &IFI, bool IsSystem)> Visitor)
Visit all the input file infos of the given module file.
Definition: ASTReader.cpp:9985
const ModuleManager & getModuleManager() const
Definition: ASTReader.h:1891
unsigned getTotalNumSLocs() const
Returns the number of source locations found in the chain.
Definition: ASTReader.h:1961
void StartTranslationUnit(ASTConsumer *Consumer) override
Function that will be invoked when we begin parsing a new translation unit involving this external AS...
Definition: ASTReader.cpp:8468
LocalDeclID mapGlobalIDToModuleFileGlobalID(ModuleFile &M, GlobalDeclID GlobalID)
Map a global declaration ID into the declaration ID used to refer to this declaration within the give...
Definition: ASTReader.cpp:8108
void resolvePendingMacro(IdentifierInfo *II, const PendingMacroInfo &PMInfo)
Definition: ASTReader.cpp:2399
bool FindExternalVisibleDeclsByName(const DeclContext *DC, DeclarationName Name) override
Finds all the visible declarations with a given name.
Definition: ASTReader.cpp:8370
void ReadTentativeDefinitions(SmallVectorImpl< VarDecl * > &TentativeDefs) override
Read the set of tentative definitions known to the external Sema source.
Definition: ASTReader.cpp:9061
Decl * GetExternalDecl(GlobalDeclID ID) override
Resolve a declaration ID into a declaration, potentially building a new declaration.
Definition: ASTReader.cpp:7717
std::pair< SourceLocation, unsigned > ReadUntranslatedSourceLocation(RawLocEncoding Raw, LocSeq *Seq=nullptr) const
Read a source location from raw form and return it in its originating module file's source location s...
Definition: ASTReader.h:2364
GlobalDeclID ReadDeclID(ModuleFile &F, const RecordDataImpl &Record, unsigned &Idx)
Reads a declaration ID from the given position in a record in the given module.
Definition: ASTReader.cpp:8137
llvm::Expected< SourceLocation::UIntTy > readSLocOffset(ModuleFile *F, unsigned Index)
Try to read the offset of the SLocEntry at the given index in the given module file.
Definition: ASTReader.cpp:1613
void forEachImportedKeyDecl(const Decl *D, Fn Visit)
Run a callback on each imported key declaration of D.
Definition: ASTReader.h:1432
~ASTReader() override
bool haveUnloadedSpecializations(const Decl *D) const
If we have any unloaded specialization for D.
Definition: ASTReader.cpp:8436
Stmt * ReadSubStmt()
Reads a sub-statement operand during statement reading.
Definition: ASTReader.h:2456
void CompleteRedeclChain(const Decl *D) override
If any redeclarations of D have been imported since it was last checked, this digs out those redeclar...
Definition: ASTReader.cpp:7719
Expr * ReadSubExpr()
Reads a sub-expression operand during statement reading.
SourceLocation TranslateSourceLocation(ModuleFile &ModuleFile, SourceLocation Loc) const
Translate a source location from another module file's source location space into ours.
Definition: ASTReader.h:2387
static llvm::Error ReadBlockAbbrevs(llvm::BitstreamCursor &Cursor, unsigned BlockID, uint64_t *StartOfBlockOffset=nullptr)
ReadBlockAbbrevs - Enter a subblock of the specified BlockID with the specified cursor.
Definition: ASTReader.cpp:1905
void SetIdentifierInfo(serialization::IdentifierID ID, IdentifierInfo *II)
Definition: ASTReader.cpp:9250
serialization::PreprocessedEntityID getGlobalPreprocessedEntityID(ModuleFile &M, unsigned LocalID) const
Determine the global preprocessed entity ID that corresponds to the given local ID within the given m...
Definition: ASTReader.cpp:2116
std::pair< unsigned, unsigned > findPreprocessedEntitiesInRange(SourceRange Range) override
Returns a pair of [Begin, End) indices of preallocated preprocessed entities that Range encompasses.
Definition: ASTReader.cpp:6621
IdentifierInfo * get(StringRef Name) override
Retrieve the IdentifierInfo for the named identifier.
Definition: ASTReader.cpp:8758
IdentifierInfo * getLocalIdentifier(ModuleFile &M, uint64_t LocalID)
Definition: ASTReader.cpp:9354
void visitInputFiles(serialization::ModuleFile &MF, bool IncludeSystem, bool Complain, llvm::function_ref< void(const serialization::InputFile &IF, bool isSystem)> Visitor)
Visit all the input files of the given module file.
Module * getModule(unsigned ID) override
Retrieve the module that corresponds to the given module ID.
Definition: ASTReader.cpp:9448
llvm::iterator_range< ModuleDeclIterator > getModuleFileLevelDecls(ModuleFile &Mod)
Definition: ASTReader.cpp:6394
Stmt * GetExternalDeclStmt(uint64_t Offset) override
Resolve the offset of a statement into a statement.
Definition: ASTReader.cpp:8152
Selector GetExternalSelector(serialization::SelectorID ID) override
Resolve a selector ID into a selector.
Definition: ASTReader.cpp:9536
unsigned getTotalNumSelectors() const
Returns the number of selectors found in the chain.
Definition: ASTReader.h:1991
MacroInfo * getMacro(serialization::MacroID ID)
Retrieve the macro with the given ID.
Definition: ASTReader.cpp:9377
void ReadUndefinedButUsed(llvm::MapVector< NamedDecl *, SourceLocation > &Undefined) override
Load the set of used but not defined functions or variables with internal linkage,...
Definition: ASTReader.cpp:9034
void ReadDelegatingConstructors(SmallVectorImpl< CXXConstructorDecl * > &Decls) override
Read the set of delegating constructors known to the external Sema source.
Definition: ASTReader.cpp:9082
unsigned getTotalNumTypes() const
Returns the number of types found in the chain.
Definition: ASTReader.h:1976
QualType GetType(serialization::TypeID ID)
Resolve a type ID into a type, potentially building a new type.
Definition: ASTReader.cpp:7331
void addPendingMacro(IdentifierInfo *II, ModuleFile *M, uint32_t MacroDirectivesOffset)
Add a macro to deserialize its macro directive history.
Definition: ASTReader.cpp:2239
SourceRange ReadSourceRange(ModuleFile &F, const RecordData &Record, unsigned &Idx, LocSeq *Seq=nullptr)
Read a source range.
Definition: ASTReader.cpp:9793
GlobalDeclID getGlobalDeclID(ModuleFile &F, LocalDeclID LocalID) const
Map from a local declaration ID within a given module to a global declaration ID.
Definition: ASTReader.cpp:7865
Expr * ReadExpr(ModuleFile &F)
Reads an expression.
void ReadWeakUndeclaredIdentifiers(SmallVectorImpl< std::pair< IdentifierInfo *, WeakInfo > > &WeakIDs) override
Read the set of weak, undeclared identifiers known to the external Sema source.
Definition: ASTReader.cpp:9143
void completeVisibleDeclsMap(const DeclContext *DC) override
Load all external visible decls in the given DeclContext.
Definition: ASTReader.cpp:8398
void AssignedLambdaNumbering(CXXRecordDecl *Lambda) override
Notify the external source that a lambda was assigned a mangling number.
Definition: ASTReader.cpp:9215
void ReadUnusedLocalTypedefNameCandidates(llvm::SmallSetVector< const TypedefNameDecl *, 4 > &Decls) override
Read the set of potentially unused typedefs known to the source.
Definition: ASTReader.cpp:9103
IdentifierResolver & getIdResolver()
Get the identifier resolver used for name lookup / updates in the translation unit scope.
static bool readASTFileControlBlock(StringRef Filename, FileManager &FileMgr, const InMemoryModuleCache &ModuleCache, const PCHContainerReader &PCHContainerRdr, bool FindModuleFileExtensions, ASTReaderListener &Listener, bool ValidateDiagnosticOptions, unsigned ClientLoadCapabilities=ARR_ConfigurationMismatch|ARR_OutOfDate)
Read the control block for the named AST file.
Definition: ASTReader.cpp:5544
void ReadExtVectorDecls(SmallVectorImpl< TypedefNameDecl * > &Decls) override
Read the set of ext_vector type declarations known to the external Sema source.
Definition: ASTReader.cpp:9093
SmallVector< GlobalDeclID, 16 > PreloadedDeclIDs
Definition: ASTReader.h:2508
std::pair< SourceLocation, StringRef > getModuleImportLoc(int ID) override
Retrieve the module import location and module name for the given source manager entry ID.
Definition: ASTReader.cpp:1868
void ReadUnusedFileScopedDecls(SmallVectorImpl< const DeclaratorDecl * > &Decls) override
Read the set of unused file-scope declarations known to the external Sema source.
Definition: ASTReader.cpp:9071
void ReadReferencedSelectors(SmallVectorImpl< std::pair< Selector, SourceLocation > > &Sels) override
Read the set of referenced selectors known to the external Sema source.
Definition: ASTReader.cpp:9125
Selector DecodeSelector(serialization::SelectorID Idx)
Definition: ASTReader.cpp:9511
ASTReadResult ReadAST(StringRef FileName, ModuleKind Type, SourceLocation ImportLoc, unsigned ClientLoadCapabilities, ModuleFile **NewLoadedModuleFile=nullptr)
Load the AST file designated by the given file name.
Definition: ASTReader.cpp:4570
StringRef getOriginalSourceFile()
Retrieve the name of the original source file name for the primary module file.
Definition: ASTReader.h:1898
std::string ReadPath(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Definition: ASTReader.cpp:9833
ASTDeserializationListener * getDeserializationListener()
Get the AST deserialization listener.
Definition: ASTReader.h:1848
void addListener(std::unique_ptr< ASTReaderListener > L)
Add an AST callback listener.
Definition: ASTReader.h:1811
unsigned getModuleFileID(ModuleFile *M)
Get an ID for the given module file.
Definition: ASTReader.cpp:9465
Decl * getKeyDeclaration(Decl *D)
Returns the first key declaration for the given declaration.
Definition: ASTReader.h:1416
void setListener(std::unique_ptr< ASTReaderListener > Listener)
Set the AST callbacks listener.
Definition: ASTReader.h:1804
Selector ReadSelector(ModuleFile &M, const RecordData &Record, unsigned &Idx)
Definition: ASTReader.h:2342
ModuleManager::ModuleReverseIterator ModuleReverseIterator
Definition: ASTReader.h:434
IdentifierInfo * DecodeIdentifierInfo(serialization::IdentifierID ID)
Definition: ASTReader.cpp:9323
ASTReadResult
The result of reading the control block of an AST file, which can fail for various reasons.
Definition: ASTReader.h:403
@ Success
The control block was read successfully.
Definition: ASTReader.h:406
@ ConfigurationMismatch
The AST file was written with a different language/target configuration.
Definition: ASTReader.h:423
@ OutOfDate
The AST file is out-of-date relative to its input files, and needs to be regenerated.
Definition: ASTReader.h:416
@ Failure
The AST file itself appears corrupted.
Definition: ASTReader.h:409
@ VersionMismatch
The AST file was written by a different version of Clang.
Definition: ASTReader.h:419
@ HadErrors
The AST file has errors.
Definition: ASTReader.h:426
@ Missing
The AST file was missing.
Definition: ASTReader.h:412
void addInMemoryBuffer(StringRef &FileName, std::unique_ptr< llvm::MemoryBuffer > Buffer)
Add in-memory (virtual file) buffer.
Definition: ASTReader.h:1877
static VersionTuple ReadVersionTuple(const RecordData &Record, unsigned &Idx)
Read a version tuple.
Definition: ASTReader.cpp:9851
SmallString< 0 > & getPathBuf()
Get the buffer for resolving paths.
Definition: ASTReader.h:1393
Token ReadToken(ModuleFile &M, const RecordDataImpl &Record, unsigned &Idx)
Reads a token out of a record.
Definition: ASTReader.cpp:1932
SwitchCase * getSwitchCaseWithID(unsigned ID)
Retrieve the switch-case statement with the given ID.
Definition: ASTReader.cpp:9904
serialization::IdentifierID getGlobalIdentifierID(ModuleFile &M, uint64_t LocalID)
Definition: ASTReader.cpp:9358
FileID TranslateFileID(ModuleFile &F, FileID FID) const
Translate a FileID from another module file's FileID space into ours.
Definition: ASTReader.h:2415
void ReadLateParsedTemplates(llvm::MapVector< const FunctionDecl *, std::unique_ptr< LateParsedTemplate > > &LPTMap) override
Read the set of late parsed template functions for this source.
Definition: ASTReader.cpp:9186
IdentifierIterator * getIdentifiers() override
Retrieve an iterator into the set of all identifiers in all loaded AST files.
Definition: ASTReader.cpp:8883
void ReadUsedVTables(SmallVectorImpl< ExternalVTableUse > &VTables) override
Read the set of used vtables known to the external Sema source.
Definition: ASTReader.cpp:9161
bool isGlobalIndexUnavailable() const
Determine whether we tried to load the global index, but failed, e.g., because it is out-of-date or d...
Definition: ASTReader.cpp:4517
uint32_t GetNumExternalSelectors() override
Returns the number of selectors known to the external AST source.
Definition: ASTReader.cpp:9540
static TemporarilyOwnedStringRef ResolveImportedPath(SmallString< 0 > &Buf, StringRef Path, ModuleFile &ModF)
Resolve Path in the context of module file M.
Definition: ASTReader.cpp:2815
void updateOutOfDateSelector(Selector Sel) override
Load the contents of the global method pool for a given selector if necessary.
Definition: ASTReader.cpp:9018
Decl * GetExistingDecl(GlobalDeclID ID)
Resolve a declaration ID into a declaration.
Definition: ASTReader.cpp:8061
Stmt * ReadStmt(ModuleFile &F)
Reads a statement.
static llvm::BitVector ReadBitVector(const RecordData &Record, const StringRef Blob)
Definition: ASTReader.cpp:9800
ModuleFile * getLocalModuleFile(ModuleFile &M, unsigned ID) const
Retrieve the module file with a given local ID within the specified ModuleFile.
Definition: ASTReader.cpp:9452
void ForgetSema() override
Inform the semantic consumer that Sema is no longer available.
Definition: ASTReader.h:2180
DiagnosticsEngine & getDiags() const
Definition: ASTReader.h:1719
void LoadSelector(Selector Sel)
Load a selector from disk, registering its ID if it exists.
Definition: ASTReader.cpp:9245
void ReadPragmaDiagnosticMappings(DiagnosticsEngine &Diag)
Definition: ASTReader.cpp:6693
void makeNamesVisible(const HiddenNames &Names, Module *Owner)
Make the names within this set of hidden names visible.
Definition: ASTReader.cpp:4414
void UpdateSema()
Update the state of Sema after loading some additional modules.
Definition: ASTReader.cpp:8653
Decl * GetDecl(GlobalDeclID ID)
Resolve a declaration ID into a declaration, potentially building a new declaration.
Definition: ASTReader.cpp:8087
Decl * GetLocalDecl(ModuleFile &F, LocalDeclID LocalID)
Reads a declaration with the given local ID in the given module.
Definition: ASTReader.h:2049
bool isProcessingUpdateRecords()
Definition: ASTReader.h:2558
T * GetLocalDeclAs(ModuleFile &F, LocalDeclID LocalID)
Reads a declaration with the given local ID in the given module.
Definition: ASTReader.h:2056
ASTReader(Preprocessor &PP, InMemoryModuleCache &ModuleCache, ASTContext *Context, const PCHContainerReader &PCHContainerRdr, ArrayRef< std::shared_ptr< ModuleFileExtension > > Extensions, StringRef isysroot="", DisableValidationForModuleKind DisableValidationKind=DisableValidationForModuleKind::None, bool AllowASTWithCompilerErrors=false, bool AllowConfigurationMismatch=false, bool ValidateSystemInputs=false, bool ValidateASTInputFilesContent=false, bool UseGlobalIndex=true, std::unique_ptr< llvm::Timer > ReadTimer={})
Load the AST file and validate its contents against the given Preprocessor.
int getSLocEntryID(SourceLocation::UIntTy SLocOffset) override
Get the index ID for the loaded SourceLocation offset.
Definition: ASTReader.cpp:1648
void ReadPendingInstantiations(SmallVectorImpl< std::pair< ValueDecl *, SourceLocation > > &Pending) override
Read the set of pending instantiations known to the external Sema source.
Definition: ASTReader.cpp:9174
Preprocessor & getPreprocessor() const
Retrieve the preprocessor.
Definition: ASTReader.h:1894
serialization::reader::LazySpecializationInfoLookupTable * getLoadedSpecializationsLookupTables(const Decl *D, bool IsPartial)
Get the loaded specializations lookup tables for D, if any.
Definition: ASTReader.cpp:8428
CXXTemporary * ReadCXXTemporary(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Definition: ASTReader.cpp:9863
void ReadKnownNamespaces(SmallVectorImpl< NamespaceDecl * > &Namespaces) override
Load the set of namespaces that are known to the external source, which will be used during typo corr...
Definition: ASTReader.cpp:9023
const Decl * getKeyDeclaration(const Decl *D)
Definition: ASTReader.h:1426
ModuleManager::ModuleConstIterator ModuleConstIterator
Definition: ASTReader.h:433
Module * getSubmodule(serialization::SubmoduleID GlobalID)
Retrieve the submodule that corresponds to a global submodule ID.
Definition: ASTReader.cpp:9434
void PrintStats() override
Print some statistics about AST usage.
Definition: ASTReader.cpp:8478
void mergeDefinitionVisibility(NamedDecl *Def, NamedDecl *MergedDef)
Note that MergedDef is a redefinition of the canonical definition Def, so Def should be visible whene...
Definition: ASTReader.cpp:4477
serialization::SelectorID getGlobalSelectorID(ModuleFile &M, unsigned LocalID) const
Retrieve the global selector ID that corresponds to this the local selector ID in a given module.
Definition: ASTReader.cpp:9546
void runWithSufficientStackSpace(SourceLocation Loc, llvm::function_ref< void()> Fn)
Definition: ASTReader.cpp:9878
SmallVector< uint64_t, 64 > RecordData
Definition: ASTReader.h:398
unsigned getTotalNumMacros() const
Returns the number of macros found in the chain.
Definition: ASTReader.h:1971
FileID ReadFileID(ModuleFile &F, const RecordDataImpl &Record, unsigned &Idx) const
Read a FileID.
Definition: ASTReader.h:2409
void StartedDeserializing() override
Notify ASTReader that we started deserialization of a decl or type so until FinishedDeserializing is ...
void ReadMethodPool(Selector Sel) override
Load the contents of the global method pool for a given selector.
Definition: ASTReader.cpp:8982
void InitializeContext()
Initializes the ASTContext.
Definition: ASTReader.cpp:5226
CXXBaseSpecifier * GetExternalCXXBaseSpecifiers(uint64_t Offset) override
Resolve the offset of a set of C++ base specifiers in the decl stream into an array of specifiers.
Definition: ASTReader.cpp:7823
std::unique_ptr< ASTReaderListener > takeListener()
Take the AST callbacks listener.
Definition: ASTReader.h:1799
void resetForReload()
Reset reader for a reload try.
Definition: ASTReader.h:1859
FileManager & getFileManager() const
Definition: ASTReader.h:1718
unsigned getTotalNumDecls() const
Returns the number of declarations found in the chain.
Definition: ASTReader.h:1981
static bool isAcceptableASTFile(StringRef Filename, FileManager &FileMgr, const InMemoryModuleCache &ModuleCache, const PCHContainerReader &PCHContainerRdr, const LangOptions &LangOpts, const TargetOptions &TargetOpts, const PreprocessorOptions &PPOpts, StringRef ExistingModuleCachePath, bool RequireStrictOptionMatches=false)
Determine whether the given AST file is acceptable to load into a translation unit with the given lan...
Definition: ASTReader.cpp:5841
void FinishedDeserializing() override
Notify ASTReader that we finished the deserialization of a decl or type.
IdentifierInfo * readIdentifier(ModuleFile &M, const RecordData &Record, unsigned &Idx)
Definition: ASTReader.h:2268
void updateOutOfDateIdentifier(const IdentifierInfo &II) override
Update an out-of-date identifier.
Definition: ASTReader.cpp:2363
void ReadDefinedMacros() override
Read the set of macros defined by this external macro source.
Definition: ASTReader.cpp:2245
GlobalModuleIndex * getGlobalIndex()
Return global module index.
Definition: ASTReader.h:1856
IdentifierInfo * GetIdentifier(serialization::IdentifierID ID) override
Return the identifier associated with the given ID number.
Definition: ASTReader.h:2273
HeaderFileInfo GetHeaderFileInfo(FileEntryRef FE) override
Read the header file information for the given file entry.
Definition: ASTReader.cpp:6684
SourceLocation ReadSourceLocation(ModuleFile &ModuleFile, const RecordDataImpl &Record, unsigned &Idx, LocSeq *Seq=nullptr)
Read a source location.
Definition: ASTReader.h:2402
serialization::MacroID getGlobalMacroID(ModuleFile &M, unsigned LocalID)
Retrieve the global macro ID corresponding to the given local ID within the given module file.
Definition: ASTReader.cpp:9404
serialization::ModuleFile ModuleFile
Definition: ASTReader.h:429
bool hasGlobalIndex() const
Determine whether this AST reader has a global index.
Definition: ASTReader.h:1853
An object for streaming information from a record.
Utility class for loading a ASTContext from an AST file.
Definition: ASTUnit.h:89
Writes an AST file containing the contents of a translation unit.
Definition: ASTWriter.h:89
A simple helper class to unpack an integer to bits and consuming the bits in order.
Definition: ASTReader.h:2563
BitsUnpacker operator=(const BitsUnpacker &)=delete
uint32_t getNextBits(uint32_t Width)
Definition: ASTReader.h:2586
void advance(uint32_t BitsWidth)
Definition: ASTReader.h:2579
bool canGetNextNBits(uint32_t Width) const
Definition: ASTReader.h:2594
BitsUnpacker(BitsUnpacker &&)=delete
BitsUnpacker(const BitsUnpacker &)=delete
void updateValue(uint32_t V)
Definition: ASTReader.h:2574
BitsUnpacker operator=(BitsUnpacker &&)=delete
BitsUnpacker(uint32_t V)
Definition: ASTReader.h:2567
~BitsUnpacker()=default
Represents a base class of a C++ class.
Definition: DeclCXX.h:146
Represents a C++ base or member initializer.
Definition: DeclCXX.h:2318
Represents a C++ struct/union/class.
Definition: DeclCXX.h:258
Represents a C++ temporary.
Definition: ExprCXX.h:1457
Simple wrapper class for chaining listeners.
Definition: ASTReader.h:254
bool visitInputFile(StringRef Filename, bool isSystem, bool isOverridden, bool isExplicitModule) override
if needsInputFileVisitation returns true, this is called for each non-system input file of the AST Fi...
Definition: ASTReader.cpp:249
std::unique_ptr< ASTReaderListener > takeSecond()
Definition: ASTReader.h:265
bool ReadFullVersionInformation(StringRef FullVersion) override
Receives the full Clang version information.
Definition: ASTReader.cpp:162
bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts, StringRef ModuleFilename, StringRef SpecificModuleCachePath, bool Complain) override
Receives the header search options.
Definition: ASTReader.cpp:209
bool ReadFileSystemOptions(const FileSystemOptions &FSOpts, bool Complain) override
Receives the file system options.
Definition: ASTReader.cpp:203
std::unique_ptr< ASTReaderListener > takeFirst()
Definition: ASTReader.h:264
void ReadCounter(const serialization::ModuleFile &M, unsigned Value) override
Receives COUNTER value.
Definition: ASTReader.cpp:227
void ReadModuleMapFile(StringRef ModuleMapPath) override
Definition: ASTReader.cpp:172
bool ReadLanguageOptions(const LangOptions &LangOpts, StringRef ModuleFilename, bool Complain, bool AllowCompatibleDifferences) override
Receives the language options.
Definition: ASTReader.cpp:177
bool ReadTargetOptions(const TargetOptions &TargetOpts, StringRef ModuleFilename, bool Complain, bool AllowCompatibleDifferences) override
Receives the target options.
Definition: ASTReader.cpp:186
void ReadModuleName(StringRef ModuleName) override
Definition: ASTReader.cpp:167
bool needsInputFileVisitation() override
Returns true if this ASTReaderListener wants to receive the input files of the AST file via visitInpu...
Definition: ASTReader.cpp:233
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, StringRef ModuleFilename, bool ReadMacros, bool Complain, std::string &SuggestedPredefines) override
Receives the preprocessor options.
Definition: ASTReader.cpp:218
ChainedASTReaderListener(std::unique_ptr< ASTReaderListener > First, std::unique_ptr< ASTReaderListener > Second)
Takes ownership of First and Second.
Definition: ASTReader.h:260
void readModuleFileExtension(const ModuleFileExtensionMetadata &Metadata) override
Indicates that a particular module file extension has been read.
Definition: ASTReader.cpp:265
void visitModuleFile(StringRef Filename, serialization::ModuleKind Kind) override
This is called for each AST file loaded.
Definition: ASTReader.cpp:243
bool ReadDiagnosticOptions(IntrusiveRefCntPtr< DiagnosticOptions > DiagOpts, StringRef ModuleFilename, bool Complain) override
Receives the diagnostic options.
Definition: ASTReader.cpp:195
bool needsSystemInputFileVisitation() override
Returns true if this ASTReaderListener wants to receive the system input files of the AST file via vi...
Definition: ASTReader.cpp:238
A map from continuous integer ranges to some value, with a very specialized interface.
typename Representation::const_iterator const_iterator
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1435
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:86
bool isFromGlobalModule() const
Whether this declaration comes from global module.
Definition: DeclBase.cpp:1160
ASTContext & getASTContext() const LLVM_READONLY
Definition: DeclBase.cpp:520
Kind
Lists the kind of concrete classes of Decl.
Definition: DeclBase.h:89
bool isFromHeaderUnit() const
Whether this declaration comes from a header unit.
Definition: DeclBase.cpp:1168
The name of a declaration.
A little helper class used to produce diagnostics.
Definition: Diagnostic.h:1220
Concrete class used by the front-end to report problems and issues.
Definition: Diagnostic.h:231
This represents one expression.
Definition: Expr.h:110
RAII class for safely pairing a StartedDeserializing call with FinishedDeserializing.
MemoryBufferSizes getMemoryBufferSizes() const
Return the amount of memory used by memory buffers, breaking down by heap-backed versus mmap'ed memor...
An external source of header file information, which may supply information about header files alread...
Definition: HeaderSearch.h:147
An abstract class that should be subclassed by any external source of preprocessing record entries.
Abstract interface for external sources of preprocessor information.
External source of source location entries.
An abstract interface that should be implemented by external AST sources that also provide informatio...
Represents a member of a struct/union/class.
Definition: Decl.h:3033
A reference to a FileEntry that includes the name of the file as it was accessed by the FileManager's...
Definition: FileEntry.h:57
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
bool isInvalid() const
Implements support for file system lookup, file system caching, and directory search management.
Definition: FileManager.h:53
Keeps track of options that affect how file operations are performed.
Represents a function declaration or definition.
Definition: Decl.h:1935
A global index for a set of module files, providing information about the identifiers within those mo...
HeaderSearchOptions - Helper class for storing options related to the initialization of the HeaderSea...
Provides lookups to, and iteration over, IdentiferInfo objects.
One of these records is kept for each identifier that is lexed.
An iterator that walks over all of the known identifiers in the lookup table.
IdentifierResolver - Keeps track of shadowed decls on enclosing scopes.
Implements an efficient mapping from strings to IdentifierInfo nodes.
In-memory cache for modules.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:499
static LocalDeclID get(ASTReader &Reader, serialization::ModuleFile &MF, DeclID ID)
Definition: ASTReader.cpp:941
Encapsulates the data about a macro definition (e.g.
Definition: MacroInfo.h:39
Describes a module or submodule.
Definition: Module.h:115
NameVisibilityKind
Describes the visibility of the various names within a particular module.
Definition: Module.h:414
This represents a decl that may have a name.
Definition: Decl.h:253
This abstract interface provides operations for unwrapping containers for serialized ASTs (precompile...
ASTReaderListener implementation to validate the information of the PCH file against an initialized P...
Definition: ASTReader.h:303
bool ReadLanguageOptions(const LangOptions &LangOpts, StringRef ModuleFilename, bool Complain, bool AllowCompatibleDifferences) override
Receives the language options.
Definition: ASTReader.cpp:459
bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts, StringRef ModuleFilename, StringRef SpecificModuleCachePath, bool Complain) override
Receives the header search options.
Definition: ASTReader.cpp:887
bool ReadDiagnosticOptions(IntrusiveRefCntPtr< DiagnosticOptions > DiagOpts, StringRef ModuleFilename, bool Complain) override
Receives the diagnostic options.
Definition: ASTReader.cpp:598
PCHValidator(Preprocessor &PP, ASTReader &Reader)
Definition: ASTReader.h:308
void ReadCounter(const serialization::ModuleFile &M, unsigned Value) override
Receives COUNTER value.
Definition: ASTReader.cpp:898
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, StringRef ModuleFilename, bool ReadMacros, bool Complain, std::string &SuggestedPredefines) override
Receives the preprocessor options.
Definition: ASTReader.cpp:842
bool ReadTargetOptions(const TargetOptions &TargetOpts, StringRef ModuleFilename, bool Complain, bool AllowCompatibleDifferences) override
Receives the target options.
Definition: ASTReader.cpp:468
Base class that describes a preprocessed entity, which may be a preprocessor directive or macro expan...
PreprocessorOptions - This class is used for passing the various options used in preprocessor initial...
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
Definition: Preprocessor.h:138
A (possibly-)qualified type.
Definition: Type.h:929
Smart pointer class that efficiently represents Objective-C method names.
static AlignPackInfo getFromRawEncoding(unsigned Encoding)
Definition: Sema.h:1486
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:463
ASTReaderListenter implementation to set SuggestedPredefines of ASTReader which is required to use a ...
Definition: ASTReader.h:334
SimpleASTReaderListener(Preprocessor &PP)
Definition: ASTReader.h:338
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, StringRef ModuleFilename, bool ReadMacros, bool Complain, std::string &SuggestedPredefines) override
Receives the preprocessor options.
Definition: ASTReader.cpp:854
static std::pair< SourceLocation, unsigned > decode(RawLocEncoding, SourceLocationSequence *=nullptr)
Serialized encoding of a sequence of SourceLocations.
Encodes a location in the source.
This class handles loading and caching of source files into memory.
bool isLoadedSourceLocation(SourceLocation Loc) const
Returns true if Loc came from a PCH/Module.
A trivial tuple used to represent a source range.
Stmt - This represents one statement.
Definition: Stmt.h:84
Options for controlling the target.
Definition: TargetOptions.h:26
Token - This structure provides full information about a lexed token.
Definition: Token.h:36
The base class of the type hierarchy.
Definition: Type.h:1828
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:671
The input file that has been loaded from this AST file, along with bools indicating whether this was ...
Definition: ModuleFile.h:84
Information about a module that has been loaded by the ASTReader.
Definition: ModuleFile.h:130
int SLocEntryBaseID
The base ID in the source manager's view of this module.
Definition: ModuleFile.h:291
std::string OriginalSourceFileName
The original source file name that was used to build the primary AST file, which may have been modifi...
Definition: ModuleFile.h:160
StringRef ModuleOffsetMap
The module offset map data for this file.
Definition: ModuleFile.h:250
SourceLocation::UIntTy SLocEntryBaseOffset
The base offset in the source manager's view of this module.
Definition: ModuleFile.h:294
llvm::SmallVector< ModuleFile *, 16 > TransitiveImports
List of modules which this modules dependent on.
Definition: ModuleFile.h:508
Manages the set of modules loaded by an AST reader.
Definition: ModuleManager.h:46
ModuleFile & getPrimaryModule()
Returns the primary module associated with the manager, that is, the first module loaded.
llvm::pointee_iterator< SmallVectorImpl< std::unique_ptr< ModuleFile > >::const_iterator > ModuleConstIterator
void addInMemoryBuffer(StringRef FileName, std::unique_ptr< llvm::MemoryBuffer > Buffer)
Add an in-memory buffer the list of known buffers.
llvm::pointee_iterator< SmallVectorImpl< std::unique_ptr< ModuleFile > >::reverse_iterator > ModuleReverseIterator
llvm::pointee_iterator< SmallVectorImpl< std::unique_ptr< ModuleFile > >::iterator > ModuleIterator
Class that performs lookup for an identifier stored in an AST file.
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
uint64_t TypeID
An ID number that refers to a type in an AST file.
Definition: ASTBitCodes.h:88
llvm::support::detail::packed_endian_specific_integral< serialization::DeclID, llvm::endianness::native, llvm::support::unaligned > unaligned_decl_id_t
Definition: ASTBitCodes.h:286
TypeID LocalTypeID
Same with TypeID except that the LocalTypeID is only meaningful with the corresponding ModuleFile.
Definition: ASTBitCodes.h:94
uint32_t SubmoduleID
An ID number that refers to a submodule in a module file.
Definition: ASTBitCodes.h:185
uint32_t SelectorID
An ID number that refers to an ObjC selector in an AST file.
Definition: ASTBitCodes.h:167
uint32_t PreprocessedEntityID
An ID number that refers to an entity in the detailed preprocessing record.
Definition: ASTBitCodes.h:182
ModuleKind
Specifies the kind of module that has been loaded.
Definition: ModuleFile.h:43
uint64_t IdentifierID
An ID number that refers to an identifier in an AST file.
Definition: ASTBitCodes.h:63
uint32_t MacroID
An ID number that refers to a macro in an AST file.
Definition: ASTBitCodes.h:154
The JSON file list parser is used to communicate input to InstallAPI.
@ Seq
'seq' clause, allowed on 'loop' and 'routine' directives.
@ Module
Module linkage, which indicates that the entity can be referred to from other translation units withi...
PredefinedDeclIDs
Predefined declaration IDs.
Definition: DeclID.h:31
@ Result
The result type of a method or function.
const FunctionProtoType * T
DisableValidationForModuleKind
Whether to disable the normal validation performed on precompiled headers and module files when they ...
@ None
Perform validation, don't disable it.
bool shouldSkipCheckingODR(const Decl *D)
Definition: ASTReader.h:2605
std::string getClangFullRepositoryVersion()
Retrieves the full repository version that is an amalgamation of the information in getClangRepositor...
Definition: Version.cpp:68
unsigned long uint64_t
unsigned int uint32_t
The preprocessor keeps track of this information for each file that is #included.
Definition: HeaderSearch.h:59
Metadata for a module file extension.
The input file info that has been loaded from an AST file.
Definition: ModuleFile.h:64