clang  16.0.0git
ASTReader.h
Go to the documentation of this file.
1 //===- ASTReader.h - AST File Reader ----------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines the ASTReader class, which reads AST files.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_CLANG_SERIALIZATION_ASTREADER_H
14 #define LLVM_CLANG_SERIALIZATION_ASTREADER_H
15 
16 #include "clang/AST/Type.h"
17 #include "clang/Basic/Diagnostic.h"
22 #include "clang/Basic/Version.h"
24 #include "clang/Lex/HeaderSearch.h"
29 #include "clang/Sema/Sema.h"
36 #include "llvm/ADT/ArrayRef.h"
37 #include "llvm/ADT/DenseMap.h"
38 #include "llvm/ADT/DenseSet.h"
39 #include "llvm/ADT/IntrusiveRefCntPtr.h"
40 #include "llvm/ADT/MapVector.h"
41 #include "llvm/ADT/Optional.h"
42 #include "llvm/ADT/STLExtras.h"
43 #include "llvm/ADT/SetVector.h"
44 #include "llvm/ADT/SmallPtrSet.h"
45 #include "llvm/ADT/SmallVector.h"
46 #include "llvm/ADT/StringMap.h"
47 #include "llvm/ADT/StringRef.h"
48 #include "llvm/ADT/iterator.h"
49 #include "llvm/ADT/iterator_range.h"
50 #include "llvm/Bitstream/BitstreamReader.h"
51 #include "llvm/Support/MemoryBuffer.h"
52 #include "llvm/Support/Timer.h"
53 #include "llvm/Support/VersionTuple.h"
54 #include <cassert>
55 #include <cstddef>
56 #include <cstdint>
57 #include <ctime>
58 #include <deque>
59 #include <memory>
60 #include <set>
61 #include <string>
62 #include <utility>
63 #include <vector>
64 
65 namespace clang {
66 
67 class ASTConsumer;
68 class ASTContext;
69 class ASTDeserializationListener;
70 class ASTReader;
71 class ASTRecordReader;
72 class CXXTemporary;
73 class Decl;
74 class DeclarationName;
75 class DeclaratorDecl;
76 class DeclContext;
77 class EnumDecl;
78 class Expr;
79 class FieldDecl;
80 class FileEntry;
81 class FileManager;
82 class FileSystemOptions;
83 class FunctionDecl;
84 class GlobalModuleIndex;
85 struct HeaderFileInfo;
86 class HeaderSearchOptions;
87 class LangOptions;
88 class MacroInfo;
89 class InMemoryModuleCache;
90 class NamedDecl;
91 class NamespaceDecl;
92 class ObjCCategoryDecl;
93 class ObjCInterfaceDecl;
94 class PCHContainerReader;
95 class Preprocessor;
96 class PreprocessorOptions;
97 class Sema;
98 class SourceManager;
99 class Stmt;
100 class SwitchCase;
101 class TargetOptions;
102 class Token;
103 class TypedefNameDecl;
104 class ValueDecl;
105 class VarDecl;
106 
107 /// Abstract interface for callback invocations by the ASTReader.
108 ///
109 /// While reading an AST file, the ASTReader will call the methods of the
110 /// listener to pass on specific information. Some of the listener methods can
111 /// return true to indicate to the ASTReader that the information (and
112 /// consequently the AST file) is invalid.
114 public:
115  virtual ~ASTReaderListener();
116 
117  /// Receives the full Clang version information.
118  ///
119  /// \returns true to indicate that the version is invalid. Subclasses should
120  /// generally defer to this implementation.
121  virtual bool ReadFullVersionInformation(StringRef FullVersion) {
122  return FullVersion != getClangFullRepositoryVersion();
123  }
124 
125  virtual void ReadModuleName(StringRef ModuleName) {}
126  virtual void ReadModuleMapFile(StringRef ModuleMapPath) {}
127 
128  /// Receives the language options.
129  ///
130  /// \returns true to indicate the options are invalid or false otherwise.
131  virtual bool ReadLanguageOptions(const LangOptions &LangOpts,
132  bool Complain,
133  bool AllowCompatibleDifferences) {
134  return false;
135  }
136 
137  /// Receives the target options.
138  ///
139  /// \returns true to indicate the target options are invalid, or false
140  /// otherwise.
141  virtual bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain,
142  bool AllowCompatibleDifferences) {
143  return false;
144  }
145 
146  /// Receives the diagnostic options.
147  ///
148  /// \returns true to indicate the diagnostic options are invalid, or false
149  /// otherwise.
150  virtual bool
152  bool Complain) {
153  return false;
154  }
155 
156  /// Receives the file system options.
157  ///
158  /// \returns true to indicate the file system options are invalid, or false
159  /// otherwise.
160  virtual bool ReadFileSystemOptions(const FileSystemOptions &FSOpts,
161  bool Complain) {
162  return false;
163  }
164 
165  /// Receives the header search options.
166  ///
167  /// \returns true to indicate the header search options are invalid, or false
168  /// otherwise.
169  virtual bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts,
170  StringRef SpecificModuleCachePath,
171  bool Complain) {
172  return false;
173  }
174 
175  /// Receives the preprocessor options.
176  ///
177  /// \param SuggestedPredefines Can be filled in with the set of predefines
178  /// that are suggested by the preprocessor options. Typically only used when
179  /// loading a precompiled header.
180  ///
181  /// \returns true to indicate the preprocessor options are invalid, or false
182  /// otherwise.
183  virtual bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts,
184  bool Complain,
185  std::string &SuggestedPredefines) {
186  return false;
187  }
188 
189  /// Receives __COUNTER__ value.
190  virtual void ReadCounter(const serialization::ModuleFile &M,
191  unsigned Value) {}
192 
193  /// This is called for each AST file loaded.
194  virtual void visitModuleFile(StringRef Filename,
196 
197  /// Returns true if this \c ASTReaderListener wants to receive the
198  /// input files of the AST file via \c visitInputFile, false otherwise.
199  virtual bool needsInputFileVisitation() { return false; }
200 
201  /// Returns true if this \c ASTReaderListener wants to receive the
202  /// system input files of the AST file via \c visitInputFile, false otherwise.
203  virtual bool needsSystemInputFileVisitation() { return false; }
204 
205  /// if \c needsInputFileVisitation returns true, this is called for
206  /// each non-system input file of the AST File. If
207  /// \c needsSystemInputFileVisitation is true, then it is called for all
208  /// system input files as well.
209  ///
210  /// \returns true to continue receiving the next input file, false to stop.
211  virtual bool visitInputFile(StringRef Filename, bool isSystem,
212  bool isOverridden, bool isExplicitModule) {
213  return true;
214  }
215 
216  /// Returns true if this \c ASTReaderListener wants to receive the
217  /// imports of the AST file via \c visitImport, false otherwise.
218  virtual bool needsImportVisitation() const { return false; }
219 
220  /// If needsImportVisitation returns \c true, this is called for each
221  /// AST file imported by this AST file.
222  virtual void visitImport(StringRef ModuleName, StringRef Filename) {}
223 
224  /// Indicates that a particular module file extension has been read.
226  const ModuleFileExtensionMetadata &Metadata) {}
227 };
228 
229 /// Simple wrapper class for chaining listeners.
231  std::unique_ptr<ASTReaderListener> First;
232  std::unique_ptr<ASTReaderListener> Second;
233 
234 public:
235  /// Takes ownership of \p First and \p Second.
236  ChainedASTReaderListener(std::unique_ptr<ASTReaderListener> First,
237  std::unique_ptr<ASTReaderListener> Second)
238  : First(std::move(First)), Second(std::move(Second)) {}
239 
240  std::unique_ptr<ASTReaderListener> takeFirst() { return std::move(First); }
241  std::unique_ptr<ASTReaderListener> takeSecond() { return std::move(Second); }
242 
243  bool ReadFullVersionInformation(StringRef FullVersion) override;
244  void ReadModuleName(StringRef ModuleName) override;
245  void ReadModuleMapFile(StringRef ModuleMapPath) override;
246  bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain,
247  bool AllowCompatibleDifferences) override;
248  bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain,
249  bool AllowCompatibleDifferences) override;
251  bool Complain) override;
252  bool ReadFileSystemOptions(const FileSystemOptions &FSOpts,
253  bool Complain) override;
254 
255  bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts,
256  StringRef SpecificModuleCachePath,
257  bool Complain) override;
258  bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts,
259  bool Complain,
260  std::string &SuggestedPredefines) override;
261 
262  void ReadCounter(const serialization::ModuleFile &M, unsigned Value) override;
263  bool needsInputFileVisitation() override;
264  bool needsSystemInputFileVisitation() override;
265  void visitModuleFile(StringRef Filename,
267  bool visitInputFile(StringRef Filename, bool isSystem,
268  bool isOverridden, bool isExplicitModule) override;
270  const ModuleFileExtensionMetadata &Metadata) override;
271 };
272 
273 /// ASTReaderListener implementation to validate the information of
274 /// the PCH file against an initialized Preprocessor.
276  Preprocessor &PP;
277  ASTReader &Reader;
278 
279 public:
281  : PP(PP), Reader(Reader) {}
282 
283  bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain,
284  bool AllowCompatibleDifferences) override;
285  bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain,
286  bool AllowCompatibleDifferences) override;
288  bool Complain) override;
289  bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, bool Complain,
290  std::string &SuggestedPredefines) override;
291  bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts,
292  StringRef SpecificModuleCachePath,
293  bool Complain) override;
294  void ReadCounter(const serialization::ModuleFile &M, unsigned Value) override;
295 
296 private:
297  void Error(const char *Msg);
298 };
299 
300 /// ASTReaderListenter implementation to set SuggestedPredefines of
301 /// ASTReader which is required to use a pch file. This is the replacement
302 /// of PCHValidator or SimplePCHValidator when using a pch file without
303 /// validating it.
305  Preprocessor &PP;
306 
307 public:
309 
310  bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, bool Complain,
311  std::string &SuggestedPredefines) override;
312 };
313 
314 namespace serialization {
315 
316 class ReadMethodPoolVisitor;
317 
318 namespace reader {
319 
321 
322 /// The on-disk hash table(s) used for DeclContext name lookup.
324 
325 } // namespace reader
326 
327 } // namespace serialization
328 
329 /// Reads an AST files chain containing the contents of a translation
330 /// unit.
331 ///
332 /// The ASTReader class reads bitstreams (produced by the ASTWriter
333 /// class) containing the serialized representation of a given
334 /// abstract syntax tree and its supporting data structures. An
335 /// instance of the ASTReader can be attached to an ASTContext object,
336 /// which will provide access to the contents of the AST files.
337 ///
338 /// The AST reader provides lazy de-serialization of declarations, as
339 /// required when traversing the AST. Only those AST nodes that are
340 /// actually required will be de-serialized.
345  public ExternalSemaSource,
346  public IdentifierInfoLookup,
348 {
349 public:
350  /// Types of AST files.
351  friend class ASTDeclReader;
352  friend class ASTIdentifierIterator;
353  friend class ASTRecordReader;
354  friend class ASTUnit; // ASTUnit needs to remap source locations.
355  friend class ASTWriter;
356  friend class PCHValidator;
359  friend class TypeLocReader;
360 
363 
364  /// The result of reading the control block of an AST file, which
365  /// can fail for various reasons.
367  /// The control block was read successfully. Aside from failures,
368  /// the AST file is safe to read into the current context.
370 
371  /// The AST file itself appears corrupted.
373 
374  /// The AST file was missing.
376 
377  /// The AST file is out-of-date relative to its input files,
378  /// and needs to be regenerated.
380 
381  /// The AST file was written by a different version of Clang.
383 
384  /// The AST file was written with a different language/target
385  /// configuration.
387 
388  /// The AST file has errors.
390  };
391 
398 
399 private:
401 
402  /// The receiver of some callbacks invoked by ASTReader.
403  std::unique_ptr<ASTReaderListener> Listener;
404 
405  /// The receiver of deserialization events.
406  ASTDeserializationListener *DeserializationListener = nullptr;
407 
408  bool OwnsDeserializationListener = false;
409 
410  SourceManager &SourceMgr;
411  FileManager &FileMgr;
412  const PCHContainerReader &PCHContainerRdr;
413  DiagnosticsEngine &Diags;
414 
415  /// The semantic analysis object that will be processing the
416  /// AST files and the translation unit that uses it.
417  Sema *SemaObj = nullptr;
418 
419  /// The preprocessor that will be loading the source file.
420  Preprocessor &PP;
421 
422  /// The AST context into which we'll read the AST files.
423  ASTContext *ContextObj = nullptr;
424 
425  /// The AST consumer.
426  ASTConsumer *Consumer = nullptr;
427 
428  /// The module manager which manages modules and their dependencies
429  ModuleManager ModuleMgr;
430 
431  /// A dummy identifier resolver used to merge TU-scope declarations in
432  /// C, for the cases where we don't have a Sema object to provide a real
433  /// identifier resolver.
434  IdentifierResolver DummyIdResolver;
435 
436  /// A mapping from extension block names to module file extensions.
437  llvm::StringMap<std::shared_ptr<ModuleFileExtension>> ModuleFileExtensions;
438 
439  /// A timer used to track the time spent deserializing.
440  std::unique_ptr<llvm::Timer> ReadTimer;
441 
442  /// The location where the module file will be considered as
443  /// imported from. For non-module AST types it should be invalid.
444  SourceLocation CurrentImportLoc;
445 
446  /// The module kind that is currently deserializing.
447  Optional<ModuleKind> CurrentDeserializingModuleKind;
448 
449  /// The global module index, if loaded.
450  std::unique_ptr<GlobalModuleIndex> GlobalIndex;
451 
452  /// A map of global bit offsets to the module that stores entities
453  /// at those bit offsets.
455 
456  /// A map of negated SLocEntryIDs to the modules containing them.
458 
461 
462  /// A map of reversed (SourceManager::MaxLoadedOffset - SLocOffset)
463  /// SourceLocation offsets to the modules containing them.
464  GlobalSLocOffsetMapType GlobalSLocOffsetMap;
465 
466  /// Types that have already been loaded from the chain.
467  ///
468  /// When the pointer at index I is non-NULL, the type with
469  /// ID = (I + 1) << FastQual::Width has already been loaded
470  std::vector<QualType> TypesLoaded;
471 
472  using GlobalTypeMapType =
474 
475  /// Mapping from global type IDs to the module in which the
476  /// type resides along with the offset that should be added to the
477  /// global type ID to produce a local ID.
478  GlobalTypeMapType GlobalTypeMap;
479 
480  /// Declarations that have already been loaded from the chain.
481  ///
482  /// When the pointer at index I is non-NULL, the declaration with ID
483  /// = I + 1 has already been loaded.
484  std::vector<Decl *> DeclsLoaded;
485 
486  using GlobalDeclMapType =
488 
489  /// Mapping from global declaration IDs to the module in which the
490  /// declaration resides.
491  GlobalDeclMapType GlobalDeclMap;
492 
493  using FileOffset = std::pair<ModuleFile *, uint64_t>;
495  using DeclUpdateOffsetsMap =
496  llvm::DenseMap<serialization::DeclID, FileOffsetsTy>;
497 
498  /// Declarations that have modifications residing in a later file
499  /// in the chain.
500  DeclUpdateOffsetsMap DeclUpdateOffsets;
501 
502  struct PendingUpdateRecord {
503  Decl *D;
505 
506  // Whether the declaration was just deserialized.
507  bool JustLoaded;
508 
509  PendingUpdateRecord(serialization::GlobalDeclID ID, Decl *D,
510  bool JustLoaded)
511  : D(D), ID(ID), JustLoaded(JustLoaded) {}
512  };
513 
514  /// Declaration updates for already-loaded declarations that we need
515  /// to apply once we finish processing an import.
516  llvm::SmallVector<PendingUpdateRecord, 16> PendingUpdateRecords;
517 
518  enum class PendingFakeDefinitionKind { NotFake, Fake, FakeLoaded };
519 
520  /// The DefinitionData pointers that we faked up for class definitions
521  /// that we needed but hadn't loaded yet.
522  llvm::DenseMap<void *, PendingFakeDefinitionKind> PendingFakeDefinitionData;
523 
524  /// Exception specification updates that have been loaded but not yet
525  /// propagated across the relevant redeclaration chain. The map key is the
526  /// canonical declaration (used only for deduplication) and the value is a
527  /// declaration that has an exception specification.
528  llvm::SmallMapVector<Decl *, FunctionDecl *, 4> PendingExceptionSpecUpdates;
529 
530  /// Deduced return type updates that have been loaded but not yet propagated
531  /// across the relevant redeclaration chain. The map key is the canonical
532  /// declaration and the value is the deduced return type.
533  llvm::SmallMapVector<FunctionDecl *, QualType, 4> PendingDeducedTypeUpdates;
534 
535  /// Declarations that have been imported and have typedef names for
536  /// linkage purposes.
537  llvm::DenseMap<std::pair<DeclContext *, IdentifierInfo *>, NamedDecl *>
538  ImportedTypedefNamesForLinkage;
539 
540  /// Mergeable declaration contexts that have anonymous declarations
541  /// within them, and those anonymous declarations.
542  llvm::DenseMap<Decl*, llvm::SmallVector<NamedDecl*, 2>>
543  AnonymousDeclarationsForMerging;
544 
545  /// Key used to identify LifetimeExtendedTemporaryDecl for merging,
546  /// containing the lifetime-extending declaration and the mangling number.
547  using LETemporaryKey = std::pair<Decl *, unsigned>;
548 
549  /// Map of already deserialiazed temporaries.
550  llvm::DenseMap<LETemporaryKey, LifetimeExtendedTemporaryDecl *>
551  LETemporaryForMerging;
552 
553  struct FileDeclsInfo {
554  ModuleFile *Mod = nullptr;
555  ArrayRef<serialization::LocalDeclID> Decls;
556 
557  FileDeclsInfo() = default;
558  FileDeclsInfo(ModuleFile *Mod, ArrayRef<serialization::LocalDeclID> Decls)
559  : Mod(Mod), Decls(Decls) {}
560  };
561 
562  /// Map from a FileID to the file-level declarations that it contains.
563  llvm::DenseMap<FileID, FileDeclsInfo> FileDeclIDs;
564 
565  /// An array of lexical contents of a declaration context, as a sequence of
566  /// Decl::Kind, DeclID pairs.
567  using LexicalContents = ArrayRef<llvm::support::unaligned_uint32_t>;
568 
569  /// Map from a DeclContext to its lexical contents.
570  llvm::DenseMap<const DeclContext*, std::pair<ModuleFile*, LexicalContents>>
571  LexicalDecls;
572 
573  /// Map from the TU to its lexical contents from each module file.
574  std::vector<std::pair<ModuleFile*, LexicalContents>> TULexicalDecls;
575 
576  /// Map from a DeclContext to its lookup tables.
577  llvm::DenseMap<const DeclContext *,
578  serialization::reader::DeclContextLookupTable> Lookups;
579 
580  // Updates for visible decls can occur for other contexts than just the
581  // TU, and when we read those update records, the actual context may not
582  // be available yet, so have this pending map using the ID as a key. It
583  // will be realized when the context is actually loaded.
584  struct PendingVisibleUpdate {
585  ModuleFile *Mod;
586  const unsigned char *Data;
587  };
588  using DeclContextVisibleUpdates = SmallVector<PendingVisibleUpdate, 1>;
589 
590  /// Updates to the visible declarations of declaration contexts that
591  /// haven't been loaded yet.
592  llvm::DenseMap<serialization::DeclID, DeclContextVisibleUpdates>
593  PendingVisibleUpdates;
594 
595  /// The set of C++ or Objective-C classes that have forward
596  /// declarations that have not yet been linked to their definitions.
597  llvm::SmallPtrSet<Decl *, 4> PendingDefinitions;
598 
599  using PendingBodiesMap =
600  llvm::MapVector<Decl *, uint64_t,
601  llvm::SmallDenseMap<Decl *, unsigned, 4>,
602  SmallVector<std::pair<Decl *, uint64_t>, 4>>;
603 
604  /// Functions or methods that have bodies that will be attached.
605  PendingBodiesMap PendingBodies;
606 
607  /// Definitions for which we have added merged definitions but not yet
608  /// performed deduplication.
609  llvm::SetVector<NamedDecl *> PendingMergedDefinitionsToDeduplicate;
610 
611  /// Read the record that describes the lexical contents of a DC.
612  bool ReadLexicalDeclContextStorage(ModuleFile &M,
613  llvm::BitstreamCursor &Cursor,
614  uint64_t Offset, DeclContext *DC);
615 
616  /// Read the record that describes the visible contents of a DC.
617  bool ReadVisibleDeclContextStorage(ModuleFile &M,
618  llvm::BitstreamCursor &Cursor,
620 
621  /// A vector containing identifiers that have already been
622  /// loaded.
623  ///
624  /// If the pointer at index I is non-NULL, then it refers to the
625  /// IdentifierInfo for the identifier with ID=I+1 that has already
626  /// been loaded.
627  std::vector<IdentifierInfo *> IdentifiersLoaded;
628 
629  using GlobalIdentifierMapType =
630  ContinuousRangeMap<serialization::IdentID, ModuleFile *, 4>;
631 
632  /// Mapping from global identifier IDs to the module in which the
633  /// identifier resides along with the offset that should be added to the
634  /// global identifier ID to produce a local ID.
635  GlobalIdentifierMapType GlobalIdentifierMap;
636 
637  /// A vector containing macros that have already been
638  /// loaded.
639  ///
640  /// If the pointer at index I is non-NULL, then it refers to the
641  /// MacroInfo for the identifier with ID=I+1 that has already
642  /// been loaded.
643  std::vector<MacroInfo *> MacrosLoaded;
644 
645  using LoadedMacroInfo =
646  std::pair<IdentifierInfo *, serialization::SubmoduleID>;
647 
648  /// A set of #undef directives that we have loaded; used to
649  /// deduplicate the same #undef information coming from multiple module
650  /// files.
651  llvm::DenseSet<LoadedMacroInfo> LoadedUndefs;
652 
653  using GlobalMacroMapType =
654  ContinuousRangeMap<serialization::MacroID, ModuleFile *, 4>;
655 
656  /// Mapping from global macro IDs to the module in which the
657  /// macro resides along with the offset that should be added to the
658  /// global macro ID to produce a local ID.
659  GlobalMacroMapType GlobalMacroMap;
660 
661  /// A vector containing submodules that have already been loaded.
662  ///
663  /// This vector is indexed by the Submodule ID (-1). NULL submodule entries
664  /// indicate that the particular submodule ID has not yet been loaded.
665  SmallVector<Module *, 2> SubmodulesLoaded;
666 
667  using GlobalSubmoduleMapType =
668  ContinuousRangeMap<serialization::SubmoduleID, ModuleFile *, 4>;
669 
670  /// Mapping from global submodule IDs to the module file in which the
671  /// submodule resides along with the offset that should be added to the
672  /// global submodule ID to produce a local ID.
673  GlobalSubmoduleMapType GlobalSubmoduleMap;
674 
675  /// A set of hidden declarations.
676  using HiddenNames = SmallVector<Decl *, 2>;
677  using HiddenNamesMapType = llvm::DenseMap<Module *, HiddenNames>;
678 
679  /// A mapping from each of the hidden submodules to the deserialized
680  /// declarations in that submodule that could be made visible.
681  HiddenNamesMapType HiddenNamesMap;
682 
683  /// A module import, export, or conflict that hasn't yet been resolved.
684  struct UnresolvedModuleRef {
685  /// The file in which this module resides.
686  ModuleFile *File;
687 
688  /// The module that is importing or exporting.
689  Module *Mod;
690 
691  /// The kind of module reference.
692  enum { Import, Export, Conflict, Affecting } Kind;
693 
694  /// The local ID of the module that is being exported.
695  unsigned ID;
696 
697  /// Whether this is a wildcard export.
698  unsigned IsWildcard : 1;
699 
700  /// String data.
701  StringRef String;
702  };
703 
704  /// The set of module imports and exports that still need to be
705  /// resolved.
706  SmallVector<UnresolvedModuleRef, 2> UnresolvedModuleRefs;
707 
708  /// A vector containing selectors that have already been loaded.
709  ///
710  /// This vector is indexed by the Selector ID (-1). NULL selector
711  /// entries indicate that the particular selector ID has not yet
712  /// been loaded.
713  SmallVector<Selector, 16> SelectorsLoaded;
714 
715  using GlobalSelectorMapType =
716  ContinuousRangeMap<serialization::SelectorID, ModuleFile *, 4>;
717 
718  /// Mapping from global selector IDs to the module in which the
719  /// global selector ID to produce a local ID.
720  GlobalSelectorMapType GlobalSelectorMap;
721 
722  /// The generation number of the last time we loaded data from the
723  /// global method pool for this selector.
724  llvm::DenseMap<Selector, unsigned> SelectorGeneration;
725 
726  /// Whether a selector is out of date. We mark a selector as out of date
727  /// if we load another module after the method pool entry was pulled in.
728  llvm::DenseMap<Selector, bool> SelectorOutOfDate;
729 
730  struct PendingMacroInfo {
731  ModuleFile *M;
732  /// Offset relative to ModuleFile::MacroOffsetsBase.
733  uint32_t MacroDirectivesOffset;
734 
735  PendingMacroInfo(ModuleFile *M, uint32_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<unsigned, ModuleFile *, 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<unsigned, ModuleFile *, 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<serialization::DeclID, 16> EagerlyDeserializedDecls;
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<serialization::DeclID, 16> TentativeDefinitions;
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<serialization::DeclID, 64> VTableUses;
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<serialization::DeclID, 64> PendingInstantiations;
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<serialization::DeclID, 16> UnusedFileScopedDecls;
804 
805  /// A list of all the delegating constructors we've seen, to diagnose
806  /// cycles.
807  SmallVector<serialization::DeclID, 4> DelegatingCtorDecls;
808 
809  /// Method selectors used in a @selector expression. Used for
810  /// implementation of -Wselector.
811  SmallVector<serialization::SelectorID, 64> ReferencedSelectorsData;
812 
813  /// A snapshot of Sema's weak undeclared identifier tracking, for
814  /// generating warnings.
815  SmallVector<serialization::IdentifierID, 64> WeakUndeclaredIdentifiers;
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<serialization::DeclID, 4> ExtVectorDecls;
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<serialization::DeclID, 16> UnusedLocalTypedefNameCandidates;
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<serialization::DeclID, 4> SemaDeclRefs;
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<serialization::TypeID, 16> SpecialTypes;
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<serialization::DeclID, 2> CUDASpecialDeclRefs;
852 
853  /// The floating point pragma option settings.
854  SmallVector<uint64_t, 1> FPPragmaOptions;
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 float_control state.
867  Optional<FPOptionsOverride> FpPragmaCurrentValue;
868  SourceLocation FpPragmaCurrentLocation;
869  struct FpPragmaStackEntry {
870  FPOptionsOverride Value;
871  SourceLocation Location;
872  SourceLocation PushLocation;
873  StringRef SlotLabel;
874  };
876  llvm::SmallVector<std::string, 2> FpPragmaStrings;
877 
878  /// The pragma align/pack state.
879  Optional<Sema::AlignPackInfo> PragmaAlignPackCurrentValue;
880  SourceLocation PragmaAlignPackCurrentLocation;
881  struct PragmaAlignPackStackEntry {
882  Sema::AlignPackInfo Value;
883  SourceLocation Location;
884  SourceLocation PushLocation;
885  StringRef SlotLabel;
886  };
888  llvm::SmallVector<std::string, 2> PragmaAlignPackStrings;
889 
890  /// The OpenCL extension settings.
891  OpenCLOptions OpenCLExtensions;
892 
893  /// Extensions required by an OpenCL type.
894  llvm::DenseMap<const Type *, std::set<std::string>> OpenCLTypeExtMap;
895 
896  /// Extensions required by an OpenCL declaration.
897  llvm::DenseMap<const Decl *, std::set<std::string>> OpenCLDeclExtMap;
898 
899  /// A list of the namespaces we've seen.
900  SmallVector<serialization::DeclID, 4> KnownNamespaces;
901 
902  /// A list of undefined decls with internal linkage followed by the
903  /// SourceLocation of a matching ODR-use.
904  SmallVector<serialization::DeclID, 8> UndefinedButUsed;
905 
906  /// Delete expressions to analyze at the end of translation unit.
907  SmallVector<uint64_t, 8> DelayedDeleteExprs;
908 
909  // A list of late parsed template function data with their module files.
910  SmallVector<std::pair<ModuleFile *, SmallVector<uint64_t, 1>>, 4>
911  LateParsedTemplates;
912 
913  /// The IDs of all decls to be checked for deferred diags.
914  ///
915  /// Sema tracks these to emit deferred diags.
916  llvm::SmallSetVector<serialization::DeclID, 4> DeclsToCheckForDeferredDiags;
917 
918 public:
922 
924  : ID(ID), ImportLoc(ImportLoc) {}
925  };
926 
927 private:
928  /// A list of modules that were imported by precompiled headers or
929  /// any other non-module AST file.
930  SmallVector<ImportedSubmodule, 2> ImportedModules;
931  //@}
932 
933  /// The system include root to be used when loading the
934  /// precompiled header.
935  std::string isysroot;
936 
937  /// Whether to disable the normal validation performed on precompiled
938  /// headers and module files when they are loaded.
939  DisableValidationForModuleKind DisableValidationKind;
940 
941  /// Whether to accept an AST file with compiler errors.
942  bool AllowASTWithCompilerErrors;
943 
944  /// Whether to accept an AST file that has a different configuration
945  /// from the current compiler instance.
946  bool AllowConfigurationMismatch;
947 
948  /// Whether validate system input files.
949  bool ValidateSystemInputs;
950 
951  /// Whether validate headers and module maps using hash based on contents.
952  bool ValidateASTInputFilesContent;
953 
954  /// Whether we are allowed to use the global module index.
955  bool UseGlobalIndex;
956 
957  /// Whether we have tried loading the global module index yet.
958  bool TriedLoadingGlobalIndex = false;
959 
960  ///Whether we are currently processing update records.
961  bool ProcessingUpdateRecords = false;
962 
963  using SwitchCaseMapTy = llvm::DenseMap<unsigned, SwitchCase *>;
964 
965  /// Mapping from switch-case IDs in the chain to switch-case statements
966  ///
967  /// Statements usually don't have IDs, but switch cases need them, so that the
968  /// switch statement can refer to them.
969  SwitchCaseMapTy SwitchCaseStmts;
970 
971  SwitchCaseMapTy *CurrSwitchCaseStmts;
972 
973  /// The number of source location entries de-serialized from
974  /// the PCH file.
975  unsigned NumSLocEntriesRead = 0;
976 
977  /// The number of source location entries in the chain.
978  unsigned TotalNumSLocEntries = 0;
979 
980  /// The number of statements (and expressions) de-serialized
981  /// from the chain.
982  unsigned NumStatementsRead = 0;
983 
984  /// The total number of statements (and expressions) stored
985  /// in the chain.
986  unsigned TotalNumStatements = 0;
987 
988  /// The number of macros de-serialized from the chain.
989  unsigned NumMacrosRead = 0;
990 
991  /// The total number of macros stored in the chain.
992  unsigned TotalNumMacros = 0;
993 
994  /// The number of lookups into identifier tables.
995  unsigned NumIdentifierLookups = 0;
996 
997  /// The number of lookups into identifier tables that succeed.
998  unsigned NumIdentifierLookupHits = 0;
999 
1000  /// The number of selectors that have been read.
1001  unsigned NumSelectorsRead = 0;
1002 
1003  /// The number of method pool entries that have been read.
1004  unsigned NumMethodPoolEntriesRead = 0;
1005 
1006  /// The number of times we have looked up a selector in the method
1007  /// pool.
1008  unsigned NumMethodPoolLookups = 0;
1009 
1010  /// The number of times we have looked up a selector in the method
1011  /// pool and found something.
1012  unsigned NumMethodPoolHits = 0;
1013 
1014  /// The number of times we have looked up a selector in the method
1015  /// pool within a specific module.
1016  unsigned NumMethodPoolTableLookups = 0;
1017 
1018  /// The number of times we have looked up a selector in the method
1019  /// pool within a specific module and found something.
1020  unsigned NumMethodPoolTableHits = 0;
1021 
1022  /// The total number of method pool entries in the selector table.
1023  unsigned TotalNumMethodPoolEntries = 0;
1024 
1025  /// Number of lexical decl contexts read/total.
1026  unsigned NumLexicalDeclContextsRead = 0, TotalLexicalDeclContexts = 0;
1027 
1028  /// Number of visible decl contexts read/total.
1029  unsigned NumVisibleDeclContextsRead = 0, TotalVisibleDeclContexts = 0;
1030 
1031  /// Total size of modules, in bits, currently loaded
1032  uint64_t TotalModulesSizeInBits = 0;
1033 
1034  /// Number of Decl/types that are currently deserializing.
1035  unsigned NumCurrentElementsDeserializing = 0;
1036 
1037  /// Set true while we are in the process of passing deserialized
1038  /// "interesting" decls to consumer inside FinishedDeserializing().
1039  /// This is used as a guard to avoid recursively repeating the process of
1040  /// passing decls to consumer.
1041  bool PassingDeclsToConsumer = false;
1042 
1043  /// The set of identifiers that were read while the AST reader was
1044  /// (recursively) loading declarations.
1045  ///
1046  /// The declarations on the identifier chain for these identifiers will be
1047  /// loaded once the recursive loading has completed.
1048  llvm::MapVector<IdentifierInfo *, SmallVector<uint32_t, 4>>
1049  PendingIdentifierInfos;
1050 
1051  /// The set of lookup results that we have faked in order to support
1052  /// merging of partially deserialized decls but that we have not yet removed.
1053  llvm::SmallMapVector<IdentifierInfo *, SmallVector<NamedDecl*, 2>, 16>
1054  PendingFakeLookupResults;
1055 
1056  /// The generation number of each identifier, which keeps track of
1057  /// the last time we loaded information about this identifier.
1058  llvm::DenseMap<IdentifierInfo *, unsigned> IdentifierGeneration;
1059 
1060  class InterestingDecl {
1061  Decl *D;
1062  bool DeclHasPendingBody;
1063 
1064  public:
1065  InterestingDecl(Decl *D, bool HasBody)
1066  : D(D), DeclHasPendingBody(HasBody) {}
1067 
1068  Decl *getDecl() { return D; }
1069 
1070  /// Whether the declaration has a pending body.
1071  bool hasPendingBody() { return DeclHasPendingBody; }
1072  };
1073 
1074  /// Contains declarations and definitions that could be
1075  /// "interesting" to the ASTConsumer, when we get that AST consumer.
1076  ///
1077  /// "Interesting" declarations are those that have data that may
1078  /// need to be emitted, such as inline function definitions or
1079  /// Objective-C protocols.
1080  std::deque<InterestingDecl> PotentiallyInterestingDecls;
1081 
1082  /// The list of deduced function types that we have not yet read, because
1083  /// they might contain a deduced return type that refers to a local type
1084  /// declared within the function.
1085  SmallVector<std::pair<FunctionDecl *, serialization::TypeID>, 16>
1086  PendingFunctionTypes;
1087 
1088  /// The list of redeclaration chains that still need to be
1089  /// reconstructed, and the local offset to the corresponding list
1090  /// of redeclarations.
1091  SmallVector<std::pair<Decl *, uint64_t>, 16> PendingDeclChains;
1092 
1093  /// The list of canonical declarations whose redeclaration chains
1094  /// need to be marked as incomplete once we're done deserializing things.
1095  SmallVector<Decl *, 16> PendingIncompleteDeclChains;
1096 
1097  /// The Decl IDs for the Sema/Lexical DeclContext of a Decl that has
1098  /// been loaded but its DeclContext was not set yet.
1099  struct PendingDeclContextInfo {
1100  Decl *D;
1102  serialization::GlobalDeclID LexicalDC;
1103  };
1104 
1105  /// The set of Decls that have been loaded but their DeclContexts are
1106  /// not set yet.
1107  ///
1108  /// The DeclContexts for these Decls will be set once recursive loading has
1109  /// been completed.
1110  std::deque<PendingDeclContextInfo> PendingDeclContextInfos;
1111 
1112  template <typename DeclTy>
1113  using DuplicateObjCDecls = std::pair<DeclTy *, DeclTy *>;
1114 
1115  /// When resolving duplicate ivars from Objective-C extensions we don't error
1116  /// out immediately but check if can merge identical extensions. Not checking
1117  /// extensions for equality immediately because ivar deserialization isn't
1118  /// over yet at that point.
1119  llvm::SmallMapVector<DuplicateObjCDecls<ObjCCategoryDecl>,
1121  2>
1122  PendingObjCExtensionIvarRedeclarations;
1123 
1124  /// The set of NamedDecls that have been loaded, but are members of a
1125  /// context that has been merged into another context where the corresponding
1126  /// declaration is either missing or has not yet been loaded.
1127  ///
1128  /// We will check whether the corresponding declaration is in fact missing
1129  /// once recursing loading has been completed.
1130  llvm::SmallVector<NamedDecl *, 16> PendingOdrMergeChecks;
1131 
1132  using DataPointers =
1133  std::pair<CXXRecordDecl *, struct CXXRecordDecl::DefinitionData *>;
1134  using ObjCProtocolDataPointers =
1135  std::pair<ObjCProtocolDecl *, struct ObjCProtocolDecl::DefinitionData *>;
1136 
1137  /// Record definitions in which we found an ODR violation.
1138  llvm::SmallDenseMap<CXXRecordDecl *, llvm::SmallVector<DataPointers, 2>, 2>
1139  PendingOdrMergeFailures;
1140 
1141  /// Function definitions in which we found an ODR violation.
1142  llvm::SmallDenseMap<FunctionDecl *, llvm::SmallVector<FunctionDecl *, 2>, 2>
1143  PendingFunctionOdrMergeFailures;
1144 
1145  /// Enum definitions in which we found an ODR violation.
1146  llvm::SmallDenseMap<EnumDecl *, llvm::SmallVector<EnumDecl *, 2>, 2>
1147  PendingEnumOdrMergeFailures;
1148 
1149  /// ObjCProtocolDecl in which we found an ODR violation.
1150  llvm::SmallDenseMap<ObjCProtocolDecl *,
1152  PendingObjCProtocolOdrMergeFailures;
1153 
1154  /// DeclContexts in which we have diagnosed an ODR violation.
1155  llvm::SmallPtrSet<DeclContext*, 2> DiagnosedOdrMergeFailures;
1156 
1157  /// The set of Objective-C categories that have been deserialized
1158  /// since the last time the declaration chains were linked.
1159  llvm::SmallPtrSet<ObjCCategoryDecl *, 16> CategoriesDeserialized;
1160 
1161  /// The set of Objective-C class definitions that have already been
1162  /// loaded, for which we will need to check for categories whenever a new
1163  /// module is loaded.
1164  SmallVector<ObjCInterfaceDecl *, 16> ObjCClassesLoaded;
1165 
1166  using KeyDeclsMap =
1167  llvm::DenseMap<Decl *, SmallVector<serialization::DeclID, 2>>;
1168 
1169  /// A mapping from canonical declarations to the set of global
1170  /// declaration IDs for key declaration that have been merged with that
1171  /// canonical declaration. A key declaration is a formerly-canonical
1172  /// declaration whose module did not import any other key declaration for that
1173  /// entity. These are the IDs that we use as keys when finding redecl chains.
1174  KeyDeclsMap KeyDecls;
1175 
1176  /// A mapping from DeclContexts to the semantic DeclContext that we
1177  /// are treating as the definition of the entity. This is used, for instance,
1178  /// when merging implicit instantiations of class templates across modules.
1179  llvm::DenseMap<DeclContext *, DeclContext *> MergedDeclContexts;
1180 
1181  /// A mapping from canonical declarations of enums to their canonical
1182  /// definitions. Only populated when using modules in C++.
1183  llvm::DenseMap<EnumDecl *, EnumDecl *> EnumDefinitions;
1184 
1185  /// A mapping from canonical declarations of records to their canonical
1186  /// definitions. Doesn't cover CXXRecordDecl.
1187  llvm::DenseMap<RecordDecl *, RecordDecl *> RecordDefinitions;
1188 
1189  /// When reading a Stmt tree, Stmt operands are placed in this stack.
1190  SmallVector<Stmt *, 16> StmtStack;
1191 
1192  /// What kind of records we are reading.
1193  enum ReadingKind {
1194  Read_None, Read_Decl, Read_Type, Read_Stmt
1195  };
1196 
1197  /// What kind of records we are reading.
1198  ReadingKind ReadingKind = Read_None;
1199 
1200  /// RAII object to change the reading kind.
1201  class ReadingKindTracker {
1202  ASTReader &Reader;
1203  enum ReadingKind PrevKind;
1204 
1205  public:
1206  ReadingKindTracker(enum ReadingKind newKind, ASTReader &reader)
1207  : Reader(reader), PrevKind(Reader.ReadingKind) {
1208  Reader.ReadingKind = newKind;
1209  }
1210 
1211  ReadingKindTracker(const ReadingKindTracker &) = delete;
1212  ReadingKindTracker &operator=(const ReadingKindTracker &) = delete;
1213  ~ReadingKindTracker() { Reader.ReadingKind = PrevKind; }
1214  };
1215 
1216  /// RAII object to mark the start of processing updates.
1217  class ProcessingUpdatesRAIIObj {
1218  ASTReader &Reader;
1219  bool PrevState;
1220 
1221  public:
1222  ProcessingUpdatesRAIIObj(ASTReader &reader)
1223  : Reader(reader), PrevState(Reader.ProcessingUpdateRecords) {
1224  Reader.ProcessingUpdateRecords = true;
1225  }
1226 
1227  ProcessingUpdatesRAIIObj(const ProcessingUpdatesRAIIObj &) = delete;
1228  ProcessingUpdatesRAIIObj &
1229  operator=(const ProcessingUpdatesRAIIObj &) = delete;
1230  ~ProcessingUpdatesRAIIObj() { Reader.ProcessingUpdateRecords = PrevState; }
1231  };
1232 
1233  /// Suggested contents of the predefines buffer, after this
1234  /// PCH file has been processed.
1235  ///
1236  /// In most cases, this string will be empty, because the predefines
1237  /// buffer computed to build the PCH file will be identical to the
1238  /// predefines buffer computed from the command line. However, when
1239  /// there are differences that the PCH reader can work around, this
1240  /// predefines buffer may contain additional definitions.
1241  std::string SuggestedPredefines;
1242 
1243  llvm::DenseMap<const Decl *, bool> DefinitionSource;
1244 
1245  bool shouldDisableValidationForFile(const serialization::ModuleFile &M) const;
1246 
1247  /// Reads a statement from the specified cursor.
1248  Stmt *ReadStmtFromStream(ModuleFile &F);
1249 
1250  struct InputFileInfo {
1252  uint64_t ContentHash;
1253  off_t StoredSize;
1254  time_t StoredTime;
1255  bool Overridden;
1256  bool Transient;
1257  bool TopLevelModuleMap;
1258  };
1259 
1260  /// Reads the stored information about an input file.
1261  InputFileInfo readInputFileInfo(ModuleFile &F, unsigned ID);
1262 
1263  /// Retrieve the file entry and 'overridden' bit for an input
1264  /// file in the given module file.
1265  serialization::InputFile getInputFile(ModuleFile &F, unsigned ID,
1266  bool Complain = true);
1267 
1268 public:
1270  static void ResolveImportedPath(std::string &Filename, StringRef Prefix);
1271 
1272  /// Returns the first key declaration for the given declaration. This
1273  /// is one that is formerly-canonical (or still canonical) and whose module
1274  /// did not import any other key declaration of the entity.
1276  D = D->getCanonicalDecl();
1277  if (D->isFromASTFile())
1278  return D;
1279 
1280  auto I = KeyDecls.find(D);
1281  if (I == KeyDecls.end() || I->second.empty())
1282  return D;
1283  return GetExistingDecl(I->second[0]);
1284  }
1285  const Decl *getKeyDeclaration(const Decl *D) {
1286  return getKeyDeclaration(const_cast<Decl*>(D));
1287  }
1288 
1289  /// Run a callback on each imported key declaration of \p D.
1290  template <typename Fn>
1291  void forEachImportedKeyDecl(const Decl *D, Fn Visit) {
1292  D = D->getCanonicalDecl();
1293  if (D->isFromASTFile())
1294  Visit(D);
1295 
1296  auto It = KeyDecls.find(const_cast<Decl*>(D));
1297  if (It != KeyDecls.end())
1298  for (auto ID : It->second)
1299  Visit(GetExistingDecl(ID));
1300  }
1301 
1302  /// Get the loaded lookup tables for \p Primary, if any.
1304  getLoadedLookupTables(DeclContext *Primary) const;
1305 
1306 private:
1307  struct ImportedModule {
1308  ModuleFile *Mod;
1309  ModuleFile *ImportedBy;
1310  SourceLocation ImportLoc;
1311 
1312  ImportedModule(ModuleFile *Mod,
1313  ModuleFile *ImportedBy,
1314  SourceLocation ImportLoc)
1315  : Mod(Mod), ImportedBy(ImportedBy), ImportLoc(ImportLoc) {}
1316  };
1317 
1318  ASTReadResult ReadASTCore(StringRef FileName, ModuleKind Type,
1319  SourceLocation ImportLoc, ModuleFile *ImportedBy,
1320  SmallVectorImpl<ImportedModule> &Loaded,
1321  off_t ExpectedSize, time_t ExpectedModTime,
1322  ASTFileSignature ExpectedSignature,
1323  unsigned ClientLoadCapabilities);
1324  ASTReadResult ReadControlBlock(ModuleFile &F,
1325  SmallVectorImpl<ImportedModule> &Loaded,
1326  const ModuleFile *ImportedBy,
1327  unsigned ClientLoadCapabilities);
1328  static ASTReadResult ReadOptionsBlock(
1329  llvm::BitstreamCursor &Stream, unsigned ClientLoadCapabilities,
1330  bool AllowCompatibleConfigurationMismatch, ASTReaderListener &Listener,
1331  std::string &SuggestedPredefines);
1332 
1333  /// Read the unhashed control block.
1334  ///
1335  /// This has no effect on \c F.Stream, instead creating a fresh cursor from
1336  /// \c F.Data and reading ahead.
1337  ASTReadResult readUnhashedControlBlock(ModuleFile &F, bool WasImportedBy,
1338  unsigned ClientLoadCapabilities);
1339 
1340  static ASTReadResult
1341  readUnhashedControlBlockImpl(ModuleFile *F, llvm::StringRef StreamData,
1342  unsigned ClientLoadCapabilities,
1343  bool AllowCompatibleConfigurationMismatch,
1344  ASTReaderListener *Listener,
1345  bool ValidateDiagnosticOptions);
1346 
1347  llvm::Error ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities);
1348  llvm::Error ReadExtensionBlock(ModuleFile &F);
1349  void ReadModuleOffsetMap(ModuleFile &F) const;
1350  void ParseLineTable(ModuleFile &F, const RecordData &Record);
1351  llvm::Error ReadSourceManagerBlock(ModuleFile &F);
1352  llvm::BitstreamCursor &SLocCursorForID(int ID);
1353  SourceLocation getImportLocation(ModuleFile *F);
1354  void readIncludedFiles(ModuleFile &F, StringRef Blob, Preprocessor &PP);
1355  ASTReadResult ReadModuleMapFileBlock(RecordData &Record, ModuleFile &F,
1356  const ModuleFile *ImportedBy,
1357  unsigned ClientLoadCapabilities);
1358  llvm::Error ReadSubmoduleBlock(ModuleFile &F,
1359  unsigned ClientLoadCapabilities);
1360  static bool ParseLanguageOptions(const RecordData &Record, bool Complain,
1361  ASTReaderListener &Listener,
1362  bool AllowCompatibleDifferences);
1363  static bool ParseTargetOptions(const RecordData &Record, bool Complain,
1364  ASTReaderListener &Listener,
1365  bool AllowCompatibleDifferences);
1366  static bool ParseDiagnosticOptions(const RecordData &Record, bool Complain,
1367  ASTReaderListener &Listener);
1368  static bool ParseFileSystemOptions(const RecordData &Record, bool Complain,
1369  ASTReaderListener &Listener);
1370  static bool ParseHeaderSearchOptions(const RecordData &Record, bool Complain,
1371  ASTReaderListener &Listener);
1372  static bool ParsePreprocessorOptions(const RecordData &Record, bool Complain,
1373  ASTReaderListener &Listener,
1374  std::string &SuggestedPredefines);
1375 
1376  struct RecordLocation {
1377  ModuleFile *F;
1378  uint64_t Offset;
1379 
1380  RecordLocation(ModuleFile *M, uint64_t O) : F(M), Offset(O) {}
1381  };
1382 
1383  QualType readTypeRecord(unsigned Index);
1384  RecordLocation TypeCursorForIndex(unsigned Index);
1385  void LoadedDecl(unsigned Index, Decl *D);
1386  Decl *ReadDeclRecord(serialization::DeclID ID);
1387  void markIncompleteDeclChain(Decl *Canon);
1388 
1389  /// Returns the most recent declaration of a declaration (which must be
1390  /// of a redeclarable kind) that is either local or has already been loaded
1391  /// merged into its redecl chain.
1392  Decl *getMostRecentExistingDecl(Decl *D);
1393 
1394  RecordLocation DeclCursorForID(serialization::DeclID ID,
1395  SourceLocation &Location);
1396  void loadDeclUpdateRecords(PendingUpdateRecord &Record);
1397  void loadPendingDeclChain(Decl *D, uint64_t LocalOffset);
1398  void loadObjCCategories(serialization::GlobalDeclID ID, ObjCInterfaceDecl *D,
1399  unsigned PreviousGeneration = 0);
1400 
1401  RecordLocation getLocalBitOffset(uint64_t GlobalOffset);
1402  uint64_t getGlobalBitOffset(ModuleFile &M, uint64_t LocalOffset);
1403 
1404  /// Returns the first preprocessed entity ID that begins or ends after
1405  /// \arg Loc.
1407  findPreprocessedEntity(SourceLocation Loc, bool EndsAfter) const;
1408 
1409  /// Find the next module that contains entities and return the ID
1410  /// of the first entry.
1411  ///
1412  /// \param SLocMapI points at a chunk of a module that contains no
1413  /// preprocessed entities or the entities it contains are not the
1414  /// ones we are looking for.
1416  findNextPreprocessedEntity(
1418 
1419  /// Returns (ModuleFile, Local index) pair for \p GlobalIndex of a
1420  /// preprocessed entity.
1421  std::pair<ModuleFile *, unsigned>
1422  getModulePreprocessedEntity(unsigned GlobalIndex);
1423 
1424  /// Returns (begin, end) pair for the preprocessed entities of a
1425  /// particular module.
1426  llvm::iterator_range<PreprocessingRecord::iterator>
1427  getModulePreprocessedEntities(ModuleFile &Mod) const;
1428 
1429  bool canRecoverFromOutOfDate(StringRef ModuleFileName,
1430  unsigned ClientLoadCapabilities);
1431 
1432 public:
1434  : public llvm::iterator_adaptor_base<
1435  ModuleDeclIterator, const serialization::LocalDeclID *,
1436  std::random_access_iterator_tag, const Decl *, ptrdiff_t,
1437  const Decl *, const Decl *> {
1438  ASTReader *Reader = nullptr;
1439  ModuleFile *Mod = nullptr;
1440 
1441  public:
1442  ModuleDeclIterator() : iterator_adaptor_base(nullptr) {}
1443 
1445  const serialization::LocalDeclID *Pos)
1446  : iterator_adaptor_base(Pos), Reader(Reader), Mod(Mod) {}
1447 
1448  value_type operator*() const {
1449  return Reader->GetDecl(Reader->getGlobalDeclID(*Mod, *I));
1450  }
1451 
1452  value_type operator->() const { return **this; }
1453 
1454  bool operator==(const ModuleDeclIterator &RHS) const {
1455  assert(Reader == RHS.Reader && Mod == RHS.Mod);
1456  return I == RHS.I;
1457  }
1458  };
1459 
1460  llvm::iterator_range<ModuleDeclIterator>
1462 
1463 private:
1464  void PassInterestingDeclsToConsumer();
1465  void PassInterestingDeclToConsumer(Decl *D);
1466 
1467  void finishPendingActions();
1468  void diagnoseOdrViolations();
1469 
1470  void pushExternalDeclIntoScope(NamedDecl *D, DeclarationName Name);
1471 
1472  void addPendingDeclContextInfo(Decl *D,
1474  serialization::GlobalDeclID LexicalDC) {
1475  assert(D);
1476  PendingDeclContextInfo Info = { D, SemaDC, LexicalDC };
1477  PendingDeclContextInfos.push_back(Info);
1478  }
1479 
1480  /// Produce an error diagnostic and return true.
1481  ///
1482  /// This routine should only be used for fatal errors that have to
1483  /// do with non-routine failures (e.g., corrupted AST file).
1484  void Error(StringRef Msg) const;
1485  void Error(unsigned DiagID, StringRef Arg1 = StringRef(),
1486  StringRef Arg2 = StringRef(), StringRef Arg3 = StringRef()) const;
1487  void Error(llvm::Error &&Err) const;
1488 
1489 public:
1490  /// Load the AST file and validate its contents against the given
1491  /// Preprocessor.
1492  ///
1493  /// \param PP the preprocessor associated with the context in which this
1494  /// precompiled header will be loaded.
1495  ///
1496  /// \param Context the AST context that this precompiled header will be
1497  /// loaded into, if any.
1498  ///
1499  /// \param PCHContainerRdr the PCHContainerOperations to use for loading and
1500  /// creating modules.
1501  ///
1502  /// \param Extensions the list of module file extensions that can be loaded
1503  /// from the AST files.
1504  ///
1505  /// \param isysroot If non-NULL, the system include path specified by the
1506  /// user. This is only used with relocatable PCH files. If non-NULL,
1507  /// a relocatable PCH file will use the default path "/".
1508  ///
1509  /// \param DisableValidationKind If set, the AST reader will suppress most
1510  /// of its regular consistency checking, allowing the use of precompiled
1511  /// headers and module files that cannot be determined to be compatible.
1512  ///
1513  /// \param AllowASTWithCompilerErrors If true, the AST reader will accept an
1514  /// AST file the was created out of an AST with compiler errors,
1515  /// otherwise it will reject it.
1516  ///
1517  /// \param AllowConfigurationMismatch If true, the AST reader will not check
1518  /// for configuration differences between the AST file and the invocation.
1519  ///
1520  /// \param ValidateSystemInputs If true, the AST reader will validate
1521  /// system input files in addition to user input files. This is only
1522  /// meaningful if \p DisableValidation is false.
1523  ///
1524  /// \param UseGlobalIndex If true, the AST reader will try to load and use
1525  /// the global module index.
1526  ///
1527  /// \param ReadTimer If non-null, a timer used to track the time spent
1528  /// deserializing.
1529  ASTReader(Preprocessor &PP, InMemoryModuleCache &ModuleCache,
1530  ASTContext *Context, const PCHContainerReader &PCHContainerRdr,
1531  ArrayRef<std::shared_ptr<ModuleFileExtension>> Extensions,
1532  StringRef isysroot = "",
1533  DisableValidationForModuleKind DisableValidationKind =
1535  bool AllowASTWithCompilerErrors = false,
1536  bool AllowConfigurationMismatch = false,
1537  bool ValidateSystemInputs = false,
1538  bool ValidateASTInputFilesContent = false,
1539  bool UseGlobalIndex = true,
1540  std::unique_ptr<llvm::Timer> ReadTimer = {});
1541  ASTReader(const ASTReader &) = delete;
1542  ASTReader &operator=(const ASTReader &) = delete;
1543  ~ASTReader() override;
1544 
1545  SourceManager &getSourceManager() const { return SourceMgr; }
1546  FileManager &getFileManager() const { return FileMgr; }
1547  DiagnosticsEngine &getDiags() const { return Diags; }
1548 
1549  /// Flags that indicate what kind of AST loading failures the client
1550  /// of the AST reader can directly handle.
1551  ///
1552  /// When a client states that it can handle a particular kind of failure,
1553  /// the AST reader will not emit errors when producing that kind of failure.
1555  /// The client can't handle any AST loading failures.
1557 
1558  /// The client can handle an AST file that cannot load because it
1559  /// is missing.
1561 
1562  /// The client can handle an AST file that cannot load because it
1563  /// is out-of-date relative to its input files.
1565 
1566  /// The client can handle an AST file that cannot load because it
1567  /// was built with a different version of Clang.
1569 
1570  /// The client can handle an AST file that cannot load because it's
1571  /// compiled configuration doesn't match that of the context it was
1572  /// loaded into.
1574 
1575  /// If a module file is marked with errors treat it as out-of-date so the
1576  /// caller can rebuild it.
1578  };
1579 
1580  /// Load the AST file designated by the given file name.
1581  ///
1582  /// \param FileName The name of the AST file to load.
1583  ///
1584  /// \param Type The kind of AST being loaded, e.g., PCH, module, main file,
1585  /// or preamble.
1586  ///
1587  /// \param ImportLoc the location where the module file will be considered as
1588  /// imported from. For non-module AST types it should be invalid.
1589  ///
1590  /// \param ClientLoadCapabilities The set of client load-failure
1591  /// capabilities, represented as a bitset of the enumerators of
1592  /// LoadFailureCapabilities.
1593  ///
1594  /// \param Imported optional out-parameter to append the list of modules
1595  /// that were imported by precompiled headers or any other non-module AST file
1596  ASTReadResult ReadAST(StringRef FileName, ModuleKind Type,
1597  SourceLocation ImportLoc,
1598  unsigned ClientLoadCapabilities,
1599  SmallVectorImpl<ImportedSubmodule> *Imported = nullptr);
1600 
1601  /// Make the entities in the given module and any of its (non-explicit)
1602  /// submodules visible to name lookup.
1603  ///
1604  /// \param Mod The module whose names should be made visible.
1605  ///
1606  /// \param NameVisibility The level of visibility to give the names in the
1607  /// module. Visibility can only be increased over time.
1608  ///
1609  /// \param ImportLoc The location at which the import occurs.
1610  void makeModuleVisible(Module *Mod,
1611  Module::NameVisibilityKind NameVisibility,
1612  SourceLocation ImportLoc);
1613 
1614  /// Make the names within this set of hidden names visible.
1615  void makeNamesVisible(const HiddenNames &Names, Module *Owner);
1616 
1617  /// Note that MergedDef is a redefinition of the canonical definition
1618  /// Def, so Def should be visible whenever MergedDef is.
1619  void mergeDefinitionVisibility(NamedDecl *Def, NamedDecl *MergedDef);
1620 
1621  /// Take the AST callbacks listener.
1622  std::unique_ptr<ASTReaderListener> takeListener() {
1623  return std::move(Listener);
1624  }
1625 
1626  /// Set the AST callbacks listener.
1627  void setListener(std::unique_ptr<ASTReaderListener> Listener) {
1628  this->Listener = std::move(Listener);
1629  }
1630 
1631  /// Add an AST callback listener.
1632  ///
1633  /// Takes ownership of \p L.
1634  void addListener(std::unique_ptr<ASTReaderListener> L) {
1635  if (Listener)
1636  L = std::make_unique<ChainedASTReaderListener>(std::move(L),
1637  std::move(Listener));
1638  Listener = std::move(L);
1639  }
1640 
1641  /// RAII object to temporarily add an AST callback listener.
1643  ASTReader &Reader;
1644  bool Chained = false;
1645 
1646  public:
1647  ListenerScope(ASTReader &Reader, std::unique_ptr<ASTReaderListener> L)
1648  : Reader(Reader) {
1649  auto Old = Reader.takeListener();
1650  if (Old) {
1651  Chained = true;
1652  L = std::make_unique<ChainedASTReaderListener>(std::move(L),
1653  std::move(Old));
1654  }
1655  Reader.setListener(std::move(L));
1656  }
1657 
1659  auto New = Reader.takeListener();
1660  if (Chained)
1661  Reader.setListener(static_cast<ChainedASTReaderListener *>(New.get())
1662  ->takeSecond());
1663  }
1664  };
1665 
1666  /// Set the AST deserialization listener.
1668  bool TakeOwnership = false);
1669 
1670  /// Get the AST deserialization listener.
1672  return DeserializationListener;
1673  }
1674 
1675  /// Determine whether this AST reader has a global index.
1676  bool hasGlobalIndex() const { return (bool)GlobalIndex; }
1677 
1678  /// Return global module index.
1679  GlobalModuleIndex *getGlobalIndex() { return GlobalIndex.get(); }
1680 
1681  /// Reset reader for a reload try.
1682  void resetForReload() { TriedLoadingGlobalIndex = false; }
1683 
1684  /// Attempts to load the global index.
1685  ///
1686  /// \returns true if loading the global index has failed for any reason.
1687  bool loadGlobalIndex();
1688 
1689  /// Determine whether we tried to load the global index, but failed,
1690  /// e.g., because it is out-of-date or does not exist.
1691  bool isGlobalIndexUnavailable() const;
1692 
1693  /// Initializes the ASTContext
1694  void InitializeContext();
1695 
1696  /// Update the state of Sema after loading some additional modules.
1697  void UpdateSema();
1698 
1699  /// Add in-memory (virtual file) buffer.
1700  void addInMemoryBuffer(StringRef &FileName,
1701  std::unique_ptr<llvm::MemoryBuffer> Buffer) {
1702  ModuleMgr.addInMemoryBuffer(FileName, std::move(Buffer));
1703  }
1704 
1705  /// Finalizes the AST reader's state before writing an AST file to
1706  /// disk.
1707  ///
1708  /// This operation may undo temporary state in the AST that should not be
1709  /// emitted.
1710  void finalizeForWriting();
1711 
1712  /// Retrieve the module manager.
1713  ModuleManager &getModuleManager() { return ModuleMgr; }
1714 
1715  /// Retrieve the preprocessor.
1716  Preprocessor &getPreprocessor() const { return PP; }
1717 
1718  /// Retrieve the name of the original source file name for the primary
1719  /// module file.
1721  return ModuleMgr.getPrimaryModule().OriginalSourceFileName;
1722  }
1723 
1724  /// Retrieve the name of the original source file name directly from
1725  /// the AST file, without actually loading the AST file.
1726  static std::string
1727  getOriginalSourceFile(const std::string &ASTFileName, FileManager &FileMgr,
1728  const PCHContainerReader &PCHContainerRdr,
1729  DiagnosticsEngine &Diags);
1730 
1731  /// Read the control block for the named AST file.
1732  ///
1733  /// \returns true if an error occurred, false otherwise.
1734  static bool readASTFileControlBlock(StringRef Filename, FileManager &FileMgr,
1735  const InMemoryModuleCache &ModuleCache,
1736  const PCHContainerReader &PCHContainerRdr,
1737  bool FindModuleFileExtensions,
1738  ASTReaderListener &Listener,
1739  bool ValidateDiagnosticOptions);
1740 
1741  /// Determine whether the given AST file is acceptable to load into a
1742  /// translation unit with the given language and target options.
1743  static bool isAcceptableASTFile(StringRef Filename, FileManager &FileMgr,
1744  const InMemoryModuleCache &ModuleCache,
1745  const PCHContainerReader &PCHContainerRdr,
1746  const LangOptions &LangOpts,
1747  const TargetOptions &TargetOpts,
1748  const PreprocessorOptions &PPOpts,
1749  StringRef ExistingModuleCachePath,
1750  bool RequireStrictOptionMatches = false);
1751 
1752  /// Returns the suggested contents of the predefines buffer,
1753  /// which contains a (typically-empty) subset of the predefines
1754  /// build prior to including the precompiled header.
1755  const std::string &getSuggestedPredefines() { return SuggestedPredefines; }
1756 
1757  /// Read a preallocated preprocessed entity from the external source.
1758  ///
1759  /// \returns null if an error occurred that prevented the preprocessed
1760  /// entity from being loaded.
1761  PreprocessedEntity *ReadPreprocessedEntity(unsigned Index) override;
1762 
1763  /// Returns a pair of [Begin, End) indices of preallocated
1764  /// preprocessed entities that \p Range encompasses.
1765  std::pair<unsigned, unsigned>
1767 
1768  /// Optionally returns true or false if the preallocated preprocessed
1769  /// entity with index \p Index came from file \p FID.
1771  FileID FID) override;
1772 
1773  /// Read a preallocated skipped range from the external source.
1774  SourceRange ReadSkippedRange(unsigned Index) override;
1775 
1776  /// Read the header file information for the given file entry.
1777  HeaderFileInfo GetHeaderFileInfo(const FileEntry *FE) override;
1778 
1780 
1781  /// Returns the number of source locations found in the chain.
1782  unsigned getTotalNumSLocs() const {
1783  return TotalNumSLocEntries;
1784  }
1785 
1786  /// Returns the number of identifiers found in the chain.
1787  unsigned getTotalNumIdentifiers() const {
1788  return static_cast<unsigned>(IdentifiersLoaded.size());
1789  }
1790 
1791  /// Returns the number of macros found in the chain.
1792  unsigned getTotalNumMacros() const {
1793  return static_cast<unsigned>(MacrosLoaded.size());
1794  }
1795 
1796  /// Returns the number of types found in the chain.
1797  unsigned getTotalNumTypes() const {
1798  return static_cast<unsigned>(TypesLoaded.size());
1799  }
1800 
1801  /// Returns the number of declarations found in the chain.
1802  unsigned getTotalNumDecls() const {
1803  return static_cast<unsigned>(DeclsLoaded.size());
1804  }
1805 
1806  /// Returns the number of submodules known.
1807  unsigned getTotalNumSubmodules() const {
1808  return static_cast<unsigned>(SubmodulesLoaded.size());
1809  }
1810 
1811  /// Returns the number of selectors found in the chain.
1812  unsigned getTotalNumSelectors() const {
1813  return static_cast<unsigned>(SelectorsLoaded.size());
1814  }
1815 
1816  /// Returns the number of preprocessed entities known to the AST
1817  /// reader.
1819  unsigned Result = 0;
1820  for (const auto &M : ModuleMgr)
1821  Result += M.NumPreprocessedEntities;
1822  return Result;
1823  }
1824 
1825  /// Resolve a type ID into a type, potentially building a new
1826  /// type.
1828 
1829  /// Resolve a local type ID within a given AST file into a type.
1830  QualType getLocalType(ModuleFile &F, unsigned LocalID);
1831 
1832  /// Map a local type ID within a given AST file into a global type ID.
1833  serialization::TypeID getGlobalTypeID(ModuleFile &F, unsigned LocalID) const;
1834 
1835  /// Read a type from the current position in the given record, which
1836  /// was read from the given AST file.
1837  QualType readType(ModuleFile &F, const RecordData &Record, unsigned &Idx) {
1838  if (Idx >= Record.size())
1839  return {};
1840 
1841  return getLocalType(F, Record[Idx++]);
1842  }
1843 
1844  /// Map from a local declaration ID within a given module to a
1845  /// global declaration ID.
1847  serialization::LocalDeclID LocalID) const;
1848 
1849  /// Returns true if global DeclID \p ID originated from module \p M.
1851 
1852  /// Retrieve the module file that owns the given declaration, or NULL
1853  /// if the declaration is not from a module file.
1854  ModuleFile *getOwningModuleFile(const Decl *D);
1855 
1856  /// Returns the source location for the decl \p ID.
1858 
1859  /// Resolve a declaration ID into a declaration, potentially
1860  /// building a new declaration.
1862  Decl *GetExternalDecl(uint32_t ID) override;
1863 
1864  /// Resolve a declaration ID into a declaration. Return 0 if it's not
1865  /// been loaded yet.
1867 
1868  /// Reads a declaration with the given local ID in the given module.
1869  Decl *GetLocalDecl(ModuleFile &F, uint32_t LocalID) {
1870  return GetDecl(getGlobalDeclID(F, LocalID));
1871  }
1872 
1873  /// Reads a declaration with the given local ID in the given module.
1874  ///
1875  /// \returns The requested declaration, casted to the given return type.
1876  template<typename T>
1877  T *GetLocalDeclAs(ModuleFile &F, uint32_t LocalID) {
1878  return cast_or_null<T>(GetLocalDecl(F, LocalID));
1879  }
1880 
1881  /// Map a global declaration ID into the declaration ID used to
1882  /// refer to this declaration within the given module fule.
1883  ///
1884  /// \returns the global ID of the given declaration as known in the given
1885  /// module file.
1888  serialization::DeclID GlobalID);
1889 
1890  /// Reads a declaration ID from the given position in a record in the
1891  /// given module.
1892  ///
1893  /// \returns The declaration ID read from the record, adjusted to a global ID.
1895  unsigned &Idx);
1896 
1897  /// Reads a declaration from the given position in a record in the
1898  /// given module.
1899  Decl *ReadDecl(ModuleFile &F, const RecordData &R, unsigned &I) {
1900  return GetDecl(ReadDeclID(F, R, I));
1901  }
1902 
1903  /// Reads a declaration from the given position in a record in the
1904  /// given module.
1905  ///
1906  /// \returns The declaration read from this location, casted to the given
1907  /// result type.
1908  template<typename T>
1909  T *ReadDeclAs(ModuleFile &F, const RecordData &R, unsigned &I) {
1910  return cast_or_null<T>(GetDecl(ReadDeclID(F, R, I)));
1911  }
1912 
1913  /// If any redeclarations of \p D have been imported since it was
1914  /// last checked, this digs out those redeclarations and adds them to the
1915  /// redeclaration chain for \p D.
1916  void CompleteRedeclChain(const Decl *D) override;
1917 
1919 
1920  /// Resolve the offset of a statement into a statement.
1921  ///
1922  /// This operation will read a new statement from the external
1923  /// source each time it is called, and is meant to be used via a
1924  /// LazyOffsetPtr (which is used by Decls for the body of functions, etc).
1926 
1927  /// ReadBlockAbbrevs - Enter a subblock of the specified BlockID with the
1928  /// specified cursor. Read the abbreviations that are at the top of the block
1929  /// and then leave the cursor pointing into the block.
1930  static llvm::Error ReadBlockAbbrevs(llvm::BitstreamCursor &Cursor,
1931  unsigned BlockID,
1932  uint64_t *StartOfBlockOffset = nullptr);
1933 
1934  /// Finds all the visible declarations with a given name.
1935  /// The current implementation of this method just loads the entire
1936  /// lookup table as unmaterialized references.
1938  DeclarationName Name) override;
1939 
1940  /// Read all of the declarations lexically stored in a
1941  /// declaration context.
1942  ///
1943  /// \param DC The declaration context whose declarations will be
1944  /// read.
1945  ///
1946  /// \param IsKindWeWant A predicate indicating which declaration kinds
1947  /// we are interested in.
1948  ///
1949  /// \param Decls Vector that will contain the declarations loaded
1950  /// from the external source. The caller is responsible for merging
1951  /// these declarations with any declarations already stored in the
1952  /// declaration context.
1953  void
1955  llvm::function_ref<bool(Decl::Kind)> IsKindWeWant,
1956  SmallVectorImpl<Decl *> &Decls) override;
1957 
1958  /// Get the decls that are contained in a file in the Offset/Length
1959  /// range. \p Length can be 0 to indicate a point at \p Offset instead of
1960  /// a range.
1961  void FindFileRegionDecls(FileID File, unsigned Offset, unsigned Length,
1962  SmallVectorImpl<Decl *> &Decls) override;
1963 
1964  /// Notify ASTReader that we started deserialization of
1965  /// a decl or type so until FinishedDeserializing is called there may be
1966  /// decls that are initializing. Must be paired with FinishedDeserializing.
1967  void StartedDeserializing() override;
1968 
1969  /// Notify ASTReader that we finished the deserialization of
1970  /// a decl or type. Must be paired with StartedDeserializing.
1971  void FinishedDeserializing() override;
1972 
1973  /// Function that will be invoked when we begin parsing a new
1974  /// translation unit involving this external AST source.
1975  ///
1976  /// This function will provide all of the external definitions to
1977  /// the ASTConsumer.
1978  void StartTranslationUnit(ASTConsumer *Consumer) override;
1979 
1980  /// Print some statistics about AST usage.
1981  void PrintStats() override;
1982 
1983  /// Dump information about the AST reader to standard error.
1984  void dump();
1985 
1986  /// Return the amount of memory used by memory buffers, breaking down
1987  /// by heap-backed versus mmap'ed memory.
1988  void getMemoryBufferSizes(MemoryBufferSizes &sizes) const override;
1989 
1990  /// Initialize the semantic source with the Sema instance
1991  /// being used to perform semantic analysis on the abstract syntax
1992  /// tree.
1993  void InitializeSema(Sema &S) override;
1994 
1995  /// Inform the semantic consumer that Sema is no longer available.
1996  void ForgetSema() override { SemaObj = nullptr; }
1997 
1998  /// Retrieve the IdentifierInfo for the named identifier.
1999  ///
2000  /// This routine builds a new IdentifierInfo for the given identifier. If any
2001  /// declarations with this name are visible from translation unit scope, their
2002  /// declarations will be deserialized and introduced into the declaration
2003  /// chain of the identifier.
2004  IdentifierInfo *get(StringRef Name) override;
2005 
2006  /// Retrieve an iterator into the set of all identifiers
2007  /// in all loaded AST files.
2008  IdentifierIterator *getIdentifiers() override;
2009 
2010  /// Load the contents of the global method pool for a given
2011  /// selector.
2012  void ReadMethodPool(Selector Sel) override;
2013 
2014  /// Load the contents of the global method pool for a given
2015  /// selector if necessary.
2016  void updateOutOfDateSelector(Selector Sel) override;
2017 
2018  /// Load the set of namespaces that are known to the external source,
2019  /// which will be used during typo correction.
2020  void ReadKnownNamespaces(
2021  SmallVectorImpl<NamespaceDecl *> &Namespaces) override;
2022 
2023  void ReadUndefinedButUsed(
2024  llvm::MapVector<NamedDecl *, SourceLocation> &Undefined) override;
2025 
2026  void ReadMismatchingDeleteExpressions(llvm::MapVector<
2027  FieldDecl *, llvm::SmallVector<std::pair<SourceLocation, bool>, 4>> &
2028  Exprs) override;
2029 
2031  SmallVectorImpl<VarDecl *> &TentativeDefs) override;
2032 
2034  SmallVectorImpl<const DeclaratorDecl *> &Decls) override;
2035 
2037  SmallVectorImpl<CXXConstructorDecl *> &Decls) override;
2038 
2040 
2043 
2045  llvm::SmallSetVector<Decl *, 4> &Decls) override;
2046 
2048  SmallVectorImpl<std::pair<Selector, SourceLocation>> &Sels) override;
2049 
2051  SmallVectorImpl<std::pair<IdentifierInfo *, WeakInfo>> &WI) override;
2052 
2053  void ReadUsedVTables(SmallVectorImpl<ExternalVTableUse> &VTables) override;
2054 
2056  SmallVectorImpl<std::pair<ValueDecl *,
2057  SourceLocation>> &Pending) override;
2058 
2060  llvm::MapVector<const FunctionDecl *, std::unique_ptr<LateParsedTemplate>>
2061  &LPTMap) override;
2062 
2063  /// Load a selector from disk, registering its ID if it exists.
2064  void LoadSelector(Selector Sel);
2065 
2066  void SetIdentifierInfo(unsigned ID, IdentifierInfo *II);
2068  const SmallVectorImpl<uint32_t> &DeclIDs,
2069  SmallVectorImpl<Decl *> *Decls = nullptr);
2070 
2071  /// Report a diagnostic.
2072  DiagnosticBuilder Diag(unsigned DiagID) const;
2073 
2074  /// Report a diagnostic.
2075  DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID) const;
2076 
2078 
2080  unsigned &Idx) {
2081  return DecodeIdentifierInfo(getGlobalIdentifierID(M, Record[Idx++]));
2082  }
2083 
2085  // Note that we are loading an identifier.
2086  Deserializing AnIdentifier(this);
2087 
2088  return DecodeIdentifierInfo(ID);
2089  }
2090 
2091  IdentifierInfo *getLocalIdentifier(ModuleFile &M, unsigned LocalID);
2092 
2094  unsigned LocalID);
2095 
2096  void resolvePendingMacro(IdentifierInfo *II, const PendingMacroInfo &PMInfo);
2097 
2098  /// Retrieve the macro with the given ID.
2100 
2101  /// Retrieve the global macro ID corresponding to the given local
2102  /// ID within the given module file.
2103  serialization::MacroID getGlobalMacroID(ModuleFile &M, unsigned LocalID);
2104 
2105  /// Read the source location entry with index ID.
2106  bool ReadSLocEntry(int ID) override;
2107 
2108  /// Retrieve the module import location and module name for the
2109  /// given source manager entry ID.
2110  std::pair<SourceLocation, StringRef> getModuleImportLoc(int ID) override;
2111 
2112  /// Retrieve the global submodule ID given a module and its local ID
2113  /// number.
2115  getGlobalSubmoduleID(ModuleFile &M, unsigned LocalID);
2116 
2117  /// Retrieve the submodule that corresponds to a global submodule ID.
2118  ///
2120 
2121  /// Retrieve the module that corresponds to the given module ID.
2122  ///
2123  /// Note: overrides method in ExternalASTSource
2124  Module *getModule(unsigned ID) override;
2125 
2126  /// Retrieve the module file with a given local ID within the specified
2127  /// ModuleFile.
2128  ModuleFile *getLocalModuleFile(ModuleFile &M, unsigned ID);
2129 
2130  /// Get an ID for the given module file.
2131  unsigned getModuleFileID(ModuleFile *M);
2132 
2133  /// Return a descriptor for the corresponding module.
2135 
2136  ExtKind hasExternalDefinitions(const Decl *D) override;
2137 
2138  /// Retrieve a selector from the given module with its local ID
2139  /// number.
2140  Selector getLocalSelector(ModuleFile &M, unsigned LocalID);
2141 
2143 
2145  uint32_t GetNumExternalSelectors() override;
2146 
2147  Selector ReadSelector(ModuleFile &M, const RecordData &Record, unsigned &Idx) {
2148  return getLocalSelector(M, Record[Idx++]);
2149  }
2150 
2151  /// Retrieve the global selector ID that corresponds to this
2152  /// the local selector ID in a given module.
2154  unsigned LocalID) const;
2155 
2156  /// Read the contents of a CXXCtorInitializer array.
2158 
2159  /// Read a AlignPackInfo from raw form.
2162  }
2163 
2164  /// Read a source location from raw form and return it in its
2165  /// originating module file's source location space.
2167  LocSeq *Seq = nullptr) const {
2168  return SourceLocationEncoding::decode(Raw, Seq);
2169  }
2170 
2171  /// Read a source location from raw form.
2174  LocSeq *Seq = nullptr) const {
2176  return TranslateSourceLocation(ModuleFile, Loc);
2177  }
2178 
2179  /// Translate a source location from another module file's source
2180  /// location space into ours.
2182  SourceLocation Loc) const {
2183  if (!ModuleFile.ModuleOffsetMap.empty())
2184  ReadModuleOffsetMap(ModuleFile);
2185  assert(ModuleFile.SLocRemap.find(Loc.getOffset()) !=
2186  ModuleFile.SLocRemap.end() &&
2187  "Cannot find offset to remap.");
2188  SourceLocation::IntTy Remap =
2189  ModuleFile.SLocRemap.find(Loc.getOffset())->second;
2190  return Loc.getLocWithOffset(Remap);
2191  }
2192 
2193  /// Read a source location.
2195  const RecordDataImpl &Record, unsigned &Idx,
2196  LocSeq *Seq = nullptr) {
2197  return ReadSourceLocation(ModuleFile, Record[Idx++], Seq);
2198  }
2199 
2200  /// Read a FileID.
2202  unsigned &Idx) const {
2203  return TranslateFileID(F, FileID::get(Record[Idx++]));
2204  }
2205 
2206  /// Translate a FileID from another module file's FileID space into ours.
2208  assert(FID.ID >= 0 && "Reading non-local FileID.");
2209  return FileID::get(F.SLocEntryBaseID + FID.ID - 1);
2210  }
2211 
2212  /// Read a source range.
2214  unsigned &Idx, LocSeq *Seq = nullptr);
2215 
2216  // Read a string
2217  static std::string ReadString(const RecordData &Record, unsigned &Idx);
2218 
2219  // Skip a string
2220  static void SkipString(const RecordData &Record, unsigned &Idx) {
2221  Idx += Record[Idx] + 1;
2222  }
2223 
2224  // Read a path
2225  std::string ReadPath(ModuleFile &F, const RecordData &Record, unsigned &Idx);
2226 
2227  // Read a path
2228  std::string ReadPath(StringRef BaseDirectory, const RecordData &Record,
2229  unsigned &Idx);
2230 
2231  // Skip a path
2232  static void SkipPath(const RecordData &Record, unsigned &Idx) {
2233  SkipString(Record, Idx);
2234  }
2235 
2236  /// Read a version tuple.
2237  static VersionTuple ReadVersionTuple(const RecordData &Record, unsigned &Idx);
2238 
2240  unsigned &Idx);
2241 
2242  /// Reads a statement.
2243  Stmt *ReadStmt(ModuleFile &F);
2244 
2245  /// Reads an expression.
2246  Expr *ReadExpr(ModuleFile &F);
2247 
2248  /// Reads a sub-statement operand during statement reading.
2250  assert(ReadingKind == Read_Stmt &&
2251  "Should be called only during statement reading!");
2252  // Subexpressions are stored from last to first, so the next Stmt we need
2253  // is at the back of the stack.
2254  assert(!StmtStack.empty() && "Read too many sub-statements!");
2255  return StmtStack.pop_back_val();
2256  }
2257 
2258  /// Reads a sub-expression operand during statement reading.
2259  Expr *ReadSubExpr();
2260 
2261  /// Reads a token out of a record.
2262  Token ReadToken(ModuleFile &M, const RecordDataImpl &Record, unsigned &Idx);
2263 
2264  /// Reads the macro record located at the given offset.
2266 
2267  /// Determine the global preprocessed entity ID that corresponds to
2268  /// the given local ID within the given module.
2270  getGlobalPreprocessedEntityID(ModuleFile &M, unsigned LocalID) const;
2271 
2272  /// Add a macro to deserialize its macro directive history.
2273  ///
2274  /// \param II The name of the macro.
2275  /// \param M The module file.
2276  /// \param MacroDirectivesOffset Offset of the serialized macro directive
2277  /// history.
2279  uint32_t MacroDirectivesOffset);
2280 
2281  /// Read the set of macros defined by this external macro source.
2282  void ReadDefinedMacros() override;
2283 
2284  /// Update an out-of-date identifier.
2285  void updateOutOfDateIdentifier(IdentifierInfo &II) override;
2286 
2287  /// Note that this identifier is up-to-date.
2289 
2290  /// Load all external visible decls in the given DeclContext.
2291  void completeVisibleDeclsMap(const DeclContext *DC) override;
2292 
2293  /// Retrieve the AST context that this AST reader supplements.
2295  assert(ContextObj && "requested AST context when not loading AST");
2296  return *ContextObj;
2297  }
2298 
2299  // Contains the IDs for declarations that were requested before we have
2300  // access to a Sema object.
2302 
2303  /// Retrieve the semantic analysis object used to analyze the
2304  /// translation unit in which the precompiled header is being
2305  /// imported.
2306  Sema *getSema() { return SemaObj; }
2307 
2308  /// Get the identifier resolver used for name lookup / updates
2309  /// in the translation unit scope. We have one of these even if we don't
2310  /// have a Sema object.
2312 
2313  /// Retrieve the identifier table associated with the
2314  /// preprocessor.
2316 
2317  /// Record that the given ID maps to the given switch-case
2318  /// statement.
2319  void RecordSwitchCaseID(SwitchCase *SC, unsigned ID);
2320 
2321  /// Retrieve the switch-case statement with the given ID.
2322  SwitchCase *getSwitchCaseWithID(unsigned ID);
2323 
2324  void ClearSwitchCaseIDs();
2325 
2326  /// Cursors for comments blocks.
2327  SmallVector<std::pair<llvm::BitstreamCursor,
2329 
2330  /// Loads comments ranges.
2331  void ReadComments() override;
2332 
2333  /// Visit all the input files of the given module file.
2335  bool IncludeSystem, bool Complain,
2336  llvm::function_ref<void(const serialization::InputFile &IF,
2337  bool isSystem)> Visitor);
2338 
2339  /// Visit all the top-level module maps loaded when building the given module
2340  /// file.
2342  llvm::function_ref<void(FileEntryRef)> Visitor);
2343 
2344  bool isProcessingUpdateRecords() { return ProcessingUpdateRecords; }
2345 };
2346 
2347 } // namespace clang
2348 
2349 #endif // LLVM_CLANG_SERIALIZATION_ASTREADER_H
clang::ASTReader::getTotalNumIdentifiers
unsigned getTotalNumIdentifiers() const
Returns the number of identifiers found in the chain.
Definition: ASTReader.h:1787
clang::serialization::ReadMethodPoolVisitor
Definition: ASTReader.cpp:8202
clang::ASTReader::getFileManager
FileManager & getFileManager() const
Definition: ASTReader.h:1546
clang::ASTReaderListener::ReadLanguageOptions
virtual bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain, bool AllowCompatibleDifferences)
Receives the language options.
Definition: ASTReader.h:131
clang::ASTReader::DecodeIdentifierInfo
IdentifierInfo * DecodeIdentifierInfo(serialization::IdentifierID ID)
Definition: ASTReader.cpp:8579
clang::ChainedASTReaderListener::ReadLanguageOptions
bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain, bool AllowCompatibleDifferences) override
Receives the language options.
Definition: ASTReader.cpp:171
clang::ASTReader::ReadSourceLocation
SourceLocation ReadSourceLocation(ModuleFile &ModuleFile, const RecordDataImpl &Record, unsigned &Idx, LocSeq *Seq=nullptr)
Read a source location.
Definition: ASTReader.h:2194
clang::ASTUnit
Utility class for loading a ASTContext from an AST file.
Definition: ASTUnit.h:89
clang::ChainedASTReaderListener::readModuleFileExtension
void readModuleFileExtension(const ModuleFileExtensionMetadata &Metadata) override
Indicates that a particular module file extension has been read.
Definition: ASTReader.cpp:257
clang::ASTReader::getContext
ASTContext & getContext()
Retrieve the AST context that this AST reader supplements.
Definition: ASTReader.h:2294
clang::ASTReaderListener::needsInputFileVisitation
virtual bool needsInputFileVisitation()
Returns true if this ASTReaderListener wants to receive the input files of the AST file via visitInpu...
Definition: ASTReader.h:199
clang::GlobalModuleIndex
A global index for a set of module files, providing information about the identifiers within those mo...
Definition: GlobalModuleIndex.h:54
clang::Sema::AlignPackInfo::getFromRawEncoding
static AlignPackInfo getFromRawEncoding(unsigned Encoding)
Definition: Sema.h:526
clang::ASTReader::resetForReload
void resetForReload()
Reset reader for a reload try.
Definition: ASTReader.h:1682
clang::ExternalPreprocessorSource
Abstract interface for external sources of preprocessor information.
Definition: ExternalPreprocessorSource.h:26
clang::ExternalPreprocessingRecordSource
An abstract class that should be subclassed by any external source of preprocessing record entries.
Definition: PreprocessingRecord.h:277
clang::ASTReader::ModuleDeclIterator
Definition: ASTReader.h:1433
clang::DiagnosticBuilder
A little helper class used to produce diagnostics.
Definition: Diagnostic.h:1266
clang::FileEntryRef
A reference to a FileEntry that includes the name of the file as it was accessed by the FileManager's...
Definition: FileEntry.h:62
clang::ASTReader::ClearSwitchCaseIDs
void ClearSwitchCaseIDs()
Definition: ASTReader.cpp:9124
clang::serialization::ModuleManager
Manages the set of modules loaded by an AST reader.
Definition: ModuleManager.h:47
clang::ASTReader::ModuleDeclIterator::operator==
bool operator==(const ModuleDeclIterator &RHS) const
Definition: ASTReader.h:1454
clang::ASTReader::operator=
ASTReader & operator=(const ASTReader &)=delete
clang::ASTReader::HadErrors
@ HadErrors
The AST file has errors.
Definition: ASTReader.h:389
clang::DeclaratorContext::File
@ File
Error
llvm::Error Error
Definition: ByteCodeEmitter.cpp:20
clang::ASTReader::GetExternalDeclStmt
Stmt * GetExternalDeclStmt(uint64_t Offset) override
Resolve the offset of a statement into a statement.
Definition: ASTReader.cpp:7569
clang::ASTReader::makeModuleVisible
void makeModuleVisible(Module *Mod, Module::NameVisibilityKind NameVisibility, SourceLocation ImportLoc)
Make the entities in the given module and any of its (non-explicit) submodules visible to name lookup...
Definition: ASTReader.cpp:4087
clang::SourceRange
A trivial tuple used to represent a source range.
Definition: SourceLocation.h:210
string
string(SUBSTRING ${CMAKE_CURRENT_BINARY_DIR} 0 ${PATH_LIB_START} PATH_HEAD) string(SUBSTRING $
Definition: CMakeLists.txt:22
clang::PreprocessorOptions
PreprocessorOptions - This class is used for passing the various options used in preprocessor initial...
Definition: PreprocessorOptions.h:65
clang::DeclContext
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1389
OpenCLOptions.h
clang::ASTReader::UpdateSema
void UpdateSema()
Update the state of Sema after loading some additional modules.
Definition: ASTReader.cpp:7957
clang::ASTReader::getTotalNumDecls
unsigned getTotalNumDecls() const
Returns the number of declarations found in the chain.
Definition: ASTReader.h:1802
clang::ASTReader::getTotalNumMacros
unsigned getTotalNumMacros() const
Returns the number of macros found in the chain.
Definition: ASTReader.h:1792
clang::TypeLocReader
Definition: ASTReader.cpp:6510
clang::serialization::ModuleManager::addInMemoryBuffer
void addInMemoryBuffer(StringRef FileName, std::unique_ptr< llvm::MemoryBuffer > Buffer)
Add an in-memory buffer the list of known buffers.
Definition: ModuleManager.cpp:291
clang::ASTReaderListener::ReadPreprocessorOptions
virtual bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, bool Complain, std::string &SuggestedPredefines)
Receives the preprocessor options.
Definition: ASTReader.h:183
clang::ASTReader::ReadPendingInstantiations
void ReadPendingInstantiations(SmallVectorImpl< std::pair< ValueDecl *, SourceLocation >> &Pending) override
Definition: ASTReader.cpp:8476
clang::ASTReader::Failure
@ Failure
The AST file itself appears corrupted.
Definition: ASTReader.h:372
clang::serialization::ModuleFile::SLocEntryBaseID
int SLocEntryBaseID
The base ID in the source manager's view of this module.
Definition: ModuleFile.h:260
clang::serialization::reader::ASTIdentifierLookupTrait
Class that performs lookup for an identifier stored in an AST file.
Definition: ASTReaderInternals.h:158
clang::ASTReader::FindExternalVisibleDeclsByName
bool FindExternalVisibleDeclsByName(const DeclContext *DC, DeclarationName Name) override
Finds all the visible declarations with a given name.
Definition: ASTReader.cpp:7703
llvm::SmallVector< uint64_t, 64 >
clang::ASTReader::ReadSubStmt
Stmt * ReadSubStmt()
Reads a sub-statement operand during statement reading.
Definition: ASTReader.h:2249
clang::ASTReader::ReadMismatchingDeleteExpressions
void ReadMismatchingDeleteExpressions(llvm::MapVector< FieldDecl *, llvm::SmallVector< std::pair< SourceLocation, bool >, 4 >> &Exprs) override
Definition: ASTReader.cpp:8349
clang::SourceLocation
Encodes a location in the source.
Definition: SourceLocation.h:86
clang::SourceLocation::getLocWithOffset
SourceLocation getLocWithOffset(IntTy Offset) const
Return a source location with the specified offset from this SourceLocation.
Definition: SourceLocation.h:134
clang::ASTReader::GetLocalDeclAs
T * GetLocalDeclAs(ModuleFile &F, uint32_t LocalID)
Reads a declaration with the given local ID in the given module.
Definition: ASTReader.h:1877
clang::ASTRecordReader
An object for streaming information from a record.
Definition: ASTRecordReader.h:31
clang::ASTReader::RecordData
SmallVector< uint64_t, 64 > RecordData
Definition: ASTReader.h:361
clang::NamedDecl
This represents a decl that may have a name.
Definition: Decl.h:247
clang::ChainedASTReaderListener::ReadFileSystemOptions
bool ReadFileSystemOptions(const FileSystemOptions &FSOpts, bool Complain) override
Receives the file system options.
Definition: ASTReader.cpp:196
IdentifierResolver.h
clang::ASTReader::getSema
Sema * getSema()
Retrieve the semantic analysis object used to analyze the translation unit in which the precompiled h...
Definition: ASTReader.h:2306
clang::ASTReader::ReadSelector
Selector ReadSelector(ModuleFile &M, const RecordData &Record, unsigned &Idx)
Definition: ASTReader.h:2147
clang::ASTReader::get
IdentifierInfo * get(StringRef Name) override
Retrieve the IdentifierInfo for the named identifier.
Definition: ASTReader.cpp:8061
clang::QualType
A (possibly-)qualified type.
Definition: Type.h:737
clang::ASTReader::visitTopLevelModuleMaps
void visitTopLevelModuleMaps(serialization::ModuleFile &MF, llvm::function_ref< void(FileEntryRef)> Visitor)
Visit all the top-level module maps loaded when building the given module file.
Definition: ASTReader.cpp:9215
clang::ASTReaderListener::ReadTargetOptions
virtual bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain, bool AllowCompatibleDifferences)
Receives the target options.
Definition: ASTReader.h:141
clang::ASTReader::visitInputFiles
void visitInputFiles(serialization::ModuleFile &MF, bool IncludeSystem, bool Complain, llvm::function_ref< void(const serialization::InputFile &IF, bool isSystem)> Visitor)
Visit all the input files of the given module file.
Definition: ASTReader.cpp:9200
clang::ASTReader::ReadAST
ASTReadResult ReadAST(StringRef FileName, ModuleKind Type, SourceLocation ImportLoc, unsigned ClientLoadCapabilities, SmallVectorImpl< ImportedSubmodule > *Imported=nullptr)
Load the AST file designated by the given file name.
Definition: ASTReader.cpp:4242
clang::ASTReader::getIdentifiers
IdentifierIterator * getIdentifiers() override
Retrieve an iterator into the set of all identifiers in all loaded AST files.
Definition: ASTReader.cpp:8186
clang::ASTReader::GetExistingDecl
Decl * GetExistingDecl(serialization::DeclID ID)
Resolve a declaration ID into a declaration.
Definition: ASTReader.cpp:7490
Cursor
Cursor
Definition: SerializedDiagnosticReader.cpp:109
clang::ASTReader::TranslateFileID
FileID TranslateFileID(ModuleFile &F, FileID FID) const
Translate a FileID from another module file's FileID space into ours.
Definition: ASTReader.h:2207
clang::FieldDecl
Represents a member of a struct/union/class.
Definition: Decl.h:2930
clang::ASTReader::ReadExtVectorDecls
void ReadExtVectorDecls(SmallVectorImpl< TypedefNameDecl * > &Decls) override
Read the set of ext_vector type declarations known to the external Sema source.
Definition: ASTReader.cpp:8396
Filename
StringRef Filename
Definition: Format.cpp:2715
clang::DiagnosticsEngine
Concrete class used by the front-end to report problems and issues.
Definition: Diagnostic.h:192
clang::ASTReader::getSourceDescriptor
llvm::Optional< ASTSourceDescriptor > getSourceDescriptor(unsigned ID) override
Return a descriptor for the corresponding module.
Definition: ASTReader.cpp:8735
clang::ASTReader::ARR_ConfigurationMismatch
@ ARR_ConfigurationMismatch
The client can handle an AST file that cannot load because it's compiled configuration doesn't match ...
Definition: ASTReader.h:1573
clang::ASTReader::readIdentifier
IdentifierInfo * readIdentifier(ModuleFile &M, const RecordData &Record, unsigned &Idx)
Definition: ASTReader.h:2079
clang::ASTReader::ModuleReverseIterator
ModuleManager::ModuleReverseIterator ModuleReverseIterator
Definition: ASTReader.h:397
clang::Module::NameVisibilityKind
NameVisibilityKind
Describes the visibility of the various names within a particular module.
Definition: Module.h:334
clang::ChainedASTReaderListener::ReadTargetOptions
bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain, bool AllowCompatibleDifferences) override
Receives the target options.
Definition: ASTReader.cpp:180
clang::ASTReader::ReadVersionTuple
static VersionTuple ReadVersionTuple(const RecordData &Record, unsigned &Idx)
Read a version tuple.
Definition: ASTReader.cpp:9077
clang::ASTReader::ASTReader
ASTReader(Preprocessor &PP, InMemoryModuleCache &ModuleCache, ASTContext *Context, const PCHContainerReader &PCHContainerRdr, ArrayRef< std::shared_ptr< ModuleFileExtension >> Extensions, StringRef isysroot="", DisableValidationForModuleKind DisableValidationKind=DisableValidationForModuleKind::None, bool AllowASTWithCompilerErrors=false, bool AllowConfigurationMismatch=false, bool ValidateSystemInputs=false, bool ValidateASTInputFilesContent=false, bool UseGlobalIndex=true, std::unique_ptr< llvm::Timer > ReadTimer={})
Load the AST file and validate its contents against the given Preprocessor.
Definition: ASTReader.cpp:9794
clang::ASTReader::getOriginalSourceFile
StringRef getOriginalSourceFile()
Retrieve the name of the original source file name for the primary module file.
Definition: ASTReader.h:1720
clang::ASTReader::getPreprocessor
Preprocessor & getPreprocessor() const
Retrieve the preprocessor.
Definition: ASTReader.h:1716
clang::ASTReader::getMacro
MacroInfo * getMacro(serialization::MacroID ID)
Retrieve the macro with the given ID.
Definition: ASTReader.cpp:8629
llvm::Optional< ModuleKind >
clang::PCHValidator::ReadCounter
void ReadCounter(const serialization::ModuleFile &M, unsigned Value) override
Receives COUNTER value.
Definition: ASTReader.cpp:838
clang::ComparisonCategoryType::First
@ First
clang::ASTReader::ReadPreprocessedEntity
PreprocessedEntity * ReadPreprocessedEntity(unsigned Index) override
Read a preallocated preprocessed entity from the external source.
Definition: ASTReader.cpp:6018
clang::ASTReader::TranslateSourceLocation
SourceLocation TranslateSourceLocation(ModuleFile &ModuleFile, SourceLocation Loc) const
Translate a source location from another module file's source location space into ours.
Definition: ASTReader.h:2181
llvm::SmallPtrSet
Definition: ASTContext.h:82
clang::MacroInfo
Encapsulates the data about a macro definition (e.g.
Definition: MacroInfo.h:39
clang::SimpleASTReaderListener::ReadPreprocessorOptions
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, bool Complain, std::string &SuggestedPredefines) override
Receives the preprocessor options.
Definition: ASTReader.cpp:797
clang::PCHValidator::PCHValidator
PCHValidator(Preprocessor &PP, ASTReader &Reader)
Definition: ASTReader.h:280
clang::ASTReader::getKeyDeclaration
const Decl * getKeyDeclaration(const Decl *D)
Definition: ASTReader.h:1285
clang::ASTReader::getGlobalDeclID
serialization::DeclID getGlobalDeclID(ModuleFile &F, serialization::LocalDeclID LocalID) const
Map from a local declaration ID within a given module to a global declaration ID.
Definition: ASTReader.cpp:7380
ContinuousRangeMap.h
clang::ASTReader::ReadSLocEntry
bool ReadSLocEntry(int ID) override
Read the source location entry with index ID.
Definition: ASTReader.cpp:1423
clang::serialization::ModuleManager::ModuleReverseIterator
llvm::pointee_iterator< SmallVectorImpl< std::unique_ptr< ModuleFile > >::reverse_iterator > ModuleReverseIterator
Definition: ModuleManager.h:134
clang::Token
Token - This structure provides full information about a lexed token.
Definition: Token.h:35
clang::ASTReader::getModule
Module * getModule(unsigned ID) override
Retrieve the module that corresponds to the given module ID.
Definition: ASTReader.cpp:8700
clang::DeclarationName
The name of a declaration.
Definition: DeclarationName.h:144
clang::ASTReaderListener::~ASTReaderListener
virtual ~ASTReaderListener()
clang::PCHContainerReader
This abstract interface provides operations for unwrapping containers for serialized ASTs (precompile...
Definition: PCHContainerOperations.h:55
clang::DisableValidationForModuleKind::None
@ None
Perform validation, don't disable it.
clang::SourceManager
This class handles loading and caching of source files into memory.
Definition: SourceManager.h:636
clang::ASTReader::CompleteRedeclChain
void CompleteRedeclChain(const Decl *D) override
If any redeclarations of D have been imported since it was last checked, this digs out those redeclar...
Definition: ASTReader.cpp:7250
clang::ASTReader::FinishedDeserializing
void FinishedDeserializing() override
Notify ASTReader that we finished the deserialization of a decl or type.
Definition: ASTReader.cpp:9716
clang::serialization::MacroID
uint32_t MacroID
An ID number that refers to a macro in an AST file.
Definition: ASTBitCodes.h:140
clang::ASTReader::GetDecl
Decl * GetDecl(serialization::DeclID ID)
Resolve a declaration ID into a declaration, potentially building a new declaration.
Definition: ASTReader.cpp:7515
clang::ASTReader::ReadDefinedMacros
void ReadDefinedMacros() override
Read the set of macros defined by this external macro source.
Definition: ASTReader.cpp:1968
clang::ASTReader::makeNamesVisible
void makeNamesVisible(const HiddenNames &Names, Module *Owner)
Make the names within this set of hidden names visible.
Definition: ASTReader.cpp:4073
clang::Type
The base class of the type hierarchy.
Definition: Type.h:1565
clang::ChainedASTReaderListener::ReadCounter
void ReadCounter(const serialization::ModuleFile &M, unsigned Value) override
Receives COUNTER value.
Definition: ASTReader.cpp:219
Offset
unsigned Offset
Definition: Format.cpp:2717
clang::FileSystemOptions
Keeps track of options that affect how file operations are performed.
Definition: FileSystemOptions.h:22
clang::ASTReader::ReadDelegatingConstructors
void ReadDelegatingConstructors(SmallVectorImpl< CXXConstructorDecl * > &Decls) override
Read the set of delegating constructors known to the external Sema source.
Definition: ASTReader.cpp:8385
clang::ASTReader::ARR_VersionMismatch
@ ARR_VersionMismatch
The client can handle an AST file that cannot load because it was built with a different version of C...
Definition: ASTReader.h:1568
clang::CodeGen::AlignmentSource::Decl
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
clang::ASTReader::ReadWeakUndeclaredIdentifiers
void ReadWeakUndeclaredIdentifiers(SmallVectorImpl< std::pair< IdentifierInfo *, WeakInfo >> &WI) override
Definition: ASTReader.cpp:8446
clang::SourceLocation::IntTy
int32_t IntTy
Definition: SourceLocation.h:94
clang::ASTReader::StartTranslationUnit
void StartTranslationUnit(ASTConsumer *Consumer) override
Function that will be invoked when we begin parsing a new translation unit involving this external AS...
Definition: ASTReader.cpp:7780
clang::ASTReader::getLoadedLookupTables
const serialization::reader::DeclContextLookupTable * getLoadedLookupTables(DeclContext *Primary) const
Get the loaded lookup tables for Primary, if any.
Definition: ASTReader.cpp:7754
clang::ContinuousRangeMap::find
iterator find(Int K)
Definition: ContinuousRangeMap.h:93
clang::ChainedASTReaderListener::ReadPreprocessorOptions
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, bool Complain, std::string &SuggestedPredefines) override
Receives the preprocessor options.
Definition: ASTReader.cpp:211
clang::ASTReader::ReadUndefinedButUsed
void ReadUndefinedButUsed(llvm::MapVector< NamedDecl *, SourceLocation > &Undefined) override
Load the set of used but not defined functions or variables with internal linkage,...
Definition: ASTReader.cpp:8339
clang::ASTReader::GetExternalDecl
Decl * GetExternalDecl(uint32_t ID) override
Resolve a declaration ID into a declaration, potentially building a new declaration.
Definition: ASTReader.cpp:7246
clang::ASTReader::addListener
void addListener(std::unique_ptr< ASTReaderListener > L)
Add an AST callback listener.
Definition: ASTReader.h:1634
clang::ChainedASTReaderListener::visitModuleFile
void visitModuleFile(StringRef Filename, serialization::ModuleKind Kind) override
This is called for each AST file loaded.
Definition: ASTReader.cpp:235
clang::ASTReader::ReadKnownNamespaces
void ReadKnownNamespaces(SmallVectorImpl< NamespaceDecl * > &Namespaces) override
Load the set of namespaces that are known to the external source, which will be used during typo corr...
Definition: ASTReader.cpp:8328
clang::serialization::SubmoduleID
uint32_t SubmoduleID
An ID number that refers to a submodule in a module file.
Definition: ASTBitCodes.h:171
clang::ASTReader::GetLocalDecl
Decl * GetLocalDecl(ModuleFile &F, uint32_t LocalID)
Reads a declaration with the given local ID in the given module.
Definition: ASTReader.h:1869
clang::ASTReader::ModuleFile
serialization::ModuleFile ModuleFile
Definition: ASTReader.h:392
clang::Decl::Kind
Kind
Lists the kind of concrete classes of Decl.
Definition: DeclBase.h:86
clang::ASTReader::Success
@ Success
The control block was read successfully.
Definition: ASTReader.h:369
clang::ASTReaderListener::ReadModuleMapFile
virtual void ReadModuleMapFile(StringRef ModuleMapPath)
Definition: ASTReader.h:126
clang::Module
Describes a module or submodule.
Definition: Module.h:98
clang::ASTReaderListener::ReadFullVersionInformation
virtual bool ReadFullVersionInformation(StringRef FullVersion)
Receives the full Clang version information.
Definition: ASTReader.h:121
clang::PCHValidator
ASTReaderListener implementation to validate the information of the PCH file against an initialized P...
Definition: ASTReader.h:275
clang::ASTReaderListener::readModuleFileExtension
virtual void readModuleFileExtension(const ModuleFileExtensionMetadata &Metadata)
Indicates that a particular module file extension has been read.
Definition: ASTReader.h:225
clang::ASTReader::ReadComments
void ReadComments() override
Loads comments ranges.
Definition: ASTReader.cpp:9128
clang::ASTReader::ImportedSubmodule::ImportLoc
SourceLocation ImportLoc
Definition: ASTReader.h:921
clang::ASTReaderListener::needsSystemInputFileVisitation
virtual bool needsSystemInputFileVisitation()
Returns true if this ASTReaderListener wants to receive the system input files of the AST file via vi...
Definition: ASTReader.h:203
clang::ASTReader::GetIdentifier
IdentifierInfo * GetIdentifier(serialization::IdentifierID ID) override
Definition: ASTReader.h:2084
clang::ExternalHeaderFileInfoSource
An external source of header file information, which may supply information about header files alread...
Definition: HeaderSearch.h:133
clang::ASTReader::getGlobalTypeID
serialization::TypeID getGlobalTypeID(ModuleFile &F, unsigned LocalID) const
Map a local type ID within a given AST file into a global type ID.
Definition: ASTReader.cpp:7175
clang::ASTReader::getModuleFileID
unsigned getModuleFileID(ModuleFile *M)
Get an ID for the given module file.
Definition: ASTReader.cpp:8717
clang::ASTReader::ReadSourceLocation
SourceLocation ReadSourceLocation(ModuleFile &ModuleFile, SourceLocation::UIntTy Raw, LocSeq *Seq=nullptr) const
Read a source location from raw form.
Definition: ASTReader.h:2172
clang::ASTReaderListener::visitInputFile
virtual bool visitInputFile(StringRef Filename, bool isSystem, bool isOverridden, bool isExplicitModule)
if needsInputFileVisitation returns true, this is called for each non-system input file of the AST Fi...
Definition: ASTReader.h:211
hlsl::uint64_t
unsigned long uint64_t
Definition: hlsl_basic_types.h:25
clang::ASTReader::getModuleManager
ModuleManager & getModuleManager()
Retrieve the module manager.
Definition: ASTReader.h:1713
clang::ASTReader::ReadUsedVTables
void ReadUsedVTables(SmallVectorImpl< ExternalVTableUse > &VTables) override
Read the set of used vtables known to the external Sema source.
Definition: ASTReader.cpp:8464
clang::ASTReader::ReadSkippedRange
SourceRange ReadSkippedRange(unsigned Index) override
Read a preallocated skipped range from the external source.
Definition: ASTReader.cpp:6004
clang::ASTReader::updateOutOfDateIdentifier
void updateOutOfDateIdentifier(IdentifierInfo &II) override
Update an out-of-date identifier.
Definition: ASTReader.cpp:2086
clang::serialization::InputFile
The input file that has been loaded from this AST file, along with bools indicating whether this was ...
Definition: ModuleFile.h:65
clang::ASTReader::getTotalNumSubmodules
unsigned getTotalNumSubmodules() const
Returns the number of submodules known.
Definition: ASTReader.h:1807
clang::ASTReader::ARR_None
@ ARR_None
The client can't handle any AST loading failures.
Definition: ASTReader.h:1556
clang::ASTReader::getKeyDeclaration
Decl * getKeyDeclaration(Decl *D)
Returns the first key declaration for the given declaration.
Definition: ASTReader.h:1275
clang::ASTReader::getGlobalSubmoduleID
serialization::SubmoduleID getGlobalSubmoduleID(ModuleFile &M, unsigned LocalID)
Retrieve the global submodule ID given a module and its local ID number.
Definition: ASTReader.cpp:8671
clang::index::SymbolKind::Module
@ Module
clang::ASTContext
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:209
clang::PCHValidator::ReadLanguageOptions
bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain, bool AllowCompatibleDifferences) override
Receives the language options.
Definition: ASTReader.cpp:442
clang::ASTReader::getGlobalSelectorID
serialization::SelectorID getGlobalSelectorID(ModuleFile &F, unsigned LocalID) const
Retrieve the global selector ID that corresponds to this the local selector ID in a given module.
Definition: ASTReader.cpp:8799
Version.h
clang::serialization::ModuleManager::ModuleIterator
llvm::pointee_iterator< SmallVectorImpl< std::unique_ptr< ModuleFile > >::iterator > ModuleIterator
Definition: ModuleManager.h:130
Diagnostic.h
clang::ASTReaderListener::ReadDiagnosticOptions
virtual bool ReadDiagnosticOptions(IntrusiveRefCntPtr< DiagnosticOptions > DiagOpts, bool Complain)
Receives the diagnostic options.
Definition: ASTReader.h:151
clang::ASTIdentifierIterator
An identifier-lookup iterator that enumerates all of the identifiers stored within a set of AST files...
Definition: ASTReader.cpp:8100
clang::ASTReader::hasExternalDefinitions
ExtKind hasExternalDefinitions(const Decl *D) override
Definition: ASTReader.cpp:8753
clang::ASTConsumer
ASTConsumer - This is an abstract interface that should be implemented by clients that read ASTs.
Definition: ASTConsumer.h:33
clang::Sema::AlignPackInfo
Definition: Sema.h:487
clang::ExternalSemaSource
An abstract interface that should be implemented by external AST sources that also provide informatio...
Definition: ExternalSemaSource.h:50
clang::ASTReader::ImportedSubmodule::ID
serialization::SubmoduleID ID
Definition: ASTReader.h:920
clang::Decl::getCanonicalDecl
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
Definition: DeclBase.h:943
clang::DisableValidationForModuleKind
DisableValidationForModuleKind
Whether to disable the normal validation performed on precompiled headers and module files when they ...
Definition: PreprocessorOptions.h:47
clang::ChainedASTReaderListener::visitInputFile
bool visitInputFile(StringRef Filename, bool isSystem, bool isOverridden, bool isExplicitModule) override
if needsInputFileVisitation returns true, this is called for each non-system input file of the AST Fi...
Definition: ASTReader.cpp:241
clang::ASTReader::ARR_OutOfDate
@ ARR_OutOfDate
The client can handle an AST file that cannot load because it is out-of-date relative to its input fi...
Definition: ASTReader.h:1564
clang::serialization::ModuleFile::SLocRemap
ContinuousRangeMap< SourceLocation::UIntTy, SourceLocation::IntTy, 2 > SLocRemap
Remapping table for source locations in this module.
Definition: ModuleFile.h:278
clang::ASTReader::getModuleImportLoc
std::pair< SourceLocation, StringRef > getModuleImportLoc(int ID) override
Retrieve the module import location and module name for the given source manager entry ID.
Definition: ASTReader.cpp:1603
clang::api_notes::BlockID
BlockID
The various types of blocks that can occur within a API notes file.
Definition: APINotesFormat.h:38
IdentifierTable.h
clang::ContinuousRangeMap::end
iterator end()
Definition: ContinuousRangeMap.h:89
clang::ASTReader::getSubmodule
Module * getSubmodule(serialization::SubmoduleID GlobalID)
Retrieve the submodule that corresponds to a global submodule ID.
Definition: ASTReader.cpp:8686
Type.h
clang::ChainedASTReaderListener::ReadDiagnosticOptions
bool ReadDiagnosticOptions(IntrusiveRefCntPtr< DiagnosticOptions > DiagOpts, bool Complain) override
Receives the diagnostic options.
Definition: ASTReader.cpp:189
clang::ASTReader::updateOutOfDateSelector
void updateOutOfDateSelector(Selector Sel) override
Load the contents of the global method pool for a given selector if necessary.
Definition: ASTReader.cpp:8323
clang::ASTReader::ARR_Missing
@ ARR_Missing
The client can handle an AST file that cannot load because it is missing.
Definition: ASTReader.h:1560
clang::IdentifierIterator
An iterator that walks over all of the known identifiers in the lookup table.
Definition: IdentifierTable.h:516
clang::ASTReader::isAcceptableASTFile
static bool isAcceptableASTFile(StringRef Filename, FileManager &FileMgr, const InMemoryModuleCache &ModuleCache, const PCHContainerReader &PCHContainerRdr, const LangOptions &LangOpts, const TargetOptions &TargetOpts, const PreprocessorOptions &PPOpts, StringRef ExistingModuleCachePath, bool RequireStrictOptionMatches=false)
Determine whether the given AST file is acceptable to load into a translation unit with the given lan...
Definition: ASTReader.cpp:5478
clang::ASTReaderListener::ReadModuleName
virtual void ReadModuleName(StringRef ModuleName)
Definition: ASTReader.h:125
clang::getClangFullRepositoryVersion
std::string getClangFullRepositoryVersion()
Retrieves the full repository version that is an amalgamation of the information in getClangRepositor...
Definition: Version.cpp:60
clang::serialization::IdentifierID
uint32_t IdentifierID
An ID number that refers to an identifier in an AST file.
Definition: ASTBitCodes.h:60
clang::serialization::TypeID
uint32_t TypeID
An ID number that refers to a type in an AST file.
Definition: ASTBitCodes.h:85
clang::ASTReader::getDiags
DiagnosticsEngine & getDiags() const
Definition: ASTReader.h:1547
clang::PCHValidator::ReadHeaderSearchOptions
bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts, StringRef SpecificModuleCachePath, bool Complain) override
Receives the header search options.
Definition: ASTReader.cpp:829
clang::ASTReader::loadGlobalIndex
bool loadGlobalIndex()
Attempts to load the global index.
Definition: ASTReader.cpp:4151
clang::ASTReader::getModuleFileLevelDecls
llvm::iterator_range< ModuleDeclIterator > getModuleFileLevelDecls(ModuleFile &Mod)
Definition: ASTReader.cpp:5997
llvm::DenseSet< LoadedMacroInfo >
clang::ASTReader::dump
void dump()
Dump information about the AST reader to standard error.
Definition: ASTReader.cpp:7895
clang::CXXTemporary
Represents a C++ temporary.
Definition: ExprCXX.h:1387
clang::ASTReader::ARR_TreatModuleWithErrorsAsOutOfDate
@ ARR_TreatModuleWithErrorsAsOutOfDate
If a module file is marked with errors treat it as out-of-date so the caller can rebuild it.
Definition: ASTReader.h:1577
clang::SwitchCase
Definition: Stmt.h:1558
clang::ASTReader::ReadUnusedFileScopedDecls
void ReadUnusedFileScopedDecls(SmallVectorImpl< const DeclaratorDecl * > &Decls) override
Read the set of unused file-scope declarations known to the external Sema source.
Definition: ASTReader.cpp:8374
clang::ASTReader::getTotalNumPreprocessedEntities
unsigned getTotalNumPreprocessedEntities() const
Returns the number of preprocessed entities known to the AST reader.
Definition: ASTReader.h:1818
clang::ASTWriter
Writes an AST file containing the contents of a translation unit.
Definition: ASTWriter.h:85
clang::ASTReader::isGlobalIndexUnavailable
bool isGlobalIndexUnavailable() const
Determine whether we tried to load the global index, but failed, e.g., because it is out-of-date or d...
Definition: ASTReader.cpp:4176
clang::ASTReader::ListenerScope
RAII object to temporarily add an AST callback listener.
Definition: ASTReader.h:1642
clang::ASTReader::Diag
DiagnosticBuilder Diag(unsigned DiagID) const
Report a diagnostic.
Definition: ASTReader.cpp:9096
clang::IdentifierResolver
IdentifierResolver - Keeps track of shadowed decls on enclosing scopes.
Definition: IdentifierResolver.h:38
clang::ASTReader::ReadLateParsedTemplates
void ReadLateParsedTemplates(llvm::MapVector< const FunctionDecl *, std::unique_ptr< LateParsedTemplate >> &LPTMap) override
Read the set of late parsed template functions for this source.
Definition: ASTReader.cpp:8488
clang::ASTReader::ImportedSubmodule
Definition: ASTReader.h:919
Sema.h
clang::FileEntry
Cached information about one file (either on disk or in the virtual file system).
Definition: FileEntry.h:366
clang::PCHValidator::ReadPreprocessorOptions
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, bool Complain, std::string &SuggestedPredefines) override
Receives the preprocessor options.
Definition: ASTReader.cpp:785
clang::ASTReader::GetExternalSelector
Selector GetExternalSelector(serialization::SelectorID ID) override
Resolve a selector ID into a selector.
Definition: ASTReader.cpp:8789
clang::ASTReader::getSourceManager
SourceManager & getSourceManager() const
Definition: ASTReader.h:1545
clang::PCHValidator::ReadTargetOptions
bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain, bool AllowCompatibleDifferences) override
Receives the target options.
Definition: ASTReader.cpp:451
clang::ASTReader::ReadString
static std::string ReadString(const RecordData &Record, unsigned &Idx)
Definition: ASTReader.cpp:9055
clang::ASTReader::addPendingMacro
void addPendingMacro(IdentifierInfo *II, ModuleFile *M, uint32_t MacroDirectivesOffset)
Add a macro to deserialize its macro directive history.
Definition: ASTReader.cpp:1962
clang::ASTReader::LoadSelector
void LoadSelector(Selector Sel)
Load a selector from disk, registering its ID if it exists.
Definition: ASTReader.cpp:8517
clang::ASTReader::setListener
void setListener(std::unique_ptr< ASTReaderListener > Listener)
Set the AST callbacks listener.
Definition: ASTReader.h:1627
clang::ASTReader::ModuleDeclIterator::operator*
value_type operator*() const
Definition: ASTReader.h:1448
clang::ASTReader::ReadSubExpr
Expr * ReadSubExpr()
Reads a sub-expression operand during statement reading.
Definition: ASTReaderStmt.cpp:2704
clang::ASTReader::ReadToken
Token ReadToken(ModuleFile &M, const RecordDataImpl &Record, unsigned &Idx)
Reads a token out of a record.
Definition: ASTReader.cpp:1667
clang::serialization::PreprocessedEntityID
uint32_t PreprocessedEntityID
An ID number that refers to an entity in the detailed preprocessing record.
Definition: ASTBitCodes.h:168
clang::ASTReader::RecordDataImpl
SmallVectorImpl< uint64_t > RecordDataImpl
Definition: ASTReader.h:362
clang::ASTReader::getLocalType
QualType getLocalType(ModuleFile &F, unsigned LocalID)
Resolve a local type ID within a given AST file into a type.
Definition: ASTReader.cpp:7170
clang::ASTReader::markIdentifierUpToDate
void markIdentifierUpToDate(IdentifierInfo *II)
Note that this identifier is up-to-date.
Definition: ASTReader.cpp:2111
clang::ExternalASTSource::getMemoryBufferSizes
MemoryBufferSizes getMemoryBufferSizes() const
Return the amount of memory used by memory buffers, breaking down by heap-backed versus mmap'ed memor...
Definition: ExternalASTSource.h:288
clang::ASTReader::readType
QualType readType(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a type from the current position in the given record, which was read from the given AST file.
Definition: ASTReader.h:1837
ASTBitCodes.h
clang::serialization::ModuleFile::ModuleOffsetMap
StringRef ModuleOffsetMap
The module offset map data for this file.
Definition: ModuleFile.h:225
clang::ASTReader::ModuleKind
serialization::ModuleKind ModuleKind
Definition: ASTReader.h:393
SourceLocation.h
clang::ASTReader::GetType
QualType GetType(serialization::TypeID ID)
Resolve a type ID into a type, potentially building a new type.
Definition: ASTReader.cpp:6890
clang::ASTReader::ResolveImportedPath
void ResolveImportedPath(ModuleFile &M, std::string &Filename)
If we are loading a relocatable PCH or module file, and the filename is not an absolute path,...
Definition: ASTReader.cpp:2487
clang::ASTReader::ReadSourceRange
SourceRange ReadSourceRange(ModuleFile &F, const RecordData &Record, unsigned &Idx, LocSeq *Seq=nullptr)
Read a source range.
Definition: ASTReader.cpp:9042
clang::SourceLocationEncoding::decode
static SourceLocation decode(uint64_t, SourceLocationSequence *=nullptr)
Definition: SourceLocationEncoding.h:157
clang::ChainedASTReaderListener::ReadModuleMapFile
void ReadModuleMapFile(StringRef ModuleMapPath) override
Definition: ASTReader.cpp:165
clang::ASTReader::ModuleDeclIterator::ModuleDeclIterator
ModuleDeclIterator(ASTReader *Reader, ModuleFile *Mod, const serialization::LocalDeclID *Pos)
Definition: ASTReader.h:1444
clang::ASTReader::LoadFailureCapabilities
LoadFailureCapabilities
Flags that indicate what kind of AST loading failures the client of the AST reader can directly handl...
Definition: ASTReader.h:1554
clang::ASTReader::getSourceLocationForDeclID
SourceLocation getSourceLocationForDeclID(serialization::GlobalDeclID ID)
Returns the source location for the decl ID.
Definition: ASTReader.cpp:7412
clang::ASTReader::getGlobalMacroID
serialization::MacroID getGlobalMacroID(ModuleFile &M, unsigned LocalID)
Retrieve the global macro ID corresponding to the given local ID within the given module file.
Definition: ASTReader.cpp:8656
clang::ASTReader::getTotalNumSelectors
unsigned getTotalNumSelectors() const
Returns the number of selectors found in the chain.
Definition: ASTReader.h:1812
clang::Decl::isFromASTFile
bool isFromASTFile() const
Determine whether this declaration came from an AST file (such as a precompiled header or module) rat...
Definition: DeclBase.h:751
clang::ASTReader::ListenerScope::~ListenerScope
~ListenerScope()
Definition: ASTReader.h:1658
ExternalSemaSource.h
clang::ASTDeserializationListener
Definition: ASTDeserializationListener.h:30
clang::ASTReader::getLocalModuleFile
ModuleFile * getLocalModuleFile(ModuleFile &M, unsigned ID)
Retrieve the module file with a given local ID within the specified ModuleFile.
Definition: ASTReader.cpp:8704
clang::ASTReader::getGlobalIndex
GlobalModuleIndex * getGlobalIndex()
Return global module index.
Definition: ASTReader.h:1679
clang::ASTReader::SkipString
static void SkipString(const RecordData &Record, unsigned &Idx)
Definition: ASTReader.h:2220
clang::ValueDecl
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:701
clang::ASTReader::InitializeSema
void InitializeSema(Sema &S) override
Initialize the semantic source with the Sema instance being used to perform semantic analysis on the ...
Definition: ASTReader.cpp:7931
clang::ASTReader::getTotalNumTypes
unsigned getTotalNumTypes() const
Returns the number of types found in the chain.
Definition: ASTReader.h:1797
clang::ASTReaderListener::visitImport
virtual void visitImport(StringRef ModuleName, StringRef Filename)
If needsImportVisitation returns true, this is called for each AST file imported by this AST file.
Definition: ASTReader.h:222
clang::SourceLocationSequence
Serialized encoding of a sequence of SourceLocations.
Definition: SourceLocationEncoding.h:87
clang::ASTReader::ModuleIterator
ModuleManager::ModuleIterator ModuleIterator
Definition: ASTReader.h:395
clang::ASTReader::OutOfDate
@ OutOfDate
The AST file is out-of-date relative to its input files, and needs to be regenerated.
Definition: ASTReader.h:379
PreprocessingRecord.h
clang::ChainedASTReaderListener::ChainedASTReaderListener
ChainedASTReaderListener(std::unique_ptr< ASTReaderListener > First, std::unique_ptr< ASTReaderListener > Second)
Takes ownership of First and Second.
Definition: ASTReader.h:236
clang::ASTReader::ReadFileID
FileID ReadFileID(ModuleFile &F, const RecordDataImpl &Record, unsigned &Idx) const
Read a FileID.
Definition: ASTReader.h:2201
Value
Value
Definition: UninitializedValues.cpp:103
clang::ExternalASTSource::ExtKind
ExtKind
Definition: ExternalASTSource.h:165
clang::Decl
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:83
clang::ChainedASTReaderListener::takeFirst
std::unique_ptr< ASTReaderListener > takeFirst()
Definition: ASTReader.h:240
clang::ASTReader::~ASTReader
~ASTReader() override
Definition: ASTReader.cpp:9833
clang::ASTReader::RecordSwitchCaseID
void RecordSwitchCaseID(SwitchCase *SC, unsigned ID)
Record that the given ID maps to the given switch-case statement.
Definition: ASTReader.cpp:9112
clang::ASTReader::getSuggestedPredefines
const std::string & getSuggestedPredefines()
Returns the suggested contents of the predefines buffer, which contains a (typically-empty) subset of...
Definition: ASTReader.h:1755
clang::ChainedASTReaderListener::needsInputFileVisitation
bool needsInputFileVisitation() override
Returns true if this ASTReaderListener wants to receive the input files of the AST file via visitInpu...
Definition: ASTReader.cpp:225
clang::ASTReader::getGlobalIdentifierID
serialization::IdentifierID getGlobalIdentifierID(ModuleFile &M, unsigned LocalID)
Definition: ASTReader.cpp:8614
HeaderSearch.h
clang::ASTReader::FindExternalLexicalDecls
void FindExternalLexicalDecls(const DeclContext *DC, llvm::function_ref< bool(Decl::Kind)> IsKindWeWant, SmallVectorImpl< Decl * > &Decls) override
Read all of the declarations lexically stored in a declaration context.
Definition: ASTReader.cpp:7585
clang::ASTReader::takeListener
std::unique_ptr< ASTReaderListener > takeListener()
Take the AST callbacks listener.
Definition: ASTReader.h:1622
clang::ASTReader::ConfigurationMismatch
@ ConfigurationMismatch
The AST file was written with a different language/target configuration.
Definition: ASTReader.h:386
clang::ASTReader::getLocalIdentifier
IdentifierInfo * getLocalIdentifier(ModuleFile &M, unsigned LocalID)
Definition: ASTReader.cpp:8610
clang::Sema
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:358
clang::ASTReaderListener::visitModuleFile
virtual void visitModuleFile(StringRef Filename, serialization::ModuleKind Kind)
This is called for each AST file loaded.
Definition: ASTReader.h:194
clang::ASTReader::ReadUnusedLocalTypedefNameCandidates
void ReadUnusedLocalTypedefNameCandidates(llvm::SmallSetVector< const TypedefNameDecl *, 4 > &Decls) override
Read the set of potentially unused typedefs known to the source.
Definition: ASTReader.cpp:8406
clang::ASTReader::ReadBlockAbbrevs
static llvm::Error ReadBlockAbbrevs(llvm::BitstreamCursor &Cursor, unsigned BlockID, uint64_t *StartOfBlockOffset=nullptr)
ReadBlockAbbrevs - Enter a subblock of the specified BlockID with the specified cursor.
Definition: ASTReader.cpp:1640
clang::ASTReader::ReadTentativeDefinitions
void ReadTentativeDefinitions(SmallVectorImpl< VarDecl * > &TentativeDefs) override
Read the set of tentative definitions known to the external Sema source.
Definition: ASTReader.cpp:8364
clang::ASTReader::GetNumExternalSelectors
uint32_t GetNumExternalSelectors() override
Returns the number of selectors known to the external AST source.
Definition: ASTReader.cpp:8793
clang::ASTReader::ReadReferencedSelectors
void ReadReferencedSelectors(SmallVectorImpl< std::pair< Selector, SourceLocation >> &Sels) override
Definition: ASTReader.cpp:8428
clang::ASTReader::ReadMethodPool
void ReadMethodPool(Selector Sel) override
Load the contents of the global method pool for a given selector.
Definition: ASTReader.cpp:8285
clang::serialization::ModuleManager::getPrimaryModule
ModuleFile & getPrimaryModule()
Returns the primary module associated with the manager, that is, the first module loaded.
Definition: ModuleManager.h:167
clang::ASTReader::mapGlobalIDToModuleFileGlobalID
serialization::DeclID mapGlobalIDToModuleFileGlobalID(ModuleFile &M, serialization::DeclID GlobalID)
Map a global declaration ID into the declaration ID used to refer to this declaration within the give...
Definition: ASTReader.cpp:7536
clang::ASTReader::ReadMacroRecord
MacroInfo * ReadMacroRecord(ModuleFile &F, uint64_t Offset)
Reads the macro record located at the given offset.
Definition: ASTReader.cpp:1707
clang::serialization::ModuleManager::ModuleConstIterator
llvm::pointee_iterator< SmallVectorImpl< std::unique_ptr< ModuleFile > >::const_iterator > ModuleConstIterator
Definition: ModuleManager.h:132
clang::HeaderFileInfo
The preprocessor keeps track of this information for each file that is #included.
Definition: HeaderSearch.h:58
ModuleManager.h
clang::IdentifierInfo
One of these records is kept for each identifier that is lexed.
Definition: IdentifierTable.h:85
clang::ASTReader::resolvePendingMacro
void resolvePendingMacro(IdentifierInfo *II, const PendingMacroInfo &PMInfo)
Definition: ASTReader.cpp:2122
clang::serialization::LocalDeclID
DeclID LocalDeclID
Definition: ASTBitCodes.h:72
clang::ASTReader::mergeDefinitionVisibility
void mergeDefinitionVisibility(NamedDecl *Def, NamedDecl *MergedDef)
Note that MergedDef is a redefinition of the canonical definition Def, so Def should be visible whene...
Definition: ASTReader.cpp:4136
ModuleFileExtension.h
clang::ASTReader::getIdentifierTable
IdentifierTable & getIdentifierTable()
Retrieve the identifier table associated with the preprocessor.
Definition: ASTReader.cpp:9106
clang::ASTReaderListener::ReadHeaderSearchOptions
virtual bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts, StringRef SpecificModuleCachePath, bool Complain)
Receives the header search options.
Definition: ASTReader.h:169
clang::ASTReader::SkipPath
static void SkipPath(const RecordData &Record, unsigned &Idx)
Definition: ASTReader.h:2232
clang::LangOptions
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:81
clang::ASTReader::ReadAlignPackInfo
Sema::AlignPackInfo ReadAlignPackInfo(uint32_t Raw) const
Read a AlignPackInfo from raw form.
Definition: ASTReader.h:2160
clang::ObjCPropertyAttribute::Kind
Kind
Definition: DeclObjCCommon.h:22
clang::ASTReader::PrintStats
void PrintStats() override
Print some statistics about AST usage.
Definition: ASTReader.cpp:7790
clang::ASTReader
Reads an AST files chain containing the contents of a translation unit.
Definition: ASTReader.h:341
std
Definition: Format.h:4477
clang::ASTReader::CommentsCursors
SmallVector< std::pair< llvm::BitstreamCursor, serialization::ModuleFile * >, 8 > CommentsCursors
Cursors for comments blocks.
Definition: ASTReader.h:2328
clang::ASTReader::readASTFileControlBlock
static bool readASTFileControlBlock(StringRef Filename, FileManager &FileMgr, const InMemoryModuleCache &ModuleCache, const PCHContainerReader &PCHContainerRdr, bool FindModuleFileExtensions, ASTReaderListener &Listener, bool ValidateDiagnosticOptions)
Read the control block for the named AST file.
Definition: ASTReader.cpp:5203
clang::ChainedASTReaderListener::ReadModuleName
void ReadModuleName(StringRef ModuleName) override
Definition: ASTReader.cpp:160
clang::SimpleASTReaderListener::SimpleASTReaderListener
SimpleASTReaderListener(Preprocessor &PP)
Definition: ASTReader.h:308
clang::ASTReader::SetIdentifierInfo
void SetIdentifierInfo(unsigned ID, IdentifierInfo *II)
Definition: ASTReader.cpp:8522
ModuleFile.h
clang::ASTReader::isPreprocessedEntityInFileID
Optional< bool > isPreprocessedEntityInFileID(unsigned Index, FileID FID) override
Optionally returns true or false if the preallocated preprocessed entity with index Index came from f...
Definition: ASTReader.cpp:6237
clang::Builtin::ID
ID
Definition: Builtins.h:52
clang::serialization::reader::DeclContextLookupTable
Definition: ASTReaderInternals.h:118
clang::ASTReader::ListenerScope::ListenerScope
ListenerScope(ASTReader &Reader, std::unique_ptr< ASTReaderListener > L)
Definition: ASTReader.h:1647
clang
Definition: CalledOnceCheck.h:17
clang::ASTReader::getTotalNumSLocs
unsigned getTotalNumSLocs() const
Returns the number of source locations found in the chain.
Definition: ASTReader.h:1782
clang::FileManager
Implements support for file system lookup, file system caching, and directory search management.
Definition: FileManager.h:53
clang::ASTReader::addInMemoryBuffer
void addInMemoryBuffer(StringRef &FileName, std::unique_ptr< llvm::MemoryBuffer > Buffer)
Add in-memory (virtual file) buffer.
Definition: ASTReader.h:1700
clang::Selector
Smart pointer class that efficiently represents Objective-C method names.
Definition: IdentifierTable.h:759
clang::Stmt
Stmt - This represents one statement.
Definition: Stmt.h:71
clang::ASTReader::ModuleDeclIterator::operator->
value_type operator->() const
Definition: ASTReader.h:1452
clang::ASTReader::StartedDeserializing
void StartedDeserializing() override
Notify ASTReader that we started deserialization of a decl or type so until FinishedDeserializing is ...
Definition: ASTReader.cpp:9711
clang::ContinuousRangeMap
A map from continuous integer ranges to some value, with a very specialized interface.
Definition: ContinuousRangeMap.h:37
clang::ContinuousRangeMap< unsigned, ModuleFile *, 64 >::const_iterator
typename Representation::const_iterator const_iterator
Definition: ContinuousRangeMap.h:86
clang::ASTReaderListener
Abstract interface for callback invocations by the ASTReader.
Definition: ASTReader.h:113
SourceLocationEncoding.h
clang::ModuleFileExtensionMetadata
Metadata for a module file extension.
Definition: ModuleFileExtension.h:36
clang::FileID
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
Definition: SourceLocation.h:38
clang::ASTReader::VersionMismatch
@ VersionMismatch
The AST file was written by a different version of Clang.
Definition: ASTReader.h:382
clang::ASTReader::ReadStmt
Stmt * ReadStmt(ModuleFile &F)
Reads a statement.
Definition: ASTReaderStmt.cpp:2686
clang::CXXBaseSpecifier
Represents a base class of a C++ class.
Definition: DeclCXX.h:146
clang::IdentifierTable
Implements an efficient mapping from strings to IdentifierInfo nodes.
Definition: IdentifierTable.h:564
clang::ASTReaderListener::needsImportVisitation
virtual bool needsImportVisitation() const
Returns true if this ASTReaderListener wants to receive the imports of the AST file via visitImport,...
Definition: ASTReader.h:218
clang::InMemoryModuleCache
In-memory cache for modules.
Definition: InMemoryModuleCache.h:30
clang::ASTReader::setDeserializationListener
void setDeserializationListener(ASTDeserializationListener *Listener, bool TakeOwnership=false)
Set the AST deserialization listener.
Definition: ASTReader.cpp:871
clang::SrcMgr::isSystem
bool isSystem(CharacteristicKind CK)
Determine whether a file / directory characteristic is for system code.
Definition: SourceManager.h:88
clang::IdentifierInfoLookup
Provides lookups to, and iteration over, IdentiferInfo objects.
Definition: IdentifierTable.h:535
clang::ChainedASTReaderListener::ReadHeaderSearchOptions
bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts, StringRef SpecificModuleCachePath, bool Complain) override
Receives the header search options.
Definition: ASTReader.cpp:202
clang::ASTReader::ReadDeclAs
T * ReadDeclAs(ModuleFile &F, const RecordData &R, unsigned &I)
Reads a declaration from the given position in a record in the given module.
Definition: ASTReader.h:1909
clang::ASTReader::ReadCXXTemporary
CXXTemporary * ReadCXXTemporary(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Definition: ASTReader.cpp:9089
clang::ASTReader::getLocalSelector
Selector getLocalSelector(ModuleFile &M, unsigned LocalID)
Retrieve a selector from the given module with its local ID number.
Definition: ASTReader.cpp:8760
clang::ASTReader::ReadExpr
Expr * ReadExpr(ModuleFile &F)
Reads an expression.
Definition: ASTReaderStmt.cpp:2700
clang::ASTReader::PreloadedDeclIDs
SmallVector< uint64_t, 16 > PreloadedDeclIDs
Definition: ASTReader.h:2301
clang::ChainedASTReaderListener::takeSecond
std::unique_ptr< ASTReaderListener > takeSecond()
Definition: ASTReader.h:241
clang::ASTReader::ReadPragmaDiagnosticMappings
void ReadPragmaDiagnosticMappings(DiagnosticsEngine &Diag)
Definition: ASTReader.cpp:6296
clang::ASTReader::ReadDeclsToCheckForDeferredDiags
void ReadDeclsToCheckForDeferredDiags(llvm::SmallSetVector< Decl *, 4 > &Decls) override
Read the set of decls to be checked for deferred diags.
Definition: ASTReader.cpp:8418
DiagnosticOptions.h
clang::ASTReader::ForgetSema
void ForgetSema() override
Inform the semantic consumer that Sema is no longer available.
Definition: ASTReader.h:1996
clang::ASTReader::ModuleConstIterator
ModuleManager::ModuleConstIterator ModuleConstIterator
Definition: ASTReader.h:396
clang::serialization::ModuleFile::OriginalSourceFileName
std::string OriginalSourceFileName
The original source file name that was used to build the primary AST file, which may have been modifi...
Definition: ModuleFile.h:141
clang::ExternalASTSource::Deserializing
RAII class for safely pairing a StartedDeserializing call with FinishedDeserializing.
Definition: ExternalASTSource.h:76
clang::serialization::ModuleKind
ModuleKind
Specifies the kind of module that has been loaded.
Definition: ModuleFile.h:42
clang::ASTReader::hasGlobalIndex
bool hasGlobalIndex() const
Determine whether this AST reader has a global index.
Definition: ASTReader.h:1676
clang::ASTReader::getOwningModuleFile
ModuleFile * getOwningModuleFile(const Decl *D)
Retrieve the module file that owns the given declaration, or NULL if the declaration is not from a mo...
Definition: ASTReader.cpp:7404
clang::ASTReader::forEachImportedKeyDecl
void forEachImportedKeyDecl(const Decl *D, Fn Visit)
Run a callback on each imported key declaration of D.
Definition: ASTReader.h:1291
clang::TargetOptions
Options for controlling the target.
Definition: TargetOptions.h:26
clang::ASTReader::DecodeSelector
Selector DecodeSelector(serialization::SelectorID Idx)
Definition: ASTReader.cpp:8764
llvm::SmallVectorImpl
Definition: Randstruct.h:18
clang::ASTReader::GetExternalCXXCtorInitializers
CXXCtorInitializer ** GetExternalCXXCtorInitializers(uint64_t Offset) override
Read the contents of a CXXCtorInitializer array.
Definition: ASTReader.cpp:7307
llvm::SmallSetVector< serialization::DeclID, 4 >
PreprocessorOptions.h
clang::Expr
This represents one expression.
Definition: Expr.h:109
clang::Preprocessor
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
Definition: Preprocessor.h:129
clang::ASTReader::isProcessingUpdateRecords
bool isProcessingUpdateRecords()
Definition: ASTReader.h:2344
clang::ASTDeclReader
Definition: ASTReaderDecl.cpp:81
clang::serialization::DeclID
uint32_t DeclID
An ID number that refers to a declaration in an AST file.
Definition: ASTBitCodes.h:68
clang::CXXCtorInitializer
Represents a C++ base or member initializer.
Definition: DeclCXX.h:2207
clang::ASTReader::getSwitchCaseWithID
SwitchCase * getSwitchCaseWithID(unsigned ID)
Retrieve the switch-case statement with the given ID.
Definition: ASTReader.cpp:9119
clang::ASTReader::getIdResolver
IdentifierResolver & getIdResolver()
Get the identifier resolver used for name lookup / updates in the translation unit scope.
Definition: ASTReader.cpp:9838
clang::serialization::GlobalDeclID
DeclID GlobalDeclID
Definition: ASTBitCodes.h:73
clang::ASTReader::ReadDeclID
serialization::DeclID ReadDeclID(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Reads a declaration ID from the given position in a record in the given module.
Definition: ASTReader.cpp:7553
clang::ExternalSLocEntrySource
External source of source location entries.
Definition: SourceManager.h:523
clang::SimpleASTReaderListener
ASTReaderListenter implementation to set SuggestedPredefines of ASTReader which is required to use a ...
Definition: ASTReader.h:304
clang::ASTReader::findPreprocessedEntitiesInRange
std::pair< unsigned, unsigned > findPreprocessedEntitiesInRange(SourceRange Range) override
Returns a pair of [Begin, End) indices of preallocated preprocessed entities that Range encompasses.
Definition: ASTReader.cpp:6224
clang::serialization::SelectorID
uint32_t SelectorID
An ID number that refers to an ObjC selector in an AST file.
Definition: ASTBitCodes.h:153
clang::ChainedASTReaderListener::ReadFullVersionInformation
bool ReadFullVersionInformation(StringRef FullVersion) override
Receives the full Clang version information.
Definition: ASTReader.cpp:155
clang::ASTReader::FindFileRegionDecls
void FindFileRegionDecls(FileID File, unsigned Offset, unsigned Length, SmallVectorImpl< Decl * > &Decls) override
Get the decls that are contained in a file in the Offset/Length range.
Definition: ASTReader.cpp:7661
clang::ASTReaderListener::ReadCounter
virtual void ReadCounter(const serialization::ModuleFile &M, unsigned Value)
Receives COUNTER value.
Definition: ASTReader.h:190
clang::ASTReader::finalizeForWriting
void finalizeForWriting()
Finalizes the AST reader's state before writing an AST file to disk.
Definition: ASTReader.cpp:5038
clang::ASTReader::GetHeaderFileInfo
HeaderFileInfo GetHeaderFileInfo(const FileEntry *FE) override
Read the header file information for the given file entry.
Definition: ASTReader.cpp:6287
clang::ASTReader::isDeclIDFromModule
bool isDeclIDFromModule(serialization::GlobalDeclID ID, ModuleFile &M) const
Returns true if global DeclID ID originated from module M.
Definition: ASTReader.cpp:7394
clang::ASTReader::getDeserializationListener
ASTDeserializationListener * getDeserializationListener()
Get the AST deserialization listener.
Definition: ASTReader.h:1671
clang::ASTReader::ReadDecl
Decl * ReadDecl(ModuleFile &F, const RecordData &R, unsigned &I)
Reads a declaration from the given position in a record in the given module.
Definition: ASTReader.h:1899
clang::PreprocessedEntity
Base class that describes a preprocessed entity, which may be a preprocessor directive or macro expan...
Definition: PreprocessingRecord.h:59
clang::FunctionDecl
Represents a function declaration or definition.
Definition: Decl.h:1904
clang::ASTReader::getGlobalPreprocessedEntityID
serialization::PreprocessedEntityID getGlobalPreprocessedEntityID(ModuleFile &M, unsigned LocalID) const
Determine the global preprocessed entity ID that corresponds to the given local ID within the given m...
Definition: ASTReader.cpp:1838
clang::ASTReader::ImportedSubmodule::ImportedSubmodule
ImportedSubmodule(serialization::SubmoduleID ID, SourceLocation ImportLoc)
Definition: ASTReader.h:923
clang::ChainedASTReaderListener
Simple wrapper class for chaining listeners.
Definition: ASTReader.h:230
clang::serialization::ModuleFile
Information about a module that has been loaded by the ASTReader.
Definition: ModuleFile.h:111
clang::ASTReader::GetExternalCXXBaseSpecifiers
CXXBaseSpecifier * GetExternalCXXBaseSpecifiers(uint64_t Offset) override
Resolve the offset of a set of C++ base specifiers in the decl stream into an array of specifiers.
Definition: ASTReader.cpp:7338
clang::ASTReader::ASTReadResult
ASTReadResult
The result of reading the control block of an AST file, which can fail for various reasons.
Definition: ASTReader.h:366
clang::ASTReader::SetGloballyVisibleDecls
void SetGloballyVisibleDecls(IdentifierInfo *II, const SmallVectorImpl< uint32_t > &DeclIDs, SmallVectorImpl< Decl * > *Decls=nullptr)
Set the globally-visible declarations associated with the given identifier.
Definition: ASTReader.cpp:8547
clang::ASTReader::InitializeContext
void InitializeContext()
Initializes the ASTContext.
Definition: ASTReader.cpp:4899
clang::ASTReader::ReadPath
std::string ReadPath(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Definition: ASTReader.cpp:9062
llvm::IntrusiveRefCntPtr
Definition: LLVM.h:47
clang::ASTReader::ReadUntranslatedSourceLocation
SourceLocation ReadUntranslatedSourceLocation(SourceLocation::UIntTy Raw, LocSeq *Seq=nullptr) const
Read a source location from raw form and return it in its originating module file's source location s...
Definition: ASTReader.h:2166
clang::ChainedASTReaderListener::needsSystemInputFileVisitation
bool needsSystemInputFileVisitation() override
Returns true if this ASTReaderListener wants to receive the system input files of the AST file via vi...
Definition: ASTReader.cpp:230
clang::SourceLocation::UIntTy
uint32_t UIntTy
Definition: SourceLocation.h:93
clang::ASTReader::completeVisibleDeclsMap
void completeVisibleDeclsMap(const DeclContext *DC) override
Load all external visible decls in the given DeclContext.
Definition: ASTReader.cpp:7730
clang::ASTReaderListener::ReadFileSystemOptions
virtual bool ReadFileSystemOptions(const FileSystemOptions &FSOpts, bool Complain)
Receives the file system options.
Definition: ASTReader.h:160
ExternalPreprocessorSource.h
clang::HeaderSearchOptions
HeaderSearchOptions - Helper class for storing options related to the initialization of the HeaderSea...
Definition: HeaderSearchOptions.h:68
clang::PCHValidator::ReadDiagnosticOptions
bool ReadDiagnosticOptions(IntrusiveRefCntPtr< DiagnosticOptions > DiagOpts, bool Complain) override
Receives the diagnostic options.
Definition: ASTReader.cpp:568
clang::ASTReader::ModuleDeclIterator::ModuleDeclIterator
ModuleDeclIterator()
Definition: ASTReader.h:1442
clang::ASTReader::Missing
@ Missing
The AST file was missing.
Definition: ASTReader.h:375