Clang Project

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