clang  3.7.0
ASTReader.h
Go to the documentation of this file.
1 //===--- ASTReader.h - AST File Reader --------------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines the ASTReader class, which reads AST files.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_CLANG_SERIALIZATION_ASTREADER_H
15 #define LLVM_CLANG_SERIALIZATION_ASTREADER_H
16 
17 #include "clang/AST/DeclObjC.h"
19 #include "clang/AST/TemplateBase.h"
20 #include "clang/Basic/Diagnostic.h"
25 #include "clang/Basic/Version.h"
27 #include "clang/Lex/HeaderSearch.h"
34 #include "llvm/ADT/APFloat.h"
35 #include "llvm/ADT/APInt.h"
36 #include "llvm/ADT/APSInt.h"
37 #include "llvm/ADT/MapVector.h"
38 #include "llvm/ADT/SmallPtrSet.h"
39 #include "llvm/ADT/SmallSet.h"
40 #include "llvm/ADT/SmallVector.h"
41 #include "llvm/ADT/StringRef.h"
42 #include "llvm/ADT/TinyPtrVector.h"
43 #include "llvm/Bitcode/BitstreamReader.h"
44 #include "llvm/Support/DataTypes.h"
45 #include "llvm/Support/Timer.h"
46 #include <deque>
47 #include <map>
48 #include <memory>
49 #include <string>
50 #include <utility>
51 #include <vector>
52 
53 namespace llvm {
54  class MemoryBuffer;
55 }
56 
57 namespace clang {
58 
59 class AddrLabelExpr;
60 class ASTConsumer;
61 class ASTContext;
62 class ASTIdentifierIterator;
63 class ASTUnit; // FIXME: Layering violation and egregious hack.
64 class Attr;
65 class Decl;
66 class DeclContext;
67 class DefMacroDirective;
68 class DiagnosticOptions;
69 class NestedNameSpecifier;
70 class CXXBaseSpecifier;
71 class CXXConstructorDecl;
72 class CXXCtorInitializer;
73 class GlobalModuleIndex;
74 class GotoStmt;
75 class MacroDefinition;
76 class MacroDirective;
77 class ModuleMacro;
78 class NamedDecl;
79 class OpaqueValueExpr;
80 class Preprocessor;
81 class PreprocessorOptions;
82 class Sema;
83 class SwitchCase;
84 class ASTDeserializationListener;
85 class ASTWriter;
86 class ASTReader;
87 class ASTDeclReader;
88 class ASTStmtReader;
89 class TypeLocReader;
90 struct HeaderFileInfo;
91 class VersionTuple;
92 class TargetOptions;
93 class LazyASTUnresolvedSet;
94 
95 /// \brief Abstract interface for callback invocations by the ASTReader.
96 ///
97 /// While reading an AST file, the ASTReader will call the methods of the
98 /// listener to pass on specific information. Some of the listener methods can
99 /// return true to indicate to the ASTReader that the information (and
100 /// consequently the AST file) is invalid.
102 public:
103  virtual ~ASTReaderListener();
104 
105  /// \brief Receives the full Clang version information.
106  ///
107  /// \returns true to indicate that the version is invalid. Subclasses should
108  /// generally defer to this implementation.
109  virtual bool ReadFullVersionInformation(StringRef FullVersion) {
110  return FullVersion != getClangFullRepositoryVersion();
111  }
112 
113  virtual void ReadModuleName(StringRef ModuleName) {}
114  virtual void ReadModuleMapFile(StringRef ModuleMapPath) {}
115 
116  /// \brief Receives the language options.
117  ///
118  /// \returns true to indicate the options are invalid or false otherwise.
119  virtual bool ReadLanguageOptions(const LangOptions &LangOpts,
120  bool Complain,
121  bool AllowCompatibleDifferences) {
122  return false;
123  }
124 
125  /// \brief Receives the target options.
126  ///
127  /// \returns true to indicate the target options are invalid, or false
128  /// otherwise.
129  virtual bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain,
130  bool AllowCompatibleDifferences) {
131  return false;
132  }
133 
134  /// \brief Receives the diagnostic options.
135  ///
136  /// \returns true to indicate the diagnostic options are invalid, or false
137  /// otherwise.
138  virtual bool
140  bool Complain) {
141  return false;
142  }
143 
144  /// \brief Receives the file system options.
145  ///
146  /// \returns true to indicate the file system options are invalid, or false
147  /// otherwise.
148  virtual bool ReadFileSystemOptions(const FileSystemOptions &FSOpts,
149  bool Complain) {
150  return false;
151  }
152 
153  /// \brief Receives the header search options.
154  ///
155  /// \returns true to indicate the header search options are invalid, or false
156  /// otherwise.
157  virtual bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts,
158  StringRef SpecificModuleCachePath,
159  bool Complain) {
160  return false;
161  }
162 
163  /// \brief Receives the preprocessor options.
164  ///
165  /// \param SuggestedPredefines Can be filled in with the set of predefines
166  /// that are suggested by the preprocessor options. Typically only used when
167  /// loading a precompiled header.
168  ///
169  /// \returns true to indicate the preprocessor options are invalid, or false
170  /// otherwise.
171  virtual bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts,
172  bool Complain,
173  std::string &SuggestedPredefines) {
174  return false;
175  }
176 
177  /// \brief Receives __COUNTER__ value.
178  virtual void ReadCounter(const serialization::ModuleFile &M,
179  unsigned Value) {}
180 
181  /// This is called for each AST file loaded.
182  virtual void visitModuleFile(StringRef Filename) {}
183 
184  /// \brief Returns true if this \c ASTReaderListener wants to receive the
185  /// input files of the AST file via \c visitInputFile, false otherwise.
186  virtual bool needsInputFileVisitation() { return false; }
187  /// \brief Returns true if this \c ASTReaderListener wants to receive the
188  /// system input files of the AST file via \c visitInputFile, false otherwise.
189  virtual bool needsSystemInputFileVisitation() { return false; }
190  /// \brief if \c needsInputFileVisitation returns true, this is called for
191  /// each non-system input file of the AST File. If
192  /// \c needsSystemInputFileVisitation is true, then it is called for all
193  /// system input files as well.
194  ///
195  /// \returns true to continue receiving the next input file, false to stop.
196  virtual bool visitInputFile(StringRef Filename, bool isSystem,
197  bool isOverridden) {
198  return true;
199  }
200 
201  /// \brief Returns true if this \c ASTReaderListener wants to receive the
202  /// imports of the AST file via \c visitImport, false otherwise.
203  virtual bool needsImportVisitation() const { return false; }
204  /// \brief If needsImportVisitation returns \c true, this is called for each
205  /// AST file imported by this AST file.
206  virtual void visitImport(StringRef Filename) {}
207 };
208 
209 /// \brief Simple wrapper class for chaining listeners.
211  std::unique_ptr<ASTReaderListener> First;
212  std::unique_ptr<ASTReaderListener> Second;
213 
214 public:
215  /// Takes ownership of \p First and \p Second.
216  ChainedASTReaderListener(std::unique_ptr<ASTReaderListener> First,
217  std::unique_ptr<ASTReaderListener> Second)
218  : First(std::move(First)), Second(std::move(Second)) {}
219 
220  std::unique_ptr<ASTReaderListener> takeFirst() { return std::move(First); }
221  std::unique_ptr<ASTReaderListener> takeSecond() { return std::move(Second); }
222 
223  bool ReadFullVersionInformation(StringRef FullVersion) override;
224  void ReadModuleName(StringRef ModuleName) override;
225  void ReadModuleMapFile(StringRef ModuleMapPath) override;
226  bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain,
227  bool AllowCompatibleDifferences) override;
228  bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain,
229  bool AllowCompatibleDifferences) override;
231  bool Complain) override;
232  bool ReadFileSystemOptions(const FileSystemOptions &FSOpts,
233  bool Complain) override;
234 
235  bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts,
236  StringRef SpecificModuleCachePath,
237  bool Complain) override;
238  bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts,
239  bool Complain,
240  std::string &SuggestedPredefines) override;
241 
242  void ReadCounter(const serialization::ModuleFile &M, unsigned Value) override;
243  bool needsInputFileVisitation() override;
244  bool needsSystemInputFileVisitation() override;
245  void visitModuleFile(StringRef Filename) override;
246  bool visitInputFile(StringRef Filename, bool isSystem,
247  bool isOverridden) override;
248 };
249 
250 /// \brief ASTReaderListener implementation to validate the information of
251 /// the PCH file against an initialized Preprocessor.
253  Preprocessor &PP;
254  ASTReader &Reader;
255 
256 public:
258  : PP(PP), Reader(Reader) {}
259 
260  bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain,
261  bool AllowCompatibleDifferences) override;
262  bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain,
263  bool AllowCompatibleDifferences) override;
265  bool Complain) override;
266  bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, bool Complain,
267  std::string &SuggestedPredefines) override;
268  bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts,
269  StringRef SpecificModuleCachePath,
270  bool Complain) override;
271  void ReadCounter(const serialization::ModuleFile &M, unsigned Value) override;
272 
273 private:
274  void Error(const char *Msg);
275 };
276 
277 namespace serialization {
278 
279 class ReadMethodPoolVisitor;
280 
281 namespace reader {
283  /// \brief The on-disk hash table used for the DeclContext's Name lookup table.
286 }
287 
288 } // end namespace serialization
289 
290 /// \brief Reads an AST files chain containing the contents of a translation
291 /// unit.
292 ///
293 /// The ASTReader class reads bitstreams (produced by the ASTWriter
294 /// class) containing the serialized representation of a given
295 /// abstract syntax tree and its supporting data structures. An
296 /// instance of the ASTReader can be attached to an ASTContext object,
297 /// which will provide access to the contents of the AST files.
298 ///
299 /// The AST reader provides lazy de-serialization of declarations, as
300 /// required when traversing the AST. Only those AST nodes that are
301 /// actually required will be de-serialized.
306  public ExternalSemaSource,
307  public IdentifierInfoLookup,
309 {
310 public:
313 
314  /// \brief The result of reading the control block of an AST file, which
315  /// can fail for various reasons.
317  /// \brief The control block was read successfully. Aside from failures,
318  /// the AST file is safe to read into the current context.
320  /// \brief The AST file itself appears corrupted.
322  /// \brief The AST file was missing.
324  /// \brief The AST file is out-of-date relative to its input files,
325  /// and needs to be regenerated.
327  /// \brief The AST file was written by a different version of Clang.
329  /// \brief The AST file was writtten with a different language/target
330  /// configuration.
332  /// \brief The AST file has errors.
334  };
335 
336  /// \brief Types of AST files.
337  friend class PCHValidator;
338  friend class ASTDeclReader;
339  friend class ASTStmtReader;
340  friend class ASTIdentifierIterator;
342  friend class TypeLocReader;
343  friend class ASTWriter;
344  friend class ASTUnit; // ASTUnit needs to remap source locations.
346 
350 
354 
355 private:
356  /// \brief The receiver of some callbacks invoked by ASTReader.
357  std::unique_ptr<ASTReaderListener> Listener;
358 
359  /// \brief The receiver of deserialization events.
360  ASTDeserializationListener *DeserializationListener;
361  bool OwnsDeserializationListener;
362 
364  FileManager &FileMgr;
365  const PCHContainerReader &PCHContainerRdr;
366  DiagnosticsEngine &Diags;
367 
368  /// \brief The semantic analysis object that will be processing the
369  /// AST files and the translation unit that uses it.
370  Sema *SemaObj;
371 
372  /// \brief The preprocessor that will be loading the source file.
373  Preprocessor &PP;
374 
375  /// \brief The AST context into which we'll read the AST files.
377 
378  /// \brief The AST consumer.
379  ASTConsumer *Consumer;
380 
381  /// \brief The module manager which manages modules and their dependencies
382  ModuleManager ModuleMgr;
383 
384  /// \brief A timer used to track the time spent deserializing.
385  std::unique_ptr<llvm::Timer> ReadTimer;
386 
387  /// \brief The location where the module file will be considered as
388  /// imported from. For non-module AST types it should be invalid.
389  SourceLocation CurrentImportLoc;
390 
391  /// \brief The global module index, if loaded.
392  std::unique_ptr<GlobalModuleIndex> GlobalIndex;
393 
394  /// \brief A map of global bit offsets to the module that stores entities
395  /// at those bit offsets.
397 
398  /// \brief A map of negated SLocEntryIDs to the modules containing them.
400 
402 
403  /// \brief A map of reversed (SourceManager::MaxLoadedOffset - SLocOffset)
404  /// SourceLocation offsets to the modules containing them.
405  GlobalSLocOffsetMapType GlobalSLocOffsetMap;
406 
407  /// \brief Types that have already been loaded from the chain.
408  ///
409  /// When the pointer at index I is non-NULL, the type with
410  /// ID = (I + 1) << FastQual::Width has already been loaded
411  std::vector<QualType> TypesLoaded;
412 
415 
416  /// \brief Mapping from global type IDs to the module in which the
417  /// type resides along with the offset that should be added to the
418  /// global type ID to produce a local ID.
419  GlobalTypeMapType GlobalTypeMap;
420 
421  /// \brief Declarations that have already been loaded from the chain.
422  ///
423  /// When the pointer at index I is non-NULL, the declaration with ID
424  /// = I + 1 has already been loaded.
425  std::vector<Decl *> DeclsLoaded;
426 
429 
430  /// \brief Mapping from global declaration IDs to the module in which the
431  /// declaration resides.
432  GlobalDeclMapType GlobalDeclMap;
433 
434  typedef std::pair<ModuleFile *, uint64_t> FileOffset;
436  typedef llvm::DenseMap<serialization::DeclID, FileOffsetsTy>
437  DeclUpdateOffsetsMap;
438 
439  /// \brief Declarations that have modifications residing in a later file
440  /// in the chain.
441  DeclUpdateOffsetsMap DeclUpdateOffsets;
442 
443  /// \brief Declaration updates for already-loaded declarations that we need
444  /// to apply once we finish processing an import.
446  PendingUpdateRecords;
447 
448  enum class PendingFakeDefinitionKind { NotFake, Fake, FakeLoaded };
449 
450  /// \brief The DefinitionData pointers that we faked up for class definitions
451  /// that we needed but hadn't loaded yet.
452  llvm::DenseMap<void *, PendingFakeDefinitionKind> PendingFakeDefinitionData;
453 
454  /// \brief Exception specification updates that have been loaded but not yet
455  /// propagated across the relevant redeclaration chain. The map key is the
456  /// canonical declaration (used only for deduplication) and the value is a
457  /// declaration that has an exception specification.
458  llvm::SmallMapVector<Decl *, FunctionDecl *, 4> PendingExceptionSpecUpdates;
459 
460  struct ReplacedDeclInfo {
461  ModuleFile *Mod;
462  uint64_t Offset;
463  unsigned RawLoc;
464 
465  ReplacedDeclInfo() : Mod(nullptr), Offset(0), RawLoc(0) {}
466  ReplacedDeclInfo(ModuleFile *Mod, uint64_t Offset, unsigned RawLoc)
467  : Mod(Mod), Offset(Offset), RawLoc(RawLoc) {}
468  };
469 
470  typedef llvm::DenseMap<serialization::DeclID, ReplacedDeclInfo>
471  DeclReplacementMap;
472  /// \brief Declarations that have been replaced in a later file in the chain.
473  DeclReplacementMap ReplacedDecls;
474 
475  /// \brief Declarations that have been imported and have typedef names for
476  /// linkage purposes.
477  llvm::DenseMap<std::pair<DeclContext*, IdentifierInfo*>, NamedDecl*>
478  ImportedTypedefNamesForLinkage;
479 
480  /// \brief Mergeable declaration contexts that have anonymous declarations
481  /// within them, and those anonymous declarations.
482  llvm::DenseMap<DeclContext*, llvm::SmallVector<NamedDecl*, 2>>
483  AnonymousDeclarationsForMerging;
484 
485  struct FileDeclsInfo {
486  ModuleFile *Mod;
487  ArrayRef<serialization::LocalDeclID> Decls;
488 
489  FileDeclsInfo() : Mod(nullptr) {}
490  FileDeclsInfo(ModuleFile *Mod, ArrayRef<serialization::LocalDeclID> Decls)
491  : Mod(Mod), Decls(Decls) {}
492  };
493 
494  /// \brief Map from a FileID to the file-level declarations that it contains.
495  llvm::DenseMap<FileID, FileDeclsInfo> FileDeclIDs;
496 
497  // Updates for visible decls can occur for other contexts than just the
498  // TU, and when we read those update records, the actual context will not
499  // be available yet (unless it's the TU), so have this pending map using the
500  // ID as a key. It will be realized when the context is actually loaded.
501  typedef
503  ModuleFile*>, 1> DeclContextVisibleUpdates;
504  typedef llvm::DenseMap<serialization::DeclID, DeclContextVisibleUpdates>
505  DeclContextVisibleUpdatesPending;
506 
507  /// \brief Updates to the visible declarations of declaration contexts that
508  /// haven't been loaded yet.
509  DeclContextVisibleUpdatesPending PendingVisibleUpdates;
510 
511  /// \brief The set of C++ or Objective-C classes that have forward
512  /// declarations that have not yet been linked to their definitions.
513  llvm::SmallPtrSet<Decl *, 4> PendingDefinitions;
514 
515  typedef llvm::MapVector<Decl *, uint64_t,
516  llvm::SmallDenseMap<Decl *, unsigned, 4>,
517  SmallVector<std::pair<Decl *, uint64_t>, 4> >
518  PendingBodiesMap;
519 
520  /// \brief Functions or methods that have bodies that will be attached.
521  PendingBodiesMap PendingBodies;
522 
523  /// \brief Definitions for which we have added merged definitions but not yet
524  /// performed deduplication.
525  llvm::SetVector<NamedDecl*> PendingMergedDefinitionsToDeduplicate;
526 
527  /// \brief Read the records that describe the contents of declcontexts.
528  bool ReadDeclContextStorage(ModuleFile &M,
529  llvm::BitstreamCursor &Cursor,
530  const std::pair<uint64_t, uint64_t> &Offsets,
531  serialization::DeclContextInfo &Info);
532 
533  /// \brief A vector containing identifiers that have already been
534  /// loaded.
535  ///
536  /// If the pointer at index I is non-NULL, then it refers to the
537  /// IdentifierInfo for the identifier with ID=I+1 that has already
538  /// been loaded.
539  std::vector<IdentifierInfo *> IdentifiersLoaded;
540 
541  typedef ContinuousRangeMap<serialization::IdentID, ModuleFile *, 4>
542  GlobalIdentifierMapType;
543 
544  /// \brief Mapping from global identifier IDs to the module in which the
545  /// identifier resides along with the offset that should be added to the
546  /// global identifier ID to produce a local ID.
547  GlobalIdentifierMapType GlobalIdentifierMap;
548 
549  /// \brief A vector containing macros that have already been
550  /// loaded.
551  ///
552  /// If the pointer at index I is non-NULL, then it refers to the
553  /// MacroInfo for the identifier with ID=I+1 that has already
554  /// been loaded.
555  std::vector<MacroInfo *> MacrosLoaded;
556 
557  typedef std::pair<IdentifierInfo *, serialization::SubmoduleID>
558  LoadedMacroInfo;
559 
560  /// \brief A set of #undef directives that we have loaded; used to
561  /// deduplicate the same #undef information coming from multiple module
562  /// files.
563  llvm::DenseSet<LoadedMacroInfo> LoadedUndefs;
564 
565  typedef ContinuousRangeMap<serialization::MacroID, ModuleFile *, 4>
566  GlobalMacroMapType;
567 
568  /// \brief Mapping from global macro IDs to the module in which the
569  /// macro resides along with the offset that should be added to the
570  /// global macro ID to produce a local ID.
571  GlobalMacroMapType GlobalMacroMap;
572 
573  /// \brief A vector containing submodules that have already been loaded.
574  ///
575  /// This vector is indexed by the Submodule ID (-1). NULL submodule entries
576  /// indicate that the particular submodule ID has not yet been loaded.
577  SmallVector<Module *, 2> SubmodulesLoaded;
578 
579  typedef ContinuousRangeMap<serialization::SubmoduleID, ModuleFile *, 4>
580  GlobalSubmoduleMapType;
581 
582  /// \brief Mapping from global submodule IDs to the module file in which the
583  /// submodule resides along with the offset that should be added to the
584  /// global submodule ID to produce a local ID.
585  GlobalSubmoduleMapType GlobalSubmoduleMap;
586 
587  /// \brief A set of hidden declarations.
588  typedef SmallVector<Decl*, 2> HiddenNames;
589  typedef llvm::DenseMap<Module *, HiddenNames> HiddenNamesMapType;
590 
591  /// \brief A mapping from each of the hidden submodules to the deserialized
592  /// declarations in that submodule that could be made visible.
593  HiddenNamesMapType HiddenNamesMap;
594 
595 
596  /// \brief A module import, export, or conflict that hasn't yet been resolved.
597  struct UnresolvedModuleRef {
598  /// \brief The file in which this module resides.
599  ModuleFile *File;
600 
601  /// \brief The module that is importing or exporting.
602  Module *Mod;
603 
604  /// \brief The kind of module reference.
605  enum { Import, Export, Conflict } Kind;
606 
607  /// \brief The local ID of the module that is being exported.
608  unsigned ID;
609 
610  /// \brief Whether this is a wildcard export.
611  unsigned IsWildcard : 1;
612 
613  /// \brief String data.
614  StringRef String;
615  };
616 
617  /// \brief The set of module imports and exports that still need to be
618  /// resolved.
619  SmallVector<UnresolvedModuleRef, 2> UnresolvedModuleRefs;
620 
621  /// \brief A vector containing selectors that have already been loaded.
622  ///
623  /// This vector is indexed by the Selector ID (-1). NULL selector
624  /// entries indicate that the particular selector ID has not yet
625  /// been loaded.
626  SmallVector<Selector, 16> SelectorsLoaded;
627 
628  typedef ContinuousRangeMap<serialization::SelectorID, ModuleFile *, 4>
629  GlobalSelectorMapType;
630 
631  /// \brief Mapping from global selector IDs to the module in which the
632 
633  /// global selector ID to produce a local ID.
634  GlobalSelectorMapType GlobalSelectorMap;
635 
636  /// \brief The generation number of the last time we loaded data from the
637  /// global method pool for this selector.
638  llvm::DenseMap<Selector, unsigned> SelectorGeneration;
639 
640  struct PendingMacroInfo {
641  ModuleFile *M;
642  uint64_t MacroDirectivesOffset;
643 
644  PendingMacroInfo(ModuleFile *M, uint64_t MacroDirectivesOffset)
645  : M(M), MacroDirectivesOffset(MacroDirectivesOffset) {}
646  };
647 
648  typedef llvm::MapVector<IdentifierInfo *, SmallVector<PendingMacroInfo, 2> >
649  PendingMacroIDsMap;
650 
651  /// \brief Mapping from identifiers that have a macro history to the global
652  /// IDs have not yet been deserialized to the global IDs of those macros.
653  PendingMacroIDsMap PendingMacroIDs;
654 
655  typedef ContinuousRangeMap<unsigned, ModuleFile *, 4>
656  GlobalPreprocessedEntityMapType;
657 
658  /// \brief Mapping from global preprocessing entity IDs to the module in
659  /// which the preprocessed entity resides along with the offset that should be
660  /// added to the global preprocessing entitiy ID to produce a local ID.
661  GlobalPreprocessedEntityMapType GlobalPreprocessedEntityMap;
662 
663  /// \name CodeGen-relevant special data
664  /// \brief Fields containing data that is relevant to CodeGen.
665  //@{
666 
667  /// \brief The IDs of all declarations that fulfill the criteria of
668  /// "interesting" decls.
669  ///
670  /// This contains the data loaded from all EAGERLY_DESERIALIZED_DECLS blocks
671  /// in the chain. The referenced declarations are deserialized and passed to
672  /// the consumer eagerly.
673  SmallVector<uint64_t, 16> EagerlyDeserializedDecls;
674 
675  /// \brief The IDs of all tentative definitions stored in the chain.
676  ///
677  /// Sema keeps track of all tentative definitions in a TU because it has to
678  /// complete them and pass them on to CodeGen. Thus, tentative definitions in
679  /// the PCH chain must be eagerly deserialized.
680  SmallVector<uint64_t, 16> TentativeDefinitions;
681 
682  /// \brief The IDs of all CXXRecordDecls stored in the chain whose VTables are
683  /// used.
684  ///
685  /// CodeGen has to emit VTables for these records, so they have to be eagerly
686  /// deserialized.
687  SmallVector<uint64_t, 64> VTableUses;
688 
689  /// \brief A snapshot of the pending instantiations in the chain.
690  ///
691  /// This record tracks the instantiations that Sema has to perform at the
692  /// end of the TU. It consists of a pair of values for every pending
693  /// instantiation where the first value is the ID of the decl and the second
694  /// is the instantiation location.
695  SmallVector<uint64_t, 64> PendingInstantiations;
696 
697  //@}
698 
699  /// \name DiagnosticsEngine-relevant special data
700  /// \brief Fields containing data that is used for generating diagnostics
701  //@{
702 
703  /// \brief A snapshot of Sema's unused file-scoped variable tracking, for
704  /// generating warnings.
705  SmallVector<uint64_t, 16> UnusedFileScopedDecls;
706 
707  /// \brief A list of all the delegating constructors we've seen, to diagnose
708  /// cycles.
709  SmallVector<uint64_t, 4> DelegatingCtorDecls;
710 
711  /// \brief Method selectors used in a @selector expression. Used for
712  /// implementation of -Wselector.
713  SmallVector<uint64_t, 64> ReferencedSelectorsData;
714 
715  /// \brief A snapshot of Sema's weak undeclared identifier tracking, for
716  /// generating warnings.
717  SmallVector<uint64_t, 64> WeakUndeclaredIdentifiers;
718 
719  /// \brief The IDs of type aliases for ext_vectors that exist in the chain.
720  ///
721  /// Used by Sema for finding sugared names for ext_vectors in diagnostics.
722  SmallVector<uint64_t, 4> ExtVectorDecls;
723 
724  //@}
725 
726  /// \name Sema-relevant special data
727  /// \brief Fields containing data that is used for semantic analysis
728  //@{
729 
730  /// \brief The IDs of all potentially unused typedef names in the chain.
731  ///
732  /// Sema tracks these to emit warnings.
733  SmallVector<uint64_t, 16> UnusedLocalTypedefNameCandidates;
734 
735  /// \brief The IDs of the declarations Sema stores directly.
736  ///
737  /// Sema tracks a few important decls, such as namespace std, directly.
738  SmallVector<uint64_t, 4> SemaDeclRefs;
739 
740  /// \brief The IDs of the types ASTContext stores directly.
741  ///
742  /// The AST context tracks a few important types, such as va_list, directly.
743  SmallVector<uint64_t, 16> SpecialTypes;
744 
745  /// \brief The IDs of CUDA-specific declarations ASTContext stores directly.
746  ///
747  /// The AST context tracks a few important decls, currently cudaConfigureCall,
748  /// directly.
749  SmallVector<uint64_t, 2> CUDASpecialDeclRefs;
750 
751  /// \brief The floating point pragma option settings.
752  SmallVector<uint64_t, 1> FPPragmaOptions;
753 
754  /// \brief The pragma clang optimize location (if the pragma state is "off").
755  SourceLocation OptimizeOffPragmaLocation;
756 
757  /// \brief The OpenCL extension settings.
758  SmallVector<uint64_t, 1> OpenCLExtensions;
759 
760  /// \brief A list of the namespaces we've seen.
761  SmallVector<uint64_t, 4> KnownNamespaces;
762 
763  /// \brief A list of undefined decls with internal linkage followed by the
764  /// SourceLocation of a matching ODR-use.
765  SmallVector<uint64_t, 8> UndefinedButUsed;
766 
767  /// \brief Delete expressions to analyze at the end of translation unit.
768  SmallVector<uint64_t, 8> DelayedDeleteExprs;
769 
770  // \brief A list of late parsed template function data.
771  SmallVector<uint64_t, 1> LateParsedTemplates;
772 
773  struct ImportedSubmodule {
775  SourceLocation ImportLoc;
776 
777  ImportedSubmodule(serialization::SubmoduleID ID, SourceLocation ImportLoc)
778  : ID(ID), ImportLoc(ImportLoc) {}
779  };
780 
781  /// \brief A list of modules that were imported by precompiled headers or
782  /// any other non-module AST file.
783  SmallVector<ImportedSubmodule, 2> ImportedModules;
784  //@}
785 
786  /// \brief The directory that the PCH we are reading is stored in.
787  std::string CurrentDir;
788 
789  /// \brief The system include root to be used when loading the
790  /// precompiled header.
791  std::string isysroot;
792 
793  /// \brief Whether to disable the normal validation performed on precompiled
794  /// headers when they are loaded.
795  bool DisableValidation;
796 
797  /// \brief Whether to accept an AST file with compiler errors.
798  bool AllowASTWithCompilerErrors;
799 
800  /// \brief Whether to accept an AST file that has a different configuration
801  /// from the current compiler instance.
802  bool AllowConfigurationMismatch;
803 
804  /// \brief Whether validate system input files.
805  bool ValidateSystemInputs;
806 
807  /// \brief Whether we are allowed to use the global module index.
808  bool UseGlobalIndex;
809 
810  /// \brief Whether we have tried loading the global module index yet.
811  bool TriedLoadingGlobalIndex;
812 
813  typedef llvm::DenseMap<unsigned, SwitchCase *> SwitchCaseMapTy;
814  /// \brief Mapping from switch-case IDs in the chain to switch-case statements
815  ///
816  /// Statements usually don't have IDs, but switch cases need them, so that the
817  /// switch statement can refer to them.
818  SwitchCaseMapTy SwitchCaseStmts;
819 
820  SwitchCaseMapTy *CurrSwitchCaseStmts;
821 
822  /// \brief The number of source location entries de-serialized from
823  /// the PCH file.
824  unsigned NumSLocEntriesRead;
825 
826  /// \brief The number of source location entries in the chain.
827  unsigned TotalNumSLocEntries;
828 
829  /// \brief The number of statements (and expressions) de-serialized
830  /// from the chain.
831  unsigned NumStatementsRead;
832 
833  /// \brief The total number of statements (and expressions) stored
834  /// in the chain.
835  unsigned TotalNumStatements;
836 
837  /// \brief The number of macros de-serialized from the chain.
838  unsigned NumMacrosRead;
839 
840  /// \brief The total number of macros stored in the chain.
841  unsigned TotalNumMacros;
842 
843  /// \brief The number of lookups into identifier tables.
844  unsigned NumIdentifierLookups;
845 
846  /// \brief The number of lookups into identifier tables that succeed.
847  unsigned NumIdentifierLookupHits;
848 
849  /// \brief The number of selectors that have been read.
850  unsigned NumSelectorsRead;
851 
852  /// \brief The number of method pool entries that have been read.
853  unsigned NumMethodPoolEntriesRead;
854 
855  /// \brief The number of times we have looked up a selector in the method
856  /// pool.
857  unsigned NumMethodPoolLookups;
858 
859  /// \brief The number of times we have looked up a selector in the method
860  /// pool and found something.
861  unsigned NumMethodPoolHits;
862 
863  /// \brief The number of times we have looked up a selector in the method
864  /// pool within a specific module.
865  unsigned NumMethodPoolTableLookups;
866 
867  /// \brief The number of times we have looked up a selector in the method
868  /// pool within a specific module and found something.
869  unsigned NumMethodPoolTableHits;
870 
871  /// \brief The total number of method pool entries in the selector table.
872  unsigned TotalNumMethodPoolEntries;
873 
874  /// Number of lexical decl contexts read/total.
875  unsigned NumLexicalDeclContextsRead, TotalLexicalDeclContexts;
876 
877  /// Number of visible decl contexts read/total.
878  unsigned NumVisibleDeclContextsRead, TotalVisibleDeclContexts;
879 
880  /// Total size of modules, in bits, currently loaded
881  uint64_t TotalModulesSizeInBits;
882 
883  /// \brief Number of Decl/types that are currently deserializing.
884  unsigned NumCurrentElementsDeserializing;
885 
886  /// \brief Set true while we are in the process of passing deserialized
887  /// "interesting" decls to consumer inside FinishedDeserializing().
888  /// This is used as a guard to avoid recursively repeating the process of
889  /// passing decls to consumer.
890  bool PassingDeclsToConsumer;
891 
892  /// \brief The set of identifiers that were read while the AST reader was
893  /// (recursively) loading declarations.
894  ///
895  /// The declarations on the identifier chain for these identifiers will be
896  /// loaded once the recursive loading has completed.
897  llvm::MapVector<IdentifierInfo *, SmallVector<uint32_t, 4> >
898  PendingIdentifierInfos;
899 
900  /// \brief The set of lookup results that we have faked in order to support
901  /// merging of partially deserialized decls but that we have not yet removed.
902  llvm::SmallMapVector<IdentifierInfo *, SmallVector<NamedDecl*, 2>, 16>
903  PendingFakeLookupResults;
904 
905  /// \brief The generation number of each identifier, which keeps track of
906  /// the last time we loaded information about this identifier.
907  llvm::DenseMap<IdentifierInfo *, unsigned> IdentifierGeneration;
908 
909  /// \brief Contains declarations and definitions that will be
910  /// "interesting" to the ASTConsumer, when we get that AST consumer.
911  ///
912  /// "Interesting" declarations are those that have data that may
913  /// need to be emitted, such as inline function definitions or
914  /// Objective-C protocols.
915  std::deque<Decl *> InterestingDecls;
916 
917  /// \brief The set of redeclarable declarations that have been deserialized
918  /// since the last time the declaration chains were linked.
919  llvm::SmallPtrSet<Decl *, 16> RedeclsDeserialized;
920 
921  /// \brief The list of redeclaration chains that still need to be
922  /// reconstructed.
923  ///
924  /// Each element is the canonical declaration of the chain.
925  /// Elements in this vector should be unique; use
926  /// PendingDeclChainsKnown to ensure uniqueness.
927  SmallVector<Decl *, 16> PendingDeclChains;
928 
929  /// \brief Keeps track of the elements added to PendingDeclChains.
930  llvm::SmallSet<Decl *, 16> PendingDeclChainsKnown;
931 
932  /// \brief The list of canonical declarations whose redeclaration chains
933  /// need to be marked as incomplete once we're done deserializing things.
934  SmallVector<Decl *, 16> PendingIncompleteDeclChains;
935 
936  /// \brief The Decl IDs for the Sema/Lexical DeclContext of a Decl that has
937  /// been loaded but its DeclContext was not set yet.
938  struct PendingDeclContextInfo {
939  Decl *D;
941  serialization::GlobalDeclID LexicalDC;
942  };
943 
944  /// \brief The set of Decls that have been loaded but their DeclContexts are
945  /// not set yet.
946  ///
947  /// The DeclContexts for these Decls will be set once recursive loading has
948  /// been completed.
949  std::deque<PendingDeclContextInfo> PendingDeclContextInfos;
950 
951  /// \brief The set of NamedDecls that have been loaded, but are members of a
952  /// context that has been merged into another context where the corresponding
953  /// declaration is either missing or has not yet been loaded.
954  ///
955  /// We will check whether the corresponding declaration is in fact missing
956  /// once recursing loading has been completed.
957  llvm::SmallVector<NamedDecl *, 16> PendingOdrMergeChecks;
958 
959  /// \brief Record definitions in which we found an ODR violation.
960  llvm::SmallDenseMap<CXXRecordDecl *, llvm::TinyPtrVector<CXXRecordDecl *>, 2>
961  PendingOdrMergeFailures;
962 
963  /// \brief DeclContexts in which we have diagnosed an ODR violation.
964  llvm::SmallPtrSet<DeclContext*, 2> DiagnosedOdrMergeFailures;
965 
966  /// \brief The set of Objective-C categories that have been deserialized
967  /// since the last time the declaration chains were linked.
968  llvm::SmallPtrSet<ObjCCategoryDecl *, 16> CategoriesDeserialized;
969 
970  /// \brief The set of Objective-C class definitions that have already been
971  /// loaded, for which we will need to check for categories whenever a new
972  /// module is loaded.
973  SmallVector<ObjCInterfaceDecl *, 16> ObjCClassesLoaded;
974 
975  /// \brief A mapping from a primary context for a declaration chain to the
976  /// other declarations of that entity that also have name lookup tables.
977  /// Used when we merge together two class definitions that have different
978  /// sets of declared special member functions.
979  llvm::DenseMap<const DeclContext*, SmallVector<const DeclContext*, 2>>
980  MergedLookups;
981 
982  typedef llvm::DenseMap<Decl *, SmallVector<serialization::DeclID, 2> >
983  KeyDeclsMap;
984 
985  /// \brief A mapping from canonical declarations to the set of global
986  /// declaration IDs for key declaration that have been merged with that
987  /// canonical declaration. A key declaration is a formerly-canonical
988  /// declaration whose module did not import any other key declaration for that
989  /// entity. These are the IDs that we use as keys when finding redecl chains.
990  KeyDeclsMap KeyDecls;
991 
992  /// \brief A mapping from DeclContexts to the semantic DeclContext that we
993  /// are treating as the definition of the entity. This is used, for instance,
994  /// when merging implicit instantiations of class templates across modules.
995  llvm::DenseMap<DeclContext *, DeclContext *> MergedDeclContexts;
996 
997  /// \brief A mapping from canonical declarations of enums to their canonical
998  /// definitions. Only populated when using modules in C++.
999  llvm::DenseMap<EnumDecl *, EnumDecl *> EnumDefinitions;
1000 
1001  /// \brief When reading a Stmt tree, Stmt operands are placed in this stack.
1002  SmallVector<Stmt *, 16> StmtStack;
1003 
1004  /// \brief What kind of records we are reading.
1005  enum ReadingKind {
1006  Read_None, Read_Decl, Read_Type, Read_Stmt
1007  };
1008 
1009  /// \brief What kind of records we are reading.
1010  ReadingKind ReadingKind;
1011 
1012  /// \brief RAII object to change the reading kind.
1013  class ReadingKindTracker {
1014  ASTReader &Reader;
1015  enum ReadingKind PrevKind;
1016 
1017  ReadingKindTracker(const ReadingKindTracker &) = delete;
1018  void operator=(const ReadingKindTracker &) = delete;
1019 
1020  public:
1021  ReadingKindTracker(enum ReadingKind newKind, ASTReader &reader)
1022  : Reader(reader), PrevKind(Reader.ReadingKind) {
1023  Reader.ReadingKind = newKind;
1024  }
1025 
1026  ~ReadingKindTracker() { Reader.ReadingKind = PrevKind; }
1027  };
1028 
1029  /// \brief Suggested contents of the predefines buffer, after this
1030  /// PCH file has been processed.
1031  ///
1032  /// In most cases, this string will be empty, because the predefines
1033  /// buffer computed to build the PCH file will be identical to the
1034  /// predefines buffer computed from the command line. However, when
1035  /// there are differences that the PCH reader can work around, this
1036  /// predefines buffer may contain additional definitions.
1037  std::string SuggestedPredefines;
1038 
1039  /// \brief Reads a statement from the specified cursor.
1040  Stmt *ReadStmtFromStream(ModuleFile &F);
1041 
1042  struct InputFileInfo {
1043  std::string Filename;
1044  off_t StoredSize;
1045  time_t StoredTime;
1046  bool Overridden;
1047  };
1048 
1049  /// \brief Reads the stored information about an input file.
1050  InputFileInfo readInputFileInfo(ModuleFile &F, unsigned ID);
1051  /// \brief A convenience method to read the filename from an input file.
1052  std::string getInputFileName(ModuleFile &F, unsigned ID);
1053 
1054  /// \brief Retrieve the file entry and 'overridden' bit for an input
1055  /// file in the given module file.
1056  serialization::InputFile getInputFile(ModuleFile &F, unsigned ID,
1057  bool Complain = true);
1058 
1059 public:
1060  void ResolveImportedPath(ModuleFile &M, std::string &Filename);
1061  static void ResolveImportedPath(std::string &Filename, StringRef Prefix);
1062 
1063  /// \brief Returns the first key declaration for the given declaration. This
1064  /// is one that is formerly-canonical (or still canonical) and whose module
1065  /// did not import any other key declaration of the entity.
1067  D = D->getCanonicalDecl();
1068  if (D->isFromASTFile())
1069  return D;
1070 
1071  auto I = KeyDecls.find(D);
1072  if (I == KeyDecls.end() || I->second.empty())
1073  return D;
1074  return GetExistingDecl(I->second[0]);
1075  }
1076  const Decl *getKeyDeclaration(const Decl *D) {
1077  return getKeyDeclaration(const_cast<Decl*>(D));
1078  }
1079 
1080  /// \brief Run a callback on each imported key declaration of \p D.
1081  template <typename Fn>
1082  void forEachImportedKeyDecl(const Decl *D, Fn Visit) {
1083  D = D->getCanonicalDecl();
1084  if (D->isFromASTFile())
1085  Visit(D);
1086 
1087  auto It = KeyDecls.find(const_cast<Decl*>(D));
1088  if (It != KeyDecls.end())
1089  for (auto ID : It->second)
1090  Visit(GetExistingDecl(ID));
1091  }
1092 
1093 private:
1094  struct ImportedModule {
1095  ModuleFile *Mod;
1096  ModuleFile *ImportedBy;
1097  SourceLocation ImportLoc;
1098 
1099  ImportedModule(ModuleFile *Mod,
1100  ModuleFile *ImportedBy,
1101  SourceLocation ImportLoc)
1102  : Mod(Mod), ImportedBy(ImportedBy), ImportLoc(ImportLoc) { }
1103  };
1104 
1105  ASTReadResult ReadASTCore(StringRef FileName, ModuleKind Type,
1106  SourceLocation ImportLoc, ModuleFile *ImportedBy,
1107  SmallVectorImpl<ImportedModule> &Loaded,
1108  off_t ExpectedSize, time_t ExpectedModTime,
1109  serialization::ASTFileSignature ExpectedSignature,
1110  unsigned ClientLoadCapabilities);
1111  ASTReadResult ReadControlBlock(ModuleFile &F,
1112  SmallVectorImpl<ImportedModule> &Loaded,
1113  const ModuleFile *ImportedBy,
1114  unsigned ClientLoadCapabilities);
1115  ASTReadResult ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities);
1116  bool ParseLineTable(ModuleFile &F, const RecordData &Record);
1117  bool ReadSourceManagerBlock(ModuleFile &F);
1118  llvm::BitstreamCursor &SLocCursorForID(int ID);
1119  SourceLocation getImportLocation(ModuleFile *F);
1120  ASTReadResult ReadModuleMapFileBlock(RecordData &Record, ModuleFile &F,
1121  const ModuleFile *ImportedBy,
1122  unsigned ClientLoadCapabilities);
1123  ASTReadResult ReadSubmoduleBlock(ModuleFile &F,
1124  unsigned ClientLoadCapabilities);
1125  static bool ParseLanguageOptions(const RecordData &Record, bool Complain,
1126  ASTReaderListener &Listener,
1127  bool AllowCompatibleDifferences);
1128  static bool ParseTargetOptions(const RecordData &Record, bool Complain,
1129  ASTReaderListener &Listener,
1130  bool AllowCompatibleDifferences);
1131  static bool ParseDiagnosticOptions(const RecordData &Record, bool Complain,
1132  ASTReaderListener &Listener);
1133  static bool ParseFileSystemOptions(const RecordData &Record, bool Complain,
1134  ASTReaderListener &Listener);
1135  static bool ParseHeaderSearchOptions(const RecordData &Record, bool Complain,
1136  ASTReaderListener &Listener);
1137  static bool ParsePreprocessorOptions(const RecordData &Record, bool Complain,
1138  ASTReaderListener &Listener,
1139  std::string &SuggestedPredefines);
1140 
1141  struct RecordLocation {
1142  RecordLocation(ModuleFile *M, uint64_t O)
1143  : F(M), Offset(O) {}
1144  ModuleFile *F;
1145  uint64_t Offset;
1146  };
1147 
1148  QualType readTypeRecord(unsigned Index);
1149  void readExceptionSpec(ModuleFile &ModuleFile,
1150  SmallVectorImpl<QualType> &ExceptionStorage,
1151  FunctionProtoType::ExceptionSpecInfo &ESI,
1152  const RecordData &Record, unsigned &Index);
1153  RecordLocation TypeCursorForIndex(unsigned Index);
1154  void LoadedDecl(unsigned Index, Decl *D);
1155  Decl *ReadDeclRecord(serialization::DeclID ID);
1156  void markIncompleteDeclChain(Decl *Canon);
1157 
1158  /// \brief Returns the most recent declaration of a declaration (which must be
1159  /// of a redeclarable kind) that is either local or has already been loaded
1160  /// merged into its redecl chain.
1161  Decl *getMostRecentExistingDecl(Decl *D);
1162 
1163  RecordLocation DeclCursorForID(serialization::DeclID ID,
1164  unsigned &RawLocation);
1165  void loadDeclUpdateRecords(serialization::DeclID ID, Decl *D);
1166  void loadPendingDeclChain(Decl *D);
1167  void loadObjCCategories(serialization::GlobalDeclID ID, ObjCInterfaceDecl *D,
1168  unsigned PreviousGeneration = 0);
1169 
1170  RecordLocation getLocalBitOffset(uint64_t GlobalOffset);
1171  uint64_t getGlobalBitOffset(ModuleFile &M, uint32_t LocalOffset);
1172 
1173  /// \brief Returns the first preprocessed entity ID that begins or ends after
1174  /// \arg Loc.
1176  findPreprocessedEntity(SourceLocation Loc, bool EndsAfter) const;
1177 
1178  /// \brief Find the next module that contains entities and return the ID
1179  /// of the first entry.
1180  ///
1181  /// \param SLocMapI points at a chunk of a module that contains no
1182  /// preprocessed entities or the entities it contains are not the
1183  /// ones we are looking for.
1185  findNextPreprocessedEntity(
1187 
1188  /// \brief Returns (ModuleFile, Local index) pair for \p GlobalIndex of a
1189  /// preprocessed entity.
1190  std::pair<ModuleFile *, unsigned>
1191  getModulePreprocessedEntity(unsigned GlobalIndex);
1192 
1193  /// \brief Returns (begin, end) pair for the preprocessed entities of a
1194  /// particular module.
1195  llvm::iterator_range<PreprocessingRecord::iterator>
1196  getModulePreprocessedEntities(ModuleFile &Mod) const;
1197 
1198  class ModuleDeclIterator
1199  : public llvm::iterator_adaptor_base<
1200  ModuleDeclIterator, const serialization::LocalDeclID *,
1201  std::random_access_iterator_tag, const Decl *, ptrdiff_t,
1202  const Decl *, const Decl *> {
1203  ASTReader *Reader;
1204  ModuleFile *Mod;
1205 
1206  public:
1207  ModuleDeclIterator()
1208  : iterator_adaptor_base(nullptr), Reader(nullptr), Mod(nullptr) {}
1209 
1210  ModuleDeclIterator(ASTReader *Reader, ModuleFile *Mod,
1211  const serialization::LocalDeclID *Pos)
1212  : iterator_adaptor_base(Pos), Reader(Reader), Mod(Mod) {}
1213 
1214  value_type operator*() const {
1215  return Reader->GetDecl(Reader->getGlobalDeclID(*Mod, *I));
1216  }
1217  value_type operator->() const { return **this; }
1218 
1219  bool operator==(const ModuleDeclIterator &RHS) const {
1220  assert(Reader == RHS.Reader && Mod == RHS.Mod);
1221  return I == RHS.I;
1222  }
1223  };
1224 
1225  llvm::iterator_range<ModuleDeclIterator>
1226  getModuleFileLevelDecls(ModuleFile &Mod);
1227 
1228  void PassInterestingDeclsToConsumer();
1229  void PassInterestingDeclToConsumer(Decl *D);
1230 
1231  void finishPendingActions();
1232  void diagnoseOdrViolations();
1233 
1234  void pushExternalDeclIntoScope(NamedDecl *D, DeclarationName Name);
1235 
1236  void addPendingDeclContextInfo(Decl *D,
1238  serialization::GlobalDeclID LexicalDC) {
1239  assert(D);
1240  PendingDeclContextInfo Info = { D, SemaDC, LexicalDC };
1241  PendingDeclContextInfos.push_back(Info);
1242  }
1243 
1244  /// \brief Produce an error diagnostic and return true.
1245  ///
1246  /// This routine should only be used for fatal errors that have to
1247  /// do with non-routine failures (e.g., corrupted AST file).
1248  void Error(StringRef Msg);
1249  void Error(unsigned DiagID, StringRef Arg1 = StringRef(),
1250  StringRef Arg2 = StringRef());
1251 
1252  ASTReader(const ASTReader &) = delete;
1253  void operator=(const ASTReader &) = delete;
1254 public:
1255  /// \brief Load the AST file and validate its contents against the given
1256  /// Preprocessor.
1257  ///
1258  /// \param PP the preprocessor associated with the context in which this
1259  /// precompiled header will be loaded.
1260  ///
1261  /// \param Context the AST context that this precompiled header will be
1262  /// loaded into.
1263  ///
1264  /// \param PCHContainerOps the PCHContainerOperations to use for loading and
1265  /// creating modules.
1266  ///
1267  /// \param isysroot If non-NULL, the system include path specified by the
1268  /// user. This is only used with relocatable PCH files. If non-NULL,
1269  /// a relocatable PCH file will use the default path "/".
1270  ///
1271  /// \param DisableValidation If true, the AST reader will suppress most
1272  /// of its regular consistency checking, allowing the use of precompiled
1273  /// headers that cannot be determined to be compatible.
1274  ///
1275  /// \param AllowASTWithCompilerErrors If true, the AST reader will accept an
1276  /// AST file the was created out of an AST with compiler errors,
1277  /// otherwise it will reject it.
1278  ///
1279  /// \param AllowConfigurationMismatch If true, the AST reader will not check
1280  /// for configuration differences between the AST file and the invocation.
1281  ///
1282  /// \param ValidateSystemInputs If true, the AST reader will validate
1283  /// system input files in addition to user input files. This is only
1284  /// meaningful if \p DisableValidation is false.
1285  ///
1286  /// \param UseGlobalIndex If true, the AST reader will try to load and use
1287  /// the global module index.
1288  ///
1289  /// \param ReadTimer If non-null, a timer used to track the time spent
1290  /// deserializing.
1291  ASTReader(Preprocessor &PP, ASTContext &Context,
1292  const PCHContainerReader &PCHContainerRdr,
1293  StringRef isysroot = "", bool DisableValidation = false,
1294  bool AllowASTWithCompilerErrors = false,
1295  bool AllowConfigurationMismatch = false,
1296  bool ValidateSystemInputs = false, bool UseGlobalIndex = true,
1297  std::unique_ptr<llvm::Timer> ReadTimer = {});
1298 
1299  ~ASTReader() override;
1300 
1301  SourceManager &getSourceManager() const { return SourceMgr; }
1302  FileManager &getFileManager() const { return FileMgr; }
1303 
1304  /// \brief Flags that indicate what kind of AST loading failures the client
1305  /// of the AST reader can directly handle.
1306  ///
1307  /// When a client states that it can handle a particular kind of failure,
1308  /// the AST reader will not emit errors when producing that kind of failure.
1310  /// \brief The client can't handle any AST loading failures.
1312  /// \brief The client can handle an AST file that cannot load because it
1313  /// is missing.
1315  /// \brief The client can handle an AST file that cannot load because it
1316  /// is out-of-date relative to its input files.
1318  /// \brief The client can handle an AST file that cannot load because it
1319  /// was built with a different version of Clang.
1321  /// \brief The client can handle an AST file that cannot load because it's
1322  /// compiled configuration doesn't match that of the context it was
1323  /// loaded into.
1325  };
1326 
1327  /// \brief Load the AST file designated by the given file name.
1328  ///
1329  /// \param FileName The name of the AST file to load.
1330  ///
1331  /// \param Type The kind of AST being loaded, e.g., PCH, module, main file,
1332  /// or preamble.
1333  ///
1334  /// \param ImportLoc the location where the module file will be considered as
1335  /// imported from. For non-module AST types it should be invalid.
1336  ///
1337  /// \param ClientLoadCapabilities The set of client load-failure
1338  /// capabilities, represented as a bitset of the enumerators of
1339  /// LoadFailureCapabilities.
1340  ASTReadResult ReadAST(const std::string &FileName, ModuleKind Type,
1341  SourceLocation ImportLoc,
1342  unsigned ClientLoadCapabilities);
1343 
1344  /// \brief Make the entities in the given module and any of its (non-explicit)
1345  /// submodules visible to name lookup.
1346  ///
1347  /// \param Mod The module whose names should be made visible.
1348  ///
1349  /// \param NameVisibility The level of visibility to give the names in the
1350  /// module. Visibility can only be increased over time.
1351  ///
1352  /// \param ImportLoc The location at which the import occurs.
1353  void makeModuleVisible(Module *Mod,
1354  Module::NameVisibilityKind NameVisibility,
1355  SourceLocation ImportLoc);
1356 
1357  /// \brief Make the names within this set of hidden names visible.
1358  void makeNamesVisible(const HiddenNames &Names, Module *Owner);
1359 
1360  /// \brief Take the AST callbacks listener.
1361  std::unique_ptr<ASTReaderListener> takeListener() {
1362  return std::move(Listener);
1363  }
1364 
1365  /// \brief Set the AST callbacks listener.
1366  void setListener(std::unique_ptr<ASTReaderListener> Listener) {
1367  this->Listener = std::move(Listener);
1368  }
1369 
1370  /// \brief Add an AST callback listener.
1371  ///
1372  /// Takes ownership of \p L.
1373  void addListener(std::unique_ptr<ASTReaderListener> L) {
1374  if (Listener)
1375  L = llvm::make_unique<ChainedASTReaderListener>(std::move(L),
1376  std::move(Listener));
1377  Listener = std::move(L);
1378  }
1379 
1380  /// RAII object to temporarily add an AST callback listener.
1382  ASTReader &Reader;
1383  bool Chained;
1384 
1385  public:
1386  ListenerScope(ASTReader &Reader, std::unique_ptr<ASTReaderListener> L)
1387  : Reader(Reader), Chained(false) {
1388  auto Old = Reader.takeListener();
1389  if (Old) {
1390  Chained = true;
1391  L = llvm::make_unique<ChainedASTReaderListener>(std::move(L),
1392  std::move(Old));
1393  }
1394  Reader.setListener(std::move(L));
1395  }
1397  auto New = Reader.takeListener();
1398  if (Chained)
1399  Reader.setListener(static_cast<ChainedASTReaderListener *>(New.get())
1400  ->takeSecond());
1401  }
1402  };
1403 
1404  /// \brief Set the AST deserialization listener.
1406  bool TakeOwnership = false);
1407 
1408  /// \brief Determine whether this AST reader has a global index.
1409  bool hasGlobalIndex() const { return (bool)GlobalIndex; }
1410 
1411  /// \brief Return global module index.
1412  GlobalModuleIndex *getGlobalIndex() { return GlobalIndex.get(); }
1413 
1414  /// \brief Reset reader for a reload try.
1415  void resetForReload() { TriedLoadingGlobalIndex = false; }
1416 
1417  /// \brief Attempts to load the global index.
1418  ///
1419  /// \returns true if loading the global index has failed for any reason.
1420  bool loadGlobalIndex();
1421 
1422  /// \brief Determine whether we tried to load the global index, but failed,
1423  /// e.g., because it is out-of-date or does not exist.
1424  bool isGlobalIndexUnavailable() const;
1425 
1426  /// \brief Initializes the ASTContext
1427  void InitializeContext();
1428 
1429  /// \brief Update the state of Sema after loading some additional modules.
1430  void UpdateSema();
1431 
1432  /// \brief Add in-memory (virtual file) buffer.
1433  void addInMemoryBuffer(StringRef &FileName,
1434  std::unique_ptr<llvm::MemoryBuffer> Buffer) {
1435  ModuleMgr.addInMemoryBuffer(FileName, std::move(Buffer));
1436  }
1437 
1438  /// \brief Finalizes the AST reader's state before writing an AST file to
1439  /// disk.
1440  ///
1441  /// This operation may undo temporary state in the AST that should not be
1442  /// emitted.
1443  void finalizeForWriting();
1444 
1445  /// \brief Retrieve the module manager.
1446  ModuleManager &getModuleManager() { return ModuleMgr; }
1447 
1448  /// \brief Retrieve the preprocessor.
1449  Preprocessor &getPreprocessor() const { return PP; }
1450 
1451  /// \brief Retrieve the name of the original source file name for the primary
1452  /// module file.
1454  return ModuleMgr.getPrimaryModule().OriginalSourceFileName;
1455  }
1456 
1457  /// \brief Retrieve the name of the original source file name directly from
1458  /// the AST file, without actually loading the AST file.
1459  static std::string
1460  getOriginalSourceFile(const std::string &ASTFileName, FileManager &FileMgr,
1461  const PCHContainerReader &PCHContainerRdr,
1462  DiagnosticsEngine &Diags);
1463 
1464  /// \brief Read the control block for the named AST file.
1465  ///
1466  /// \returns true if an error occurred, false otherwise.
1467  static bool
1468  readASTFileControlBlock(StringRef Filename, FileManager &FileMgr,
1469  const PCHContainerReader &PCHContainerRdr,
1470  ASTReaderListener &Listener);
1471 
1472  /// \brief Determine whether the given AST file is acceptable to load into a
1473  /// translation unit with the given language and target options.
1474  static bool isAcceptableASTFile(StringRef Filename, FileManager &FileMgr,
1475  const PCHContainerReader &PCHContainerRdr,
1476  const LangOptions &LangOpts,
1477  const TargetOptions &TargetOpts,
1478  const PreprocessorOptions &PPOpts,
1479  std::string ExistingModuleCachePath);
1480 
1481  /// \brief Returns the suggested contents of the predefines buffer,
1482  /// which contains a (typically-empty) subset of the predefines
1483  /// build prior to including the precompiled header.
1484  const std::string &getSuggestedPredefines() { return SuggestedPredefines; }
1485 
1486  /// \brief Read a preallocated preprocessed entity from the external source.
1487  ///
1488  /// \returns null if an error occurred that prevented the preprocessed
1489  /// entity from being loaded.
1490  PreprocessedEntity *ReadPreprocessedEntity(unsigned Index) override;
1491 
1492  /// \brief Returns a pair of [Begin, End) indices of preallocated
1493  /// preprocessed entities that \p Range encompasses.
1494  std::pair<unsigned, unsigned>
1496 
1497  /// \brief Optionally returns true or false if the preallocated preprocessed
1498  /// entity with index \p Index came from file \p FID.
1500  FileID FID) override;
1501 
1502  /// \brief Read the header file information for the given file entry.
1503  HeaderFileInfo GetHeaderFileInfo(const FileEntry *FE) override;
1504 
1506 
1507  /// \brief Returns the number of source locations found in the chain.
1508  unsigned getTotalNumSLocs() const {
1509  return TotalNumSLocEntries;
1510  }
1511 
1512  /// \brief Returns the number of identifiers found in the chain.
1513  unsigned getTotalNumIdentifiers() const {
1514  return static_cast<unsigned>(IdentifiersLoaded.size());
1515  }
1516 
1517  /// \brief Returns the number of macros found in the chain.
1518  unsigned getTotalNumMacros() const {
1519  return static_cast<unsigned>(MacrosLoaded.size());
1520  }
1521 
1522  /// \brief Returns the number of types found in the chain.
1523  unsigned getTotalNumTypes() const {
1524  return static_cast<unsigned>(TypesLoaded.size());
1525  }
1526 
1527  /// \brief Returns the number of declarations found in the chain.
1528  unsigned getTotalNumDecls() const {
1529  return static_cast<unsigned>(DeclsLoaded.size());
1530  }
1531 
1532  /// \brief Returns the number of submodules known.
1533  unsigned getTotalNumSubmodules() const {
1534  return static_cast<unsigned>(SubmodulesLoaded.size());
1535  }
1536 
1537  /// \brief Returns the number of selectors found in the chain.
1538  unsigned getTotalNumSelectors() const {
1539  return static_cast<unsigned>(SelectorsLoaded.size());
1540  }
1541 
1542  /// \brief Returns the number of preprocessed entities known to the AST
1543  /// reader.
1545  unsigned Result = 0;
1546  for (ModuleConstIterator I = ModuleMgr.begin(),
1547  E = ModuleMgr.end(); I != E; ++I) {
1548  Result += (*I)->NumPreprocessedEntities;
1549  }
1550 
1551  return Result;
1552  }
1553 
1554  /// \brief Reads a TemplateArgumentLocInfo appropriate for the
1555  /// given TemplateArgument kind.
1558  const RecordData &Record, unsigned &Idx);
1559 
1560  /// \brief Reads a TemplateArgumentLoc.
1563  const RecordData &Record, unsigned &Idx);
1564 
1567  const RecordData &Record, unsigned &Index);
1568 
1569  /// \brief Reads a declarator info from the given record.
1571  const RecordData &Record, unsigned &Idx);
1572 
1573  /// \brief Resolve a type ID into a type, potentially building a new
1574  /// type.
1576 
1577  /// \brief Resolve a local type ID within a given AST file into a type.
1578  QualType getLocalType(ModuleFile &F, unsigned LocalID);
1579 
1580  /// \brief Map a local type ID within a given AST file into a global type ID.
1581  serialization::TypeID getGlobalTypeID(ModuleFile &F, unsigned LocalID) const;
1582 
1583  /// \brief Read a type from the current position in the given record, which
1584  /// was read from the given AST file.
1585  QualType readType(ModuleFile &F, const RecordData &Record, unsigned &Idx) {
1586  if (Idx >= Record.size())
1587  return QualType();
1588 
1589  return getLocalType(F, Record[Idx++]);
1590  }
1591 
1592  /// \brief Map from a local declaration ID within a given module to a
1593  /// global declaration ID.
1595  serialization::LocalDeclID LocalID) const;
1596 
1597  /// \brief Returns true if global DeclID \p ID originated from module \p M.
1599 
1600  /// \brief Retrieve the module file that owns the given declaration, or NULL
1601  /// if the declaration is not from a module file.
1602  ModuleFile *getOwningModuleFile(const Decl *D);
1603 
1604  /// \brief Get the best name we know for the module that owns the given
1605  /// declaration, or an empty string if the declaration is not from a module.
1606  std::string getOwningModuleNameForDiagnostic(const Decl *D);
1607 
1608  /// \brief Returns the source location for the decl \p ID.
1610 
1611  /// \brief Resolve a declaration ID into a declaration, potentially
1612  /// building a new declaration.
1614  Decl *GetExternalDecl(uint32_t ID) override;
1615 
1616  /// \brief Resolve a declaration ID into a declaration. Return 0 if it's not
1617  /// been loaded yet.
1619 
1620  /// \brief Reads a declaration with the given local ID in the given module.
1621  Decl *GetLocalDecl(ModuleFile &F, uint32_t LocalID) {
1622  return GetDecl(getGlobalDeclID(F, LocalID));
1623  }
1624 
1625  /// \brief Reads a declaration with the given local ID in the given module.
1626  ///
1627  /// \returns The requested declaration, casted to the given return type.
1628  template<typename T>
1629  T *GetLocalDeclAs(ModuleFile &F, uint32_t LocalID) {
1630  return cast_or_null<T>(GetLocalDecl(F, LocalID));
1631  }
1632 
1633  /// \brief Map a global declaration ID into the declaration ID used to
1634  /// refer to this declaration within the given module fule.
1635  ///
1636  /// \returns the global ID of the given declaration as known in the given
1637  /// module file.
1640  serialization::DeclID GlobalID);
1641 
1642  /// \brief Reads a declaration ID from the given position in a record in the
1643  /// given module.
1644  ///
1645  /// \returns The declaration ID read from the record, adjusted to a global ID.
1647  unsigned &Idx);
1648 
1649  /// \brief Reads a declaration from the given position in a record in the
1650  /// given module.
1651  Decl *ReadDecl(ModuleFile &F, const RecordData &R, unsigned &I) {
1652  return GetDecl(ReadDeclID(F, R, I));
1653  }
1654 
1655  /// \brief Reads a declaration from the given position in a record in the
1656  /// given module.
1657  ///
1658  /// \returns The declaration read from this location, casted to the given
1659  /// result type.
1660  template<typename T>
1661  T *ReadDeclAs(ModuleFile &F, const RecordData &R, unsigned &I) {
1662  return cast_or_null<T>(GetDecl(ReadDeclID(F, R, I)));
1663  }
1664 
1665  /// \brief If any redeclarations of \p D have been imported since it was
1666  /// last checked, this digs out those redeclarations and adds them to the
1667  /// redeclaration chain for \p D.
1668  void CompleteRedeclChain(const Decl *D) override;
1669 
1670  /// \brief Read a CXXBaseSpecifiers ID form the given record and
1671  /// return its global bit offset.
1672  uint64_t readCXXBaseSpecifiers(ModuleFile &M, const RecordData &Record,
1673  unsigned &Idx);
1674 
1676 
1677  /// \brief Resolve the offset of a statement into a statement.
1678  ///
1679  /// This operation will read a new statement from the external
1680  /// source each time it is called, and is meant to be used via a
1681  /// LazyOffsetPtr (which is used by Decls for the body of functions, etc).
1682  Stmt *GetExternalDeclStmt(uint64_t Offset) override;
1683 
1684  /// ReadBlockAbbrevs - Enter a subblock of the specified BlockID with the
1685  /// specified cursor. Read the abbreviations that are at the top of the block
1686  /// and then leave the cursor pointing into the block.
1687  bool ReadBlockAbbrevs(llvm::BitstreamCursor &Cursor, unsigned BlockID);
1688 
1689  /// \brief Finds all the visible declarations with a given name.
1690  /// The current implementation of this method just loads the entire
1691  /// lookup table as unmaterialized references.
1693  DeclarationName Name) override;
1694 
1695  /// \brief Read all of the declarations lexically stored in a
1696  /// declaration context.
1697  ///
1698  /// \param DC The declaration context whose declarations will be
1699  /// read.
1700  ///
1701  /// \param Decls Vector that will contain the declarations loaded
1702  /// from the external source. The caller is responsible for merging
1703  /// these declarations with any declarations already stored in the
1704  /// declaration context.
1705  ///
1706  /// \returns true if there was an error while reading the
1707  /// declarations for this declaration context.
1709  bool (*isKindWeWant)(Decl::Kind),
1710  SmallVectorImpl<Decl*> &Decls) override;
1711 
1712  /// \brief Get the decls that are contained in a file in the Offset/Length
1713  /// range. \p Length can be 0 to indicate a point at \p Offset instead of
1714  /// a range.
1715  void FindFileRegionDecls(FileID File, unsigned Offset, unsigned Length,
1716  SmallVectorImpl<Decl *> &Decls) override;
1717 
1718  /// \brief Notify ASTReader that we started deserialization of
1719  /// a decl or type so until FinishedDeserializing is called there may be
1720  /// decls that are initializing. Must be paired with FinishedDeserializing.
1721  void StartedDeserializing() override;
1722 
1723  /// \brief Notify ASTReader that we finished the deserialization of
1724  /// a decl or type. Must be paired with StartedDeserializing.
1725  void FinishedDeserializing() override;
1726 
1727  /// \brief Function that will be invoked when we begin parsing a new
1728  /// translation unit involving this external AST source.
1729  ///
1730  /// This function will provide all of the external definitions to
1731  /// the ASTConsumer.
1732  void StartTranslationUnit(ASTConsumer *Consumer) override;
1733 
1734  /// \brief Print some statistics about AST usage.
1735  void PrintStats() override;
1736 
1737  /// \brief Dump information about the AST reader to standard error.
1738  void dump();
1739 
1740  /// Return the amount of memory used by memory buffers, breaking down
1741  /// by heap-backed versus mmap'ed memory.
1742  void getMemoryBufferSizes(MemoryBufferSizes &sizes) const override;
1743 
1744  /// \brief Initialize the semantic source with the Sema instance
1745  /// being used to perform semantic analysis on the abstract syntax
1746  /// tree.
1747  void InitializeSema(Sema &S) override;
1748 
1749  /// \brief Inform the semantic consumer that Sema is no longer available.
1750  void ForgetSema() override { SemaObj = nullptr; }
1751 
1752  /// \brief Retrieve the IdentifierInfo for the named identifier.
1753  ///
1754  /// This routine builds a new IdentifierInfo for the given identifier. If any
1755  /// declarations with this name are visible from translation unit scope, their
1756  /// declarations will be deserialized and introduced into the declaration
1757  /// chain of the identifier.
1758  virtual IdentifierInfo *get(const char *NameStart, const char *NameEnd);
1759  IdentifierInfo *get(StringRef Name) override {
1760  return get(Name.begin(), Name.end());
1761  }
1762 
1763  /// \brief Retrieve an iterator into the set of all identifiers
1764  /// in all loaded AST files.
1765  IdentifierIterator *getIdentifiers() override;
1766 
1767  /// \brief Load the contents of the global method pool for a given
1768  /// selector.
1769  void ReadMethodPool(Selector Sel) override;
1770 
1771  /// \brief Load the set of namespaces that are known to the external source,
1772  /// which will be used during typo correction.
1773  void ReadKnownNamespaces(
1774  SmallVectorImpl<NamespaceDecl *> &Namespaces) override;
1775 
1776  void ReadUndefinedButUsed(
1777  llvm::DenseMap<NamedDecl *, SourceLocation> &Undefined) override;
1778 
1779  void ReadMismatchingDeleteExpressions(llvm::MapVector<
1780  FieldDecl *, llvm::SmallVector<std::pair<SourceLocation, bool>, 4>> &
1781  Exprs) override;
1782 
1784  SmallVectorImpl<VarDecl *> &TentativeDefs) override;
1785 
1787  SmallVectorImpl<const DeclaratorDecl *> &Decls) override;
1788 
1790  SmallVectorImpl<CXXConstructorDecl *> &Decls) override;
1791 
1793 
1796 
1798  SmallVectorImpl<std::pair<Selector, SourceLocation> > &Sels) override;
1799 
1801  SmallVectorImpl<std::pair<IdentifierInfo *, WeakInfo> > &WI) override;
1802 
1803  void ReadUsedVTables(SmallVectorImpl<ExternalVTableUse> &VTables) override;
1804 
1806  SmallVectorImpl<std::pair<ValueDecl *,
1807  SourceLocation> > &Pending) override;
1808 
1810  llvm::MapVector<const FunctionDecl *, LateParsedTemplate *> &LPTMap)
1811  override;
1812 
1813  /// \brief Load a selector from disk, registering its ID if it exists.
1814  void LoadSelector(Selector Sel);
1815 
1816  void SetIdentifierInfo(unsigned ID, IdentifierInfo *II);
1818  const SmallVectorImpl<uint32_t> &DeclIDs,
1819  SmallVectorImpl<Decl *> *Decls = nullptr);
1820 
1821  /// \brief Report a diagnostic.
1822  DiagnosticBuilder Diag(unsigned DiagID);
1823 
1824  /// \brief Report a diagnostic.
1825  DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID);
1826 
1828 
1830  unsigned &Idx) {
1831  return DecodeIdentifierInfo(getGlobalIdentifierID(M, Record[Idx++]));
1832  }
1833 
1835  // Note that we are loading an identifier.
1836  Deserializing AnIdentifier(this);
1837 
1838  return DecodeIdentifierInfo(ID);
1839  }
1840 
1841  IdentifierInfo *getLocalIdentifier(ModuleFile &M, unsigned LocalID);
1842 
1844  unsigned LocalID);
1845 
1846  void resolvePendingMacro(IdentifierInfo *II, const PendingMacroInfo &PMInfo);
1847 
1848  /// \brief Retrieve the macro with the given ID.
1850 
1851  /// \brief Retrieve the global macro ID corresponding to the given local
1852  /// ID within the given module file.
1853  serialization::MacroID getGlobalMacroID(ModuleFile &M, unsigned LocalID);
1854 
1855  /// \brief Read the source location entry with index ID.
1856  bool ReadSLocEntry(int ID) override;
1857 
1858  /// \brief Retrieve the module import location and module name for the
1859  /// given source manager entry ID.
1860  std::pair<SourceLocation, StringRef> getModuleImportLoc(int ID) override;
1861 
1862  /// \brief Retrieve the global submodule ID given a module and its local ID
1863  /// number.
1865  getGlobalSubmoduleID(ModuleFile &M, unsigned LocalID);
1866 
1867  /// \brief Retrieve the submodule that corresponds to a global submodule ID.
1868  ///
1870 
1871  /// \brief Retrieve the module that corresponds to the given module ID.
1872  ///
1873  /// Note: overrides method in ExternalASTSource
1874  Module *getModule(unsigned ID) override;
1875 
1876  /// \brief Return a descriptor for the corresponding module.
1878  /// \brief Return a descriptor for the module.
1879  ASTSourceDescriptor getSourceDescriptor(const Module &M) override;
1880 
1881  /// \brief Retrieve a selector from the given module with its local ID
1882  /// number.
1883  Selector getLocalSelector(ModuleFile &M, unsigned LocalID);
1884 
1886 
1888  uint32_t GetNumExternalSelectors() override;
1889 
1890  Selector ReadSelector(ModuleFile &M, const RecordData &Record, unsigned &Idx) {
1891  return getLocalSelector(M, Record[Idx++]);
1892  }
1893 
1894  /// \brief Retrieve the global selector ID that corresponds to this
1895  /// the local selector ID in a given module.
1897  unsigned LocalID) const;
1898 
1899  /// \brief Read a declaration name.
1901  const RecordData &Record, unsigned &Idx);
1903  DeclarationNameLoc &DNLoc, DeclarationName Name,
1904  const RecordData &Record, unsigned &Idx);
1906  const RecordData &Record, unsigned &Idx);
1907 
1909  const RecordData &Record, unsigned &Idx);
1910 
1912  const RecordData &Record,
1913  unsigned &Idx);
1914 
1916  const RecordData &Record,
1917  unsigned &Idx);
1918 
1919  /// \brief Read a template name.
1921  unsigned &Idx);
1922 
1923  /// \brief Read a template argument.
1925  const RecordData &Record,unsigned &Idx);
1926 
1927  /// \brief Read a template parameter list.
1929  const RecordData &Record,
1930  unsigned &Idx);
1931 
1932  /// \brief Read a template argument array.
1933  void
1935  ModuleFile &F, const RecordData &Record,
1936  unsigned &Idx);
1937 
1938  /// \brief Read a UnresolvedSet structure.
1940  const RecordData &Record, unsigned &Idx);
1941 
1942  /// \brief Read a C++ base specifier.
1944  const RecordData &Record,unsigned &Idx);
1945 
1946  /// \brief Read a CXXCtorInitializer array.
1948  ReadCXXCtorInitializers(ModuleFile &F, const RecordData &Record,
1949  unsigned &Idx);
1950 
1951  /// \brief Read a CXXCtorInitializers ID from the given record and
1952  /// return its global bit offset.
1953  uint64_t ReadCXXCtorInitializersRef(ModuleFile &M, const RecordData &Record,
1954  unsigned &Idx);
1955 
1956  /// \brief Read the contents of a CXXCtorInitializer array.
1958 
1959  /// \brief Read a source location from raw form.
1962  assert(ModuleFile.SLocRemap.find(Loc.getOffset()) != ModuleFile.SLocRemap.end() &&
1963  "Cannot find offset to remap.");
1964  int Remap = ModuleFile.SLocRemap.find(Loc.getOffset())->second;
1965  return Loc.getLocWithOffset(Remap);
1966  }
1967 
1968  /// \brief Read a source location.
1970  const RecordDataImpl &Record,
1971  unsigned &Idx) {
1972  return ReadSourceLocation(ModuleFile, Record[Idx++]);
1973  }
1974 
1975  /// \brief Read a source range.
1977  const RecordData &Record, unsigned &Idx);
1978 
1979  /// \brief Read an integral value
1980  llvm::APInt ReadAPInt(const RecordData &Record, unsigned &Idx);
1981 
1982  /// \brief Read a signed integral value
1983  llvm::APSInt ReadAPSInt(const RecordData &Record, unsigned &Idx);
1984 
1985  /// \brief Read a floating-point value
1986  llvm::APFloat ReadAPFloat(const RecordData &Record,
1987  const llvm::fltSemantics &Sem, unsigned &Idx);
1988 
1989  // \brief Read a string
1990  static std::string ReadString(const RecordData &Record, unsigned &Idx);
1991 
1992  // \brief Read a path
1993  std::string ReadPath(ModuleFile &F, const RecordData &Record, unsigned &Idx);
1994 
1995  /// \brief Read a version tuple.
1996  static VersionTuple ReadVersionTuple(const RecordData &Record, unsigned &Idx);
1997 
1999  unsigned &Idx);
2000 
2001  /// \brief Reads attributes from the current stream position.
2002  void ReadAttributes(ModuleFile &F, AttrVec &Attrs,
2003  const RecordData &Record, unsigned &Idx);
2004 
2005  /// \brief Reads a statement.
2006  Stmt *ReadStmt(ModuleFile &F);
2007 
2008  /// \brief Reads an expression.
2009  Expr *ReadExpr(ModuleFile &F);
2010 
2011  /// \brief Reads a sub-statement operand during statement reading.
2013  assert(ReadingKind == Read_Stmt &&
2014  "Should be called only during statement reading!");
2015  // Subexpressions are stored from last to first, so the next Stmt we need
2016  // is at the back of the stack.
2017  assert(!StmtStack.empty() && "Read too many sub-statements!");
2018  return StmtStack.pop_back_val();
2019  }
2020 
2021  /// \brief Reads a sub-expression operand during statement reading.
2022  Expr *ReadSubExpr();
2023 
2024  /// \brief Reads a token out of a record.
2025  Token ReadToken(ModuleFile &M, const RecordDataImpl &Record, unsigned &Idx);
2026 
2027  /// \brief Reads the macro record located at the given offset.
2028  MacroInfo *ReadMacroRecord(ModuleFile &F, uint64_t Offset);
2029 
2030  /// \brief Determine the global preprocessed entity ID that corresponds to
2031  /// the given local ID within the given module.
2033  getGlobalPreprocessedEntityID(ModuleFile &M, unsigned LocalID) const;
2034 
2035  /// \brief Add a macro to deserialize its macro directive history.
2036  ///
2037  /// \param II The name of the macro.
2038  /// \param M The module file.
2039  /// \param MacroDirectivesOffset Offset of the serialized macro directive
2040  /// history.
2042  uint64_t MacroDirectivesOffset);
2043 
2044  /// \brief Read the set of macros defined by this external macro source.
2045  void ReadDefinedMacros() override;
2046 
2047  /// \brief Update an out-of-date identifier.
2048  void updateOutOfDateIdentifier(IdentifierInfo &II) override;
2049 
2050  /// \brief Note that this identifier is up-to-date.
2052 
2053  /// \brief Load all external visible decls in the given DeclContext.
2054  void completeVisibleDeclsMap(const DeclContext *DC) override;
2055 
2056  /// \brief Retrieve the AST context that this AST reader supplements.
2057  ASTContext &getContext() { return Context; }
2058 
2059  // \brief Contains the IDs for declarations that were requested before we have
2060  // access to a Sema object.
2062 
2063  /// \brief Retrieve the semantic analysis object used to analyze the
2064  /// translation unit in which the precompiled header is being
2065  /// imported.
2066  Sema *getSema() { return SemaObj; }
2067 
2068  /// \brief Retrieve the identifier table associated with the
2069  /// preprocessor.
2071 
2072  /// \brief Record that the given ID maps to the given switch-case
2073  /// statement.
2074  void RecordSwitchCaseID(SwitchCase *SC, unsigned ID);
2075 
2076  /// \brief Retrieve the switch-case statement with the given ID.
2077  SwitchCase *getSwitchCaseWithID(unsigned ID);
2078 
2079  void ClearSwitchCaseIDs();
2080 
2081  /// \brief Cursors for comments blocks.
2082  SmallVector<std::pair<llvm::BitstreamCursor,
2084 
2085  //RIDErief Loads comments ranges.
2086  void ReadComments() override;
2087 
2088  /// Return all input files for the given module file.
2089  void getInputFiles(ModuleFile &F,
2091 };
2092 
2093 /// \brief Helper class that saves the current stream position and
2094 /// then restores it when destroyed.
2096  explicit SavedStreamPosition(llvm::BitstreamCursor &Cursor)
2097  : Cursor(Cursor), Offset(Cursor.GetCurrentBitNo()) { }
2098 
2100  Cursor.JumpToBit(Offset);
2101  }
2102 
2103 private:
2104  llvm::BitstreamCursor &Cursor;
2105  uint64_t Offset;
2106 };
2107 
2108 inline void PCHValidator::Error(const char *Msg) {
2109  Reader.Error(Msg);
2110 }
2111 
2112 } // end namespace clang
2113 
2114 #endif
llvm::APInt ReadAPInt(const RecordData &Record, unsigned &Idx)
Read an integral value.
Definition: ASTReader.cpp:7935
Decl * GetExistingDecl(serialization::DeclID ID)
Resolve a declaration ID into a declaration. Return 0 if it's not been loaded yet.
Definition: ASTReader.cpp:6070
SmallVector< std::pair< llvm::BitstreamCursor, serialization::ModuleFile * >, 8 > CommentsCursors
Cursors for comments blocks.
Definition: ASTReader.h:2083
bool FindExternalVisibleDeclsByName(const DeclContext *DC, DeclarationName Name) override
Finds all the visible declarations with a given name. The current implementation of this method just ...
Definition: ASTReader.cpp:6418
Decl * GetLocalDecl(ModuleFile &F, uint32_t LocalID)
Reads a declaration with the given local ID in the given module.
Definition: ASTReader.h:1621
ASTReadResult
The result of reading the control block of an AST file, which can fail for various reasons...
Definition: ASTReader.h:316
The client can handle an AST file that cannot load because it was built with a different version of C...
Definition: ASTReader.h:1320
IdentifierIterator * getIdentifiers() override
Retrieve an iterator into the set of all identifiers in all loaded AST files.
Definition: ASTReader.cpp:6905
unsigned getTotalNumTypes() const
Returns the number of types found in the chain.
Definition: ASTReader.h:1523
bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts, StringRef SpecificModuleCachePath, bool Complain) override
Receives the header search options.
Definition: ASTReader.cpp:113
Smart pointer class that efficiently represents Objective-C method names.
bool visitInputFile(StringRef Filename, bool isSystem, bool isOverridden) override
if needsInputFileVisitation returns true, this is called for each non-system input file of the AST Fi...
Definition: ASTReader.cpp:145
ASTReadResult ReadAST(const std::string &FileName, ModuleKind Type, SourceLocation ImportLoc, unsigned ClientLoadCapabilities)
Load the AST file designated by the given file name.
Definition: ASTReader.cpp:3345
virtual bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, bool Complain, std::string &SuggestedPredefines)
Receives the preprocessor options.
Definition: ASTReader.h:171
Represents a version number in the form major[.minor[.subminor[.build]]].
Definition: VersionTuple.h:26
void SetIdentifierInfo(unsigned ID, IdentifierInfo *II)
Definition: ASTReader.cpp:7212
Implements support for file system lookup, file system caching, and directory search management...
Definition: FileManager.h:115
RAII class for safely pairing a StartedDeserializing call with FinishedDeserializing.
bool operator==(CanQual< T > x, CanQual< U > y)
Defines the clang::FileManager interface and associated types.
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:5960
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:4819
SourceLocation ReadSourceLocation(ModuleFile &ModuleFile, unsigned Raw) const
Read a source location from raw form.
Definition: ASTReader.h:1960
void ReadComments() override
Loads comment ranges.
Definition: ASTReader.cpp:8022
Defines the SourceManager interface.
bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain, bool AllowCompatibleDifferences) override
Receives the target options.
Definition: ASTReader.cpp:93
GlobalModuleIndex * getGlobalIndex()
Return global module index.
Definition: ASTReader.h:1412
Module * getSubmodule(serialization::SubmoduleID GlobalID)
Retrieve the submodule that corresponds to a global submodule ID.
Definition: ASTReader.cpp:7369
ModuleManager::ModuleConstIterator ModuleConstIterator
Definition: ASTReader.h:352
SmallVector< uint64_t, 64 > RecordData
Definition: ASTReader.h:311
virtual void ReadCounter(const serialization::ModuleFile &M, unsigned Value)
Receives COUNTER value.
Definition: ASTReader.h:178
Preprocessor & getPreprocessor() const
Retrieve the preprocessor.
Definition: ASTReader.h:1449
uint32_t DeclID
An ID number that refers to a declaration in an AST file.
Definition: ASTBitCodes.h:62
IdentifierInfo * getLocalIdentifier(ModuleFile &M, unsigned LocalID)
Definition: ASTReader.cpp:7303
StringRef getOriginalSourceFile()
Retrieve the name of the original source file name for the primary module file.
Definition: ASTReader.h:1453
static bool readASTFileControlBlock(StringRef Filename, FileManager &FileMgr, const PCHContainerReader &PCHContainerRdr, ASTReaderListener &Listener)
Read the control block for the named AST file.
Definition: ASTReader.cpp:3968
Decl * GetDecl(serialization::DeclID ID)
Resolve a declaration ID into a declaration, potentially building a new declaration.
Definition: ASTReader.cpp:6094
A container of type source information.
Definition: Decl.h:60
Base class that describes a preprocessed entity, which may be a preprocessor directive or macro expan...
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:3262
void addPendingMacro(IdentifierInfo *II, ModuleFile *M, uint64_t MacroDirectivesOffset)
Add a macro to deserialize its macro directive history.
Definition: ASTReader.cpp:1587
CXXBaseSpecifier ReadCXXBaseSpecifier(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a C++ base specifier.
Definition: ASTReader.cpp:7708
The client can handle an AST file that cannot load because it is out-of-date relative to its input fi...
Definition: ASTReader.h:1317
The AST file has errors.
Definition: ASTReader.h:333
uint32_t IdentifierID
An ID number that refers to an identifier in an AST file.
Definition: ASTBitCodes.h:54
Manages the set of modules loaded by an AST reader.
Definition: ModuleManager.h:32
void ReadReferencedSelectors(SmallVectorImpl< std::pair< Selector, SourceLocation > > &Sels) override
Read the set of referenced selectors known to the external Sema source.
Definition: ASTReader.cpp:7122
CXXCtorInitializer ** GetExternalCXXCtorInitializers(uint64_t Offset) override
Read the contents of a CXXCtorInitializer array.
Definition: ASTReader.cpp:5929
Options for controlling the target.
Definition: TargetOptions.h:24
serialization::TypeID getGlobalTypeID(ModuleFile &F, unsigned LocalID) const
Map a local type ID within a given AST file into a global type ID.
Definition: ASTReader.cpp:5785
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:5872
void dump()
Dump information about the AST reader to standard error.
Definition: ASTReader.cpp:6736
ModuleManager::ModuleReverseIterator ModuleReverseIterator
Definition: ASTReader.h:353
void InitializeSema(Sema &S) override
Initialize the semantic source with the Sema instance being used to perform semantic analysis on the ...
Definition: ASTReader.cpp:6775
TemplateArgument ReadTemplateArgument(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a template argument.
Definition: ASTReader.cpp:7623
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>". This is safe to be used inside an AST node, in contrast with TemplateArgumentListInfo.
Definition: TemplateBase.h:564
Stores a list of template parameters for a TemplateDecl and its derived classes.
Definition: DeclTemplate.h:46
void ReadCounter(const serialization::ModuleFile &M, unsigned Value) override
Receives COUNTER value.
Definition: ASTReader.cpp:634
T * ReadDeclAs(ModuleFile &F, const RecordData &R, unsigned &I)
Reads a declaration from the given position in a record in the given module.
Definition: ASTReader.h:1661
Selector ReadSelector(ModuleFile &M, const RecordData &Record, unsigned &Idx)
Definition: ASTReader.h:1890
MemoryBufferSizes getMemoryBufferSizes() const
void ReadTentativeDefinitions(SmallVectorImpl< VarDecl * > &TentativeDefs) override
Read the set of tentative definitions known to the external Sema source.
Definition: ASTReader.cpp:7068
An UnresolvedSet-like class that might not have been loaded from the external AST source yet...
The client can handle an AST file that cannot load because it is missing.
Definition: ASTReader.h:1314
bool ReadDiagnosticOptions(IntrusiveRefCntPtr< DiagnosticOptions > DiagOpts, bool Complain) override
Receives the diagnostic options.
Definition: ASTReader.cpp:101
SmallVectorImpl< ModuleFile * >::const_iterator ModuleConstIterator
bool hasGlobalIndex() const
Determine whether this AST reader has a global index.
Definition: ASTReader.h:1409
ModuleIterator begin()
Forward iterator to traverse all loaded modules. This is reverse source-order.
void finalizeForWriting()
Finalizes the AST reader's state before writing an AST file to disk.
Definition: ASTReader.cpp:3810
T * GetLocalDeclAs(ModuleFile &F, uint32_t LocalID)
Reads a declaration with the given local ID in the given module.
Definition: ASTReader.h:1629
unsigned getTotalNumSubmodules() const
Returns the number of submodules known.
Definition: ASTReader.h:1533
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:89
A C++ nested-name-specifier augmented with source location information.
Utility class for loading a ASTContext from an AST file.
Definition: ASTUnit.h:68
serialization::SelectorID getGlobalSelectorID(ModuleFile &F, unsigned LocalID) const
Retrieve the global selector ID that corresponds to this the local selector ID in a given module...
Definition: ASTReader.cpp:7457
static SourceLocation getFromRawEncoding(unsigned Encoding)
Turn a raw encoding of a SourceLocation object into a real SourceLocation.
serialization::ModuleManager ModuleManager
Definition: ASTReader.h:349
void ReadLateParsedTemplates(llvm::MapVector< const FunctionDecl *, LateParsedTemplate * > &LPTMap) override
Read the set of late parsed template functions for this source.
Definition: ASTReader.cpp:7184
Helper class that saves the current stream position and then restores it when destroyed.
Definition: ASTReader.h:2095
void ReadUndefinedButUsed(llvm::DenseMap< NamedDecl *, SourceLocation > &Undefined) override
Load the set of used but not defined functions or variables with internal linkage, or used but not defined internal functions.
Definition: ASTReader.cpp:7043
TemplateName ReadTemplateName(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a template name.
Definition: ASTReader.cpp:7564
virtual bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain, bool AllowCompatibleDifferences)
Receives the language options.
Definition: ASTReader.h:119
clang::CharUnits operator*(clang::CharUnits::QuantityType Scale, const clang::CharUnits &CU)
Definition: CharUnits.h:183
Sema * getSema()
Retrieve the semantic analysis object used to analyze the translation unit in which the precompiled h...
Definition: ASTReader.h:2066
Stmt * ReadSubStmt()
Reads a sub-statement operand during statement reading.
Definition: ASTReader.h:2012
void ReadExtVectorDecls(SmallVectorImpl< TypedefNameDecl * > &Decls) override
Read the set of ext_vector type declarations known to the external Sema source.
Definition: ASTReader.cpp:7100
The client can handle an AST file that cannot load because it's compiled configuration doesn't match ...
Definition: ASTReader.h:1324
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:48
Decl * getKeyDeclaration(Decl *D)
Returns the first key declaration for the given declaration. This is one that is formerly-canonical (...
Definition: ASTReader.h:1066
void ReadWeakUndeclaredIdentifiers(SmallVectorImpl< std::pair< IdentifierInfo *, WeakInfo > > &WI) override
Read the set of weak, undeclared identifiers known to the external Sema source.
Definition: ASTReader.cpp:7140
Describes a module or submodule.
Definition: Basic/Module.h:49
void completeVisibleDeclsMap(const DeclContext *DC) override
Load all external visible decls in the given DeclContext.
Definition: ASTReader.cpp:6532
static VersionTuple ReadVersionTuple(const RecordData &Record, unsigned &Idx)
Read a version tuple.
Definition: ASTReader.cpp:7971
llvm::Optional< ASTSourceDescriptor > getSourceDescriptor(unsigned ID) override
Return a descriptor for the corresponding module.
Definition: ASTReader.cpp:7401
uint32_t SubmoduleID
An ID number that refers to a submodule in a module file.
Definition: ASTBitCodes.h:162
SourceLocation getLocWithOffset(int Offset) const
Return a source location with the specified offset from this SourceLocation.
PreprocessedEntity * ReadPreprocessedEntity(unsigned Index) override
Read a preallocated preprocessed entity from the external source.
Definition: ASTReader.cpp:4616
serialization::ModuleKind ModuleKind
Definition: ASTReader.h:348
TypeSourceInfo * GetTypeSourceInfo(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Reads a declarator info from the given record.
Definition: ASTReader.cpp:5674
uint32_t Offset
Definition: CacheTokens.cpp:43
ModuleManager & getModuleManager()
Retrieve the module manager.
Definition: ASTReader.h:1446
void ReadQualifierInfo(ModuleFile &F, QualifierInfo &Info, const RecordData &Record, unsigned &Idx)
Definition: ASTReader.cpp:7551
CXXCtorInitializer ** ReadCXXCtorInitializers(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a CXXCtorInitializer array.
Definition: ASTReader.cpp:7724
llvm::APSInt ReadAPSInt(const RecordData &Record, unsigned &Idx)
Read a signed integral value.
Definition: ASTReader.cpp:7944
SourceLocation ReadSourceLocation(ModuleFile &ModuleFile, const RecordDataImpl &Record, unsigned &Idx)
Read a source location.
Definition: ASTReader.h:1969
uint64_t readCXXBaseSpecifiers(ModuleFile &M, const RecordData &Record, unsigned &Idx)
Read a CXXBaseSpecifiers ID form the given record and return its global bit offset.
Definition: ASTReader.cpp:5948
std::string ReadPath(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Definition: ASTReader.cpp:7964
ModuleIterator end()
Forward iterator end-point to traverse all loaded modules.
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, bool Complain, std::string &SuggestedPredefines) override
Receives the preprocessor options.
Definition: ASTReader.cpp:592
std::string getOwningModuleNameForDiagnostic(const Decl *D)
Get the best name we know for the module that owns the given declaration, or an empty string if the d...
Definition: ASTReader.cpp:8081
Concrete class used by the front-end to report problems and issues.
Definition: Diagnostic.h:135
serialization::SubmoduleID getGlobalSubmoduleID(ModuleFile &M, unsigned LocalID)
Retrieve the global submodule ID given a module and its local ID number.
Definition: ASTReader.cpp:7357
CXXTemporary * ReadCXXTemporary(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Definition: ASTReader.cpp:7983
ASTContext & getContext()
Retrieve the AST context that this AST reader supplements.
Definition: ASTReader.h:2057
const Decl * getKeyDeclaration(const Decl *D)
Definition: ASTReader.h:1076
std::string OriginalSourceFileName
The original source file name that was used to build the primary AST file, which may have been modifi...
void resetForReload()
Reset reader for a reload try.
Definition: ASTReader.h:1415
ModuleManager::ModuleIterator ModuleIterator
Definition: ASTReader.h:351
void ReadPendingInstantiations(SmallVectorImpl< std::pair< ValueDecl *, SourceLocation > > &Pending) override
Read the set of pending instantiations known to the external Sema source.
Definition: ASTReader.cpp:7172
ContinuousRangeMap< uint32_t, int, 2 > SLocRemap
Remapping table for source locations in this module.
void ReadPragmaDiagnosticMappings(DiagnosticsEngine &Diag)
Definition: ASTReader.cpp:4881
The AST file itself appears corrupted.
Definition: ASTReader.h:321
unsigned getTotalNumDecls() const
Returns the number of declarations found in the chain.
Definition: ASTReader.h:1528
void ReadMismatchingDeleteExpressions(llvm::MapVector< FieldDecl *, llvm::SmallVector< std::pair< SourceLocation, bool >, 4 >> &Exprs) override
Definition: ASTReader.cpp:7053
The preprocessor keeps track of this information for each file that is #included. ...
Definition: HeaderSearch.h:39
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
Definition: DeclBase.h:733
virtual bool needsInputFileVisitation()
Returns true if this ASTReaderListener wants to receive the input files of the AST file via visitInpu...
Definition: ASTReader.h:186
void ReadDelegatingConstructors(SmallVectorImpl< CXXConstructorDecl * > &Decls) override
Read the set of delegating constructors known to the external Sema source.
Definition: ASTReader.cpp:7089
static std::string ReadString(const RecordData &Record, unsigned &Idx)
Definition: ASTReader.cpp:7957
virtual bool ReadFileSystemOptions(const FileSystemOptions &FSOpts, bool Complain)
Receives the file system options.
Definition: ASTReader.h:148
llvm::OnDiskIterableChainedHashTable< ASTDeclContextNameLookupTrait > ASTDeclContextNameLookupTable
The on-disk hash table used for the DeclContext's Name lookup table.
Definition: ASTReader.h:282
IdentifierInfo * GetIdentifierInfo(ModuleFile &M, const RecordData &Record, unsigned &Idx)
Definition: ASTReader.h:1829
void ForgetSema() override
Inform the semantic consumer that Sema is no longer available.
Definition: ASTReader.h:1750
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:258
A little helper class used to produce diagnostics.
Definition: Diagnostic.h:866
Stmt * GetExternalDeclStmt(uint64_t Offset) override
Resolve the offset of a statement into a statement.
Definition: ASTReader.cpp:6148
virtual void visitModuleFile(StringRef Filename)
This is called for each AST file loaded.
Definition: ASTReader.h:182
ModuleKind
Specifies the kind of module that has been loaded.
Provides lookups to, and iteration over, IdentiferInfo objects.
void SetGloballyVisibleDecls(IdentifierInfo *II, const SmallVectorImpl< uint32_t > &DeclIDs, SmallVectorImpl< Decl * > *Decls=nullptr)
Set the globally-visible declarations associated with the given identifier.
Definition: ASTReader.cpp:7237
ASTContext * Context
void ReadModuleMapFile(StringRef ModuleMapPath) override
Definition: ASTReader.cpp:80
Decl * ReadDecl(ModuleFile &F, const RecordData &R, unsigned &I)
Reads a declaration from the given position in a record in the given module.
Definition: ASTReader.h:1651
static bool isAcceptableASTFile(StringRef Filename, FileManager &FileMgr, const PCHContainerReader &PCHContainerRdr, const LangOptions &LangOpts, const TargetOptions &TargetOpts, const PreprocessorOptions &PPOpts, std::string ExistingModuleCachePath)
Determine whether the given AST file is acceptable to load into a translation unit with the given lan...
Definition: ASTReader.cpp:4161
ID
Defines the set of possible language-specific address spaces.
Definition: AddressSpaces.h:27
void resolvePendingMacro(IdentifierInfo *II, const PendingMacroInfo &PMInfo)
Definition: ASTReader.cpp:1736
SmallVectorImpl< ModuleFile * >::reverse_iterator ModuleReverseIterator
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:1469
ASTReaderListener implementation to validate the information of the PCH file against an initialized P...
Definition: ASTReader.h:252
Abstract interface for external sources of preprocessor information.
HeaderFileInfo GetHeaderFileInfo(const FileEntry *FE) override
Read the header file information for the given file entry.
Definition: ASTReader.cpp:4872
SwitchCase * getSwitchCaseWithID(unsigned ID)
Retrieve the switch-case statement with the given ID.
Definition: ASTReader.cpp:8013
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:7345
ExternalLoadResult
Enumeration describing the result of loading information from an external source. ...
DiagnosticBuilder Diag(unsigned DiagID)
Report a diagnostic.
Definition: ASTReader.cpp:7990
virtual bool visitInputFile(StringRef Filename, bool isSystem, bool isOverridden)
if needsInputFileVisitation returns true, this is called for each non-system input file of the AST Fi...
Definition: ASTReader.h:196
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:1585
RAII object to temporarily add an AST callback listener.
Definition: ASTReader.h:1381
Stmt * ReadStmt(ModuleFile &F)
Reads a statement.
void ReadUsedVTables(SmallVectorImpl< ExternalVTableUse > &VTables) override
Read the set of used vtables known to the external Sema source.
Definition: ASTReader.cpp:7160
Implements an efficient mapping from strings to IdentifierInfo nodes.
SourceManager & SourceMgr
Definition: Format.cpp:1205
Defines version macros and version-related utility functions for Clang.
ArgKind
The kind of template argument we're storing.
Definition: TemplateBase.h:42
serialization::DeclID getGlobalDeclID(ModuleFile &F, serialization::LocalDeclID LocalID) const
Map from a local declaration ID within a given module to a global declaration ID. ...
Definition: ASTReader.cpp:5984
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:1288
SourceRange ReadSourceRange(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a source range.
Definition: ASTReader.cpp:7927
Represents a C++ template name within the type system.
Definition: TemplateName.h:175
QualType getLocalType(ModuleFile &F, unsigned LocalID)
Resolve a local type ID within a given AST file into a type.
Definition: ASTReader.cpp:5780
Information about a module that has been loaded by the ASTReader.
void ReadCounter(const serialization::ModuleFile &M, unsigned Value) override
Receives COUNTER value.
Definition: ASTReader.cpp:128
An iterator that walks over all of the known identifiers in the lookup table.
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
bool isFromASTFile() const
Determine whether this declaration came from an AST file (such as a precompiled header or module) rat...
Definition: DeclBase.h:624
bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain, bool AllowCompatibleDifferences) override
Receives the target options.
Definition: ASTReader.cpp:312
SavedStreamPosition(llvm::BitstreamCursor &Cursor)
Definition: ASTReader.h:2096
void StartedDeserializing() override
Notify ASTReader that we started deserialization of a decl or type so until FinishedDeserializing is ...
Definition: ASTReader.cpp:8409
The result type of a method or function.
SmallVector< uint64_t, 16 > PreloadedDeclIDs
Definition: ASTReader.h:2061
void ReadDeclarationNameInfo(ModuleFile &F, DeclarationNameInfo &NameInfo, const RecordData &Record, unsigned &Idx)
Definition: ASTReader.cpp:7541
The client can't handle any AST loading failures.
Definition: ASTReader.h:1311
The AST file was missing.
Definition: ASTReader.h:323
An abstract interface that should be implemented by external AST sources that also provide informatio...
NestedNameSpecifier * ReadNestedNameSpecifier(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Definition: ASTReader.cpp:7809
void addInMemoryBuffer(StringRef FileName, std::unique_ptr< llvm::MemoryBuffer > Buffer)
Add an in-memory buffer the list of known buffers.
void makeNamesVisible(const HiddenNames &Names, Module *Owner)
Make the names within this set of hidden names visible.
Definition: ASTReader.cpp:3248
The control block was read successfully. Aside from failures, the AST file is safe to read into the c...
Definition: ASTReader.h:319
bool ReadFullVersionInformation(StringRef FullVersion) override
Receives the full Clang version information.
Definition: ASTReader.cpp:72
#define false
Definition: stdbool.h:33
ExternalLoadResult FindExternalLexicalDecls(const DeclContext *DC, bool(*isKindWeWant)(Decl::Kind), SmallVectorImpl< Decl * > &Decls) override
Read all of the declarations lexically stored in a declaration context.
Definition: ASTReader.cpp:6213
Kind
void addListener(std::unique_ptr< ASTReaderListener > L)
Add an AST callback listener.
Definition: ASTReader.h:1373
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:3330
void LoadSelector(Selector Sel)
Load a selector from disk, registering its ID if it exists.
Definition: ASTReader.cpp:7207
MacroInfo * ReadMacroRecord(ModuleFile &F, uint64_t Offset)
Reads the macro record located at the given offset.
Definition: ASTReader.cpp:1357
Encodes a location in the source. The SourceManager can decode this to get at the full include stack...
Represents a C++ temporary.
Definition: ExprCXX.h:1001
void InitializeContext()
Initializes the ASTContext.
Definition: ASTReader.cpp:3676
An identifier-lookup iterator that enumerates all of the identifiers stored within a set of AST files...
Definition: ASTReader.cpp:6853
std::unique_ptr< ASTReaderListener > takeListener()
Take the AST callbacks listener.
Definition: ASTReader.h:1361
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:7032
Cached information about one file (either on disk or in the virtual file system). ...
Definition: FileManager.h:53
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, bool Complain, std::string &SuggestedPredefines) override
Receives the preprocessor options.
Definition: ASTReader.cpp:121
MacroInfo * getMacro(serialization::MacroID ID)
Retrieve the macro with the given ID.
Definition: ASTReader.cpp:7319
TemplateParameterList * ReadTemplateParameterList(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a template parameter list.
Definition: ASTReader.cpp:7666
An abstract class that should be subclassed by any external source of preprocessing record entries...
bool isDeclIDFromModule(serialization::GlobalDeclID ID, ModuleFile &M) const
Returns true if global DeclID ID originated from module M.
Definition: ASTReader.cpp:5995
void ReadMethodPool(Selector Sel) override
Load the contents of the global method pool for a given selector.
Definition: ASTReader.cpp:6996
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
std::string getClangFullRepositoryVersion()
Retrieves the full repository version that is an amalgamation of the information in getClangRepositor...
Definition: Version.cpp:90
virtual bool ReadFullVersionInformation(StringRef FullVersion)
Receives the full Clang version information.
Definition: ASTReader.h:109
void addInMemoryBuffer(StringRef &FileName, std::unique_ptr< llvm::MemoryBuffer > Buffer)
Add in-memory (virtual file) buffer.
Definition: ASTReader.h:1433
PCHValidator(Preprocessor &PP, ASTReader &Reader)
Definition: ASTReader.h:257
uint32_t MacroID
An ID number that refers to a macro in an AST file.
Definition: ASTBitCodes.h:131
void setListener(std::unique_ptr< ASTReaderListener > Listener)
Set the AST callbacks listener.
Definition: ASTReader.h:1366
External source of source location entries.
virtual void visitImport(StringRef Filename)
If needsImportVisitation returns true, this is called for each AST file imported by this AST file...
Definition: ASTReader.h:206
A global index for a set of module files, providing information about the identifiers within those mo...
DeclarationName ReadDeclarationName(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a declaration name.
Definition: ASTReader.cpp:7470
The AST file was writtten with a different language/target configuration.
Definition: ASTReader.h:331
void markIdentifierUpToDate(IdentifierInfo *II)
Note that this identifier is up-to-date.
Definition: ASTReader.cpp:1725
llvm::APFloat ReadAPFloat(const RecordData &Record, const llvm::fltSemantics &Sem, unsigned &Idx)
Read a floating-point value.
Definition: ASTReader.cpp:7950
unsigned getTotalNumSLocs() const
Returns the number of source locations found in the chain.
Definition: ASTReader.h:1508
ChainedASTReaderListener(std::unique_ptr< ASTReaderListener > First, std::unique_ptr< ASTReaderListener > Second)
Takes ownership of First and Second.
Definition: ASTReader.h:216
SmallVectorImpl< uint64_t > RecordDataImpl
Definition: ASTReader.h:312
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
Represents a template argument.
Definition: TemplateBase.h:39
Selector getLocalSelector(ModuleFile &M, unsigned LocalID)
Retrieve a selector from the given module with its local ID number.
Definition: ASTReader.cpp:7418
const ASTTemplateArgumentListInfo * ReadASTTemplateArgumentListInfo(ModuleFile &F, const RecordData &Record, unsigned &Index)
Definition: ASTReader.cpp:5850
bool ReadSLocEntry(int ID) override
Read the source location entry with index ID.
Definition: ASTReader.cpp:1159
bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts, StringRef SpecificModuleCachePath, bool Complain) override
Receives the header search options.
Definition: ASTReader.cpp:625
void ResolveImportedPath(ModuleFile &M, std::string &Filename)
If we are loading a relocatable PCH or module file, and the filename is not an absolute path...
Definition: ASTReader.cpp:2014
void setDeserializationListener(ASTDeserializationListener *Listener, bool TakeOwnership=false)
Set the AST deserialization listener.
Definition: ASTReader.cpp:642
unsigned getTotalNumIdentifiers() const
Returns the number of identifiers found in the chain.
Definition: ASTReader.h:1513
void updateOutOfDateIdentifier(IdentifierInfo &II) override
Update an out-of-date identifier.
Definition: ASTReader.cpp:1700
void ReadDefinedMacros() override
Read the set of macros defined by this external macro source.
Definition: ASTReader.cpp:1594
An external source of header file information, which may supply information about header files alread...
Definition: HeaderSearch.h:137
bool ReadFileSystemOptions(const FileSystemOptions &FSOpts, bool Complain) override
Receives the file system options.
Definition: ASTReader.cpp:107
Reads an AST files chain containing the contents of a translation unit.
Definition: ASTReader.h:302
Expr * ReadExpr(ModuleFile &F)
Reads an expression.
ListenerScope(ASTReader &Reader, std::unique_ptr< ASTReaderListener > L)
Definition: ASTReader.h:1386
bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain, bool AllowCompatibleDifferences) override
Receives the language options.
Definition: ASTReader.cpp:303
ModuleFile & getPrimaryModule()
Returns the primary module associated with the manager, that is, the first module loaded...
void getInputFiles(ModuleFile &F, SmallVectorImpl< serialization::InputFile > &Files)
Return all input files for the given module file.
Definition: ASTReader.cpp:8073
uint64_t ReadCXXCtorInitializersRef(ModuleFile &M, const RecordData &Record, unsigned &Idx)
Read a CXXCtorInitializers ID from the given record and return its global bit offset.
Definition: ASTReader.cpp:5916
LoadFailureCapabilities
Flags that indicate what kind of AST loading failures the client of the AST reader can directly handl...
Definition: ASTReader.h:1309
void visitModuleFile(StringRef Filename) override
This is called for each AST file loaded.
Definition: ASTReader.cpp:141
virtual void ReadModuleMapFile(StringRef ModuleMapPath)
Definition: ASTReader.h:114
bool needsInputFileVisitation() override
Returns true if this ASTReaderListener wants to receive the input files of the AST file via visitInpu...
Definition: ASTReader.cpp:133
SourceManager & getSourceManager() const
Definition: ASTReader.h:1301
IdentifierTable & getIdentifierTable()
Retrieve the identifier table associated with the preprocessor.
Definition: ASTReader.cpp:8000
unsigned getTotalNumMacros() const
Returns the number of macros found in the chain.
Definition: ASTReader.h:1518
A map from continuous integer ranges to some value, with a very specialized interface.
Class that performs lookup for an identifier stored in an AST file.
void ReadDeclarationNameLoc(ModuleFile &F, DeclarationNameLoc &DNLoc, DeclarationName Name, const RecordData &Record, unsigned &Idx)
Definition: ASTReader.cpp:7509
void ClearSwitchCaseIDs()
Definition: ASTReader.cpp:8018
unsigned getTotalNumSelectors() const
Returns the number of selectors found in the chain.
Definition: ASTReader.h:1538
Defines the Diagnostic-related interfaces.
Encapsulates the data about a macro definition (e.g. its tokens).
Definition: MacroInfo.h:34
Decl * GetExternalDecl(uint32_t ID) override
Resolve a declaration ID into a declaration, potentially building a new declaration.
Definition: ASTReader.cpp:5862
void ReadUnresolvedSet(ModuleFile &F, LazyASTUnresolvedSet &Set, const RecordData &Record, unsigned &Idx)
Read a UnresolvedSet structure.
Definition: ASTReader.cpp:7696
Abstract interface for callback invocations by the ASTReader.
Definition: ASTReader.h:101
NestedNameSpecifierLoc ReadNestedNameSpecifierLoc(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Definition: ASTReader.cpp:7864
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:4806
Defines the clang::FileSystemOptions interface.
Represents a C++ base or member initializer.
Definition: DeclCXX.h:1901
virtual bool needsImportVisitation() const
Returns true if this ASTReaderListener wants to receive the imports of the AST file via visitImport...
Definition: ASTReader.h:203
bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain, bool AllowCompatibleDifferences) override
Receives the language options.
Definition: ASTReader.cpp:85
void forEachImportedKeyDecl(const Decl *D, Fn Visit)
Run a callback on each imported key declaration of D.
Definition: ASTReader.h:1082
Selector DecodeSelector(serialization::SelectorID Idx)
Definition: ASTReader.cpp:7422
Represents a base class of a C++ class.
Definition: DeclCXX.h:157
uint32_t GetNumExternalSelectors() override
Returns the number of selectors known to the external AST source.
Definition: ASTReader.cpp:7451
void PrintStats() override
Print some statistics about AST usage.
Definition: ASTReader.cpp:6620
Keeps track of options that affect how file operations are performed.
bool ReadBlockAbbrevs(llvm::BitstreamCursor &Cursor, unsigned BlockID)
Definition: ASTReader.cpp:1325
QualType GetType(serialization::TypeID ID)
Resolve a type ID into a type, potentially building a new type.
Definition: ASTReader.cpp:5688
IdentifierInfo * DecodeIdentifierInfo(serialization::IdentifierID ID)
Definition: ASTReader.cpp:7269
virtual bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts, StringRef SpecificModuleCachePath, bool Complain)
Receives the header search options.
Definition: ASTReader.h:157
serialization::ModuleFile ModuleFile
Definition: ASTReader.h:347
unsigned getTotalNumPreprocessedEntities() const
Returns the number of preprocessed entities known to the AST reader.
Definition: ASTReader.h:1544
uint32_t PreprocessedEntityID
An ID number that refers to an entity in the detailed preprocessing record.
Definition: ASTBitCodes.h:159
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. Length can be 0 to indicate a ...
Definition: ASTReader.cpp:6258
FileManager & getFileManager() const
Definition: ASTReader.h:1302
TemplateArgumentLoc ReadTemplateArgumentLoc(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Reads a TemplateArgumentLoc.
Definition: ASTReader.cpp:5837
TemplateArgumentLocInfo GetTemplateArgumentLocInfo(ModuleFile &F, TemplateArgument::ArgKind Kind, const RecordData &Record, unsigned &Idx)
Reads a TemplateArgumentLocInfo appropriate for the given TemplateArgument kind.
Definition: ASTReader.cpp:5801
Selector GetExternalSelector(serialization::SelectorID ID) override
Resolve a selector ID into a selector.
Definition: ASTReader.cpp:7447
uint32_t SelectorID
An ID number that refers to an ObjC selector in an AST file.
Definition: ASTBitCodes.h:144
serialization::DeclID ReadDeclID(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Reads a declaration ID from the given position in a record in the given module.
Definition: ASTReader.cpp:6132
virtual bool needsSystemInputFileVisitation()
Returns true if this ASTReaderListener wants to receive the system input files of the AST file via vi...
Definition: ASTReader.h:189
bool needsSystemInputFileVisitation() override
Returns true if this ASTReaderListener wants to receive the system input files of the AST file via vi...
Definition: ASTReader.cpp:137
void ReadTemplateArgumentList(SmallVectorImpl< TemplateArgument > &TemplArgs, ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a template argument array.
Definition: ASTReader.cpp:7686
Expr * ReadSubExpr()
Reads a sub-expression operand during statement reading.
Token ReadToken(ModuleFile &M, const RecordDataImpl &Record, unsigned &Idx)
Reads a token out of a record.
Definition: ASTReader.cpp:1344
IdentifierInfo * GetIdentifier(serialization::IdentifierID ID) override
Definition: ASTReader.h:1834
Location information for a TemplateArgument.
Definition: TemplateBase.h:364
virtual bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain, bool AllowCompatibleDifferences)
Receives the target options.
Definition: ASTReader.h:129
Writes an AST file containing the contents of a translation unit.
Definition: ASTWriter.h:82
virtual void ReadModuleName(StringRef ModuleName)
Definition: ASTReader.h:113
bool ReadDiagnosticOptions(IntrusiveRefCntPtr< DiagnosticOptions > DiagOpts, bool Complain) override
Receives the diagnostic options.
Definition: ASTReader.cpp:403
The AST file is out-of-date relative to its input files, and needs to be regenerated.
Definition: ASTReader.h:326
NameVisibilityKind
Describes the visibility of the various names within a particular module.
Definition: Basic/Module.h:205
Simple wrapper class for chaining listeners.
Definition: ASTReader.h:210
Kind
Lists the kind of concrete classes of Decl.
Definition: DeclBase.h:76
void ReadAttributes(ModuleFile &F, AttrVec &Attrs, const RecordData &Record, unsigned &Idx)
Reads attributes from the current stream position.
SourceLocation getSourceLocationForDeclID(serialization::GlobalDeclID ID)
Returns the source location for the decl ID.
Definition: ASTReader.cpp:6013
The AST file was written by a different version of Clang.
Definition: ASTReader.h:328
std::unique_ptr< ASTReaderListener > takeSecond()
Definition: ASTReader.h:221
ModuleFile * getOwningModuleFile(const Decl *D)
Retrieve the module file that owns the given declaration, or NULL if the declaration is not from a mo...
Definition: ASTReader.cpp:6005
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:6610
const std::string & getSuggestedPredefines()
Returns the suggested contents of the predefines buffer, which contains a (typically-empty) subset of...
Definition: ASTReader.h:1484
SmallVectorImpl< ModuleFile * >::iterator ModuleIterator
uint32_t TypeID
An ID number that refers to a type in an AST file.
Definition: ASTBitCodes.h:82
A trivial tuple used to represent a source range.
void UpdateSema()
Update the state of Sema after loading some additional modules.
Definition: ASTReader.cpp:6805
serialization::DeclID mapGlobalIDToModuleFileGlobalID(ModuleFile &M, serialization::DeclID GlobalID)
Map a global declaration ID into the declaration ID used to refer to this declaration within the give...
Definition: ASTReader.cpp:6115
void ReadUnusedFileScopedDecls(SmallVectorImpl< const DeclaratorDecl * > &Decls) override
Read the set of unused file-scope declarations known to the external Sema source. ...
Definition: ASTReader.cpp:7078
void FinishedDeserializing() override
Notify ASTReader that we finished the deserialization of a decl or type. Must be paired with StartedD...
Definition: ASTReader.cpp:8414
~ASTReader() override
Definition: ASTReader.cpp:8506
std::unique_ptr< ASTReaderListener > takeFirst()
Definition: ASTReader.h:220
void ReadModuleName(StringRef ModuleName) override
Definition: ASTReader.cpp:76
This class handles loading and caching of source files into memory.
bool loadGlobalIndex()
Attempts to load the global index.
Definition: ASTReader.cpp:3308
Module * getModule(unsigned ID) override
Retrieve the module that corresponds to the given module ID.
Definition: ASTReader.cpp:7383
void ReadUnusedLocalTypedefNameCandidates(llvm::SmallSetVector< const TypedefNameDecl *, 4 > &Decls) override
Read the set of potentially unused typedefs known to the source.
Definition: ASTReader.cpp:7110
virtual bool ReadDiagnosticOptions(IntrusiveRefCntPtr< DiagnosticOptions > DiagOpts, bool Complain)
Receives the diagnostic options.
Definition: ASTReader.h:139
void RecordSwitchCaseID(SwitchCase *SC, unsigned ID)
Record that the given ID maps to the given switch-case statement.
Definition: ASTReader.cpp:8006
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
Definition: Preprocessor.h:96
serialization::IdentifierID getGlobalIdentifierID(ModuleFile &M, unsigned LocalID)
Definition: ASTReader.cpp:7307