clang  5.0.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"
23 #include "clang/Basic/Version.h"
25 #include "clang/Lex/HeaderSearch.h"
34 #include "llvm/ADT/MapVector.h"
35 #include "llvm/ADT/SmallPtrSet.h"
36 #include "llvm/ADT/SmallSet.h"
37 #include "llvm/ADT/SmallVector.h"
38 #include "llvm/ADT/StringMap.h"
39 #include "llvm/ADT/StringRef.h"
40 #include "llvm/ADT/TinyPtrVector.h"
41 #include "llvm/Support/DataTypes.h"
42 #include "llvm/Support/Timer.h"
43 #include <deque>
44 #include <memory>
45 #include <string>
46 #include <utility>
47 #include <vector>
48 
49 namespace llvm {
50  class BitstreamCursor;
51  class MemoryBuffer;
52  class APInt;
53  class APSInt;
54  class APFloat;
55 }
56 
57 namespace clang {
58 
59 class SourceManager;
60 class HeaderSearchOptions;
61 class FileManager;
62 class AddrLabelExpr;
63 class ASTConsumer;
64 class ASTContext;
65 class ASTIdentifierIterator;
66 class ASTUnit; // FIXME: Layering violation and egregious hack.
67 class Attr;
68 class Decl;
69 class DeclContext;
70 class DefMacroDirective;
71 class DiagnosticOptions;
72 class NestedNameSpecifier;
73 class CXXBaseSpecifier;
74 class CXXConstructorDecl;
75 class CXXCtorInitializer;
76 class GlobalModuleIndex;
77 class GotoStmt;
78 class MacroDefinition;
79 class MacroDirective;
80 class ModuleMacro;
81 class NamedDecl;
82 class OpaqueValueExpr;
83 class Preprocessor;
84 class PreprocessorOptions;
85 class Sema;
86 class SwitchCase;
87 class ASTDeserializationListener;
88 class ASTWriter;
89 class ASTReader;
90 class ASTDeclReader;
91 class ASTStmtReader;
92 class ASTRecordReader;
93 class TypeLocReader;
94 struct HeaderFileInfo;
95 class VersionTuple;
96 class TargetOptions;
97 class LazyASTUnresolvedSet;
98 
99 /// \brief Abstract interface for callback invocations by the ASTReader.
100 ///
101 /// While reading an AST file, the ASTReader will call the methods of the
102 /// listener to pass on specific information. Some of the listener methods can
103 /// return true to indicate to the ASTReader that the information (and
104 /// consequently the AST file) is invalid.
106 public:
107  virtual ~ASTReaderListener();
108 
109  /// \brief Receives the full Clang version information.
110  ///
111  /// \returns true to indicate that the version is invalid. Subclasses should
112  /// generally defer to this implementation.
113  virtual bool ReadFullVersionInformation(StringRef FullVersion) {
114  return FullVersion != getClangFullRepositoryVersion();
115  }
116 
117  virtual void ReadModuleName(StringRef ModuleName) {}
118  virtual void ReadModuleMapFile(StringRef ModuleMapPath) {}
119 
120  /// \brief Receives the language options.
121  ///
122  /// \returns true to indicate the options are invalid or false otherwise.
123  virtual bool ReadLanguageOptions(const LangOptions &LangOpts,
124  bool Complain,
125  bool AllowCompatibleDifferences) {
126  return false;
127  }
128 
129  /// \brief Receives the target options.
130  ///
131  /// \returns true to indicate the target options are invalid, or false
132  /// otherwise.
133  virtual bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain,
134  bool AllowCompatibleDifferences) {
135  return false;
136  }
137 
138  /// \brief Receives the diagnostic options.
139  ///
140  /// \returns true to indicate the diagnostic options are invalid, or false
141  /// otherwise.
142  virtual bool
144  bool Complain) {
145  return false;
146  }
147 
148  /// \brief Receives the file system options.
149  ///
150  /// \returns true to indicate the file system options are invalid, or false
151  /// otherwise.
152  virtual bool ReadFileSystemOptions(const FileSystemOptions &FSOpts,
153  bool Complain) {
154  return false;
155  }
156 
157  /// \brief Receives the header search options.
158  ///
159  /// \returns true to indicate the header search options are invalid, or false
160  /// otherwise.
161  virtual bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts,
162  StringRef SpecificModuleCachePath,
163  bool Complain) {
164  return false;
165  }
166 
167  /// \brief Receives the preprocessor options.
168  ///
169  /// \param SuggestedPredefines Can be filled in with the set of predefines
170  /// that are suggested by the preprocessor options. Typically only used when
171  /// loading a precompiled header.
172  ///
173  /// \returns true to indicate the preprocessor options are invalid, or false
174  /// otherwise.
175  virtual bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts,
176  bool Complain,
177  std::string &SuggestedPredefines) {
178  return false;
179  }
180 
181  /// \brief Receives __COUNTER__ value.
182  virtual void ReadCounter(const serialization::ModuleFile &M,
183  unsigned Value) {}
184 
185  /// This is called for each AST file loaded.
186  virtual void visitModuleFile(StringRef Filename,
188 
189  /// \brief Returns true if this \c ASTReaderListener wants to receive the
190  /// input files of the AST file via \c visitInputFile, false otherwise.
191  virtual bool needsInputFileVisitation() { return false; }
192  /// \brief Returns true if this \c ASTReaderListener wants to receive the
193  /// system input files of the AST file via \c visitInputFile, false otherwise.
194  virtual bool needsSystemInputFileVisitation() { return false; }
195  /// \brief if \c needsInputFileVisitation returns true, this is called for
196  /// each non-system input file of the AST File. If
197  /// \c needsSystemInputFileVisitation is true, then it is called for all
198  /// system input files as well.
199  ///
200  /// \returns true to continue receiving the next input file, false to stop.
201  virtual bool visitInputFile(StringRef Filename, bool isSystem,
202  bool isOverridden, bool isExplicitModule) {
203  return true;
204  }
205 
206  /// \brief Returns true if this \c ASTReaderListener wants to receive the
207  /// imports of the AST file via \c visitImport, false otherwise.
208  virtual bool needsImportVisitation() const { return false; }
209  /// \brief If needsImportVisitation returns \c true, this is called for each
210  /// AST file imported by this AST file.
211  virtual void visitImport(StringRef Filename) {}
212 
213  /// Indicates that a particular module file extension has been read.
215  const ModuleFileExtensionMetadata &Metadata) {}
216 };
217 
218 /// \brief Simple wrapper class for chaining listeners.
220  std::unique_ptr<ASTReaderListener> First;
221  std::unique_ptr<ASTReaderListener> Second;
222 
223 public:
224  /// Takes ownership of \p First and \p Second.
225  ChainedASTReaderListener(std::unique_ptr<ASTReaderListener> First,
226  std::unique_ptr<ASTReaderListener> Second)
227  : First(std::move(First)), Second(std::move(Second)) {}
228 
229  std::unique_ptr<ASTReaderListener> takeFirst() { return std::move(First); }
230  std::unique_ptr<ASTReaderListener> takeSecond() { return std::move(Second); }
231 
232  bool ReadFullVersionInformation(StringRef FullVersion) override;
233  void ReadModuleName(StringRef ModuleName) override;
234  void ReadModuleMapFile(StringRef ModuleMapPath) override;
235  bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain,
236  bool AllowCompatibleDifferences) override;
237  bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain,
238  bool AllowCompatibleDifferences) override;
240  bool Complain) override;
241  bool ReadFileSystemOptions(const FileSystemOptions &FSOpts,
242  bool Complain) override;
243 
244  bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts,
245  StringRef SpecificModuleCachePath,
246  bool Complain) override;
247  bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts,
248  bool Complain,
249  std::string &SuggestedPredefines) override;
250 
251  void ReadCounter(const serialization::ModuleFile &M, unsigned Value) override;
252  bool needsInputFileVisitation() override;
253  bool needsSystemInputFileVisitation() override;
254  void visitModuleFile(StringRef Filename,
256  bool visitInputFile(StringRef Filename, bool isSystem,
257  bool isOverridden, bool isExplicitModule) override;
259  const ModuleFileExtensionMetadata &Metadata) override;
260 };
261 
262 /// \brief ASTReaderListener implementation to validate the information of
263 /// the PCH file against an initialized Preprocessor.
265  Preprocessor &PP;
266  ASTReader &Reader;
267 
268 public:
270  : PP(PP), Reader(Reader) {}
271 
272  bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain,
273  bool AllowCompatibleDifferences) override;
274  bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain,
275  bool AllowCompatibleDifferences) override;
277  bool Complain) override;
278  bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, bool Complain,
279  std::string &SuggestedPredefines) override;
280  bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts,
281  StringRef SpecificModuleCachePath,
282  bool Complain) override;
283  void ReadCounter(const serialization::ModuleFile &M, unsigned Value) override;
284 
285 private:
286  void Error(const char *Msg);
287 };
288 
289 /// \brief ASTReaderListenter implementation to set SuggestedPredefines of
290 /// ASTReader which is required to use a pch file. This is the replacement
291 /// of PCHValidator or SimplePCHValidator when using a pch file without
292 /// validating it.
294  Preprocessor &PP;
295 
296 public:
298  : PP(PP) {}
299 
300  bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, bool Complain,
301  std::string &SuggestedPredefines) override;
302 };
303 
304 namespace serialization {
305 
306 class ReadMethodPoolVisitor;
307 
308 namespace reader {
310  /// \brief The on-disk hash table(s) used for DeclContext name lookup.
311  struct DeclContextLookupTable;
312 }
313 
314 } // end namespace serialization
315 
316 /// \brief Reads an AST files chain containing the contents of a translation
317 /// unit.
318 ///
319 /// The ASTReader class reads bitstreams (produced by the ASTWriter
320 /// class) containing the serialized representation of a given
321 /// abstract syntax tree and its supporting data structures. An
322 /// instance of the ASTReader can be attached to an ASTContext object,
323 /// which will provide access to the contents of the AST files.
324 ///
325 /// The AST reader provides lazy de-serialization of declarations, as
326 /// required when traversing the AST. Only those AST nodes that are
327 /// actually required will be de-serialized.
332  public ExternalSemaSource,
333  public IdentifierInfoLookup,
335 {
336 public:
339 
340  /// \brief The result of reading the control block of an AST file, which
341  /// can fail for various reasons.
343  /// \brief The control block was read successfully. Aside from failures,
344  /// the AST file is safe to read into the current context.
346  /// \brief The AST file itself appears corrupted.
348  /// \brief The AST file was missing.
350  /// \brief The AST file is out-of-date relative to its input files,
351  /// and needs to be regenerated.
353  /// \brief The AST file was written by a different version of Clang.
355  /// \brief The AST file was writtten with a different language/target
356  /// configuration.
358  /// \brief The AST file has errors.
360  };
361 
362  /// \brief Types of AST files.
363  friend class PCHValidator;
364  friend class ASTDeclReader;
365  friend class ASTStmtReader;
366  friend class ASTIdentifierIterator;
368  friend class TypeLocReader;
369  friend class ASTRecordReader;
370  friend class ASTWriter;
371  friend class ASTUnit; // ASTUnit needs to remap source locations.
373 
377 
381 
382 private:
383  /// \brief The receiver of some callbacks invoked by ASTReader.
384  std::unique_ptr<ASTReaderListener> Listener;
385 
386  /// \brief The receiver of deserialization events.
387  ASTDeserializationListener *DeserializationListener = nullptr;
388  bool OwnsDeserializationListener = false;
389 
391  FileManager &FileMgr;
392  const PCHContainerReader &PCHContainerRdr;
393  DiagnosticsEngine &Diags;
394 
395  /// \brief The semantic analysis object that will be processing the
396  /// AST files and the translation unit that uses it.
397  Sema *SemaObj = nullptr;
398 
399  /// \brief The preprocessor that will be loading the source file.
400  Preprocessor &PP;
401 
402  /// \brief The AST context into which we'll read the AST files.
403  ASTContext *ContextObj = nullptr;
404 
405  /// \brief The AST consumer.
406  ASTConsumer *Consumer = nullptr;
407 
408  /// \brief The module manager which manages modules and their dependencies
409  ModuleManager ModuleMgr;
410 
411  /// The cache that manages memory buffers for PCM files.
412  MemoryBufferCache &PCMCache;
413 
414  /// \brief A dummy identifier resolver used to merge TU-scope declarations in
415  /// C, for the cases where we don't have a Sema object to provide a real
416  /// identifier resolver.
417  IdentifierResolver DummyIdResolver;
418 
419  /// A mapping from extension block names to module file extensions.
420  llvm::StringMap<std::shared_ptr<ModuleFileExtension>> ModuleFileExtensions;
421 
422  /// \brief A timer used to track the time spent deserializing.
423  std::unique_ptr<llvm::Timer> ReadTimer;
424 
425  /// \brief The location where the module file will be considered as
426  /// imported from. For non-module AST types it should be invalid.
427  SourceLocation CurrentImportLoc;
428 
429  /// \brief The global module index, if loaded.
430  std::unique_ptr<GlobalModuleIndex> GlobalIndex;
431 
432  /// \brief A map of global bit offsets to the module that stores entities
433  /// at those bit offsets.
435 
436  /// \brief A map of negated SLocEntryIDs to the modules containing them.
438 
440 
441  /// \brief A map of reversed (SourceManager::MaxLoadedOffset - SLocOffset)
442  /// SourceLocation offsets to the modules containing them.
443  GlobalSLocOffsetMapType GlobalSLocOffsetMap;
444 
445  /// \brief Types that have already been loaded from the chain.
446  ///
447  /// When the pointer at index I is non-NULL, the type with
448  /// ID = (I + 1) << FastQual::Width has already been loaded
449  std::vector<QualType> TypesLoaded;
450 
453 
454  /// \brief Mapping from global type IDs to the module in which the
455  /// type resides along with the offset that should be added to the
456  /// global type ID to produce a local ID.
457  GlobalTypeMapType GlobalTypeMap;
458 
459  /// \brief Declarations that have already been loaded from the chain.
460  ///
461  /// When the pointer at index I is non-NULL, the declaration with ID
462  /// = I + 1 has already been loaded.
463  std::vector<Decl *> DeclsLoaded;
464 
467 
468  /// \brief Mapping from global declaration IDs to the module in which the
469  /// declaration resides.
470  GlobalDeclMapType GlobalDeclMap;
471 
472  typedef std::pair<ModuleFile *, uint64_t> FileOffset;
474  typedef llvm::DenseMap<serialization::DeclID, FileOffsetsTy>
475  DeclUpdateOffsetsMap;
476 
477  /// \brief Declarations that have modifications residing in a later file
478  /// in the chain.
479  DeclUpdateOffsetsMap DeclUpdateOffsets;
480 
481  struct PendingUpdateRecord {
482  Decl *D;
484  // Whether the declaration was just deserialized.
485  bool JustLoaded;
486  PendingUpdateRecord(serialization::GlobalDeclID ID, Decl *D,
487  bool JustLoaded)
488  : D(D), ID(ID), JustLoaded(JustLoaded) {}
489  };
490  /// \brief Declaration updates for already-loaded declarations that we need
491  /// to apply once we finish processing an import.
492  llvm::SmallVector<PendingUpdateRecord, 16> PendingUpdateRecords;
493 
494  enum class PendingFakeDefinitionKind { NotFake, Fake, FakeLoaded };
495 
496  /// \brief The DefinitionData pointers that we faked up for class definitions
497  /// that we needed but hadn't loaded yet.
498  llvm::DenseMap<void *, PendingFakeDefinitionKind> PendingFakeDefinitionData;
499 
500  /// \brief Exception specification updates that have been loaded but not yet
501  /// propagated across the relevant redeclaration chain. The map key is the
502  /// canonical declaration (used only for deduplication) and the value is a
503  /// declaration that has an exception specification.
504  llvm::SmallMapVector<Decl *, FunctionDecl *, 4> PendingExceptionSpecUpdates;
505 
506  /// \brief Declarations that have been imported and have typedef names for
507  /// linkage purposes.
508  llvm::DenseMap<std::pair<DeclContext*, IdentifierInfo*>, NamedDecl*>
509  ImportedTypedefNamesForLinkage;
510 
511  /// \brief Mergeable declaration contexts that have anonymous declarations
512  /// within them, and those anonymous declarations.
513  llvm::DenseMap<DeclContext*, llvm::SmallVector<NamedDecl*, 2>>
514  AnonymousDeclarationsForMerging;
515 
516  struct FileDeclsInfo {
517  ModuleFile *Mod;
518  ArrayRef<serialization::LocalDeclID> Decls;
519 
520  FileDeclsInfo() : Mod(nullptr) {}
521  FileDeclsInfo(ModuleFile *Mod, ArrayRef<serialization::LocalDeclID> Decls)
522  : Mod(Mod), Decls(Decls) {}
523  };
524 
525  /// \brief Map from a FileID to the file-level declarations that it contains.
526  llvm::DenseMap<FileID, FileDeclsInfo> FileDeclIDs;
527 
528  /// \brief An array of lexical contents of a declaration context, as a sequence of
529  /// Decl::Kind, DeclID pairs.
530  typedef ArrayRef<llvm::support::unaligned_uint32_t> LexicalContents;
531 
532  /// \brief Map from a DeclContext to its lexical contents.
533  llvm::DenseMap<const DeclContext*, std::pair<ModuleFile*, LexicalContents>>
534  LexicalDecls;
535 
536  /// \brief Map from the TU to its lexical contents from each module file.
537  std::vector<std::pair<ModuleFile*, LexicalContents>> TULexicalDecls;
538 
539  /// \brief Map from a DeclContext to its lookup tables.
540  llvm::DenseMap<const DeclContext *,
541  serialization::reader::DeclContextLookupTable> Lookups;
542 
543  // Updates for visible decls can occur for other contexts than just the
544  // TU, and when we read those update records, the actual context may not
545  // be available yet, so have this pending map using the ID as a key. It
546  // will be realized when the context is actually loaded.
547  struct PendingVisibleUpdate {
548  ModuleFile *Mod;
549  const unsigned char *Data;
550  };
551  typedef SmallVector<PendingVisibleUpdate, 1> DeclContextVisibleUpdates;
552 
553  /// \brief Updates to the visible declarations of declaration contexts that
554  /// haven't been loaded yet.
555  llvm::DenseMap<serialization::DeclID, DeclContextVisibleUpdates>
556  PendingVisibleUpdates;
557 
558  /// \brief The set of C++ or Objective-C classes that have forward
559  /// declarations that have not yet been linked to their definitions.
560  llvm::SmallPtrSet<Decl *, 4> PendingDefinitions;
561 
562  typedef llvm::MapVector<Decl *, uint64_t,
563  llvm::SmallDenseMap<Decl *, unsigned, 4>,
564  SmallVector<std::pair<Decl *, uint64_t>, 4> >
565  PendingBodiesMap;
566 
567  /// \brief Functions or methods that have bodies that will be attached.
568  PendingBodiesMap PendingBodies;
569 
570  /// \brief Definitions for which we have added merged definitions but not yet
571  /// performed deduplication.
572  llvm::SetVector<NamedDecl*> PendingMergedDefinitionsToDeduplicate;
573 
574  /// \brief Read the record that describes the lexical contents of a DC.
575  bool ReadLexicalDeclContextStorage(ModuleFile &M,
576  llvm::BitstreamCursor &Cursor,
577  uint64_t Offset, DeclContext *DC);
578  /// \brief Read the record that describes the visible contents of a DC.
579  bool ReadVisibleDeclContextStorage(ModuleFile &M,
580  llvm::BitstreamCursor &Cursor,
581  uint64_t Offset, serialization::DeclID ID);
582 
583  /// \brief A vector containing identifiers that have already been
584  /// loaded.
585  ///
586  /// If the pointer at index I is non-NULL, then it refers to the
587  /// IdentifierInfo for the identifier with ID=I+1 that has already
588  /// been loaded.
589  std::vector<IdentifierInfo *> IdentifiersLoaded;
590 
591  typedef ContinuousRangeMap<serialization::IdentID, ModuleFile *, 4>
592  GlobalIdentifierMapType;
593 
594  /// \brief Mapping from global identifier IDs to the module in which the
595  /// identifier resides along with the offset that should be added to the
596  /// global identifier ID to produce a local ID.
597  GlobalIdentifierMapType GlobalIdentifierMap;
598 
599  /// \brief A vector containing macros that have already been
600  /// loaded.
601  ///
602  /// If the pointer at index I is non-NULL, then it refers to the
603  /// MacroInfo for the identifier with ID=I+1 that has already
604  /// been loaded.
605  std::vector<MacroInfo *> MacrosLoaded;
606 
607  typedef std::pair<IdentifierInfo *, serialization::SubmoduleID>
608  LoadedMacroInfo;
609 
610  /// \brief A set of #undef directives that we have loaded; used to
611  /// deduplicate the same #undef information coming from multiple module
612  /// files.
613  llvm::DenseSet<LoadedMacroInfo> LoadedUndefs;
614 
615  typedef ContinuousRangeMap<serialization::MacroID, ModuleFile *, 4>
616  GlobalMacroMapType;
617 
618  /// \brief Mapping from global macro IDs to the module in which the
619  /// macro resides along with the offset that should be added to the
620  /// global macro ID to produce a local ID.
621  GlobalMacroMapType GlobalMacroMap;
622 
623  /// \brief A vector containing submodules that have already been loaded.
624  ///
625  /// This vector is indexed by the Submodule ID (-1). NULL submodule entries
626  /// indicate that the particular submodule ID has not yet been loaded.
627  SmallVector<Module *, 2> SubmodulesLoaded;
628 
629  typedef ContinuousRangeMap<serialization::SubmoduleID, ModuleFile *, 4>
630  GlobalSubmoduleMapType;
631 
632  /// \brief Mapping from global submodule IDs to the module file in which the
633  /// submodule resides along with the offset that should be added to the
634  /// global submodule ID to produce a local ID.
635  GlobalSubmoduleMapType GlobalSubmoduleMap;
636 
637  /// \brief A set of hidden declarations.
638  typedef SmallVector<Decl*, 2> HiddenNames;
639  typedef llvm::DenseMap<Module *, HiddenNames> HiddenNamesMapType;
640 
641  /// \brief A mapping from each of the hidden submodules to the deserialized
642  /// declarations in that submodule that could be made visible.
643  HiddenNamesMapType HiddenNamesMap;
644 
645 
646  /// \brief A module import, export, or conflict that hasn't yet been resolved.
647  struct UnresolvedModuleRef {
648  /// \brief The file in which this module resides.
649  ModuleFile *File;
650 
651  /// \brief The module that is importing or exporting.
652  Module *Mod;
653 
654  /// \brief The kind of module reference.
655  enum { Import, Export, Conflict } Kind;
656 
657  /// \brief The local ID of the module that is being exported.
658  unsigned ID;
659 
660  /// \brief Whether this is a wildcard export.
661  unsigned IsWildcard : 1;
662 
663  /// \brief String data.
664  StringRef String;
665  };
666 
667  /// \brief The set of module imports and exports that still need to be
668  /// resolved.
669  SmallVector<UnresolvedModuleRef, 2> UnresolvedModuleRefs;
670 
671  /// \brief A vector containing selectors that have already been loaded.
672  ///
673  /// This vector is indexed by the Selector ID (-1). NULL selector
674  /// entries indicate that the particular selector ID has not yet
675  /// been loaded.
676  SmallVector<Selector, 16> SelectorsLoaded;
677 
678  typedef ContinuousRangeMap<serialization::SelectorID, ModuleFile *, 4>
679  GlobalSelectorMapType;
680 
681  /// \brief Mapping from global selector IDs to the module in which the
682 
683  /// global selector ID to produce a local ID.
684  GlobalSelectorMapType GlobalSelectorMap;
685 
686  /// \brief The generation number of the last time we loaded data from the
687  /// global method pool for this selector.
688  llvm::DenseMap<Selector, unsigned> SelectorGeneration;
689 
690  /// Whether a selector is out of date. We mark a selector as out of date
691  /// if we load another module after the method pool entry was pulled in.
692  llvm::DenseMap<Selector, bool> SelectorOutOfDate;
693 
694  struct PendingMacroInfo {
695  ModuleFile *M;
696  uint64_t MacroDirectivesOffset;
697 
698  PendingMacroInfo(ModuleFile *M, uint64_t MacroDirectivesOffset)
699  : M(M), MacroDirectivesOffset(MacroDirectivesOffset) {}
700  };
701 
702  typedef llvm::MapVector<IdentifierInfo *, SmallVector<PendingMacroInfo, 2> >
703  PendingMacroIDsMap;
704 
705  /// \brief Mapping from identifiers that have a macro history to the global
706  /// IDs have not yet been deserialized to the global IDs of those macros.
707  PendingMacroIDsMap PendingMacroIDs;
708 
709  typedef ContinuousRangeMap<unsigned, ModuleFile *, 4>
710  GlobalPreprocessedEntityMapType;
711 
712  /// \brief Mapping from global preprocessing entity IDs to the module in
713  /// which the preprocessed entity resides along with the offset that should be
714  /// added to the global preprocessing entity ID to produce a local ID.
715  GlobalPreprocessedEntityMapType GlobalPreprocessedEntityMap;
716 
717  /// \name CodeGen-relevant special data
718  /// \brief Fields containing data that is relevant to CodeGen.
719  //@{
720 
721  /// \brief The IDs of all declarations that fulfill the criteria of
722  /// "interesting" decls.
723  ///
724  /// This contains the data loaded from all EAGERLY_DESERIALIZED_DECLS blocks
725  /// in the chain. The referenced declarations are deserialized and passed to
726  /// the consumer eagerly.
727  SmallVector<uint64_t, 16> EagerlyDeserializedDecls;
728 
729  /// \brief The IDs of all tentative definitions stored in the chain.
730  ///
731  /// Sema keeps track of all tentative definitions in a TU because it has to
732  /// complete them and pass them on to CodeGen. Thus, tentative definitions in
733  /// the PCH chain must be eagerly deserialized.
734  SmallVector<uint64_t, 16> TentativeDefinitions;
735 
736  /// \brief The IDs of all CXXRecordDecls stored in the chain whose VTables are
737  /// used.
738  ///
739  /// CodeGen has to emit VTables for these records, so they have to be eagerly
740  /// deserialized.
741  SmallVector<uint64_t, 64> VTableUses;
742 
743  /// \brief A snapshot of the pending instantiations in the chain.
744  ///
745  /// This record tracks the instantiations that Sema has to perform at the
746  /// end of the TU. It consists of a pair of values for every pending
747  /// instantiation where the first value is the ID of the decl and the second
748  /// is the instantiation location.
749  SmallVector<uint64_t, 64> PendingInstantiations;
750 
751  //@}
752 
753  /// \name DiagnosticsEngine-relevant special data
754  /// \brief Fields containing data that is used for generating diagnostics
755  //@{
756 
757  /// \brief A snapshot of Sema's unused file-scoped variable tracking, for
758  /// generating warnings.
759  SmallVector<uint64_t, 16> UnusedFileScopedDecls;
760 
761  /// \brief A list of all the delegating constructors we've seen, to diagnose
762  /// cycles.
763  SmallVector<uint64_t, 4> DelegatingCtorDecls;
764 
765  /// \brief Method selectors used in a @selector expression. Used for
766  /// implementation of -Wselector.
767  SmallVector<uint64_t, 64> ReferencedSelectorsData;
768 
769  /// \brief A snapshot of Sema's weak undeclared identifier tracking, for
770  /// generating warnings.
771  SmallVector<uint64_t, 64> WeakUndeclaredIdentifiers;
772 
773  /// \brief The IDs of type aliases for ext_vectors that exist in the chain.
774  ///
775  /// Used by Sema for finding sugared names for ext_vectors in diagnostics.
776  SmallVector<uint64_t, 4> ExtVectorDecls;
777 
778  //@}
779 
780  /// \name Sema-relevant special data
781  /// \brief Fields containing data that is used for semantic analysis
782  //@{
783 
784  /// \brief The IDs of all potentially unused typedef names in the chain.
785  ///
786  /// Sema tracks these to emit warnings.
787  SmallVector<uint64_t, 16> UnusedLocalTypedefNameCandidates;
788 
789  /// \brief Our current depth in #pragma cuda force_host_device begin/end
790  /// macros.
791  unsigned ForceCUDAHostDeviceDepth = 0;
792 
793  /// \brief The IDs of the declarations Sema stores directly.
794  ///
795  /// Sema tracks a few important decls, such as namespace std, directly.
796  SmallVector<uint64_t, 4> SemaDeclRefs;
797 
798  /// \brief The IDs of the types ASTContext stores directly.
799  ///
800  /// The AST context tracks a few important types, such as va_list, directly.
801  SmallVector<uint64_t, 16> SpecialTypes;
802 
803  /// \brief The IDs of CUDA-specific declarations ASTContext stores directly.
804  ///
805  /// The AST context tracks a few important decls, currently cudaConfigureCall,
806  /// directly.
807  SmallVector<uint64_t, 2> CUDASpecialDeclRefs;
808 
809  /// \brief The floating point pragma option settings.
810  SmallVector<uint64_t, 1> FPPragmaOptions;
811 
812  /// \brief The pragma clang optimize location (if the pragma state is "off").
813  SourceLocation OptimizeOffPragmaLocation;
814 
815  /// \brief The PragmaMSStructKind pragma ms_struct state if set, or -1.
816  int PragmaMSStructState = -1;
817 
818  /// \brief The PragmaMSPointersToMembersKind pragma pointers_to_members state.
819  int PragmaMSPointersToMembersState = -1;
820  SourceLocation PointersToMembersPragmaLocation;
821 
822  /// \brief The pragma pack state.
823  Optional<unsigned> PragmaPackCurrentValue;
824  SourceLocation PragmaPackCurrentLocation;
825  struct PragmaPackStackEntry {
826  unsigned Value;
827  SourceLocation Location;
828  StringRef SlotLabel;
829  };
831  llvm::SmallVector<std::string, 2> PragmaPackStrings;
832 
833  /// \brief The OpenCL extension settings.
834  OpenCLOptions OpenCLExtensions;
835 
836  /// \brief Extensions required by an OpenCL type.
837  llvm::DenseMap<const Type *, std::set<std::string>> OpenCLTypeExtMap;
838 
839  /// \brief Extensions required by an OpenCL declaration.
840  llvm::DenseMap<const Decl *, std::set<std::string>> OpenCLDeclExtMap;
841 
842  /// \brief A list of the namespaces we've seen.
843  SmallVector<uint64_t, 4> KnownNamespaces;
844 
845  /// \brief A list of undefined decls with internal linkage followed by the
846  /// SourceLocation of a matching ODR-use.
847  SmallVector<uint64_t, 8> UndefinedButUsed;
848 
849  /// \brief Delete expressions to analyze at the end of translation unit.
850  SmallVector<uint64_t, 8> DelayedDeleteExprs;
851 
852  // \brief A list of late parsed template function data.
853  SmallVector<uint64_t, 1> LateParsedTemplates;
854 
855 public:
859 
861  : ID(ID), ImportLoc(ImportLoc) {}
862  };
863 
864 private:
865  /// \brief A list of modules that were imported by precompiled headers or
866  /// any other non-module AST file.
867  SmallVector<ImportedSubmodule, 2> ImportedModules;
868  //@}
869 
870  /// \brief The directory that the PCH we are reading is stored in.
871  std::string CurrentDir;
872 
873  /// \brief The system include root to be used when loading the
874  /// precompiled header.
875  std::string isysroot;
876 
877  /// \brief Whether to disable the normal validation performed on precompiled
878  /// headers when they are loaded.
879  bool DisableValidation;
880 
881  /// \brief Whether to accept an AST file with compiler errors.
882  bool AllowASTWithCompilerErrors;
883 
884  /// \brief Whether to accept an AST file that has a different configuration
885  /// from the current compiler instance.
886  bool AllowConfigurationMismatch;
887 
888  /// \brief Whether validate system input files.
889  bool ValidateSystemInputs;
890 
891  /// \brief Whether we are allowed to use the global module index.
892  bool UseGlobalIndex;
893 
894  /// \brief Whether we have tried loading the global module index yet.
895  bool TriedLoadingGlobalIndex = false;
896 
897  ///\brief Whether we are currently processing update records.
898  bool ProcessingUpdateRecords = false;
899 
900  typedef llvm::DenseMap<unsigned, SwitchCase *> SwitchCaseMapTy;
901  /// \brief Mapping from switch-case IDs in the chain to switch-case statements
902  ///
903  /// Statements usually don't have IDs, but switch cases need them, so that the
904  /// switch statement can refer to them.
905  SwitchCaseMapTy SwitchCaseStmts;
906 
907  SwitchCaseMapTy *CurrSwitchCaseStmts;
908 
909  /// \brief The number of source location entries de-serialized from
910  /// the PCH file.
911  unsigned NumSLocEntriesRead = 0;
912 
913  /// \brief The number of source location entries in the chain.
914  unsigned TotalNumSLocEntries = 0;
915 
916  /// \brief The number of statements (and expressions) de-serialized
917  /// from the chain.
918  unsigned NumStatementsRead = 0;
919 
920  /// \brief The total number of statements (and expressions) stored
921  /// in the chain.
922  unsigned TotalNumStatements = 0;
923 
924  /// \brief The number of macros de-serialized from the chain.
925  unsigned NumMacrosRead = 0;
926 
927  /// \brief The total number of macros stored in the chain.
928  unsigned TotalNumMacros = 0;
929 
930  /// \brief The number of lookups into identifier tables.
931  unsigned NumIdentifierLookups = 0;
932 
933  /// \brief The number of lookups into identifier tables that succeed.
934  unsigned NumIdentifierLookupHits = 0;
935 
936  /// \brief The number of selectors that have been read.
937  unsigned NumSelectorsRead = 0;
938 
939  /// \brief The number of method pool entries that have been read.
940  unsigned NumMethodPoolEntriesRead = 0;
941 
942  /// \brief The number of times we have looked up a selector in the method
943  /// pool.
944  unsigned NumMethodPoolLookups = 0;
945 
946  /// \brief The number of times we have looked up a selector in the method
947  /// pool and found something.
948  unsigned NumMethodPoolHits = 0;
949 
950  /// \brief The number of times we have looked up a selector in the method
951  /// pool within a specific module.
952  unsigned NumMethodPoolTableLookups = 0;
953 
954  /// \brief The number of times we have looked up a selector in the method
955  /// pool within a specific module and found something.
956  unsigned NumMethodPoolTableHits = 0;
957 
958  /// \brief The total number of method pool entries in the selector table.
959  unsigned TotalNumMethodPoolEntries = 0;
960 
961  /// Number of lexical decl contexts read/total.
962  unsigned NumLexicalDeclContextsRead = 0, TotalLexicalDeclContexts = 0;
963 
964  /// Number of visible decl contexts read/total.
965  unsigned NumVisibleDeclContextsRead = 0, TotalVisibleDeclContexts = 0;
966 
967  /// Total size of modules, in bits, currently loaded
968  uint64_t TotalModulesSizeInBits = 0;
969 
970  /// \brief Number of Decl/types that are currently deserializing.
971  unsigned NumCurrentElementsDeserializing = 0;
972 
973  /// \brief Set true while we are in the process of passing deserialized
974  /// "interesting" decls to consumer inside FinishedDeserializing().
975  /// This is used as a guard to avoid recursively repeating the process of
976  /// passing decls to consumer.
977  bool PassingDeclsToConsumer = false;
978 
979  /// \brief The set of identifiers that were read while the AST reader was
980  /// (recursively) loading declarations.
981  ///
982  /// The declarations on the identifier chain for these identifiers will be
983  /// loaded once the recursive loading has completed.
984  llvm::MapVector<IdentifierInfo *, SmallVector<uint32_t, 4> >
985  PendingIdentifierInfos;
986 
987  /// \brief The set of lookup results that we have faked in order to support
988  /// merging of partially deserialized decls but that we have not yet removed.
989  llvm::SmallMapVector<IdentifierInfo *, SmallVector<NamedDecl*, 2>, 16>
990  PendingFakeLookupResults;
991 
992  /// \brief The generation number of each identifier, which keeps track of
993  /// the last time we loaded information about this identifier.
994  llvm::DenseMap<IdentifierInfo *, unsigned> IdentifierGeneration;
995 
996  class InterestingDecl {
997  Decl *D;
998  bool DeclHasPendingBody;
999 
1000  public:
1001  InterestingDecl(Decl *D, bool HasBody)
1002  : D(D), DeclHasPendingBody(HasBody) {}
1003  Decl *getDecl() { return D; }
1004  /// Whether the declaration has a pending body.
1005  bool hasPendingBody() { return DeclHasPendingBody; }
1006  };
1007 
1008  /// \brief Contains declarations and definitions that could be
1009  /// "interesting" to the ASTConsumer, when we get that AST consumer.
1010  ///
1011  /// "Interesting" declarations are those that have data that may
1012  /// need to be emitted, such as inline function definitions or
1013  /// Objective-C protocols.
1014  std::deque<InterestingDecl> PotentiallyInterestingDecls;
1015 
1016  /// \brief The list of redeclaration chains that still need to be
1017  /// reconstructed, and the local offset to the corresponding list
1018  /// of redeclarations.
1019  SmallVector<std::pair<Decl *, uint64_t>, 16> PendingDeclChains;
1020 
1021  /// \brief The list of canonical declarations whose redeclaration chains
1022  /// need to be marked as incomplete once we're done deserializing things.
1023  SmallVector<Decl *, 16> PendingIncompleteDeclChains;
1024 
1025  /// \brief The Decl IDs for the Sema/Lexical DeclContext of a Decl that has
1026  /// been loaded but its DeclContext was not set yet.
1027  struct PendingDeclContextInfo {
1028  Decl *D;
1030  serialization::GlobalDeclID LexicalDC;
1031  };
1032 
1033  /// \brief The set of Decls that have been loaded but their DeclContexts are
1034  /// not set yet.
1035  ///
1036  /// The DeclContexts for these Decls will be set once recursive loading has
1037  /// been completed.
1038  std::deque<PendingDeclContextInfo> PendingDeclContextInfos;
1039 
1040  /// \brief The set of NamedDecls that have been loaded, but are members of a
1041  /// context that has been merged into another context where the corresponding
1042  /// declaration is either missing or has not yet been loaded.
1043  ///
1044  /// We will check whether the corresponding declaration is in fact missing
1045  /// once recursing loading has been completed.
1046  llvm::SmallVector<NamedDecl *, 16> PendingOdrMergeChecks;
1047 
1048  /// \brief Record definitions in which we found an ODR violation.
1049  llvm::SmallDenseMap<CXXRecordDecl *, llvm::TinyPtrVector<CXXRecordDecl *>, 2>
1050  PendingOdrMergeFailures;
1051 
1052  /// \brief DeclContexts in which we have diagnosed an ODR violation.
1053  llvm::SmallPtrSet<DeclContext*, 2> DiagnosedOdrMergeFailures;
1054 
1055  /// \brief The set of Objective-C categories that have been deserialized
1056  /// since the last time the declaration chains were linked.
1057  llvm::SmallPtrSet<ObjCCategoryDecl *, 16> CategoriesDeserialized;
1058 
1059  /// \brief The set of Objective-C class definitions that have already been
1060  /// loaded, for which we will need to check for categories whenever a new
1061  /// module is loaded.
1062  SmallVector<ObjCInterfaceDecl *, 16> ObjCClassesLoaded;
1063 
1064  typedef llvm::DenseMap<Decl *, SmallVector<serialization::DeclID, 2> >
1065  KeyDeclsMap;
1066 
1067  /// \brief A mapping from canonical declarations to the set of global
1068  /// declaration IDs for key declaration that have been merged with that
1069  /// canonical declaration. A key declaration is a formerly-canonical
1070  /// declaration whose module did not import any other key declaration for that
1071  /// entity. These are the IDs that we use as keys when finding redecl chains.
1072  KeyDeclsMap KeyDecls;
1073 
1074  /// \brief A mapping from DeclContexts to the semantic DeclContext that we
1075  /// are treating as the definition of the entity. This is used, for instance,
1076  /// when merging implicit instantiations of class templates across modules.
1077  llvm::DenseMap<DeclContext *, DeclContext *> MergedDeclContexts;
1078 
1079  /// \brief A mapping from canonical declarations of enums to their canonical
1080  /// definitions. Only populated when using modules in C++.
1081  llvm::DenseMap<EnumDecl *, EnumDecl *> EnumDefinitions;
1082 
1083  /// \brief When reading a Stmt tree, Stmt operands are placed in this stack.
1084  SmallVector<Stmt *, 16> StmtStack;
1085 
1086  /// \brief What kind of records we are reading.
1087  enum ReadingKind {
1088  Read_None, Read_Decl, Read_Type, Read_Stmt
1089  };
1090 
1091  /// \brief What kind of records we are reading.
1092  ReadingKind ReadingKind = Read_None;
1093 
1094  /// \brief RAII object to change the reading kind.
1095  class ReadingKindTracker {
1096  ASTReader &Reader;
1097  enum ReadingKind PrevKind;
1098 
1099  ReadingKindTracker(const ReadingKindTracker &) = delete;
1100  void operator=(const ReadingKindTracker &) = delete;
1101 
1102  public:
1103  ReadingKindTracker(enum ReadingKind newKind, ASTReader &reader)
1104  : Reader(reader), PrevKind(Reader.ReadingKind) {
1105  Reader.ReadingKind = newKind;
1106  }
1107 
1108  ~ReadingKindTracker() { Reader.ReadingKind = PrevKind; }
1109  };
1110 
1111  /// \brief RAII object to mark the start of processing updates.
1112  class ProcessingUpdatesRAIIObj {
1113  ASTReader &Reader;
1114  bool PrevState;
1115 
1116  ProcessingUpdatesRAIIObj(const ProcessingUpdatesRAIIObj &) = delete;
1117  void operator=(const ProcessingUpdatesRAIIObj &) = delete;
1118 
1119  public:
1120  ProcessingUpdatesRAIIObj(ASTReader &reader)
1121  : Reader(reader), PrevState(Reader.ProcessingUpdateRecords) {
1122  Reader.ProcessingUpdateRecords = true;
1123  }
1124 
1125  ~ProcessingUpdatesRAIIObj() { Reader.ProcessingUpdateRecords = PrevState; }
1126  };
1127 
1128  /// \brief Suggested contents of the predefines buffer, after this
1129  /// PCH file has been processed.
1130  ///
1131  /// In most cases, this string will be empty, because the predefines
1132  /// buffer computed to build the PCH file will be identical to the
1133  /// predefines buffer computed from the command line. However, when
1134  /// there are differences that the PCH reader can work around, this
1135  /// predefines buffer may contain additional definitions.
1136  std::string SuggestedPredefines;
1137 
1138  llvm::DenseMap<const Decl *, bool> BodySource;
1139 
1140  /// \brief Reads a statement from the specified cursor.
1141  Stmt *ReadStmtFromStream(ModuleFile &F);
1142 
1143  struct InputFileInfo {
1144  std::string Filename;
1145  off_t StoredSize;
1146  time_t StoredTime;
1147  bool Overridden;
1148  bool Transient;
1149  bool TopLevelModuleMap;
1150  };
1151 
1152  /// \brief Reads the stored information about an input file.
1153  InputFileInfo readInputFileInfo(ModuleFile &F, unsigned ID);
1154 
1155  /// \brief Retrieve the file entry and 'overridden' bit for an input
1156  /// file in the given module file.
1157  serialization::InputFile getInputFile(ModuleFile &F, unsigned ID,
1158  bool Complain = true);
1159 
1160 public:
1161  void ResolveImportedPath(ModuleFile &M, std::string &Filename);
1162  static void ResolveImportedPath(std::string &Filename, StringRef Prefix);
1163 
1164  /// \brief Returns the first key declaration for the given declaration. This
1165  /// is one that is formerly-canonical (or still canonical) and whose module
1166  /// did not import any other key declaration of the entity.
1168  D = D->getCanonicalDecl();
1169  if (D->isFromASTFile())
1170  return D;
1171 
1172  auto I = KeyDecls.find(D);
1173  if (I == KeyDecls.end() || I->second.empty())
1174  return D;
1175  return GetExistingDecl(I->second[0]);
1176  }
1177  const Decl *getKeyDeclaration(const Decl *D) {
1178  return getKeyDeclaration(const_cast<Decl*>(D));
1179  }
1180 
1181  /// \brief Run a callback on each imported key declaration of \p D.
1182  template <typename Fn>
1183  void forEachImportedKeyDecl(const Decl *D, Fn Visit) {
1184  D = D->getCanonicalDecl();
1185  if (D->isFromASTFile())
1186  Visit(D);
1187 
1188  auto It = KeyDecls.find(const_cast<Decl*>(D));
1189  if (It != KeyDecls.end())
1190  for (auto ID : It->second)
1191  Visit(GetExistingDecl(ID));
1192  }
1193 
1194  /// \brief Get the loaded lookup tables for \p Primary, if any.
1196  getLoadedLookupTables(DeclContext *Primary) const;
1197 
1198 private:
1199  struct ImportedModule {
1200  ModuleFile *Mod;
1201  ModuleFile *ImportedBy;
1202  SourceLocation ImportLoc;
1203 
1204  ImportedModule(ModuleFile *Mod,
1205  ModuleFile *ImportedBy,
1206  SourceLocation ImportLoc)
1207  : Mod(Mod), ImportedBy(ImportedBy), ImportLoc(ImportLoc) { }
1208  };
1209 
1210  ASTReadResult ReadASTCore(StringRef FileName, ModuleKind Type,
1211  SourceLocation ImportLoc, ModuleFile *ImportedBy,
1212  SmallVectorImpl<ImportedModule> &Loaded,
1213  off_t ExpectedSize, time_t ExpectedModTime,
1214  ASTFileSignature ExpectedSignature,
1215  unsigned ClientLoadCapabilities);
1216  ASTReadResult ReadControlBlock(ModuleFile &F,
1217  SmallVectorImpl<ImportedModule> &Loaded,
1218  const ModuleFile *ImportedBy,
1219  unsigned ClientLoadCapabilities);
1220  static ASTReadResult ReadOptionsBlock(
1221  llvm::BitstreamCursor &Stream, unsigned ClientLoadCapabilities,
1222  bool AllowCompatibleConfigurationMismatch, ASTReaderListener &Listener,
1223  std::string &SuggestedPredefines);
1224 
1225  /// Read the unhashed control block.
1226  ///
1227  /// This has no effect on \c F.Stream, instead creating a fresh cursor from
1228  /// \c F.Data and reading ahead.
1229  ASTReadResult readUnhashedControlBlock(ModuleFile &F, bool WasImportedBy,
1230  unsigned ClientLoadCapabilities);
1231 
1232  static ASTReadResult
1233  readUnhashedControlBlockImpl(ModuleFile *F, llvm::StringRef StreamData,
1234  unsigned ClientLoadCapabilities,
1235  bool AllowCompatibleConfigurationMismatch,
1236  ASTReaderListener *Listener,
1237  bool ValidateDiagnosticOptions);
1238 
1239  ASTReadResult ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities);
1240  ASTReadResult ReadExtensionBlock(ModuleFile &F);
1241  void ReadModuleOffsetMap(ModuleFile &F) const;
1242  bool ParseLineTable(ModuleFile &F, const RecordData &Record);
1243  bool ReadSourceManagerBlock(ModuleFile &F);
1244  llvm::BitstreamCursor &SLocCursorForID(int ID);
1245  SourceLocation getImportLocation(ModuleFile *F);
1246  ASTReadResult ReadModuleMapFileBlock(RecordData &Record, ModuleFile &F,
1247  const ModuleFile *ImportedBy,
1248  unsigned ClientLoadCapabilities);
1249  ASTReadResult ReadSubmoduleBlock(ModuleFile &F,
1250  unsigned ClientLoadCapabilities);
1251  static bool ParseLanguageOptions(const RecordData &Record, bool Complain,
1252  ASTReaderListener &Listener,
1253  bool AllowCompatibleDifferences);
1254  static bool ParseTargetOptions(const RecordData &Record, bool Complain,
1255  ASTReaderListener &Listener,
1256  bool AllowCompatibleDifferences);
1257  static bool ParseDiagnosticOptions(const RecordData &Record, bool Complain,
1258  ASTReaderListener &Listener);
1259  static bool ParseFileSystemOptions(const RecordData &Record, bool Complain,
1260  ASTReaderListener &Listener);
1261  static bool ParseHeaderSearchOptions(const RecordData &Record, bool Complain,
1262  ASTReaderListener &Listener);
1263  static bool ParsePreprocessorOptions(const RecordData &Record, bool Complain,
1264  ASTReaderListener &Listener,
1265  std::string &SuggestedPredefines);
1266 
1267  struct RecordLocation {
1268  RecordLocation(ModuleFile *M, uint64_t O)
1269  : F(M), Offset(O) {}
1270  ModuleFile *F;
1271  uint64_t Offset;
1272  };
1273 
1274  QualType readTypeRecord(unsigned Index);
1275  void readExceptionSpec(ModuleFile &ModuleFile,
1276  SmallVectorImpl<QualType> &ExceptionStorage,
1277  FunctionProtoType::ExceptionSpecInfo &ESI,
1278  const RecordData &Record, unsigned &Index);
1279  RecordLocation TypeCursorForIndex(unsigned Index);
1280  void LoadedDecl(unsigned Index, Decl *D);
1281  Decl *ReadDeclRecord(serialization::DeclID ID);
1282  void markIncompleteDeclChain(Decl *Canon);
1283 
1284  /// \brief Returns the most recent declaration of a declaration (which must be
1285  /// of a redeclarable kind) that is either local or has already been loaded
1286  /// merged into its redecl chain.
1287  Decl *getMostRecentExistingDecl(Decl *D);
1288 
1289  RecordLocation DeclCursorForID(serialization::DeclID ID,
1290  SourceLocation &Location);
1291  void loadDeclUpdateRecords(PendingUpdateRecord &Record);
1292  void loadPendingDeclChain(Decl *D, uint64_t LocalOffset);
1293  void loadObjCCategories(serialization::GlobalDeclID ID, ObjCInterfaceDecl *D,
1294  unsigned PreviousGeneration = 0);
1295 
1296  RecordLocation getLocalBitOffset(uint64_t GlobalOffset);
1297  uint64_t getGlobalBitOffset(ModuleFile &M, uint32_t LocalOffset);
1298 
1299  /// \brief Returns the first preprocessed entity ID that begins or ends after
1300  /// \arg Loc.
1302  findPreprocessedEntity(SourceLocation Loc, bool EndsAfter) const;
1303 
1304  /// \brief Find the next module that contains entities and return the ID
1305  /// of the first entry.
1306  ///
1307  /// \param SLocMapI points at a chunk of a module that contains no
1308  /// preprocessed entities or the entities it contains are not the
1309  /// ones we are looking for.
1311  findNextPreprocessedEntity(
1313 
1314  /// \brief Returns (ModuleFile, Local index) pair for \p GlobalIndex of a
1315  /// preprocessed entity.
1316  std::pair<ModuleFile *, unsigned>
1317  getModulePreprocessedEntity(unsigned GlobalIndex);
1318 
1319  /// \brief Returns (begin, end) pair for the preprocessed entities of a
1320  /// particular module.
1321  llvm::iterator_range<PreprocessingRecord::iterator>
1322  getModulePreprocessedEntities(ModuleFile &Mod) const;
1323 
1324 public:
1326  : public llvm::iterator_adaptor_base<
1327  ModuleDeclIterator, const serialization::LocalDeclID *,
1328  std::random_access_iterator_tag, const Decl *, ptrdiff_t,
1329  const Decl *, const Decl *> {
1330  ASTReader *Reader;
1331  ModuleFile *Mod;
1332 
1333  public:
1335  : iterator_adaptor_base(nullptr), Reader(nullptr), Mod(nullptr) {}
1336 
1338  const serialization::LocalDeclID *Pos)
1339  : iterator_adaptor_base(Pos), Reader(Reader), Mod(Mod) {}
1340 
1341  value_type operator*() const {
1342  return Reader->GetDecl(Reader->getGlobalDeclID(*Mod, *I));
1343  }
1344  value_type operator->() const { return **this; }
1345 
1346  bool operator==(const ModuleDeclIterator &RHS) const {
1347  assert(Reader == RHS.Reader && Mod == RHS.Mod);
1348  return I == RHS.I;
1349  }
1350  };
1351 
1352  llvm::iterator_range<ModuleDeclIterator>
1354 
1355 private:
1356  void PassInterestingDeclsToConsumer();
1357  void PassInterestingDeclToConsumer(Decl *D);
1358 
1359  void finishPendingActions();
1360  void diagnoseOdrViolations();
1361 
1362  void pushExternalDeclIntoScope(NamedDecl *D, DeclarationName Name);
1363 
1364  void addPendingDeclContextInfo(Decl *D,
1366  serialization::GlobalDeclID LexicalDC) {
1367  assert(D);
1368  PendingDeclContextInfo Info = { D, SemaDC, LexicalDC };
1369  PendingDeclContextInfos.push_back(Info);
1370  }
1371 
1372  /// \brief Produce an error diagnostic and return true.
1373  ///
1374  /// This routine should only be used for fatal errors that have to
1375  /// do with non-routine failures (e.g., corrupted AST file).
1376  void Error(StringRef Msg) const;
1377  void Error(unsigned DiagID, StringRef Arg1 = StringRef(),
1378  StringRef Arg2 = StringRef()) const;
1379 
1380  ASTReader(const ASTReader &) = delete;
1381  void operator=(const ASTReader &) = delete;
1382 public:
1383  /// \brief Load the AST file and validate its contents against the given
1384  /// Preprocessor.
1385  ///
1386  /// \param PP the preprocessor associated with the context in which this
1387  /// precompiled header will be loaded.
1388  ///
1389  /// \param Context the AST context that this precompiled header will be
1390  /// loaded into, if any.
1391  ///
1392  /// \param PCHContainerRdr the PCHContainerOperations to use for loading and
1393  /// creating modules.
1394  ///
1395  /// \param Extensions the list of module file extensions that can be loaded
1396  /// from the AST files.
1397  ///
1398  /// \param isysroot If non-NULL, the system include path specified by the
1399  /// user. This is only used with relocatable PCH files. If non-NULL,
1400  /// a relocatable PCH file will use the default path "/".
1401  ///
1402  /// \param DisableValidation If true, the AST reader will suppress most
1403  /// of its regular consistency checking, allowing the use of precompiled
1404  /// headers that cannot be determined to be compatible.
1405  ///
1406  /// \param AllowASTWithCompilerErrors If true, the AST reader will accept an
1407  /// AST file the was created out of an AST with compiler errors,
1408  /// otherwise it will reject it.
1409  ///
1410  /// \param AllowConfigurationMismatch If true, the AST reader will not check
1411  /// for configuration differences between the AST file and the invocation.
1412  ///
1413  /// \param ValidateSystemInputs If true, the AST reader will validate
1414  /// system input files in addition to user input files. This is only
1415  /// meaningful if \p DisableValidation is false.
1416  ///
1417  /// \param UseGlobalIndex If true, the AST reader will try to load and use
1418  /// the global module index.
1419  ///
1420  /// \param ReadTimer If non-null, a timer used to track the time spent
1421  /// deserializing.
1422  ASTReader(Preprocessor &PP, ASTContext *Context,
1423  const PCHContainerReader &PCHContainerRdr,
1424  ArrayRef<std::shared_ptr<ModuleFileExtension>> Extensions,
1425  StringRef isysroot = "", bool DisableValidation = false,
1426  bool AllowASTWithCompilerErrors = false,
1427  bool AllowConfigurationMismatch = false,
1428  bool ValidateSystemInputs = false, bool UseGlobalIndex = true,
1429  std::unique_ptr<llvm::Timer> ReadTimer = {});
1430 
1431  ~ASTReader() override;
1432 
1433  SourceManager &getSourceManager() const { return SourceMgr; }
1434  FileManager &getFileManager() const { return FileMgr; }
1435  DiagnosticsEngine &getDiags() const { return Diags; }
1436 
1437  /// \brief Flags that indicate what kind of AST loading failures the client
1438  /// of the AST reader can directly handle.
1439  ///
1440  /// When a client states that it can handle a particular kind of failure,
1441  /// the AST reader will not emit errors when producing that kind of failure.
1443  /// \brief The client can't handle any AST loading failures.
1445  /// \brief The client can handle an AST file that cannot load because it
1446  /// is missing.
1448  /// \brief The client can handle an AST file that cannot load because it
1449  /// is out-of-date relative to its input files.
1451  /// \brief The client can handle an AST file that cannot load because it
1452  /// was built with a different version of Clang.
1454  /// \brief The client can handle an AST file that cannot load because it's
1455  /// compiled configuration doesn't match that of the context it was
1456  /// loaded into.
1458  };
1459 
1460  /// \brief Load the AST file designated by the given file name.
1461  ///
1462  /// \param FileName The name of the AST file to load.
1463  ///
1464  /// \param Type The kind of AST being loaded, e.g., PCH, module, main file,
1465  /// or preamble.
1466  ///
1467  /// \param ImportLoc the location where the module file will be considered as
1468  /// imported from. For non-module AST types it should be invalid.
1469  ///
1470  /// \param ClientLoadCapabilities The set of client load-failure
1471  /// capabilities, represented as a bitset of the enumerators of
1472  /// LoadFailureCapabilities.
1473  ///
1474  /// \param Imported optional out-parameter to append the list of modules
1475  /// that were imported by precompiled headers or any other non-module AST file
1477  SourceLocation ImportLoc,
1478  unsigned ClientLoadCapabilities,
1479  SmallVectorImpl<ImportedSubmodule> *Imported = nullptr);
1480 
1481  /// \brief Make the entities in the given module and any of its (non-explicit)
1482  /// submodules visible to name lookup.
1483  ///
1484  /// \param Mod The module whose names should be made visible.
1485  ///
1486  /// \param NameVisibility The level of visibility to give the names in the
1487  /// module. Visibility can only be increased over time.
1488  ///
1489  /// \param ImportLoc The location at which the import occurs.
1490  void makeModuleVisible(Module *Mod,
1491  Module::NameVisibilityKind NameVisibility,
1492  SourceLocation ImportLoc);
1493 
1494  /// \brief Make the names within this set of hidden names visible.
1495  void makeNamesVisible(const HiddenNames &Names, Module *Owner);
1496 
1497  /// \brief Note that MergedDef is a redefinition of the canonical definition
1498  /// Def, so Def should be visible whenever MergedDef is.
1499  void mergeDefinitionVisibility(NamedDecl *Def, NamedDecl *MergedDef);
1500 
1501  /// \brief Take the AST callbacks listener.
1502  std::unique_ptr<ASTReaderListener> takeListener() {
1503  return std::move(Listener);
1504  }
1505 
1506  /// \brief Set the AST callbacks listener.
1507  void setListener(std::unique_ptr<ASTReaderListener> Listener) {
1508  this->Listener = std::move(Listener);
1509  }
1510 
1511  /// \brief Add an AST callback listener.
1512  ///
1513  /// Takes ownership of \p L.
1514  void addListener(std::unique_ptr<ASTReaderListener> L) {
1515  if (Listener)
1516  L = llvm::make_unique<ChainedASTReaderListener>(std::move(L),
1517  std::move(Listener));
1518  Listener = std::move(L);
1519  }
1520 
1521  /// RAII object to temporarily add an AST callback listener.
1523  ASTReader &Reader;
1524  bool Chained;
1525 
1526  public:
1527  ListenerScope(ASTReader &Reader, std::unique_ptr<ASTReaderListener> L)
1528  : Reader(Reader), Chained(false) {
1529  auto Old = Reader.takeListener();
1530  if (Old) {
1531  Chained = true;
1532  L = llvm::make_unique<ChainedASTReaderListener>(std::move(L),
1533  std::move(Old));
1534  }
1535  Reader.setListener(std::move(L));
1536  }
1538  auto New = Reader.takeListener();
1539  if (Chained)
1540  Reader.setListener(static_cast<ChainedASTReaderListener *>(New.get())
1541  ->takeSecond());
1542  }
1543  };
1544 
1545  /// \brief Set the AST deserialization listener.
1547  bool TakeOwnership = false);
1548 
1549  /// \brief Determine whether this AST reader has a global index.
1550  bool hasGlobalIndex() const { return (bool)GlobalIndex; }
1551 
1552  /// \brief Return global module index.
1553  GlobalModuleIndex *getGlobalIndex() { return GlobalIndex.get(); }
1554 
1555  /// \brief Reset reader for a reload try.
1556  void resetForReload() { TriedLoadingGlobalIndex = false; }
1557 
1558  /// \brief Attempts to load the global index.
1559  ///
1560  /// \returns true if loading the global index has failed for any reason.
1561  bool loadGlobalIndex();
1562 
1563  /// \brief Determine whether we tried to load the global index, but failed,
1564  /// e.g., because it is out-of-date or does not exist.
1565  bool isGlobalIndexUnavailable() const;
1566 
1567  /// \brief Initializes the ASTContext
1568  void InitializeContext();
1569 
1570  /// \brief Update the state of Sema after loading some additional modules.
1571  void UpdateSema();
1572 
1573  /// \brief Add in-memory (virtual file) buffer.
1574  void addInMemoryBuffer(StringRef &FileName,
1575  std::unique_ptr<llvm::MemoryBuffer> Buffer) {
1576  ModuleMgr.addInMemoryBuffer(FileName, std::move(Buffer));
1577  }
1578 
1579  /// \brief Finalizes the AST reader's state before writing an AST file to
1580  /// disk.
1581  ///
1582  /// This operation may undo temporary state in the AST that should not be
1583  /// emitted.
1584  void finalizeForWriting();
1585 
1586  /// \brief Retrieve the module manager.
1587  ModuleManager &getModuleManager() { return ModuleMgr; }
1588 
1589  /// \brief Retrieve the preprocessor.
1590  Preprocessor &getPreprocessor() const { return PP; }
1591 
1592  /// \brief Retrieve the name of the original source file name for the primary
1593  /// module file.
1595  return ModuleMgr.getPrimaryModule().OriginalSourceFileName;
1596  }
1597 
1598  /// \brief Retrieve the name of the original source file name directly from
1599  /// the AST file, without actually loading the AST file.
1600  static std::string
1601  getOriginalSourceFile(const std::string &ASTFileName, FileManager &FileMgr,
1602  const PCHContainerReader &PCHContainerRdr,
1603  DiagnosticsEngine &Diags);
1604 
1605  /// \brief Read the control block for the named AST file.
1606  ///
1607  /// \returns true if an error occurred, false otherwise.
1608  static bool
1609  readASTFileControlBlock(StringRef Filename, FileManager &FileMgr,
1610  const PCHContainerReader &PCHContainerRdr,
1611  bool FindModuleFileExtensions,
1612  ASTReaderListener &Listener,
1613  bool ValidateDiagnosticOptions);
1614 
1615  /// \brief Determine whether the given AST file is acceptable to load into a
1616  /// translation unit with the given language and target options.
1617  static bool isAcceptableASTFile(StringRef Filename, FileManager &FileMgr,
1618  const PCHContainerReader &PCHContainerRdr,
1619  const LangOptions &LangOpts,
1620  const TargetOptions &TargetOpts,
1621  const PreprocessorOptions &PPOpts,
1622  StringRef ExistingModuleCachePath);
1623 
1624  /// \brief Returns the suggested contents of the predefines buffer,
1625  /// which contains a (typically-empty) subset of the predefines
1626  /// build prior to including the precompiled header.
1627  const std::string &getSuggestedPredefines() { return SuggestedPredefines; }
1628 
1629  /// \brief Read a preallocated preprocessed entity from the external source.
1630  ///
1631  /// \returns null if an error occurred that prevented the preprocessed
1632  /// entity from being loaded.
1633  PreprocessedEntity *ReadPreprocessedEntity(unsigned Index) override;
1634 
1635  /// \brief Returns a pair of [Begin, End) indices of preallocated
1636  /// preprocessed entities that \p Range encompasses.
1637  std::pair<unsigned, unsigned>
1639 
1640  /// \brief Optionally returns true or false if the preallocated preprocessed
1641  /// entity with index \p Index came from file \p FID.
1643  FileID FID) override;
1644 
1645  /// \brief Read the header file information for the given file entry.
1646  HeaderFileInfo GetHeaderFileInfo(const FileEntry *FE) override;
1647 
1649 
1650  /// \brief Returns the number of source locations found in the chain.
1651  unsigned getTotalNumSLocs() const {
1652  return TotalNumSLocEntries;
1653  }
1654 
1655  /// \brief Returns the number of identifiers found in the chain.
1656  unsigned getTotalNumIdentifiers() const {
1657  return static_cast<unsigned>(IdentifiersLoaded.size());
1658  }
1659 
1660  /// \brief Returns the number of macros found in the chain.
1661  unsigned getTotalNumMacros() const {
1662  return static_cast<unsigned>(MacrosLoaded.size());
1663  }
1664 
1665  /// \brief Returns the number of types found in the chain.
1666  unsigned getTotalNumTypes() const {
1667  return static_cast<unsigned>(TypesLoaded.size());
1668  }
1669 
1670  /// \brief Returns the number of declarations found in the chain.
1671  unsigned getTotalNumDecls() const {
1672  return static_cast<unsigned>(DeclsLoaded.size());
1673  }
1674 
1675  /// \brief Returns the number of submodules known.
1676  unsigned getTotalNumSubmodules() const {
1677  return static_cast<unsigned>(SubmodulesLoaded.size());
1678  }
1679 
1680  /// \brief Returns the number of selectors found in the chain.
1681  unsigned getTotalNumSelectors() const {
1682  return static_cast<unsigned>(SelectorsLoaded.size());
1683  }
1684 
1685  /// \brief Returns the number of preprocessed entities known to the AST
1686  /// reader.
1688  unsigned Result = 0;
1689  for (const auto &M : ModuleMgr)
1690  Result += M.NumPreprocessedEntities;
1691  return Result;
1692  }
1693 
1694  /// \brief Reads a TemplateArgumentLocInfo appropriate for the
1695  /// given TemplateArgument kind.
1698  const RecordData &Record, unsigned &Idx);
1699 
1700  /// \brief Reads a TemplateArgumentLoc.
1703  const RecordData &Record, unsigned &Idx);
1704 
1707  const RecordData &Record, unsigned &Index);
1708 
1709  /// \brief Reads a declarator info from the given record.
1711  const RecordData &Record, unsigned &Idx);
1712 
1713  /// \brief Resolve a type ID into a type, potentially building a new
1714  /// type.
1716 
1717  /// \brief Resolve a local type ID within a given AST file into a type.
1718  QualType getLocalType(ModuleFile &F, unsigned LocalID);
1719 
1720  /// \brief Map a local type ID within a given AST file into a global type ID.
1721  serialization::TypeID getGlobalTypeID(ModuleFile &F, unsigned LocalID) const;
1722 
1723  /// \brief Read a type from the current position in the given record, which
1724  /// was read from the given AST file.
1725  QualType readType(ModuleFile &F, const RecordData &Record, unsigned &Idx) {
1726  if (Idx >= Record.size())
1727  return QualType();
1728 
1729  return getLocalType(F, Record[Idx++]);
1730  }
1731 
1732  /// \brief Map from a local declaration ID within a given module to a
1733  /// global declaration ID.
1735  serialization::LocalDeclID LocalID) const;
1736 
1737  /// \brief Returns true if global DeclID \p ID originated from module \p M.
1739 
1740  /// \brief Retrieve the module file that owns the given declaration, or NULL
1741  /// if the declaration is not from a module file.
1742  ModuleFile *getOwningModuleFile(const Decl *D);
1743 
1744  /// \brief Get the best name we know for the module that owns the given
1745  /// declaration, or an empty string if the declaration is not from a module.
1746  std::string getOwningModuleNameForDiagnostic(const Decl *D);
1747 
1748  /// \brief Returns the source location for the decl \p ID.
1750 
1751  /// \brief Resolve a declaration ID into a declaration, potentially
1752  /// building a new declaration.
1754  Decl *GetExternalDecl(uint32_t ID) override;
1755 
1756  /// \brief Resolve a declaration ID into a declaration. Return 0 if it's not
1757  /// been loaded yet.
1759 
1760  /// \brief Reads a declaration with the given local ID in the given module.
1761  Decl *GetLocalDecl(ModuleFile &F, uint32_t LocalID) {
1762  return GetDecl(getGlobalDeclID(F, LocalID));
1763  }
1764 
1765  /// \brief Reads a declaration with the given local ID in the given module.
1766  ///
1767  /// \returns The requested declaration, casted to the given return type.
1768  template<typename T>
1769  T *GetLocalDeclAs(ModuleFile &F, uint32_t LocalID) {
1770  return cast_or_null<T>(GetLocalDecl(F, LocalID));
1771  }
1772 
1773  /// \brief Map a global declaration ID into the declaration ID used to
1774  /// refer to this declaration within the given module fule.
1775  ///
1776  /// \returns the global ID of the given declaration as known in the given
1777  /// module file.
1780  serialization::DeclID GlobalID);
1781 
1782  /// \brief Reads a declaration ID from the given position in a record in the
1783  /// given module.
1784  ///
1785  /// \returns The declaration ID read from the record, adjusted to a global ID.
1787  unsigned &Idx);
1788 
1789  /// \brief Reads a declaration from the given position in a record in the
1790  /// given module.
1791  Decl *ReadDecl(ModuleFile &F, const RecordData &R, unsigned &I) {
1792  return GetDecl(ReadDeclID(F, R, I));
1793  }
1794 
1795  /// \brief Reads a declaration from the given position in a record in the
1796  /// given module.
1797  ///
1798  /// \returns The declaration read from this location, casted to the given
1799  /// result type.
1800  template<typename T>
1801  T *ReadDeclAs(ModuleFile &F, const RecordData &R, unsigned &I) {
1802  return cast_or_null<T>(GetDecl(ReadDeclID(F, R, I)));
1803  }
1804 
1805  /// \brief If any redeclarations of \p D have been imported since it was
1806  /// last checked, this digs out those redeclarations and adds them to the
1807  /// redeclaration chain for \p D.
1808  void CompleteRedeclChain(const Decl *D) override;
1809 
1811 
1812  /// \brief Resolve the offset of a statement into a statement.
1813  ///
1814  /// This operation will read a new statement from the external
1815  /// source each time it is called, and is meant to be used via a
1816  /// LazyOffsetPtr (which is used by Decls for the body of functions, etc).
1817  Stmt *GetExternalDeclStmt(uint64_t Offset) override;
1818 
1819  /// ReadBlockAbbrevs - Enter a subblock of the specified BlockID with the
1820  /// specified cursor. Read the abbreviations that are at the top of the block
1821  /// and then leave the cursor pointing into the block.
1822  static bool ReadBlockAbbrevs(llvm::BitstreamCursor &Cursor, unsigned BlockID);
1823 
1824  /// \brief Finds all the visible declarations with a given name.
1825  /// The current implementation of this method just loads the entire
1826  /// lookup table as unmaterialized references.
1828  DeclarationName Name) override;
1829 
1830  /// \brief Read all of the declarations lexically stored in a
1831  /// declaration context.
1832  ///
1833  /// \param DC The declaration context whose declarations will be
1834  /// read.
1835  ///
1836  /// \param IsKindWeWant A predicate indicating which declaration kinds
1837  /// we are interested in.
1838  ///
1839  /// \param Decls Vector that will contain the declarations loaded
1840  /// from the external source. The caller is responsible for merging
1841  /// these declarations with any declarations already stored in the
1842  /// declaration context.
1843  void
1845  llvm::function_ref<bool(Decl::Kind)> IsKindWeWant,
1846  SmallVectorImpl<Decl *> &Decls) override;
1847 
1848  /// \brief Get the decls that are contained in a file in the Offset/Length
1849  /// range. \p Length can be 0 to indicate a point at \p Offset instead of
1850  /// a range.
1851  void FindFileRegionDecls(FileID File, unsigned Offset, unsigned Length,
1852  SmallVectorImpl<Decl *> &Decls) override;
1853 
1854  /// \brief Notify ASTReader that we started deserialization of
1855  /// a decl or type so until FinishedDeserializing is called there may be
1856  /// decls that are initializing. Must be paired with FinishedDeserializing.
1857  void StartedDeserializing() override;
1858 
1859  /// \brief Notify ASTReader that we finished the deserialization of
1860  /// a decl or type. Must be paired with StartedDeserializing.
1861  void FinishedDeserializing() override;
1862 
1863  /// \brief Function that will be invoked when we begin parsing a new
1864  /// translation unit involving this external AST source.
1865  ///
1866  /// This function will provide all of the external definitions to
1867  /// the ASTConsumer.
1868  void StartTranslationUnit(ASTConsumer *Consumer) override;
1869 
1870  /// \brief Print some statistics about AST usage.
1871  void PrintStats() override;
1872 
1873  /// \brief Dump information about the AST reader to standard error.
1874  void dump();
1875 
1876  /// Return the amount of memory used by memory buffers, breaking down
1877  /// by heap-backed versus mmap'ed memory.
1878  void getMemoryBufferSizes(MemoryBufferSizes &sizes) const override;
1879 
1880  /// \brief Initialize the semantic source with the Sema instance
1881  /// being used to perform semantic analysis on the abstract syntax
1882  /// tree.
1883  void InitializeSema(Sema &S) override;
1884 
1885  /// \brief Inform the semantic consumer that Sema is no longer available.
1886  void ForgetSema() override { SemaObj = nullptr; }
1887 
1888  /// \brief Retrieve the IdentifierInfo for the named identifier.
1889  ///
1890  /// This routine builds a new IdentifierInfo for the given identifier. If any
1891  /// declarations with this name are visible from translation unit scope, their
1892  /// declarations will be deserialized and introduced into the declaration
1893  /// chain of the identifier.
1894  IdentifierInfo *get(StringRef Name) override;
1895 
1896  /// \brief Retrieve an iterator into the set of all identifiers
1897  /// in all loaded AST files.
1898  IdentifierIterator *getIdentifiers() override;
1899 
1900  /// \brief Load the contents of the global method pool for a given
1901  /// selector.
1902  void ReadMethodPool(Selector Sel) override;
1903 
1904  /// Load the contents of the global method pool for a given
1905  /// selector if necessary.
1906  void updateOutOfDateSelector(Selector Sel) override;
1907 
1908  /// \brief Load the set of namespaces that are known to the external source,
1909  /// which will be used during typo correction.
1910  void ReadKnownNamespaces(
1911  SmallVectorImpl<NamespaceDecl *> &Namespaces) override;
1912 
1913  void ReadUndefinedButUsed(
1914  llvm::MapVector<NamedDecl *, SourceLocation> &Undefined) override;
1915 
1916  void ReadMismatchingDeleteExpressions(llvm::MapVector<
1917  FieldDecl *, llvm::SmallVector<std::pair<SourceLocation, bool>, 4>> &
1918  Exprs) override;
1919 
1921  SmallVectorImpl<VarDecl *> &TentativeDefs) override;
1922 
1924  SmallVectorImpl<const DeclaratorDecl *> &Decls) override;
1925 
1927  SmallVectorImpl<CXXConstructorDecl *> &Decls) override;
1928 
1930 
1933 
1935  SmallVectorImpl<std::pair<Selector, SourceLocation> > &Sels) override;
1936 
1938  SmallVectorImpl<std::pair<IdentifierInfo *, WeakInfo> > &WI) override;
1939 
1940  void ReadUsedVTables(SmallVectorImpl<ExternalVTableUse> &VTables) override;
1941 
1943  SmallVectorImpl<std::pair<ValueDecl *,
1944  SourceLocation> > &Pending) override;
1945 
1947  llvm::MapVector<const FunctionDecl *, std::unique_ptr<LateParsedTemplate>>
1948  &LPTMap) override;
1949 
1950  /// \brief Load a selector from disk, registering its ID if it exists.
1951  void LoadSelector(Selector Sel);
1952 
1953  void SetIdentifierInfo(unsigned ID, IdentifierInfo *II);
1955  const SmallVectorImpl<uint32_t> &DeclIDs,
1956  SmallVectorImpl<Decl *> *Decls = nullptr);
1957 
1958  /// \brief Report a diagnostic.
1959  DiagnosticBuilder Diag(unsigned DiagID) const;
1960 
1961  /// \brief Report a diagnostic.
1962  DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID) const;
1963 
1965 
1967  unsigned &Idx) {
1968  return DecodeIdentifierInfo(getGlobalIdentifierID(M, Record[Idx++]));
1969  }
1970 
1972  // Note that we are loading an identifier.
1973  Deserializing AnIdentifier(this);
1974 
1975  return DecodeIdentifierInfo(ID);
1976  }
1977 
1978  IdentifierInfo *getLocalIdentifier(ModuleFile &M, unsigned LocalID);
1979 
1981  unsigned LocalID);
1982 
1983  void resolvePendingMacro(IdentifierInfo *II, const PendingMacroInfo &PMInfo);
1984 
1985  /// \brief Retrieve the macro with the given ID.
1987 
1988  /// \brief Retrieve the global macro ID corresponding to the given local
1989  /// ID within the given module file.
1990  serialization::MacroID getGlobalMacroID(ModuleFile &M, unsigned LocalID);
1991 
1992  /// \brief Read the source location entry with index ID.
1993  bool ReadSLocEntry(int ID) override;
1994 
1995  /// \brief Retrieve the module import location and module name for the
1996  /// given source manager entry ID.
1997  std::pair<SourceLocation, StringRef> getModuleImportLoc(int ID) override;
1998 
1999  /// \brief Retrieve the global submodule ID given a module and its local ID
2000  /// number.
2002  getGlobalSubmoduleID(ModuleFile &M, unsigned LocalID);
2003 
2004  /// \brief Retrieve the submodule that corresponds to a global submodule ID.
2005  ///
2007 
2008  /// \brief Retrieve the module that corresponds to the given module ID.
2009  ///
2010  /// Note: overrides method in ExternalASTSource
2011  Module *getModule(unsigned ID) override;
2012 
2013  /// \brief Retrieve the module file with a given local ID within the specified
2014  /// ModuleFile.
2015  ModuleFile *getLocalModuleFile(ModuleFile &M, unsigned ID);
2016 
2017  /// \brief Get an ID for the given module file.
2018  unsigned getModuleFileID(ModuleFile *M);
2019 
2020  /// \brief Return a descriptor for the corresponding module.
2022 
2023  ExtKind hasExternalDefinitions(const Decl *D) override;
2024 
2025  /// \brief Retrieve a selector from the given module with its local ID
2026  /// number.
2027  Selector getLocalSelector(ModuleFile &M, unsigned LocalID);
2028 
2030 
2032  uint32_t GetNumExternalSelectors() override;
2033 
2034  Selector ReadSelector(ModuleFile &M, const RecordData &Record, unsigned &Idx) {
2035  return getLocalSelector(M, Record[Idx++]);
2036  }
2037 
2038  /// \brief Retrieve the global selector ID that corresponds to this
2039  /// the local selector ID in a given module.
2041  unsigned LocalID) const;
2042 
2043  /// \brief Read a declaration name.
2045  const RecordData &Record, unsigned &Idx);
2048  const RecordData &Record, unsigned &Idx);
2050  const RecordData &Record, unsigned &Idx);
2051 
2053  const RecordData &Record, unsigned &Idx);
2054 
2056  const RecordData &Record,
2057  unsigned &Idx);
2058 
2060  const RecordData &Record,
2061  unsigned &Idx);
2062 
2063  /// \brief Read a template name.
2065  unsigned &Idx);
2066 
2067  /// \brief Read a template argument.
2069  unsigned &Idx,
2070  bool Canonicalize = false);
2071 
2072  /// \brief Read a template parameter list.
2074  const RecordData &Record,
2075  unsigned &Idx);
2076 
2077  /// \brief Read a template argument array.
2079  ModuleFile &F, const RecordData &Record,
2080  unsigned &Idx, bool Canonicalize = false);
2081 
2082  /// \brief Read a UnresolvedSet structure.
2084  const RecordData &Record, unsigned &Idx);
2085 
2086  /// \brief Read a C++ base specifier.
2088  const RecordData &Record,unsigned &Idx);
2089 
2090  /// \brief Read a CXXCtorInitializer array.
2092  ReadCXXCtorInitializers(ModuleFile &F, const RecordData &Record,
2093  unsigned &Idx);
2094 
2095  /// \brief Read the contents of a CXXCtorInitializer array.
2097 
2098  /// \brief Read a source location from raw form and return it in its
2099  /// originating module file's source location space.
2101  return SourceLocation::getFromRawEncoding((Raw >> 1) | (Raw << 31));
2102  }
2103 
2104  /// \brief Read a source location from raw form.
2107  return TranslateSourceLocation(ModuleFile, Loc);
2108  }
2109 
2110  /// \brief Translate a source location from another module file's source
2111  /// location space into ours.
2113  SourceLocation Loc) const {
2114  if (!ModuleFile.ModuleOffsetMap.empty())
2115  ReadModuleOffsetMap(ModuleFile);
2116  assert(ModuleFile.SLocRemap.find(Loc.getOffset()) !=
2117  ModuleFile.SLocRemap.end() &&
2118  "Cannot find offset to remap.");
2119  int Remap = ModuleFile.SLocRemap.find(Loc.getOffset())->second;
2120  return Loc.getLocWithOffset(Remap);
2121  }
2122 
2123  /// \brief Read a source location.
2125  const RecordDataImpl &Record,
2126  unsigned &Idx) {
2127  return ReadSourceLocation(ModuleFile, Record[Idx++]);
2128  }
2129 
2130  /// \brief Read a source range.
2132  const RecordData &Record, unsigned &Idx);
2133 
2134  /// \brief Read an integral value
2135  llvm::APInt ReadAPInt(const RecordData &Record, unsigned &Idx);
2136 
2137  /// \brief Read a signed integral value
2138  llvm::APSInt ReadAPSInt(const RecordData &Record, unsigned &Idx);
2139 
2140  /// \brief Read a floating-point value
2141  llvm::APFloat ReadAPFloat(const RecordData &Record,
2142  const llvm::fltSemantics &Sem, unsigned &Idx);
2143 
2144  // \brief Read a string
2145  static std::string ReadString(const RecordData &Record, unsigned &Idx);
2146 
2147  // \brief Read a path
2148  std::string ReadPath(ModuleFile &F, const RecordData &Record, unsigned &Idx);
2149 
2150  /// \brief Read a version tuple.
2151  static VersionTuple ReadVersionTuple(const RecordData &Record, unsigned &Idx);
2152 
2154  unsigned &Idx);
2155 
2156  /// \brief Reads attributes from the current stream position.
2157  void ReadAttributes(ASTRecordReader &Record, AttrVec &Attrs);
2158 
2159  /// \brief Reads a statement.
2160  Stmt *ReadStmt(ModuleFile &F);
2161 
2162  /// \brief Reads an expression.
2163  Expr *ReadExpr(ModuleFile &F);
2164 
2165  /// \brief Reads a sub-statement operand during statement reading.
2167  assert(ReadingKind == Read_Stmt &&
2168  "Should be called only during statement reading!");
2169  // Subexpressions are stored from last to first, so the next Stmt we need
2170  // is at the back of the stack.
2171  assert(!StmtStack.empty() && "Read too many sub-statements!");
2172  return StmtStack.pop_back_val();
2173  }
2174 
2175  /// \brief Reads a sub-expression operand during statement reading.
2176  Expr *ReadSubExpr();
2177 
2178  /// \brief Reads a token out of a record.
2179  Token ReadToken(ModuleFile &M, const RecordDataImpl &Record, unsigned &Idx);
2180 
2181  /// \brief Reads the macro record located at the given offset.
2182  MacroInfo *ReadMacroRecord(ModuleFile &F, uint64_t Offset);
2183 
2184  /// \brief Determine the global preprocessed entity ID that corresponds to
2185  /// the given local ID within the given module.
2187  getGlobalPreprocessedEntityID(ModuleFile &M, unsigned LocalID) const;
2188 
2189  /// \brief Add a macro to deserialize its macro directive history.
2190  ///
2191  /// \param II The name of the macro.
2192  /// \param M The module file.
2193  /// \param MacroDirectivesOffset Offset of the serialized macro directive
2194  /// history.
2196  uint64_t MacroDirectivesOffset);
2197 
2198  /// \brief Read the set of macros defined by this external macro source.
2199  void ReadDefinedMacros() override;
2200 
2201  /// \brief Update an out-of-date identifier.
2202  void updateOutOfDateIdentifier(IdentifierInfo &II) override;
2203 
2204  /// \brief Note that this identifier is up-to-date.
2206 
2207  /// \brief Load all external visible decls in the given DeclContext.
2208  void completeVisibleDeclsMap(const DeclContext *DC) override;
2209 
2210  /// \brief Retrieve the AST context that this AST reader supplements.
2212  assert(ContextObj && "requested AST context when not loading AST");
2213  return *ContextObj;
2214  }
2215 
2216  // \brief Contains the IDs for declarations that were requested before we have
2217  // access to a Sema object.
2219 
2220  /// \brief Retrieve the semantic analysis object used to analyze the
2221  /// translation unit in which the precompiled header is being
2222  /// imported.
2223  Sema *getSema() { return SemaObj; }
2224 
2225  /// \brief Get the identifier resolver used for name lookup / updates
2226  /// in the translation unit scope. We have one of these even if we don't
2227  /// have a Sema object.
2229 
2230  /// \brief Retrieve the identifier table associated with the
2231  /// preprocessor.
2233 
2234  /// \brief Record that the given ID maps to the given switch-case
2235  /// statement.
2236  void RecordSwitchCaseID(SwitchCase *SC, unsigned ID);
2237 
2238  /// \brief Retrieve the switch-case statement with the given ID.
2239  SwitchCase *getSwitchCaseWithID(unsigned ID);
2240 
2241  void ClearSwitchCaseIDs();
2242 
2243  /// \brief Cursors for comments blocks.
2244  SmallVector<std::pair<llvm::BitstreamCursor,
2246 
2247  /// \brief Loads comments ranges.
2248  void ReadComments() override;
2249 
2250  /// Visit all the input files of the given module file.
2252  bool IncludeSystem, bool Complain,
2253  llvm::function_ref<void(const serialization::InputFile &IF,
2254  bool isSystem)> Visitor);
2255 
2256  /// Visit all the top-level module maps loaded when building the given module
2257  /// file.
2259  llvm::function_ref<
2260  void(const FileEntry *)> Visitor);
2261 
2262  bool isProcessingUpdateRecords() { return ProcessingUpdateRecords; }
2263 };
2264 
2265 /// \brief An object for streaming information from a record.
2268 
2269  ASTReader *Reader;
2270  ModuleFile *F;
2271  unsigned Idx = 0;
2272  ASTReader::RecordData Record;
2273 
2276 
2277 public:
2278  /// Construct an ASTRecordReader that uses the default encoding scheme.
2280  : Reader(&Reader), F(&F) {}
2281 
2282  /// \brief Reads a record with id AbbrevID from Cursor, resetting the
2283  /// internal state.
2284  unsigned readRecord(llvm::BitstreamCursor &Cursor, unsigned AbbrevID);
2285 
2286  /// \brief Is this a module file for a module (rather than a PCH or similar).
2287  bool isModule() const { return F->isModule(); }
2288 
2289  /// \brief Retrieve the AST context that this AST reader supplements.
2290  ASTContext &getContext() { return Reader->getContext(); }
2291 
2292  /// \brief The current position in this record.
2293  unsigned getIdx() const { return Idx; }
2294  /// \brief The length of this record.
2295  size_t size() const { return Record.size(); }
2296 
2297  /// \brief An arbitrary index in this record.
2298  const uint64_t &operator[](size_t N) { return Record[N]; }
2299  /// \brief The last element in this record.
2300  const uint64_t &back() const { return Record.back(); }
2301 
2302  /// \brief Returns the current value in this record, and advances to the
2303  /// next value.
2304  const uint64_t &readInt() { return Record[Idx++]; }
2305  /// \brief Returns the current value in this record, without advancing.
2306  const uint64_t &peekInt() { return Record[Idx]; }
2307 
2308  /// \brief Skips the specified number of values.
2309  void skipInts(unsigned N) { Idx += N; }
2310 
2311  /// \brief Retrieve the global submodule ID its local ID number.
2313  getGlobalSubmoduleID(unsigned LocalID) {
2314  return Reader->getGlobalSubmoduleID(*F, LocalID);
2315  }
2316 
2317  /// \brief Retrieve the submodule that corresponds to a global submodule ID.
2319  return Reader->getSubmodule(GlobalID);
2320  }
2321 
2322  /// \brief Read the record that describes the lexical contents of a DC.
2324  return Reader->ReadLexicalDeclContextStorage(*F, F->DeclsCursor, Offset,
2325  DC);
2326  }
2327 
2328  /// \brief Read the record that describes the visible contents of a DC.
2331  return Reader->ReadVisibleDeclContextStorage(*F, F->DeclsCursor, Offset,
2332  ID);
2333  }
2334 
2337  return Reader->readExceptionSpec(*F, ExceptionStorage, ESI, Record, Idx);
2338  }
2339 
2340  /// \brief Get the global offset corresponding to a local offset.
2341  uint64_t getGlobalBitOffset(uint32_t LocalOffset) {
2342  return Reader->getGlobalBitOffset(*F, LocalOffset);
2343  }
2344 
2345  /// \brief Reads a statement.
2346  Stmt *readStmt() { return Reader->ReadStmt(*F); }
2347 
2348  /// \brief Reads an expression.
2349  Expr *readExpr() { return Reader->ReadExpr(*F); }
2350 
2351  /// \brief Reads a sub-statement operand during statement reading.
2352  Stmt *readSubStmt() { return Reader->ReadSubStmt(); }
2353 
2354  /// \brief Reads a sub-expression operand during statement reading.
2355  Expr *readSubExpr() { return Reader->ReadSubExpr(); }
2356 
2357  /// \brief Reads a declaration with the given local ID in the given module.
2358  ///
2359  /// \returns The requested declaration, casted to the given return type.
2360  template<typename T>
2361  T *GetLocalDeclAs(uint32_t LocalID) {
2362  return cast_or_null<T>(Reader->GetLocalDecl(*F, LocalID));
2363  }
2364 
2365  /// \brief Reads a TemplateArgumentLocInfo appropriate for the
2366  /// given TemplateArgument kind, advancing Idx.
2369  return Reader->GetTemplateArgumentLocInfo(*F, Kind, Record, Idx);
2370  }
2371 
2372  /// \brief Reads a TemplateArgumentLoc, advancing Idx.
2375  return Reader->ReadTemplateArgumentLoc(*F, Record, Idx);
2376  }
2377 
2380  return Reader->ReadASTTemplateArgumentListInfo(*F, Record, Idx);
2381  }
2382 
2383  /// \brief Reads a declarator info from the given record, advancing Idx.
2385  return Reader->GetTypeSourceInfo(*F, Record, Idx);
2386  }
2387 
2388  /// \brief Map a local type ID within a given AST file to a global type ID.
2389  serialization::TypeID getGlobalTypeID(unsigned LocalID) const {
2390  return Reader->getGlobalTypeID(*F, LocalID);
2391  }
2392 
2393  /// \brief Read a type from the current position in the record.
2395  return Reader->readType(*F, Record, Idx);
2396  }
2397 
2398  /// \brief Reads a declaration ID from the given position in this record.
2399  ///
2400  /// \returns The declaration ID read from the record, adjusted to a global ID.
2402  return Reader->ReadDeclID(*F, Record, Idx);
2403  }
2404 
2405  /// \brief Reads a declaration from the given position in a record in the
2406  /// given module, advancing Idx.
2408  return Reader->ReadDecl(*F, Record, Idx);
2409  }
2410 
2411  /// \brief Reads a declaration from the given position in the record,
2412  /// advancing Idx.
2413  ///
2414  /// \returns The declaration read from this location, casted to the given
2415  /// result type.
2416  template<typename T>
2417  T *readDeclAs() {
2418  return Reader->ReadDeclAs<T>(*F, Record, Idx);
2419  }
2420 
2422  return Reader->GetIdentifierInfo(*F, Record, Idx);
2423  }
2424 
2425  /// \brief Read a selector from the Record, advancing Idx.
2427  return Reader->ReadSelector(*F, Record, Idx);
2428  }
2429 
2430  /// \brief Read a declaration name, advancing Idx.
2432  return Reader->ReadDeclarationName(*F, Record, Idx);
2433  }
2435  return Reader->ReadDeclarationNameLoc(*F, DNLoc, Name, Record, Idx);
2436  }
2438  return Reader->ReadDeclarationNameInfo(*F, NameInfo, Record, Idx);
2439  }
2440 
2442  return Reader->ReadQualifierInfo(*F, Info, Record, Idx);
2443  }
2444 
2446  return Reader->ReadNestedNameSpecifier(*F, Record, Idx);
2447  }
2448 
2450  return Reader->ReadNestedNameSpecifierLoc(*F, Record, Idx);
2451  }
2452 
2453  /// \brief Read a template name, advancing Idx.
2455  return Reader->ReadTemplateName(*F, Record, Idx);
2456  }
2457 
2458  /// \brief Read a template argument, advancing Idx.
2459  TemplateArgument readTemplateArgument(bool Canonicalize = false) {
2460  return Reader->ReadTemplateArgument(*F, Record, Idx, Canonicalize);
2461  }
2462 
2463  /// \brief Read a template parameter list, advancing Idx.
2465  return Reader->ReadTemplateParameterList(*F, Record, Idx);
2466  }
2467 
2468  /// \brief Read a template argument array, advancing Idx.
2470  bool Canonicalize = false) {
2471  return Reader->ReadTemplateArgumentList(TemplArgs, *F, Record, Idx,
2472  Canonicalize);
2473  }
2474 
2475  /// \brief Read a UnresolvedSet structure, advancing Idx.
2477  return Reader->ReadUnresolvedSet(*F, Set, Record, Idx);
2478  }
2479 
2480  /// \brief Read a C++ base specifier, advancing Idx.
2482  return Reader->ReadCXXBaseSpecifier(*F, Record, Idx);
2483  }
2484 
2485  /// \brief Read a CXXCtorInitializer array, advancing Idx.
2487  return Reader->ReadCXXCtorInitializers(*F, Record, Idx);
2488  }
2489 
2491  return Reader->ReadCXXTemporary(*F, Record, Idx);
2492  }
2493 
2494  /// \brief Read a source location, advancing Idx.
2496  return Reader->ReadSourceLocation(*F, Record, Idx);
2497  }
2498 
2499  /// \brief Read a source range, advancing Idx.
2501  return Reader->ReadSourceRange(*F, Record, Idx);
2502  }
2503 
2504  /// \brief Read an integral value, advancing Idx.
2505  llvm::APInt readAPInt() {
2506  return Reader->ReadAPInt(Record, Idx);
2507  }
2508 
2509  /// \brief Read a signed integral value, advancing Idx.
2510  llvm::APSInt readAPSInt() {
2511  return Reader->ReadAPSInt(Record, Idx);
2512  }
2513 
2514  /// \brief Read a floating-point value, advancing Idx.
2515  llvm::APFloat readAPFloat(const llvm::fltSemantics &Sem) {
2516  return Reader->ReadAPFloat(Record, Sem,Idx);
2517  }
2518 
2519  /// \brief Read a string, advancing Idx.
2520  std::string readString() {
2521  return Reader->ReadString(Record, Idx);
2522  }
2523 
2524  /// \brief Read a path, advancing Idx.
2525  std::string readPath() {
2526  return Reader->ReadPath(*F, Record, Idx);
2527  }
2528 
2529  /// \brief Read a version tuple, advancing Idx.
2531  return ASTReader::ReadVersionTuple(Record, Idx);
2532  }
2533 
2534  /// \brief Reads attributes from the current stream position, advancing Idx.
2535  void readAttributes(AttrVec &Attrs) {
2536  return Reader->ReadAttributes(*this, Attrs);
2537  }
2538 
2539  /// \brief Reads a token out of a record, advancing Idx.
2541  return Reader->ReadToken(*F, Record, Idx);
2542  }
2543 
2544  void recordSwitchCaseID(SwitchCase *SC, unsigned ID) {
2545  Reader->RecordSwitchCaseID(SC, ID);
2546  }
2547 
2548  /// \brief Retrieve the switch-case statement with the given ID.
2550  return Reader->getSwitchCaseWithID(ID);
2551  }
2552 };
2553 
2554 /// \brief Helper class that saves the current stream position and
2555 /// then restores it when destroyed.
2557  explicit SavedStreamPosition(llvm::BitstreamCursor &Cursor)
2558  : Cursor(Cursor), Offset(Cursor.GetCurrentBitNo()) { }
2559 
2561  Cursor.JumpToBit(Offset);
2562  }
2563 
2564 private:
2565  llvm::BitstreamCursor &Cursor;
2566  uint64_t Offset;
2567 };
2568 
2569 inline void PCHValidator::Error(const char *Msg) {
2570  Reader.Error(Msg);
2571 }
2572 
2573 } // end namespace clang
2574 
2575 #endif
llvm::APInt ReadAPInt(const RecordData &Record, unsigned &Idx)
Read an integral value.
Definition: ASTReader.cpp:8807
Decl * GetExistingDecl(serialization::DeclID ID)
Resolve a declaration ID into a declaration.
Definition: ASTReader.cpp:7064
const uint64_t & readInt()
Returns the current value in this record, and advances to the next value.
Definition: ASTReader.h:2304
SmallVector< std::pair< llvm::BitstreamCursor, serialization::ModuleFile * >, 8 > CommentsCursors
Cursors for comments blocks.
Definition: ASTReader.h:2245
static bool isAcceptableASTFile(StringRef Filename, FileManager &FileMgr, const PCHContainerReader &PCHContainerRdr, const LangOptions &LangOpts, const TargetOptions &TargetOpts, const PreprocessorOptions &PPOpts, StringRef ExistingModuleCachePath)
Determine whether the given AST file is acceptable to load into a translation unit with the given lan...
Definition: ASTReader.cpp:4834
void updateOutOfDateSelector(Selector Sel) override
Load the contents of the global method pool for a given selector if necessary.
Definition: ASTReader.cpp:7859
bool FindExternalVisibleDeclsByName(const DeclContext *DC, DeclarationName Name) override
Finds all the visible declarations with a given name.
Definition: ASTReader.cpp:7276
Decl * GetLocalDecl(ModuleFile &F, uint32_t LocalID)
Reads a declaration with the given local ID in the given module.
Definition: ASTReader.h:1761
ASTReadResult
The result of reading the control block of an AST file, which can fail for various reasons...
Definition: ASTReader.h:342
SourceLocation readSourceLocation()
Read a source location, advancing Idx.
Definition: ASTReader.h:2495
The client can handle an AST file that cannot load because it was built with a different version of C...
Definition: ASTReader.h:1453
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
Definition: Decl.h:1618
IdentifierIterator * getIdentifiers() override
Retrieve an iterator into the set of all identifiers in all loaded AST files.
Definition: ASTReader.cpp:7725
unsigned getTotalNumTypes() const
Returns the number of types found in the chain.
Definition: ASTReader.h:1666
bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts, StringRef SpecificModuleCachePath, bool Complain) override
Receives the header search options.
Definition: ASTReader.cpp:158
Smart pointer class that efficiently represents Objective-C method names.
unsigned Length
A (possibly-)qualified type.
Definition: Type.h:616
virtual bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, bool Complain, std::string &SuggestedPredefines)
Receives the preprocessor options.
Definition: ASTReader.h:175
Represents a version number in the form major[.minor[.subminor[.build]]].
Definition: VersionTuple.h:26
void SetIdentifierInfo(unsigned ID, IdentifierInfo *II)
Definition: ASTReader.cpp:8045
virtual bool visitInputFile(StringRef Filename, bool isSystem, bool isOverridden, bool isExplicitModule)
if needsInputFileVisitation returns true, this is called for each non-system input file of the AST Fi...
Definition: ASTReader.h:201
Implements support for file system lookup, file system caching, and directory search management...
Definition: FileManager.h:116
ASTConsumer - This is an abstract interface that should be implemented by clients that read ASTs...
Definition: ASTConsumer.h:34
virtual void visitModuleFile(StringRef Filename, serialization::ModuleKind Kind)
This is called for each AST file loaded.
Definition: ASTReader.h:186
RAII class for safely pairing a StartedDeserializing call with FinishedDeserializing.
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:6930
ASTRecordReader(ASTReader &Reader, ModuleFile &F)
Construct an ASTRecordReader that uses the default encoding scheme.
Definition: ASTReader.h:2279
Stmt - This represents one statement.
Definition: Stmt.h:60
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:5524
void ReadComments() override
Loads comments ranges.
Definition: ASTReader.cpp:8894
bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain, bool AllowCompatibleDifferences) override
Receives the target options.
Definition: ASTReader.cpp:136
GlobalModuleIndex * getGlobalIndex()
Return global module index.
Definition: ASTReader.h:1553
Module * getSubmodule(serialization::SubmoduleID GlobalID)
Retrieve the submodule that corresponds to a global submodule ID.
Definition: ASTReader.cpp:8212
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:81
ModuleManager::ModuleConstIterator ModuleConstIterator
Definition: ASTReader.h:379
SmallVector< uint64_t, 64 > RecordData
Definition: ASTReader.h:337
virtual void ReadCounter(const serialization::ModuleFile &M, unsigned Value)
Receives COUNTER value.
Definition: ASTReader.h:182
Preprocessor & getPreprocessor() const
Retrieve the preprocessor.
Definition: ASTReader.h:1590
llvm::APFloat readAPFloat(const llvm::fltSemantics &Sem)
Read a floating-point value, advancing Idx.
Definition: ASTReader.h:2515
bool isModule() const
Is this a module file for a module (rather than a PCH or similar).
Definition: Module.h:458
The base class of the type hierarchy.
Definition: Type.h:1303
uint32_t DeclID
An ID number that refers to a declaration in an AST file.
Definition: ASTBitCodes.h:63
IdentifierInfo * getLocalIdentifier(ModuleFile &M, unsigned LocalID)
Definition: ASTReader.cpp:8137
StringRef getOriginalSourceFile()
Retrieve the name of the original source file name for the primary module file.
Definition: ASTReader.h:1594
std::unique_ptr< llvm::MemoryBuffer > Buffer
Decl * GetDecl(serialization::DeclID ID)
Resolve a declaration ID into a declaration, potentially building a new declaration.
Definition: ASTReader.cpp:7089
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
A container of type source information.
Definition: Decl.h:62
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:3615
void readQualifierInfo(QualifierInfo &Info)
Definition: ASTReader.h:2441
PreprocessorOptions - This class is used for passing the various options used in preprocessor initial...
size_t size() const
The length of this record.
Definition: ASTReader.h:2295
void addPendingMacro(IdentifierInfo *II, ModuleFile *M, uint64_t MacroDirectivesOffset)
Add a macro to deserialize its macro directive history.
Definition: ASTReader.cpp:1749
CXXBaseSpecifier ReadCXXBaseSpecifier(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a C++ base specifier.
Definition: ASTReader.cpp:8597
The client can handle an AST file that cannot load because it is out-of-date relative to its input fi...
Definition: ASTReader.h:1450
The AST file has errors.
Definition: ASTReader.h:359
ModuleDeclIterator(ASTReader *Reader, ModuleFile *Mod, const serialization::LocalDeclID *Pos)
Definition: ASTReader.h:1337
uint32_t IdentifierID
An ID number that refers to an identifier in an AST file.
Definition: ASTBitCodes.h:55
Manages the set of modules loaded by an AST reader.
Definition: ModuleManager.h:34
void ReadReferencedSelectors(SmallVectorImpl< std::pair< Selector, SourceLocation > > &Sels) override
Read the set of referenced selectors known to the external Sema source.
Definition: ASTReader.cpp:7954
CXXCtorInitializer ** GetExternalCXXCtorInitializers(uint64_t Offset) override
Read the contents of a CXXCtorInitializer array.
Definition: ASTReader.cpp:6911
Options for controlling the target.
Definition: TargetOptions.h:26
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:6774
Manage memory buffers across multiple users.
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:6858
ModuleManager::ModuleReverseIterator ModuleReverseIterator
Definition: ASTReader.h:380
void recordSwitchCaseID(SwitchCase *SC, unsigned ID)
Definition: ASTReader.h:2544
void InitializeSema(Sema &S) override
Initialize the semantic source with the Sema instance being used to perform semantic analysis on the ...
Definition: ASTReader.cpp:7514
QualType readType()
Read a type from the current position in the record.
Definition: ASTReader.h:2394
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
Definition: TemplateBase.h:573
Stores a list of template parameters for a TemplateDecl and its derived classes.
Definition: DeclTemplate.h:50
void ReadCounter(const serialization::ModuleFile &M, unsigned Value) override
Receives COUNTER value.
Definition: ASTReader.cpp:752
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:1801
Selector ReadSelector(ModuleFile &M, const RecordData &Record, unsigned &Idx)
Definition: ASTReader.h:2034
Module * getSubmodule(serialization::SubmoduleID GlobalID)
Retrieve the submodule that corresponds to a global submodule ID.
Definition: ASTReader.h:2318
MemoryBufferSizes getMemoryBufferSizes() const
Return the amount of memory used by memory buffers, breaking down by heap-backed versus mmap'ed memor...
void ReadTentativeDefinitions(SmallVectorImpl< VarDecl * > &TentativeDefs) override
Read the set of tentative definitions known to the external Sema source.
Definition: ASTReader.cpp:7900
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:1447
void ReadUndefinedButUsed(llvm::MapVector< 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:7875
StringRef ModuleOffsetMap
The module offset map data for this file.
Definition: Module.h:205
NestedNameSpecifierLoc readNestedNameSpecifierLoc()
Definition: ASTReader.h:2449
One of these records is kept for each identifier that is lexed.
bool ReadDiagnosticOptions(IntrusiveRefCntPtr< DiagnosticOptions > DiagOpts, bool Complain) override
Receives the diagnostic options.
Definition: ASTReader.cpp:145
T * readDeclAs()
Reads a declaration from the given position in the record, advancing Idx.
Definition: ASTReader.h:2417
bool hasGlobalIndex() const
Determine whether this AST reader has a global index.
Definition: ASTReader.h:1550
void finalizeForWriting()
Finalizes the AST reader's state before writing an AST file to disk.
Definition: ASTReader.cpp:4487
T * GetLocalDeclAs(ModuleFile &F, uint32_t LocalID)
Reads a declaration with the given local ID in the given module.
Definition: ASTReader.h:1769
unsigned getTotalNumSubmodules() const
Returns the number of submodules known.
Definition: ASTReader.h:1676
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:128
A C++ nested-name-specifier augmented with source location information.
Utility class for loading a ASTContext from an AST file.
Definition: ASTUnit.h:71
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:8324
const uint64_t & back() const
The last element in this record.
Definition: ASTReader.h:2300
static SourceLocation getFromRawEncoding(unsigned Encoding)
Turn a raw encoding of a SourceLocation object into a real SourceLocation.
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
Definition: Decl.h:2366
serialization::ModuleManager ModuleManager
Definition: ASTReader.h:376
Expr * readExpr()
Reads an expression.
Definition: ASTReader.h:2349
Helper class that saves the current stream position and then restores it when destroyed.
Definition: ASTReader.h:2556
TemplateName ReadTemplateName(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a template name.
Definition: ASTReader.cpp:8441
virtual bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain, bool AllowCompatibleDifferences)
Receives the language options.
Definition: ASTReader.h:123
Token - This structure provides full information about a lexed token.
Definition: Token.h:35
TemplateArgument readTemplateArgument(bool Canonicalize=false)
Read a template argument, advancing Idx.
Definition: ASTReader.h:2459
Sema * getSema()
Retrieve the semantic analysis object used to analyze the translation unit in which the precompiled h...
Definition: ASTReader.h:2223
Stmt * ReadSubStmt()
Reads a sub-statement operand during statement reading.
Definition: ASTReader.h:2166
void ReadExtVectorDecls(SmallVectorImpl< TypedefNameDecl * > &Decls) override
Read the set of ext_vector type declarations known to the external Sema source.
Definition: ASTReader.cpp:7932
The client can handle an AST file that cannot load because it's compiled configuration doesn't match ...
Definition: ASTReader.h:1457
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:48
TypeSourceInfo * getTypeSourceInfo()
Reads a declarator info from the given record, advancing Idx.
Definition: ASTReader.h:2384
Decl * getKeyDeclaration(Decl *D)
Returns the first key declaration for the given declaration.
Definition: ASTReader.h:1167
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:7972
Describes a module or submodule.
Definition: Module.h:57
ASTReadResult ReadAST(StringRef FileName, ModuleKind Type, SourceLocation ImportLoc, unsigned ClientLoadCapabilities, SmallVectorImpl< ImportedSubmodule > *Imported=nullptr)
Load the AST file designated by the given file name.
Definition: ASTReader.cpp:3755
void completeVisibleDeclsMap(const DeclContext *DC) override
Load all external visible decls in the given DeclContext.
Definition: ASTReader.cpp:7302
static VersionTuple ReadVersionTuple(const RecordData &Record, unsigned &Idx)
Read a version tuple.
Definition: ASTReader.cpp:8843
llvm::Optional< ASTSourceDescriptor > getSourceDescriptor(unsigned ID) override
Return a descriptor for the corresponding module.
Definition: ASTReader.cpp:8261
uint32_t SubmoduleID
An ID number that refers to a submodule in a module file.
Definition: ASTBitCodes.h:160
ImportedSubmodule(serialization::SubmoduleID ID, SourceLocation ImportLoc)
Definition: ASTReader.h:860
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:5322
serialization::ModuleKind ModuleKind
Definition: ASTReader.h:375
TypeSourceInfo * GetTypeSourceInfo(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Reads a declarator info from the given record.
Definition: ASTReader.cpp:6583
uint32_t Offset
Definition: CacheTokens.cpp:43
ModuleManager & getModuleManager()
Retrieve the module manager.
Definition: ASTReader.h:1587
void ReadQualifierInfo(ModuleFile &F, QualifierInfo &Info, const RecordData &Record, unsigned &Idx)
Definition: ASTReader.cpp:8427
CXXCtorInitializer ** ReadCXXCtorInitializers(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a CXXCtorInitializer array.
Definition: ASTReader.cpp:8613
llvm::APSInt ReadAPSInt(const RecordData &Record, unsigned &Idx)
Read a signed integral value.
Definition: ASTReader.cpp:8816
DiagnosticsEngine & getDiags() const
Definition: ASTReader.h:1435
SourceLocation ReadSourceLocation(ModuleFile &ModuleFile, const RecordDataImpl &Record, unsigned &Idx)
Read a source location.
Definition: ASTReader.h:2124
std::string ReadPath(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Definition: ASTReader.cpp:8836
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, bool Complain, std::string &SuggestedPredefines) override
Receives the preprocessor options.
Definition: ASTReader.cpp:697
llvm::iterator_range< ModuleDeclIterator > getModuleFileLevelDecls(ModuleFile &Mod)
Definition: ASTReader.cpp:5315
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:8978
Concrete class used by the front-end to report problems and issues.
Definition: Diagnostic.h:147
serialization::SubmoduleID getGlobalSubmoduleID(ModuleFile &M, unsigned LocalID)
Retrieve the global submodule ID given a module and its local ID number.
Definition: ASTReader.cpp:8197
CXXTemporary * ReadCXXTemporary(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Definition: ASTReader.cpp:8855
ExtKind hasExternalDefinitions(const Decl *D) override
Definition: ASTReader.cpp:8278
TemplateArgument ReadTemplateArgument(ModuleFile &F, const RecordData &Record, unsigned &Idx, bool Canonicalize=false)
Read a template argument.
Definition: ASTReader.cpp:8500
ASTContext & getContext()
Retrieve the AST context that this AST reader supplements.
Definition: ASTReader.h:2211
Defines the Diagnostic-related interfaces.
SourceRange readSourceRange()
Read a source range, advancing Idx.
Definition: ASTReader.h:2500
const Decl * getKeyDeclaration(const Decl *D)
Definition: ASTReader.h:1177
std::string OriginalSourceFileName
The original source file name that was used to build the primary AST file, which may have been modifi...
Definition: Module.h:130
void resetForReload()
Reset reader for a reload try.
Definition: ASTReader.h:1556
TemplateArgumentLocInfo getTemplateArgumentLocInfo(TemplateArgument::ArgKind Kind)
Reads a TemplateArgumentLocInfo appropriate for the given TemplateArgument kind, advancing Idx...
Definition: ASTReader.h:2368
ModuleManager::ModuleIterator ModuleIterator
Definition: ASTReader.h:378
void ReadPendingInstantiations(SmallVectorImpl< std::pair< ValueDecl *, SourceLocation > > &Pending) override
Read the set of pending instantiations known to the external Sema source.
Definition: ASTReader.cpp:8004
ContinuousRangeMap< uint32_t, int, 2 > SLocRemap
Remapping table for source locations in this module.
Definition: Module.h:249
const ASTTemplateArgumentListInfo * readASTTemplateArgumentListInfo()
Definition: ASTReader.h:2379
void ReadPragmaDiagnosticMappings(DiagnosticsEngine &Diag)
Definition: ASTReader.cpp:5585
This abstract interface provides operations for unwrapping containers for serialized ASTs (precompile...
CXXBaseSpecifier readCXXBaseSpecifier()
Read a C++ base specifier, advancing Idx.
Definition: ASTReader.h:2481
The AST file itself appears corrupted.
Definition: ASTReader.h:347
unsigned getTotalNumDecls() const
Returns the number of declarations found in the chain.
Definition: ASTReader.h:1671
detail::InMemoryDirectory::const_iterator I
void dump()
Dump information about the AST reader to standard error.
Definition: ASTReader.cpp:7478
void ReadMismatchingDeleteExpressions(llvm::MapVector< FieldDecl *, llvm::SmallVector< std::pair< SourceLocation, bool >, 4 >> &Exprs) override
Definition: ASTReader.cpp:7885
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:841
const uint64_t & peekInt()
Returns the current value in this record, without advancing.
Definition: ASTReader.h:2306
virtual bool needsInputFileVisitation()
Returns true if this ASTReaderListener wants to receive the input files of the AST file via visitInpu...
Definition: ASTReader.h:191
void ReadDelegatingConstructors(SmallVectorImpl< CXXConstructorDecl * > &Decls) override
Read the set of delegating constructors known to the external Sema source.
Definition: ASTReader.cpp:7921
static std::string ReadString(const RecordData &Record, unsigned &Idx)
Definition: ASTReader.cpp:8829
virtual bool ReadFileSystemOptions(const FileSystemOptions &FSOpts, bool Complain)
Receives the file system options.
Definition: ASTReader.h:152
IdentifierInfo * GetIdentifierInfo(ModuleFile &M, const RecordData &Record, unsigned &Idx)
Definition: ASTReader.h:1966
void ForgetSema() override
Inform the semantic consumer that Sema is no longer available.
Definition: ASTReader.h:1886
serialization::TypeID getGlobalTypeID(unsigned LocalID) const
Map a local type ID within a given AST file to a global type ID.
Definition: ASTReader.h:2389
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:269
A little helper class used to produce diagnostics.
Definition: Diagnostic.h:953
Stmt * GetExternalDeclStmt(uint64_t Offset) override
Resolve the offset of a statement into a statement.
Definition: ASTReader.cpp:7143
TemplateParameterList * readTemplateParameterList()
Read a template parameter list, advancing Idx.
Definition: ASTReader.h:2464
ModuleKind
Specifies the kind of module that has been loaded.
Definition: Module.h:47
StringRef Filename
Definition: Format.cpp:1301
Provides lookups to, and iteration over, IdentiferInfo objects.
SourceLocation ReadUntranslatedSourceLocation(uint32_t Raw) const
Read a source location from raw form and return it in its originating module file's source location s...
Definition: ASTReader.h:2100
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:8070
ASTContext * Context
void readTemplateArgumentList(SmallVectorImpl< TemplateArgument > &TemplArgs, bool Canonicalize=false)
Read a template argument array, advancing Idx.
Definition: ASTReader.h:2469
void ReadModuleMapFile(StringRef ModuleMapPath) override
Definition: ASTReader.cpp:121
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:1791
void visitInputFiles(serialization::ModuleFile &MF, bool IncludeSystem, bool Complain, llvm::function_ref< void(const serialization::InputFile &IF, bool isSystem)> Visitor)
Visit all the input files of the given module file.
Definition: ASTReader.cpp:8950
void resolvePendingMacro(IdentifierInfo *II, const PendingMacroInfo &PMInfo)
Definition: ASTReader.cpp:1899
std::string readPath()
Read a path, advancing Idx.
Definition: ASTReader.h:2525
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:1624
ASTReaderListener implementation to validate the information of the PCH file against an initialized P...
Definition: ASTReader.h:264
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:5576
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Definition: Decl.h:580
Expr - This represents one expression.
Definition: Expr.h:105
unsigned getModuleFileID(ModuleFile *M)
Get an ID for the given module file.
Definition: ASTReader.cpp:8243
llvm::pointee_iterator< SmallVectorImpl< std::unique_ptr< ModuleFile > >::iterator > ModuleIterator
SwitchCase * getSwitchCaseWithID(unsigned ID)
Retrieve the switch-case statement with the given ID.
Definition: ASTReader.cpp:8885
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:8182
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:1725
RAII object to temporarily add an AST callback listener.
Definition: ASTReader.h:1522
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:7992
Implements an efficient mapping from strings to IdentifierInfo nodes.
Stmt * readStmt()
Reads a statement.
Definition: ASTReader.h:2346
virtual void readModuleFileExtension(const ModuleFileExtensionMetadata &Metadata)
Indicates that a particular module file extension has been read.
Definition: ASTReader.h:214
Defines version macros and version-related utility functions for Clang.
ArgKind
The kind of template argument we're storing.
Definition: TemplateBase.h:43
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:6957
SimpleASTReaderListener(Preprocessor &PP)
Definition: ASTReader.h:297
ASTReaderListenter implementation to set SuggestedPredefines of ASTReader which is required to use a ...
Definition: ASTReader.h:293
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:1447
SourceRange ReadSourceRange(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a source range.
Definition: ASTReader.cpp:8799
IdentifierResolver - Keeps track of shadowed decls on enclosing scopes.
Decl * readDecl()
Reads a declaration from the given position in a record in the given module, advancing Idx...
Definition: ASTReader.h:2407
Represents a C++ template name within the type system.
Definition: TemplateName.h:176
QualType getLocalType(ModuleFile &F, unsigned LocalID)
Resolve a local type ID within a given AST file into a type.
Definition: ASTReader.cpp:6769
Information about a module that has been loaded by the ASTReader.
Definition: Module.h:100
void ReadCounter(const serialization::ModuleFile &M, unsigned Value) override
Receives COUNTER value.
Definition: ASTReader.cpp:174
An iterator that walks over all of the known identifiers in the lookup table.
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
IdentifierInfo * getIdentifierInfo()
Definition: ASTReader.h:2421
bool isFromASTFile() const
Determine whether this declaration came from an AST file (such as a precompiled header or module) rat...
Definition: DeclBase.h:681
bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain, bool AllowCompatibleDifferences) override
Receives the target options.
Definition: ASTReader.cpp:401
SavedStreamPosition(llvm::BitstreamCursor &Cursor)
Definition: ASTReader.h:2557
void StartedDeserializing() override
Notify ASTReader that we started deserialization of a decl or type so until FinishedDeserializing is ...
llvm::pointee_iterator< SmallVectorImpl< std::unique_ptr< ModuleFile > >::const_iterator > ModuleConstIterator
The result type of a method or function.
std::string readString()
Read a string, advancing Idx.
Definition: ASTReader.h:2520
SmallVector< uint64_t, 16 > PreloadedDeclIDs
Definition: ASTReader.h:2218
void ReadDeclarationNameInfo(ModuleFile &F, DeclarationNameInfo &NameInfo, const RecordData &Record, unsigned &Idx)
Definition: ASTReader.cpp:8417
void skipInts(unsigned N)
Skips the specified number of values.
Definition: ASTReader.h:2309
The client can't handle any AST loading failures.
Definition: ASTReader.h:1444
const uint64_t & operator[](size_t N)
An arbitrary index in this record.
Definition: ASTReader.h:2298
bool operator==(const ModuleDeclIterator &RHS) const
Definition: ASTReader.h:1346
The AST file was missing.
Definition: ASTReader.h:349
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:8679
void mergeDefinitionVisibility(NamedDecl *Def, NamedDecl *MergedDef)
Note that MergedDef is a redefinition of the canonical definition Def, so Def should be visible whene...
Definition: ASTReader.cpp:3664
unsigned readRecord(llvm::BitstreamCursor &Cursor, unsigned AbbrevID)
Reads a record with id AbbrevID from Cursor, resetting the internal state.
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:3601
QualifierInfo - A struct with extended info about a syntactic name qualifier, to be used for the case...
Definition: Decl.h:603
The control block was read successfully.
Definition: ASTReader.h:345
bool ReadFullVersionInformation(StringRef FullVersion) override
Receives the full Clang version information.
Definition: ASTReader.cpp:111
#define false
Definition: stdbool.h:33
StringRef FileName
Definition: Format.cpp:1465
Kind
void addListener(std::unique_ptr< ASTReaderListener > L)
Add an AST callback listener.
Definition: ASTReader.h:1514
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:3708
SourceLocation TranslateSourceLocation(ModuleFile &ModuleFile, SourceLocation Loc) const
Translate a source location from another module file's source location space into ours...
Definition: ASTReader.h:2112
void LoadSelector(Selector Sel)
Load a selector from disk, registering its ID if it exists.
Definition: ASTReader.cpp:8040
MacroInfo * ReadMacroRecord(ModuleFile &F, uint64_t Offset)
Reads the macro record located at the given offset.
Definition: ASTReader.cpp:1514
CXXTemporary * readCXXTemporary()
Definition: ASTReader.h:2490
Encodes a location in the source.
const serialization::reader::DeclContextLookupTable * getLoadedLookupTables(DeclContext *Primary) const
Get the loaded lookup tables for Primary, if any.
Definition: ASTReader.cpp:7326
Stmt * readSubStmt()
Reads a sub-statement operand during statement reading.
Definition: ASTReader.h:2352
Represents a C++ temporary.
Definition: ExprCXX.h:1103
void InitializeContext()
Initializes the ASTContext.
Definition: ASTReader.cpp:4348
CXXCtorInitializer ** readCXXCtorInitializers()
Read a CXXCtorInitializer array, advancing Idx.
Definition: ASTReader.h:2486
An identifier-lookup iterator that enumerates all of the identifiers stored within a set of AST files...
Definition: ASTReader.cpp:7639
std::unique_ptr< ASTReaderListener > takeListener()
Take the AST callbacks listener.
Definition: ASTReader.h:1502
const std::string ID
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:7864
bool readLexicalDeclContextStorage(uint64_t Offset, DeclContext *DC)
Read the record that describes the lexical contents of a DC.
Definition: ASTReader.h:2323
Cached information about one file (either on disk or in the virtual file system). ...
Definition: FileManager.h:59
bool isProcessingUpdateRecords()
Definition: ASTReader.h:2262
void readDeclarationNameInfo(DeclarationNameInfo &NameInfo)
Definition: ASTReader.h:2437
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, bool Complain, std::string &SuggestedPredefines) override
Receives the preprocessor options.
Definition: ASTReader.cpp:167
MacroInfo * getMacro(serialization::MacroID ID)
Retrieve the macro with the given ID.
Definition: ASTReader.cpp:8156
TemplateParameterList * ReadTemplateParameterList(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a template parameter list.
Definition: ASTReader.cpp:8555
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:6971
void ReadMethodPool(Selector Sel) override
Load the contents of the global method pool for a given selector.
Definition: ASTReader.cpp:7822
Expr * readSubExpr()
Reads a sub-expression operand during statement reading.
Definition: ASTReader.h:2355
T * GetLocalDeclAs(uint32_t LocalID)
Reads a declaration with the given local ID in the given module.
Definition: ASTReader.h:2361
unsigned getIdx() const
The current position in this record.
Definition: ASTReader.h:2293
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:113
bool isModule() const
Is this a module file for a module (rather than a PCH or similar).
Definition: ASTReader.h:2287
void readDeclarationNameLoc(DeclarationNameLoc &DNLoc, DeclarationName Name)
Definition: ASTReader.h:2434
void addInMemoryBuffer(StringRef &FileName, std::unique_ptr< llvm::MemoryBuffer > Buffer)
Add in-memory (virtual file) buffer.
Definition: ASTReader.h:1574
PCHValidator(Preprocessor &PP, ASTReader &Reader)
Definition: ASTReader.h:269
uint32_t MacroID
An ID number that refers to a macro in an AST file.
Definition: ASTBitCodes.h:129
ASTContext & getContext()
Retrieve the AST context that this AST reader supplements.
Definition: ASTReader.h:2290
void setListener(std::unique_ptr< ASTReaderListener > Listener)
Set the AST callbacks listener.
Definition: ASTReader.h:1507
void readExceptionSpec(SmallVectorImpl< QualType > &ExceptionStorage, FunctionProtoType::ExceptionSpecInfo &ESI)
Definition: ASTReader.h:2335
serialization::SubmoduleID getGlobalSubmoduleID(unsigned LocalID)
Retrieve the global submodule ID its local ID number.
Definition: ASTReader.h:2313
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:211
serialization::SubmoduleID ID
Definition: ASTReader.h:857
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:8340
The AST file was writtten with a different language/target configuration.
Definition: ASTReader.h:357
void markIdentifierUpToDate(IdentifierInfo *II)
Note that this identifier is up-to-date.
Definition: ASTReader.cpp:1888
llvm::APFloat ReadAPFloat(const RecordData &Record, const llvm::fltSemantics &Sem, unsigned &Idx)
Read a floating-point value.
Definition: ASTReader.cpp:8822
The input file that has been loaded from this AST file, along with bools indicating whether this was ...
Definition: Module.h:59
serialization::DeclID readDeclID()
Reads a declaration ID from the given position in this record.
Definition: ASTReader.h:2401
unsigned getTotalNumSLocs() const
Returns the number of source locations found in the chain.
Definition: ASTReader.h:1651
ModuleFile * getLocalModuleFile(ModuleFile &M, unsigned ID)
Retrieve the module file with a given local ID within the specified ModuleFile.
Definition: ASTReader.cpp:8230
void readAttributes(AttrVec &Attrs)
Reads attributes from the current stream position, advancing Idx.
Definition: ASTReader.h:2535
DeclarationNameLoc - Additional source/type location info for a declaration name. ...
ChainedASTReaderListener(std::unique_ptr< ASTReaderListener > First, std::unique_ptr< ASTReaderListener > Second)
Takes ownership of First and Second.
Definition: ASTReader.h:225
SmallVectorImpl< uint64_t > RecordDataImpl
Definition: ASTReader.h:338
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
Represents a template argument.
Definition: TemplateBase.h:40
Selector getLocalSelector(ModuleFile &M, unsigned LocalID)
Retrieve a selector from the given module with its local ID number.
Definition: ASTReader.cpp:8285
const ASTTemplateArgumentListInfo * ReadASTTemplateArgumentListInfo(ModuleFile &F, const RecordData &Record, unsigned &Index)
Definition: ASTReader.cpp:6842
bool ReadSLocEntry(int ID) override
Read the source location entry with index ID.
Definition: ASTReader.cpp:1304
bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts, StringRef SpecificModuleCachePath, bool Complain) override
Receives the header search options.
Definition: ASTReader.cpp:743
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:2170
void setDeserializationListener(ASTDeserializationListener *Listener, bool TakeOwnership=false)
Set the AST deserialization listener.
Definition: ASTReader.cpp:760
llvm::BitstreamCursor DeclsCursor
DeclsCursor - This is a cursor to the start of the DECLS_BLOCK block.
Definition: Module.h:387
unsigned getTotalNumIdentifiers() const
Returns the number of identifiers found in the chain.
Definition: ASTReader.h:1656
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1215
llvm::pointee_iterator< SmallVectorImpl< std::unique_ptr< ModuleFile > >::reverse_iterator > ModuleReverseIterator
void updateOutOfDateIdentifier(IdentifierInfo &II) override
Update an out-of-date identifier.
Definition: ASTReader.cpp:1863
void ReadDefinedMacros() override
Read the set of macros defined by this external macro source.
Definition: ASTReader.cpp:1756
StringRef Name
Definition: USRFinder.cpp:123
An external source of header file information, which may supply information about header files alread...
Definition: HeaderSearch.h:123
bool ReadFileSystemOptions(const FileSystemOptions &FSOpts, bool Complain) override
Receives the file system options.
Definition: ASTReader.cpp:152
Reads an AST files chain containing the contents of a translation unit.
Definition: ASTReader.h:328
Selector readSelector()
Read a selector from the Record, advancing Idx.
Definition: ASTReader.h:2426
Expr * ReadExpr(ModuleFile &F)
Reads an expression.
ListenerScope(ASTReader &Reader, std::unique_ptr< ASTReaderListener > L)
Definition: ASTReader.h:1527
bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain, bool AllowCompatibleDifferences) override
Receives the language options.
Definition: ASTReader.cpp:392
ModuleFile & getPrimaryModule()
Returns the primary module associated with the manager, that is, the first module loaded...
bool visitInputFile(StringRef Filename, bool isSystem, bool isOverridden, bool isExplicitModule) override
if needsInputFileVisitation returns true, this is called for each non-system input file of the AST Fi...
Definition: ASTReader.cpp:193
LoadFailureCapabilities
Flags that indicate what kind of AST loading failures the client of the AST reader can directly handl...
Definition: ASTReader.h:1442
DeclarationName - The name of a declaration.
virtual void ReadModuleMapFile(StringRef ModuleMapPath)
Definition: ASTReader.h:118
bool needsInputFileVisitation() override
Returns true if this ASTReaderListener wants to receive the input files of the AST file via visitInpu...
Definition: ASTReader.cpp:179
void FindExternalLexicalDecls(const DeclContext *DC, llvm::function_ref< bool(Decl::Kind)> IsKindWeWant, SmallVectorImpl< Decl * > &Decls) override
Read all of the declarations lexically stored in a declaration context.
Definition: ASTReader.cpp:7156
SourceManager & getSourceManager() const
Definition: ASTReader.h:1433
IdentifierTable & getIdentifierTable()
Retrieve the identifier table associated with the preprocessor.
Definition: ASTReader.cpp:8872
unsigned getTotalNumMacros() const
Returns the number of macros found in the chain.
Definition: ASTReader.h:1661
TemplateArgumentLoc readTemplateArgumentLoc()
Reads a TemplateArgumentLoc, advancing Idx.
Definition: ASTReader.h:2374
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.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
void ReadDeclarationNameLoc(ModuleFile &F, DeclarationNameLoc &DNLoc, DeclarationName Name, const RecordData &Record, unsigned &Idx)
Definition: ASTReader.cpp:8384
void ClearSwitchCaseIDs()
Definition: ASTReader.cpp:8890
SourceLocation ReadSourceLocation(ModuleFile &ModuleFile, uint32_t Raw) const
Read a source location from raw form.
Definition: ASTReader.h:2105
SourceMgr(SourceMgr)
unsigned getTotalNumSelectors() const
Returns the number of selectors found in the chain.
Definition: ASTReader.h:1681
void ReadLateParsedTemplates(llvm::MapVector< const FunctionDecl *, std::unique_ptr< LateParsedTemplate >> &LPTMap) override
Read the set of late parsed template functions for this source.
Definition: ASTReader.cpp:8016
VersionTuple readVersionTuple()
Read a version tuple, advancing Idx.
Definition: ASTReader.h:2530
Encapsulates the data about a macro definition (e.g.
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:6854
IdentifierResolver & getIdResolver()
Get the identifier resolver used for name lookup / updates in the translation unit scope...
void ReadUnresolvedSet(ModuleFile &F, LazyASTUnresolvedSet &Set, const RecordData &Record, unsigned &Idx)
Read a UnresolvedSet structure.
Definition: ASTReader.cpp:8585
Abstract interface for callback invocations by the ASTReader.
Definition: ASTReader.h:105
Location wrapper for a TemplateArgument.
Definition: TemplateBase.h:428
NestedNameSpecifierLoc ReadNestedNameSpecifierLoc(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Definition: ASTReader.cpp:8735
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:5511
Defines the clang::FileSystemOptions interface.
Represents a C++ base or member initializer.
Definition: DeclCXX.h:2105
uint64_t getGlobalBitOffset(uint32_t LocalOffset)
Get the global offset corresponding to a local offset.
Definition: ASTReader.h:2341
virtual bool needsImportVisitation() const
Returns true if this ASTReaderListener wants to receive the imports of the AST file via visitImport...
Definition: ASTReader.h:208
void readModuleFileExtension(const ModuleFileExtensionMetadata &Metadata) override
Indicates that a particular module file extension has been read.
Definition: ASTReader.cpp:209
void ReadTemplateArgumentList(SmallVectorImpl< TemplateArgument > &TemplArgs, ModuleFile &F, const RecordData &Record, unsigned &Idx, bool Canonicalize=false)
Read a template argument array.
Definition: ASTReader.cpp:8575
llvm::APSInt readAPSInt()
Read a signed integral value, advancing Idx.
Definition: ASTReader.h:2510
void visitTopLevelModuleMaps(serialization::ModuleFile &MF, llvm::function_ref< void(const FileEntry *)> Visitor)
Visit all the top-level module maps loaded when building the given module file.
Definition: ASTReader.cpp:8965
bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain, bool AllowCompatibleDifferences) override
Receives the language options.
Definition: ASTReader.cpp:127
void forEachImportedKeyDecl(const Decl *D, Fn Visit)
Run a callback on each imported key declaration of D.
Definition: ASTReader.h:1183
Selector DecodeSelector(serialization::SelectorID Idx)
Definition: ASTReader.cpp:8289
Represents a base class of a C++ class.
Definition: DeclCXX.h:158
uint32_t GetNumExternalSelectors() override
Returns the number of selectors known to the external AST source.
Definition: ASTReader.cpp:8318
void PrintStats() override
Print some statistics about AST usage.
Definition: ASTReader.cpp:7362
Metadata for a module file extension.
Keeps track of options that affect how file operations are performed.
static bool ReadBlockAbbrevs(llvm::BitstreamCursor &Cursor, unsigned BlockID)
ReadBlockAbbrevs - Enter a subblock of the specified BlockID with the specified cursor.
Definition: ASTReader.cpp:1484
QualType GetType(serialization::TypeID ID)
Resolve a type ID into a type, potentially building a new type.
Definition: ASTReader.cpp:6596
IdentifierInfo * DecodeIdentifierInfo(serialization::IdentifierID ID)
Definition: ASTReader.cpp:8102
virtual bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts, StringRef SpecificModuleCachePath, bool Complain)
Receives the header search options.
Definition: ASTReader.h:161
serialization::ModuleFile ModuleFile
Definition: ASTReader.h:374
unsigned getTotalNumPreprocessedEntities() const
Returns the number of preprocessed entities known to the AST reader.
Definition: ASTReader.h:1687
uint32_t PreprocessedEntityID
An ID number that refers to an entity in the detailed preprocessing record.
Definition: ASTBitCodes.h:157
TemplateName readTemplateName()
Read a template name, advancing Idx.
Definition: ASTReader.h:2454
void FindFileRegionDecls(FileID File, unsigned Offset, unsigned Length, SmallVectorImpl< Decl * > &Decls) override
Get the decls that are contained in a file in the Offset/Length range.
Definition: ASTReader.cpp:7232
FileManager & getFileManager() const
Definition: ASTReader.h:1434
TemplateArgumentLoc ReadTemplateArgumentLoc(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Reads a TemplateArgumentLoc.
Definition: ASTReader.cpp:6829
TemplateArgumentLocInfo GetTemplateArgumentLocInfo(ModuleFile &F, TemplateArgument::ArgKind Kind, const RecordData &Record, unsigned &Idx)
Reads a TemplateArgumentLocInfo appropriate for the given TemplateArgument kind.
Definition: ASTReader.cpp:6793
Selector GetExternalSelector(serialization::SelectorID ID) override
Resolve a selector ID into a selector.
Definition: ASTReader.cpp:8314
uint32_t SelectorID
An ID number that refers to an ObjC selector in an AST file.
Definition: ASTBitCodes.h:142
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:7127
virtual bool needsSystemInputFileVisitation()
Returns true if this ASTReaderListener wants to receive the system input files of the AST file via vi...
Definition: ASTReader.h:194
bool needsSystemInputFileVisitation() override
Returns true if this ASTReaderListener wants to receive the system input files of the AST file via vi...
Definition: ASTReader.cpp:183
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:1501
IdentifierInfo * GetIdentifier(serialization::IdentifierID ID) override
Definition: ASTReader.h:1971
Location information for a TemplateArgument.
Definition: TemplateBase.h:369
DeclarationName readDeclarationName()
Read a declaration name, advancing Idx.
Definition: ASTReader.h:2431
virtual bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain, bool AllowCompatibleDifferences)
Receives the target options.
Definition: ASTReader.h:133
Writes an AST file containing the contents of a translation unit.
Definition: ASTWriter.h:82
virtual void ReadModuleName(StringRef ModuleName)
Definition: ASTReader.h:117
bool ReadDiagnosticOptions(IntrusiveRefCntPtr< DiagnosticOptions > DiagOpts, bool Complain) override
Receives the diagnostic options.
Definition: ASTReader.cpp:518
llvm::APInt readAPInt()
Read an integral value, advancing Idx.
Definition: ASTReader.h:2505
The AST file is out-of-date relative to its input files, and needs to be regenerated.
Definition: ASTReader.h:352
NameVisibilityKind
Describes the visibility of the various names within a particular module.
Definition: Module.h:244
Simple wrapper class for chaining listeners.
Definition: ASTReader.h:219
An object for streaming information from a record.
Definition: ASTReader.h:2266
bool readVisibleDeclContextStorage(uint64_t Offset, serialization::DeclID ID)
Read the record that describes the visible contents of a DC.
Definition: ASTReader.h:2329
Kind
Lists the kind of concrete classes of Decl.
Definition: DeclBase.h:84
HeaderSearchOptions - Helper class for storing options related to the initialization of the HeaderSea...
SourceLocation getSourceLocationForDeclID(serialization::GlobalDeclID ID)
Returns the source location for the decl ID.
Definition: ASTReader.cpp:6989
The AST file was written by a different version of Clang.
Definition: ASTReader.h:354
void ReadAttributes(ASTRecordReader &Record, AttrVec &Attrs)
Reads attributes from the current stream position.
static bool readASTFileControlBlock(StringRef Filename, FileManager &FileMgr, const PCHContainerReader &PCHContainerRdr, bool FindModuleFileExtensions, ASTReaderListener &Listener, bool ValidateDiagnosticOptions)
Read the control block for the named AST file.
Definition: ASTReader.cpp:4618
NestedNameSpecifier * readNestedNameSpecifier()
Definition: ASTReader.h:2445
Token readToken()
Reads a token out of a record, advancing Idx.
Definition: ASTReader.h:2540
std::unique_ptr< ASTReaderListener > takeSecond()
Definition: ASTReader.h:230
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:6981
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, bool Complain, std::string &SuggestedPredefines) override
Receives the preprocessor options.
Definition: ASTReader.cpp:709
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:7352
const std::string & getSuggestedPredefines()
Returns the suggested contents of the predefines buffer, which contains a (typically-empty) subset of...
Definition: ASTReader.h:1627
uint32_t TypeID
An ID number that refers to a type in an AST file.
Definition: ASTBitCodes.h:80
A trivial tuple used to represent a source range.
NamedDecl - This represents a decl with a name.
Definition: Decl.h:213
void UpdateSema()
Update the state of Sema after loading some additional modules.
Definition: ASTReader.cpp:7539
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:7110
void ReadUnusedFileScopedDecls(SmallVectorImpl< const DeclaratorDecl * > &Decls) override
Read the set of unused file-scope declarations known to the external Sema source. ...
Definition: ASTReader.cpp:7910
SwitchCase * getSwitchCaseWithID(unsigned ID)
Retrieve the switch-case statement with the given ID.
Definition: ASTReader.h:2549
void FinishedDeserializing() override
Notify ASTReader that we finished the deserialization of a decl or type.
~ASTReader() override
DiagnosticBuilder Diag(unsigned DiagID) const
Report a diagnostic.
Definition: ASTReader.cpp:8862
std::unique_ptr< ASTReaderListener > takeFirst()
Definition: ASTReader.h:229
void ReadModuleName(StringRef ModuleName) override
Definition: ASTReader.cpp:116
bool isSystem(CharacteristicKind CK)
Determine whether a file / directory characteristic is for system code.
Definition: SourceManager.h:87
This class handles loading and caching of source files into memory.
void visitModuleFile(StringRef Filename, serialization::ModuleKind Kind) override
This is called for each AST file loaded.
Definition: ASTReader.cpp:187
bool loadGlobalIndex()
Attempts to load the global index.
Definition: ASTReader.cpp:3686
Module * getModule(unsigned ID) override
Retrieve the module that corresponds to the given module ID.
Definition: ASTReader.cpp:8226
void ReadUnusedLocalTypedefNameCandidates(llvm::SmallSetVector< const TypedefNameDecl *, 4 > &Decls) override
Read the set of potentially unused typedefs known to the source.
Definition: ASTReader.cpp:7942
virtual bool ReadDiagnosticOptions(IntrusiveRefCntPtr< DiagnosticOptions > DiagOpts, bool Complain)
Receives the diagnostic options.
Definition: ASTReader.h:143
void RecordSwitchCaseID(SwitchCase *SC, unsigned ID)
Record that the given ID maps to the given switch-case statement.
Definition: ASTReader.cpp:8878
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
Definition: Preprocessor.h:98
serialization::IdentifierID getGlobalIdentifierID(ModuleFile &M, unsigned LocalID)
Definition: ASTReader.cpp:8141
void readUnresolvedSet(LazyASTUnresolvedSet &Set)
Read a UnresolvedSet structure, advancing Idx.
Definition: ASTReader.h:2476