16ab7cd853e9c15cf986a8a7c3db1f8d20e275409Sebastian Redl//===--- ASTReader.h - AST File Reader --------------------------*- C++ -*-===// 22cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor// 32cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor// The LLVM Compiler Infrastructure 42cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor// 52cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor// This file is distributed under the University of Illinois Open Source 62cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor// License. See LICENSE.TXT for details. 72cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor// 82cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor//===----------------------------------------------------------------------===// 92cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor// 10c43b54cbc10654ed59de797898042e1a05265246Sebastian Redl// This file defines the ASTReader class, which reads AST files. 112cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor// 122cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor//===----------------------------------------------------------------------===// 138b12273c86ede439edf52d35b170fd32b2ed49d4Sebastian Redl 14176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines#ifndef LLVM_CLANG_SERIALIZATION_ASTREADER_H 15176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines#define LLVM_CLANG_SERIALIZATION_ASTREADER_H 162cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor 17f0aaf7a59729a4ae0146e3464ee987745be95829Douglas Gregor#include "clang/AST/DeclObjC.h" 1830a2e16f6c27f888dd11eba6bbbae1e980078fcbChandler Carruth#include "clang/AST/DeclarationName.h" 19833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall#include "clang/AST/TemplateBase.h" 200a0428e96c6f1e8bef7a481a9eb69a6f6df38951Douglas Gregor#include "clang/Basic/Diagnostic.h" 211afb661bc5444462a246cefa0effa61ef25fab29Jonathan D. Turner#include "clang/Basic/FileManager.h" 221afb661bc5444462a246cefa0effa61ef25fab29Jonathan D. Turner#include "clang/Basic/FileSystemOptions.h" 23668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor#include "clang/Basic/IdentifierTable.h" 247f94b0b0c6791013d2f72ced9b4bedd3b23673a6Douglas Gregor#include "clang/Basic/SourceManager.h" 25c544ba09695e300f31355af342258bd57619e737Douglas Gregor#include "clang/Basic/Version.h" 2630a2e16f6c27f888dd11eba6bbbae1e980078fcbChandler Carruth#include "clang/Lex/ExternalPreprocessorSource.h" 2730a2e16f6c27f888dd11eba6bbbae1e980078fcbChandler Carruth#include "clang/Lex/HeaderSearch.h" 2830a2e16f6c27f888dd11eba6bbbae1e980078fcbChandler Carruth#include "clang/Lex/PreprocessingRecord.h" 2930a2e16f6c27f888dd11eba6bbbae1e980078fcbChandler Carruth#include "clang/Sema/ExternalSemaSource.h" 304967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar#include "clang/Sema/IdentifierResolver.h" 3130a2e16f6c27f888dd11eba6bbbae1e980078fcbChandler Carruth#include "clang/Serialization/ASTBitCodes.h" 3230a2e16f6c27f888dd11eba6bbbae1e980078fcbChandler Carruth#include "clang/Serialization/ContinuousRangeMap.h" 3330a2e16f6c27f888dd11eba6bbbae1e980078fcbChandler Carruth#include "clang/Serialization/Module.h" 3487d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar#include "clang/Serialization/ModuleFileExtension.h" 3530a2e16f6c27f888dd11eba6bbbae1e980078fcbChandler Carruth#include "clang/Serialization/ModuleManager.h" 3617fc223395d51be582fc666bb6ea21bd1dff26dcDouglas Gregor#include "llvm/ADT/APFloat.h" 370a2b45e5885b6b8477b167042c0f6cd1d99a1f13Douglas Gregor#include "llvm/ADT/APInt.h" 380a2b45e5885b6b8477b167042c0f6cd1d99a1f13Douglas Gregor#include "llvm/ADT/APSInt.h" 39ce12d2f8863588d408897602089d17c4d3c3d0e5Douglas Gregor#include "llvm/ADT/MapVector.h" 400f75323264b93a318ac9007eb5ec5b233c444068Douglas Gregor#include "llvm/ADT/SmallPtrSet.h" 410f75323264b93a318ac9007eb5ec5b233c444068Douglas Gregor#include "llvm/ADT/SmallSet.h" 422cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor#include "llvm/ADT/SmallVector.h" 4387d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar#include "llvm/ADT/StringMap.h" 44dc3c0d20375bda7775b2fade05b20e315798b9feDaniel Dunbar#include "llvm/ADT/StringRef.h" 456bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines#include "llvm/ADT/TinyPtrVector.h" 462cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor#include "llvm/Bitcode/BitstreamReader.h" 4703013fa9a0bf1ef4b907f5fec006c8f4000fdd21Michael J. Spencer#include "llvm/Support/DataTypes.h" 4887d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar#include "llvm/Support/Timer.h" 49d89275bc865e2b552836c7b33e636d4f86b8de6dDouglas Gregor#include <deque> 50025452fa0eda63e150cfaeebe64f0a19c96b3a06Douglas Gregor#include <map> 51651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines#include <memory> 522cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor#include <string> 532cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor#include <utility> 542cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor#include <vector> 552cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor 562cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregornamespace llvm { 572cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor class MemoryBuffer; 582cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor} 592cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor 602cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregornamespace clang { 612cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor 627d5c2f241c74e5f8d9ec492e8f9f268e5e9ae41fDouglas Gregorclass AddrLabelExpr; 630af2ca4b6ddc788658069a0994941268ce250fc7Douglas Gregorclass ASTConsumer; 642cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregorclass ASTContext; 6595f4292cc526c629fead321c7fcfd4fe0f3bc66eDouglas Gregorclass ASTIdentifierIterator; 66f62d43d2afe1960755a1b5813cae1e5983bcac1bDouglas Gregorclass ASTUnit; // FIXME: Layering violation and egregious hack. 6768a2eb0cc76267ba0615992fb5e0977853c397b2Douglas Gregorclass Attr; 682cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregorclass Decl; 692cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregorclass DeclContext; 70651f13cea278ec967336033dd032faef0e9fc2ecStephen Hinesclass DefMacroDirective; 715f3d8224af99ad0d9107601c0c31b74693371cc1Douglas Gregorclass DiagnosticOptions; 726ad9ac097918fbdeb443ea7b99d4db9e49b28534Chris Lattnerclass NestedNameSpecifier; 736ad9ac097918fbdeb443ea7b99d4db9e49b28534Chris Lattnerclass CXXBaseSpecifier; 74ebcbe1d3dc7d4f0c1f540a632fa0684dd0a857d5Sean Huntclass CXXConstructorDecl; 75cbb67480094b3bcb5b715acd827cbad55e2a204cSean Huntclass CXXCtorInitializer; 761a49d97d762570027863e9209af81d445e4f1502Douglas Gregorclass GlobalModuleIndex; 771de05feeeafe5b215fe7617594a7076a5192a6e2Douglas Gregorclass GotoStmt; 786a5a23f8e7fb65e028c8092bc1d1a1d9dfe2e9bcDouglas Gregorclass MacroDefinition; 799818a1d443e97677dd3422305de9cc2b1fb2a8c1Argyrios Kyrtzidisclass MacroDirective; 80b6d6993e6e6d3daf4d9876794254d20a134e37c2Pirama Arumuga Nainarclass ModuleMacro; 81668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregorclass NamedDecl; 8256ca35d396d8692c384c785f9aeebcf22563fe1eJohn McCallclass OpaqueValueExpr; 8314f79002e58556798e86168c63e48d533287eda5Douglas Gregorclass Preprocessor; 84a71a7d8a1ce4474e7bdb680658fb58b6caf391d3Douglas Gregorclass PreprocessorOptions; 85668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregorclass Sema; 86025452fa0eda63e150cfaeebe64f0a19c96b3a06Douglas Gregorclass SwitchCase; 87c3632730cc83ed7b51f0ab5c38997ae5a9439b0cSebastian Redlclass ASTDeserializationListener; 88f62d43d2afe1960755a1b5813cae1e5983bcac1bDouglas Gregorclass ASTWriter; 89c43b54cbc10654ed59de797898042e1a05265246Sebastian Redlclass ASTReader; 90d527cc06d78fe5afa5f20105b51697637eb02c56Sebastian Redlclass ASTDeclReader; 91c3632730cc83ed7b51f0ab5c38997ae5a9439b0cSebastian Redlclass ASTStmtReader; 92c3632730cc83ed7b51f0ab5c38997ae5a9439b0cSebastian Redlclass TypeLocReader; 93eb19485625c7529ffa644e10829533157a8e8d4fDaniel Dunbarstruct HeaderFileInfo; 940a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregorclass VersionTuple; 9557016dda61498294120b1a881d9e6606337b29d9Douglas Gregorclass TargetOptions; 96c2d775714f79af977672e4f1dbc16ee9e02d1deaRichard Smithclass LazyASTUnresolvedSet; 9711e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis 98c43b54cbc10654ed59de797898042e1a05265246Sebastian Redl/// \brief Abstract interface for callback invocations by the ASTReader. 9911e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis/// 100c43b54cbc10654ed59de797898042e1a05265246Sebastian Redl/// While reading an AST file, the ASTReader will call the methods of the 10111e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis/// listener to pass on specific information. Some of the listener methods can 102c43b54cbc10654ed59de797898042e1a05265246Sebastian Redl/// return true to indicate to the ASTReader that the information (and 103571db7f0cb31789737be92fce1c1b738e6dbe795Sebastian Redl/// consequently the AST file) is invalid. 104571db7f0cb31789737be92fce1c1b738e6dbe795Sebastian Redlclass ASTReaderListener { 10511e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidispublic: 106571db7f0cb31789737be92fce1c1b738e6dbe795Sebastian Redl virtual ~ASTReaderListener(); 1071eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 108c544ba09695e300f31355af342258bd57619e737Douglas Gregor /// \brief Receives the full Clang version information. 109c544ba09695e300f31355af342258bd57619e737Douglas Gregor /// 110c544ba09695e300f31355af342258bd57619e737Douglas Gregor /// \returns true to indicate that the version is invalid. Subclasses should 111c544ba09695e300f31355af342258bd57619e737Douglas Gregor /// generally defer to this implementation. 112c544ba09695e300f31355af342258bd57619e737Douglas Gregor virtual bool ReadFullVersionInformation(StringRef FullVersion) { 113c544ba09695e300f31355af342258bd57619e737Douglas Gregor return FullVersion != getClangFullRepositoryVersion(); 114c544ba09695e300f31355af342258bd57619e737Douglas Gregor } 115c544ba09695e300f31355af342258bd57619e737Douglas Gregor 1166bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines virtual void ReadModuleName(StringRef ModuleName) {} 1176bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines virtual void ReadModuleMapFile(StringRef ModuleMapPath) {} 1186bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines 11911e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis /// \brief Receives the language options. 12011e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis /// 12111e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis /// \returns true to indicate the options are invalid or false otherwise. 12227ffa6caf965ef20fdef5ae23b81cdc3d05e7afbDouglas Gregor virtual bool ReadLanguageOptions(const LangOptions &LangOpts, 123176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines bool Complain, 124176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines bool AllowCompatibleDifferences) { 12511e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis return false; 12611e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis } 1271eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 12857016dda61498294120b1a881d9e6606337b29d9Douglas Gregor /// \brief Receives the target options. 12911e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis /// 13057016dda61498294120b1a881d9e6606337b29d9Douglas Gregor /// \returns true to indicate the target options are invalid, or false 13157016dda61498294120b1a881d9e6606337b29d9Douglas Gregor /// otherwise. 1323ea9e33ea25e0c2b12db56418ba3f994eb662c04Pirama Arumuga Nainar virtual bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain, 1333ea9e33ea25e0c2b12db56418ba3f994eb662c04Pirama Arumuga Nainar bool AllowCompatibleDifferences) { 13411e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis return false; 13511e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis } 1361eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1375f3d8224af99ad0d9107601c0c31b74693371cc1Douglas Gregor /// \brief Receives the diagnostic options. 1385f3d8224af99ad0d9107601c0c31b74693371cc1Douglas Gregor /// 1395f3d8224af99ad0d9107601c0c31b74693371cc1Douglas Gregor /// \returns true to indicate the diagnostic options are invalid, or false 1405f3d8224af99ad0d9107601c0c31b74693371cc1Douglas Gregor /// otherwise. 1416bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines virtual bool 1426bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines ReadDiagnosticOptions(IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts, 1436bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines bool Complain) { 1445f3d8224af99ad0d9107601c0c31b74693371cc1Douglas Gregor return false; 1455f3d8224af99ad0d9107601c0c31b74693371cc1Douglas Gregor } 1465f3d8224af99ad0d9107601c0c31b74693371cc1Douglas Gregor 1471b2c3c0884e917ae5d59edde7d93b2af33c6a1b6Douglas Gregor /// \brief Receives the file system options. 1481b2c3c0884e917ae5d59edde7d93b2af33c6a1b6Douglas Gregor /// 1491b2c3c0884e917ae5d59edde7d93b2af33c6a1b6Douglas Gregor /// \returns true to indicate the file system options are invalid, or false 1501b2c3c0884e917ae5d59edde7d93b2af33c6a1b6Douglas Gregor /// otherwise. 1511b2c3c0884e917ae5d59edde7d93b2af33c6a1b6Douglas Gregor virtual bool ReadFileSystemOptions(const FileSystemOptions &FSOpts, 1521b2c3c0884e917ae5d59edde7d93b2af33c6a1b6Douglas Gregor bool Complain) { 1531b2c3c0884e917ae5d59edde7d93b2af33c6a1b6Douglas Gregor return false; 1541b2c3c0884e917ae5d59edde7d93b2af33c6a1b6Douglas Gregor } 1551b2c3c0884e917ae5d59edde7d93b2af33c6a1b6Douglas Gregor 156bbf38319edd4eddc55ec273934e990d7e84991deDouglas Gregor /// \brief Receives the header search options. 157bbf38319edd4eddc55ec273934e990d7e84991deDouglas Gregor /// 158bbf38319edd4eddc55ec273934e990d7e84991deDouglas Gregor /// \returns true to indicate the header search options are invalid, or false 159bbf38319edd4eddc55ec273934e990d7e84991deDouglas Gregor /// otherwise. 160bbf38319edd4eddc55ec273934e990d7e84991deDouglas Gregor virtual bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts, 1610e2c34f92f00628d48968dfea096d36381f494cbStephen Hines StringRef SpecificModuleCachePath, 162bbf38319edd4eddc55ec273934e990d7e84991deDouglas Gregor bool Complain) { 163bbf38319edd4eddc55ec273934e990d7e84991deDouglas Gregor return false; 164bbf38319edd4eddc55ec273934e990d7e84991deDouglas Gregor } 165bbf38319edd4eddc55ec273934e990d7e84991deDouglas Gregor 166a71a7d8a1ce4474e7bdb680658fb58b6caf391d3Douglas Gregor /// \brief Receives the preprocessor options. 167a71a7d8a1ce4474e7bdb680658fb58b6caf391d3Douglas Gregor /// 1688769924c97ecf2af88f7f3aa6754d381b30d1c5fDouglas Gregor /// \param SuggestedPredefines Can be filled in with the set of predefines 1698769924c97ecf2af88f7f3aa6754d381b30d1c5fDouglas Gregor /// that are suggested by the preprocessor options. Typically only used when 1708769924c97ecf2af88f7f3aa6754d381b30d1c5fDouglas Gregor /// loading a precompiled header. 1718769924c97ecf2af88f7f3aa6754d381b30d1c5fDouglas Gregor /// 172a71a7d8a1ce4474e7bdb680658fb58b6caf391d3Douglas Gregor /// \returns true to indicate the preprocessor options are invalid, or false 173a71a7d8a1ce4474e7bdb680658fb58b6caf391d3Douglas Gregor /// otherwise. 174a71a7d8a1ce4474e7bdb680658fb58b6caf391d3Douglas Gregor virtual bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, 1758769924c97ecf2af88f7f3aa6754d381b30d1c5fDouglas Gregor bool Complain, 1768769924c97ecf2af88f7f3aa6754d381b30d1c5fDouglas Gregor std::string &SuggestedPredefines) { 177a71a7d8a1ce4474e7bdb680658fb58b6caf391d3Douglas Gregor return false; 178a71a7d8a1ce4474e7bdb680658fb58b6caf391d3Douglas Gregor } 179a71a7d8a1ce4474e7bdb680658fb58b6caf391d3Douglas Gregor 18011e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis /// \brief Receives __COUNTER__ value. 18162288edde26ff4af9fc079c979a0e1bdc577ce9dArgyrios Kyrtzidis virtual void ReadCounter(const serialization::ModuleFile &M, 18262288edde26ff4af9fc079c979a0e1bdc577ce9dArgyrios Kyrtzidis unsigned Value) {} 183bdfdb1da9763b3d0966eb61e9fa0fa7804f9eb9bArgyrios Kyrtzidis 184651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines /// This is called for each AST file loaded. 18587d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar virtual void visitModuleFile(StringRef Filename, 18687d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar serialization::ModuleKind Kind) {} 187651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines 188bdfdb1da9763b3d0966eb61e9fa0fa7804f9eb9bArgyrios Kyrtzidis /// \brief Returns true if this \c ASTReaderListener wants to receive the 189bdfdb1da9763b3d0966eb61e9fa0fa7804f9eb9bArgyrios Kyrtzidis /// input files of the AST file via \c visitInputFile, false otherwise. 190bdfdb1da9763b3d0966eb61e9fa0fa7804f9eb9bArgyrios Kyrtzidis virtual bool needsInputFileVisitation() { return false; } 191651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines /// \brief Returns true if this \c ASTReaderListener wants to receive the 192651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines /// system input files of the AST file via \c visitInputFile, false otherwise. 193651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines virtual bool needsSystemInputFileVisitation() { return false; } 194651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines /// \brief if \c needsInputFileVisitation returns true, this is called for 195651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines /// each non-system input file of the AST File. If 196651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines /// \c needsSystemInputFileVisitation is true, then it is called for all 197651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines /// system input files as well. 198bdfdb1da9763b3d0966eb61e9fa0fa7804f9eb9bArgyrios Kyrtzidis /// 199bdfdb1da9763b3d0966eb61e9fa0fa7804f9eb9bArgyrios Kyrtzidis /// \returns true to continue receiving the next input file, false to stop. 200651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines virtual bool visitInputFile(StringRef Filename, bool isSystem, 20187d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar bool isOverridden, bool isExplicitModule) { 202651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines return true; 203651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines } 204176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines 205176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines /// \brief Returns true if this \c ASTReaderListener wants to receive the 206176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines /// imports of the AST file via \c visitImport, false otherwise. 207176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines virtual bool needsImportVisitation() const { return false; } 208176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines /// \brief If needsImportVisitation returns \c true, this is called for each 209176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines /// AST file imported by this AST file. 210176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines virtual void visitImport(StringRef Filename) {} 21187d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar 21287d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar /// Indicates that a particular module file extension has been read. 21387d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar virtual void readModuleFileExtension( 21487d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar const ModuleFileExtensionMetadata &Metadata) {} 215651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines}; 216651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines 217651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines/// \brief Simple wrapper class for chaining listeners. 218651f13cea278ec967336033dd032faef0e9fc2ecStephen Hinesclass ChainedASTReaderListener : public ASTReaderListener { 219651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines std::unique_ptr<ASTReaderListener> First; 220651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines std::unique_ptr<ASTReaderListener> Second; 221651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines 222651f13cea278ec967336033dd032faef0e9fc2ecStephen Hinespublic: 223651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines /// Takes ownership of \p First and \p Second. 224176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines ChainedASTReaderListener(std::unique_ptr<ASTReaderListener> First, 225176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines std::unique_ptr<ASTReaderListener> Second) 226176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines : First(std::move(First)), Second(std::move(Second)) {} 227176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines 228176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines std::unique_ptr<ASTReaderListener> takeFirst() { return std::move(First); } 229176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines std::unique_ptr<ASTReaderListener> takeSecond() { return std::move(Second); } 230651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines 231651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines bool ReadFullVersionInformation(StringRef FullVersion) override; 2326bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines void ReadModuleName(StringRef ModuleName) override; 2336bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines void ReadModuleMapFile(StringRef ModuleMapPath) override; 234176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain, 235176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines bool AllowCompatibleDifferences) override; 2363ea9e33ea25e0c2b12db56418ba3f994eb662c04Pirama Arumuga Nainar bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain, 2373ea9e33ea25e0c2b12db56418ba3f994eb662c04Pirama Arumuga Nainar bool AllowCompatibleDifferences) override; 2386bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines bool ReadDiagnosticOptions(IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts, 239651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines bool Complain) override; 240651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines bool ReadFileSystemOptions(const FileSystemOptions &FSOpts, 241651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines bool Complain) override; 242651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines 243651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts, 2440e2c34f92f00628d48968dfea096d36381f494cbStephen Hines StringRef SpecificModuleCachePath, 245651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines bool Complain) override; 246651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, 247651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines bool Complain, 248651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines std::string &SuggestedPredefines) override; 249651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines 250651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void ReadCounter(const serialization::ModuleFile &M, unsigned Value) override; 251651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines bool needsInputFileVisitation() override; 252651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines bool needsSystemInputFileVisitation() override; 25387d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar void visitModuleFile(StringRef Filename, 25487d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar serialization::ModuleKind Kind) override; 255651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines bool visitInputFile(StringRef Filename, bool isSystem, 25687d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar bool isOverridden, bool isExplicitModule) override; 25787d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar void readModuleFileExtension( 25887d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar const ModuleFileExtensionMetadata &Metadata) override; 25911e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis}; 26011e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis 261571db7f0cb31789737be92fce1c1b738e6dbe795Sebastian Redl/// \brief ASTReaderListener implementation to validate the information of 26211e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis/// the PCH file against an initialized Preprocessor. 263571db7f0cb31789737be92fce1c1b738e6dbe795Sebastian Redlclass PCHValidator : public ASTReaderListener { 26411e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis Preprocessor &PP; 265c43b54cbc10654ed59de797898042e1a05265246Sebastian Redl ASTReader &Reader; 2661eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 26711e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidispublic: 268c43b54cbc10654ed59de797898042e1a05265246Sebastian Redl PCHValidator(Preprocessor &PP, ASTReader &Reader) 269f9ba851c9b5db8ea30846215e737702a1cc2c194Argyrios Kyrtzidis : PP(PP), Reader(Reader) {} 2701eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 271176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain, 272176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines bool AllowCompatibleDifferences) override; 2733ea9e33ea25e0c2b12db56418ba3f994eb662c04Pirama Arumuga Nainar bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain, 2743ea9e33ea25e0c2b12db56418ba3f994eb662c04Pirama Arumuga Nainar bool AllowCompatibleDifferences) override; 2756bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines bool ReadDiagnosticOptions(IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts, 2766bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines bool Complain) override; 277651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, bool Complain, 278651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines std::string &SuggestedPredefines) override; 2790e2c34f92f00628d48968dfea096d36381f494cbStephen Hines bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts, 2800e2c34f92f00628d48968dfea096d36381f494cbStephen Hines StringRef SpecificModuleCachePath, 2810e2c34f92f00628d48968dfea096d36381f494cbStephen Hines bool Complain) override; 282651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void ReadCounter(const serialization::ModuleFile &M, unsigned Value) override; 283d5d7b3f61f82b0fed9d6f02839bc72e528332911Ted Kremenek 284d5d7b3f61f82b0fed9d6f02839bc72e528332911Ted Kremenekprivate: 285d5d7b3f61f82b0fed9d6f02839bc72e528332911Ted Kremenek void Error(const char *Msg); 28611e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis}; 2872cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor 288ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikienamespace serialization { 2895d6d89fef8c7fff8b1a67c943fb5557a2a803468Jonathan D. Turner 2903d15ab8d0822637ff5e39594c4f34172241cad2eDouglas Gregorclass ReadMethodPoolVisitor; 291ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 29298339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregornamespace reader { 29398339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor class ASTIdentifierLookupTrait; 29487d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar /// \brief The on-disk hash table(s) used for DeclContext name lookup. 29587d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar struct DeclContextLookupTable; 29698339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor} 297ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 29872a9ae18553bf8b6bdad84d2c54f73741a47e275Douglas Gregor} // end namespace serialization 299ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 300c43b54cbc10654ed59de797898042e1a05265246Sebastian Redl/// \brief Reads an AST files chain containing the contents of a translation 301c43b54cbc10654ed59de797898042e1a05265246Sebastian Redl/// unit. 3022cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor/// 303c43b54cbc10654ed59de797898042e1a05265246Sebastian Redl/// The ASTReader class reads bitstreams (produced by the ASTWriter 3042cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor/// class) containing the serialized representation of a given 3052cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor/// abstract syntax tree and its supporting data structures. An 306c43b54cbc10654ed59de797898042e1a05265246Sebastian Redl/// instance of the ASTReader can be attached to an ASTContext object, 307c43b54cbc10654ed59de797898042e1a05265246Sebastian Redl/// which will provide access to the contents of the AST files. 3082cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor/// 309c43b54cbc10654ed59de797898042e1a05265246Sebastian Redl/// The AST reader provides lazy de-serialization of declarations, as 3102cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor/// required when traversing the AST. Only those AST nodes that are 3112cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor/// actually required will be de-serialized. 312c43b54cbc10654ed59de797898042e1a05265246Sebastian Redlclass ASTReader 31388a35862fbe473f2a4f0c19f24dbe536937e1dc6Douglas Gregor : public ExternalPreprocessorSource, 3146a5a23f8e7fb65e028c8092bc1d1a1d9dfe2e9bcDouglas Gregor public ExternalPreprocessingRecordSource, 315cfbf1c7536e016dc275139dd842d4a5f059a749fDouglas Gregor public ExternalHeaderFileInfoSource, 31688a35862fbe473f2a4f0c19f24dbe536937e1dc6Douglas Gregor public ExternalSemaSource, 3178c5a760b82e73ed90b560090772db97e2ae27b09Douglas Gregor public IdentifierInfoLookup, 318ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie public ExternalSLocEntrySource 319cfbf1c7536e016dc275139dd842d4a5f059a749fDouglas Gregor{ 320e1d918e9fe55e3b34401fd5d420c47ea0f9572c9Douglas Gregorpublic: 321260611a32535c851237926bfcf78869b13c07d5bJohn McCall typedef SmallVector<uint64_t, 64> RecordData; 322ac32d9044b9c1e7492cef929a322d23ce899d276Richard Smith typedef SmallVectorImpl<uint64_t> RecordDataImpl; 323260611a32535c851237926bfcf78869b13c07d5bJohn McCall 3244825fd7fbb3fe87cdf8da9bccc1361fac45bdf2dDouglas Gregor /// \brief The result of reading the control block of an AST file, which 3254825fd7fbb3fe87cdf8da9bccc1361fac45bdf2dDouglas Gregor /// can fail for various reasons. 3264825fd7fbb3fe87cdf8da9bccc1361fac45bdf2dDouglas Gregor enum ASTReadResult { 3274825fd7fbb3fe87cdf8da9bccc1361fac45bdf2dDouglas Gregor /// \brief The control block was read successfully. Aside from failures, 3284825fd7fbb3fe87cdf8da9bccc1361fac45bdf2dDouglas Gregor /// the AST file is safe to read into the current context. 3294825fd7fbb3fe87cdf8da9bccc1361fac45bdf2dDouglas Gregor Success, 3304825fd7fbb3fe87cdf8da9bccc1361fac45bdf2dDouglas Gregor /// \brief The AST file itself appears corrupted. 3314825fd7fbb3fe87cdf8da9bccc1361fac45bdf2dDouglas Gregor Failure, 332677e15ffee2ecc9c1c8f46fd77cab4b5afb59640Douglas Gregor /// \brief The AST file was missing. 333677e15ffee2ecc9c1c8f46fd77cab4b5afb59640Douglas Gregor Missing, 3344825fd7fbb3fe87cdf8da9bccc1361fac45bdf2dDouglas Gregor /// \brief The AST file is out-of-date relative to its input files, 3354825fd7fbb3fe87cdf8da9bccc1361fac45bdf2dDouglas Gregor /// and needs to be regenerated. 3364825fd7fbb3fe87cdf8da9bccc1361fac45bdf2dDouglas Gregor OutOfDate, 3374825fd7fbb3fe87cdf8da9bccc1361fac45bdf2dDouglas Gregor /// \brief The AST file was written by a different version of Clang. 3384825fd7fbb3fe87cdf8da9bccc1361fac45bdf2dDouglas Gregor VersionMismatch, 3394825fd7fbb3fe87cdf8da9bccc1361fac45bdf2dDouglas Gregor /// \brief The AST file was writtten with a different language/target 3404825fd7fbb3fe87cdf8da9bccc1361fac45bdf2dDouglas Gregor /// configuration. 3414825fd7fbb3fe87cdf8da9bccc1361fac45bdf2dDouglas Gregor ConfigurationMismatch, 3424825fd7fbb3fe87cdf8da9bccc1361fac45bdf2dDouglas Gregor /// \brief The AST file has errors. 3434825fd7fbb3fe87cdf8da9bccc1361fac45bdf2dDouglas Gregor HadErrors 3444825fd7fbb3fe87cdf8da9bccc1361fac45bdf2dDouglas Gregor }; 3454825fd7fbb3fe87cdf8da9bccc1361fac45bdf2dDouglas Gregor 3461d9f1fe7173e3084325f43c78af812a36d8a2a7cSebastian Redl /// \brief Types of AST files. 347d5d7b3f61f82b0fed9d6f02839bc72e528332911Ted Kremenek friend class PCHValidator; 348d527cc06d78fe5afa5f20105b51697637eb02c56Sebastian Redl friend class ASTDeclReader; 349c3632730cc83ed7b51f0ab5c38997ae5a9439b0cSebastian Redl friend class ASTStmtReader; 35095f4292cc526c629fead321c7fcfd4fe0f3bc66eDouglas Gregor friend class ASTIdentifierIterator; 35198339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor friend class serialization::reader::ASTIdentifierLookupTrait; 352c3632730cc83ed7b51f0ab5c38997ae5a9439b0cSebastian Redl friend class TypeLocReader; 353f62d43d2afe1960755a1b5813cae1e5983bcac1bDouglas Gregor friend class ASTWriter; 354f62d43d2afe1960755a1b5813cae1e5983bcac1bDouglas Gregor friend class ASTUnit; // ASTUnit needs to remap source locations. 3553d15ab8d0822637ff5e39594c4f34172241cad2eDouglas Gregor friend class serialization::ReadMethodPoolVisitor; 356ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 3571a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor typedef serialization::ModuleFile ModuleFile; 35872a9ae18553bf8b6bdad84d2c54f73741a47e275Douglas Gregor typedef serialization::ModuleKind ModuleKind; 3595d6d89fef8c7fff8b1a67c943fb5557a2a803468Jonathan D. Turner typedef serialization::ModuleManager ModuleManager; 360ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 3615d6d89fef8c7fff8b1a67c943fb5557a2a803468Jonathan D. Turner typedef ModuleManager::ModuleIterator ModuleIterator; 3625d6d89fef8c7fff8b1a67c943fb5557a2a803468Jonathan D. Turner typedef ModuleManager::ModuleConstIterator ModuleConstIterator; 3635d6d89fef8c7fff8b1a67c943fb5557a2a803468Jonathan D. Turner typedef ModuleManager::ModuleReverseIterator ModuleReverseIterator; 3645d6d89fef8c7fff8b1a67c943fb5557a2a803468Jonathan D. Turner 365e1d918e9fe55e3b34401fd5d420c47ea0f9572c9Douglas Gregorprivate: 366c43b54cbc10654ed59de797898042e1a05265246Sebastian Redl /// \brief The receiver of some callbacks invoked by ASTReader. 367651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines std::unique_ptr<ASTReaderListener> Listener; 3681eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 36930c514c225342844700ed4640ec6d90ddf0e12b2Sebastian Redl /// \brief The receiver of deserialization events. 370571db7f0cb31789737be92fce1c1b738e6dbe795Sebastian Redl ASTDeserializationListener *DeserializationListener; 3716bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines bool OwnsDeserializationListener; 37230c514c225342844700ed4640ec6d90ddf0e12b2Sebastian Redl 37311e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis SourceManager &SourceMgr; 37411e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis FileManager &FileMgr; 37587d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar const PCHContainerReader &PCHContainerRdr; 376d6471f7c1921c7802804ce3ff6fe9768310f72b9David Blaikie DiagnosticsEngine &Diags; 377ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 378668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor /// \brief The semantic analysis object that will be processing the 3793c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// AST files and the translation unit that uses it. 380668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor Sema *SemaObj; 381668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor 38214f79002e58556798e86168c63e48d533287eda5Douglas Gregor /// \brief The preprocessor that will be loading the source file. 383712f2fcb70ae2eb0cb684d565e7d2cb76881006bDouglas Gregor Preprocessor &PP; 38414f79002e58556798e86168c63e48d533287eda5Douglas Gregor 3853c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// \brief The AST context into which we'll read the AST files. 386359427794704666ff7a5a933ace11c5256fa3af7Douglas Gregor ASTContext &Context; 387ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 3880af2ca4b6ddc788658069a0994941268ce250fc7Douglas Gregor /// \brief The AST consumer. 3890af2ca4b6ddc788658069a0994941268ce250fc7Douglas Gregor ASTConsumer *Consumer; 3900af2ca4b6ddc788658069a0994941268ce250fc7Douglas Gregor 3915d6d89fef8c7fff8b1a67c943fb5557a2a803468Jonathan D. Turner /// \brief The module manager which manages modules and their dependencies 3925d6d89fef8c7fff8b1a67c943fb5557a2a803468Jonathan D. Turner ModuleManager ModuleMgr; 3939137a5230d3164b96beb14ffb87863234b7d240fSebastian Redl 3944967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar /// \brief A dummy identifier resolver used to merge TU-scope declarations in 3954967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar /// C, for the cases where we don't have a Sema object to provide a real 3964967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar /// identifier resolver. 3974967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar IdentifierResolver DummyIdResolver; 3984967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar 39987d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar /// A mapping from extension block names to module file extensions. 40087d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar llvm::StringMap<IntrusiveRefCntPtr<ModuleFileExtension>> ModuleFileExtensions; 40187d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar 40287d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar /// \brief A timer used to track the time spent deserializing. 40387d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar std::unique_ptr<llvm::Timer> ReadTimer; 40487d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar 4053b7deda7137e62810a810ce25b062927a9fc7c71Argyrios Kyrtzidis /// \brief The location where the module file will be considered as 4063b7deda7137e62810a810ce25b062927a9fc7c71Argyrios Kyrtzidis /// imported from. For non-module AST types it should be invalid. 4073b7deda7137e62810a810ce25b062927a9fc7c71Argyrios Kyrtzidis SourceLocation CurrentImportLoc; 4083b7deda7137e62810a810ce25b062927a9fc7c71Argyrios Kyrtzidis 4091a49d97d762570027863e9209af81d445e4f1502Douglas Gregor /// \brief The global module index, if loaded. 410651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines std::unique_ptr<GlobalModuleIndex> GlobalIndex; 4111a49d97d762570027863e9209af81d445e4f1502Douglas Gregor 4128f1231b70c2b1f6fe0cee097b447487b26810301Douglas Gregor /// \brief A map of global bit offsets to the module that stores entities 4138f1231b70c2b1f6fe0cee097b447487b26810301Douglas Gregor /// at those bit offsets. 4141a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor ContinuousRangeMap<uint64_t, ModuleFile*, 4> GlobalBitOffsetsMap; 4158f1231b70c2b1f6fe0cee097b447487b26810301Douglas Gregor 416f62d43d2afe1960755a1b5813cae1e5983bcac1bDouglas Gregor /// \brief A map of negated SLocEntryIDs to the modules containing them. 4171a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor ContinuousRangeMap<unsigned, ModuleFile*, 64> GlobalSLocEntryMap; 4184ee5a6f9bd82ab3c1a4bdacc0caefe7d5f8bd37aSebastian Redl 4191a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor typedef ContinuousRangeMap<unsigned, ModuleFile*, 64> GlobalSLocOffsetMapType; 420ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 421a68c4aff8cd3aada697ad36dc6582d0e09b4b0d2Argyrios Kyrtzidis /// \brief A map of reversed (SourceManager::MaxLoadedOffset - SLocOffset) 422a68c4aff8cd3aada697ad36dc6582d0e09b4b0d2Argyrios Kyrtzidis /// SourceLocation offsets to the modules containing them. 4232dbaca748bc3eb6539f417bd8354c930bdf88fa4Argyrios Kyrtzidis GlobalSLocOffsetMapType GlobalSLocOffsetMap; 424ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 4253c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// \brief Types that have already been loaded from the chain. 4261eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// 4271eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// When the pointer at index I is non-NULL, the type with 4283c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// ID = (I + 1) << FastQual::Width has already been loaded 4290953e767ff7817f97b3ab20896b229891eeff45bJohn McCall std::vector<QualType> TypesLoaded; 4302cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor 4311a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor typedef ContinuousRangeMap<serialization::TypeID, ModuleFile *, 4> 432e9b76c11a88d0af98f32d11a6668d03d45be3123Jonathan D. Turner GlobalTypeMapType; 433e9b76c11a88d0af98f32d11a6668d03d45be3123Jonathan D. Turner 434e9b76c11a88d0af98f32d11a6668d03d45be3123Jonathan D. Turner /// \brief Mapping from global type IDs to the module in which the 435e9b76c11a88d0af98f32d11a6668d03d45be3123Jonathan D. Turner /// type resides along with the offset that should be added to the 436e9b76c11a88d0af98f32d11a6668d03d45be3123Jonathan D. Turner /// global type ID to produce a local ID. 437e9b76c11a88d0af98f32d11a6668d03d45be3123Jonathan D. Turner GlobalTypeMapType GlobalTypeMap; 438e9b76c11a88d0af98f32d11a6668d03d45be3123Jonathan D. Turner 4393c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// \brief Declarations that have already been loaded from the chain. 4402cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor /// 4418f5dc7fe4d42cea78fa92d1638f753cf65b54cb5Douglas Gregor /// When the pointer at index I is non-NULL, the declaration with ID 4428f5dc7fe4d42cea78fa92d1638f753cf65b54cb5Douglas Gregor /// = I + 1 has already been loaded. 4438f5dc7fe4d42cea78fa92d1638f753cf65b54cb5Douglas Gregor std::vector<Decl *> DeclsLoaded; 4442cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor 4451a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor typedef ContinuousRangeMap<serialization::DeclID, ModuleFile *, 4> 44696e973f2be14c9b82136f74b4108465d24894feaDouglas Gregor GlobalDeclMapType; 447ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 44896e973f2be14c9b82136f74b4108465d24894feaDouglas Gregor /// \brief Mapping from global declaration IDs to the module in which the 4499827a8049a793f23c62ade8f24f0c66c2dbf6741Douglas Gregor /// declaration resides. 45096e973f2be14c9b82136f74b4108465d24894feaDouglas Gregor GlobalDeclMapType GlobalDeclMap; 451ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 4521a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor typedef std::pair<ModuleFile *, uint64_t> FileOffset; 453686775deca8b8685eb90801495880e3abdd844c2Chris Lattner typedef SmallVector<FileOffset, 2> FileOffsetsTy; 4547b90340c9c7d07aef4e301e72b5e8a30d5f4f0c8Argyrios Kyrtzidis typedef llvm::DenseMap<serialization::DeclID, FileOffsetsTy> 4557b90340c9c7d07aef4e301e72b5e8a30d5f4f0c8Argyrios Kyrtzidis DeclUpdateOffsetsMap; 456ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 4577b90340c9c7d07aef4e301e72b5e8a30d5f4f0c8Argyrios Kyrtzidis /// \brief Declarations that have modifications residing in a later file 4587b90340c9c7d07aef4e301e72b5e8a30d5f4f0c8Argyrios Kyrtzidis /// in the chain. 4597b90340c9c7d07aef4e301e72b5e8a30d5f4f0c8Argyrios Kyrtzidis DeclUpdateOffsetsMap DeclUpdateOffsets; 4607b90340c9c7d07aef4e301e72b5e8a30d5f4f0c8Argyrios Kyrtzidis 4616bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines /// \brief Declaration updates for already-loaded declarations that we need 4626bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines /// to apply once we finish processing an import. 4636bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines llvm::SmallVector<std::pair<serialization::GlobalDeclID, Decl*>, 16> 4646bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines PendingUpdateRecords; 4656bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines 4660e2c34f92f00628d48968dfea096d36381f494cbStephen Hines enum class PendingFakeDefinitionKind { NotFake, Fake, FakeLoaded }; 4670e2c34f92f00628d48968dfea096d36381f494cbStephen Hines 4680e2c34f92f00628d48968dfea096d36381f494cbStephen Hines /// \brief The DefinitionData pointers that we faked up for class definitions 4690e2c34f92f00628d48968dfea096d36381f494cbStephen Hines /// that we needed but hadn't loaded yet. 4700e2c34f92f00628d48968dfea096d36381f494cbStephen Hines llvm::DenseMap<void *, PendingFakeDefinitionKind> PendingFakeDefinitionData; 4710e2c34f92f00628d48968dfea096d36381f494cbStephen Hines 4723ea9e33ea25e0c2b12db56418ba3f994eb662c04Pirama Arumuga Nainar /// \brief Exception specification updates that have been loaded but not yet 4733ea9e33ea25e0c2b12db56418ba3f994eb662c04Pirama Arumuga Nainar /// propagated across the relevant redeclaration chain. The map key is the 4743ea9e33ea25e0c2b12db56418ba3f994eb662c04Pirama Arumuga Nainar /// canonical declaration (used only for deduplication) and the value is a 4753ea9e33ea25e0c2b12db56418ba3f994eb662c04Pirama Arumuga Nainar /// declaration that has an exception specification. 4763ea9e33ea25e0c2b12db56418ba3f994eb662c04Pirama Arumuga Nainar llvm::SmallMapVector<Decl *, FunctionDecl *, 4> PendingExceptionSpecUpdates; 4773ea9e33ea25e0c2b12db56418ba3f994eb662c04Pirama Arumuga Nainar 478176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines /// \brief Declarations that have been imported and have typedef names for 479176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines /// linkage purposes. 480176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines llvm::DenseMap<std::pair<DeclContext*, IdentifierInfo*>, NamedDecl*> 481176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines ImportedTypedefNamesForLinkage; 482176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines 483176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines /// \brief Mergeable declaration contexts that have anonymous declarations 484176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines /// within them, and those anonymous declarations. 485176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines llvm::DenseMap<DeclContext*, llvm::SmallVector<NamedDecl*, 2>> 486176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines AnonymousDeclarationsForMerging; 487176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines 4889d128d04578c62675eeb0cce83066052f9c19c9aArgyrios Kyrtzidis struct FileDeclsInfo { 4891a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor ModuleFile *Mod; 4909d128d04578c62675eeb0cce83066052f9c19c9aArgyrios Kyrtzidis ArrayRef<serialization::LocalDeclID> Decls; 4919d128d04578c62675eeb0cce83066052f9c19c9aArgyrios Kyrtzidis 4926bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines FileDeclsInfo() : Mod(nullptr) {} 4931a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor FileDeclsInfo(ModuleFile *Mod, ArrayRef<serialization::LocalDeclID> Decls) 4949d128d04578c62675eeb0cce83066052f9c19c9aArgyrios Kyrtzidis : Mod(Mod), Decls(Decls) {} 4959d128d04578c62675eeb0cce83066052f9c19c9aArgyrios Kyrtzidis }; 4969d128d04578c62675eeb0cce83066052f9c19c9aArgyrios Kyrtzidis 49710f3df54486385e6497c9e5f229ff816e5a6c511Argyrios Kyrtzidis /// \brief Map from a FileID to the file-level declarations that it contains. 4989d128d04578c62675eeb0cce83066052f9c19c9aArgyrios Kyrtzidis llvm::DenseMap<FileID, FileDeclsInfo> FileDeclIDs; 49910f3df54486385e6497c9e5f229ff816e5a6c511Argyrios Kyrtzidis 50087d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar /// \brief An array of lexical contents of a declaration context, as a sequence of 50187d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar /// Decl::Kind, DeclID pairs. 50287d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar typedef ArrayRef<llvm::support::unaligned_uint32_t> LexicalContents; 50387d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar 50487d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar /// \brief Map from a DeclContext to its lexical contents. 50587d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar llvm::DenseMap<const DeclContext*, std::pair<ModuleFile*, LexicalContents>> 50687d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar LexicalDecls; 50787d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar 50887d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar /// \brief Map from the TU to its lexical contents from each module file. 50987d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar std::vector<std::pair<ModuleFile*, LexicalContents>> TULexicalDecls; 51087d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar 51187d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar /// \brief Map from a DeclContext to its lookup tables. 51287d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar llvm::DenseMap<const DeclContext *, 51387d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar serialization::reader::DeclContextLookupTable> Lookups; 51487d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar 515e1dde811b38e779894150cb1093d57f8411a84f7Sebastian Redl // Updates for visible decls can occur for other contexts than just the 51687d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar // TU, and when we read those update records, the actual context may not 51787d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar // be available yet, so have this pending map using the ID as a key. It 51887d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar // will be realized when the context is actually loaded. 51987d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar struct PendingVisibleUpdate { 52087d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar ModuleFile *Mod; 52187d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar const unsigned char *Data; 52287d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar }; 52387d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar typedef SmallVector<PendingVisibleUpdate, 1> DeclContextVisibleUpdates; 5242cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor 525e1dde811b38e779894150cb1093d57f8411a84f7Sebastian Redl /// \brief Updates to the visible declarations of declaration contexts that 526e1dde811b38e779894150cb1093d57f8411a84f7Sebastian Redl /// haven't been loaded yet. 52787d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar llvm::DenseMap<serialization::DeclID, DeclContextVisibleUpdates> 52887d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar PendingVisibleUpdates; 52987d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar 530fc529f7fcafe7da0b8a32621e13685891e8ce52aDouglas Gregor /// \brief The set of C++ or Objective-C classes that have forward 531fc529f7fcafe7da0b8a32621e13685891e8ce52aDouglas Gregor /// declarations that have not yet been linked to their definitions. 532fc529f7fcafe7da0b8a32621e13685891e8ce52aDouglas Gregor llvm::SmallPtrSet<Decl *, 4> PendingDefinitions; 5335456b0fe40714a78cd0ba7c1a5b7dc34eda385afDouglas Gregor 534ce12d2f8863588d408897602089d17c4d3c3d0e5Douglas Gregor typedef llvm::MapVector<Decl *, uint64_t, 535ce12d2f8863588d408897602089d17c4d3c3d0e5Douglas Gregor llvm::SmallDenseMap<Decl *, unsigned, 4>, 536cfa88f893915ceb8ae4ce2f17c46c24a4d67502fDmitri Gribenko SmallVector<std::pair<Decl *, uint64_t>, 4> > 537ce12d2f8863588d408897602089d17c4d3c3d0e5Douglas Gregor PendingBodiesMap; 538ce12d2f8863588d408897602089d17c4d3c3d0e5Douglas Gregor 5395456b0fe40714a78cd0ba7c1a5b7dc34eda385afDouglas Gregor /// \brief Functions or methods that have bodies that will be attached. 540ce12d2f8863588d408897602089d17c4d3c3d0e5Douglas Gregor PendingBodiesMap PendingBodies; 5415456b0fe40714a78cd0ba7c1a5b7dc34eda385afDouglas Gregor 542b6d6993e6e6d3daf4d9876794254d20a134e37c2Pirama Arumuga Nainar /// \brief Definitions for which we have added merged definitions but not yet 543b6d6993e6e6d3daf4d9876794254d20a134e37c2Pirama Arumuga Nainar /// performed deduplication. 544b6d6993e6e6d3daf4d9876794254d20a134e37c2Pirama Arumuga Nainar llvm::SetVector<NamedDecl*> PendingMergedDefinitionsToDeduplicate; 545b6d6993e6e6d3daf4d9876794254d20a134e37c2Pirama Arumuga Nainar 54687d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar /// \brief Read the record that describes the lexical contents of a DC. 54787d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar bool ReadLexicalDeclContextStorage(ModuleFile &M, 54887d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar llvm::BitstreamCursor &Cursor, 54987d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar uint64_t Offset, DeclContext *DC); 55087d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar /// \brief Read the record that describes the visible contents of a DC. 55187d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar bool ReadVisibleDeclContextStorage(ModuleFile &M, 55287d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar llvm::BitstreamCursor &Cursor, 55387d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar uint64_t Offset, serialization::DeclID ID); 554681d7237e1014bf64dd5ead6bf74ae55cdd19e61Sebastian Redl 5552b3a5a83ea30bde7fa8f9d8e9a0cb12623759bfbDouglas Gregor /// \brief A vector containing identifiers that have already been 5562b3a5a83ea30bde7fa8f9d8e9a0cb12623759bfbDouglas Gregor /// loaded. 5572b3a5a83ea30bde7fa8f9d8e9a0cb12623759bfbDouglas Gregor /// 5582b3a5a83ea30bde7fa8f9d8e9a0cb12623759bfbDouglas Gregor /// If the pointer at index I is non-NULL, then it refers to the 5592b3a5a83ea30bde7fa8f9d8e9a0cb12623759bfbDouglas Gregor /// IdentifierInfo for the identifier with ID=I+1 that has already 5602b3a5a83ea30bde7fa8f9d8e9a0cb12623759bfbDouglas Gregor /// been loaded. 5612b3a5a83ea30bde7fa8f9d8e9a0cb12623759bfbDouglas Gregor std::vector<IdentifierInfo *> IdentifiersLoaded; 562afaf308b779cd8e8fc8c42601b9f383423c15c2dDouglas Gregor 5631a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor typedef ContinuousRangeMap<serialization::IdentID, ModuleFile *, 4> 56467268d02388d3d25107fa9cf4998c35246255a65Douglas Gregor GlobalIdentifierMapType; 565ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 566a8235d6c4093cd38dcf742909651f867de62e55bDouglas Gregor /// \brief Mapping from global identifier IDs to the module in which the 56767268d02388d3d25107fa9cf4998c35246255a65Douglas Gregor /// identifier resides along with the offset that should be added to the 56867268d02388d3d25107fa9cf4998c35246255a65Douglas Gregor /// global identifier ID to produce a local ID. 56967268d02388d3d25107fa9cf4998c35246255a65Douglas Gregor GlobalIdentifierMapType GlobalIdentifierMap; 57067268d02388d3d25107fa9cf4998c35246255a65Douglas Gregor 571a8235d6c4093cd38dcf742909651f867de62e55bDouglas Gregor /// \brief A vector containing macros that have already been 572a8235d6c4093cd38dcf742909651f867de62e55bDouglas Gregor /// loaded. 573a8235d6c4093cd38dcf742909651f867de62e55bDouglas Gregor /// 574a8235d6c4093cd38dcf742909651f867de62e55bDouglas Gregor /// If the pointer at index I is non-NULL, then it refers to the 575a8235d6c4093cd38dcf742909651f867de62e55bDouglas Gregor /// MacroInfo for the identifier with ID=I+1 that has already 576a8235d6c4093cd38dcf742909651f867de62e55bDouglas Gregor /// been loaded. 5779317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis std::vector<MacroInfo *> MacrosLoaded; 578a8235d6c4093cd38dcf742909651f867de62e55bDouglas Gregor 5793ea9e33ea25e0c2b12db56418ba3f994eb662c04Pirama Arumuga Nainar typedef std::pair<IdentifierInfo *, serialization::SubmoduleID> 5803ea9e33ea25e0c2b12db56418ba3f994eb662c04Pirama Arumuga Nainar LoadedMacroInfo; 5813ea9e33ea25e0c2b12db56418ba3f994eb662c04Pirama Arumuga Nainar 5823ea9e33ea25e0c2b12db56418ba3f994eb662c04Pirama Arumuga Nainar /// \brief A set of #undef directives that we have loaded; used to 5833ea9e33ea25e0c2b12db56418ba3f994eb662c04Pirama Arumuga Nainar /// deduplicate the same #undef information coming from multiple module 5843ea9e33ea25e0c2b12db56418ba3f994eb662c04Pirama Arumuga Nainar /// files. 5853ea9e33ea25e0c2b12db56418ba3f994eb662c04Pirama Arumuga Nainar llvm::DenseSet<LoadedMacroInfo> LoadedUndefs; 5863ea9e33ea25e0c2b12db56418ba3f994eb662c04Pirama Arumuga Nainar 587a8235d6c4093cd38dcf742909651f867de62e55bDouglas Gregor typedef ContinuousRangeMap<serialization::MacroID, ModuleFile *, 4> 588a8235d6c4093cd38dcf742909651f867de62e55bDouglas Gregor GlobalMacroMapType; 589a8235d6c4093cd38dcf742909651f867de62e55bDouglas Gregor 590a8235d6c4093cd38dcf742909651f867de62e55bDouglas Gregor /// \brief Mapping from global macro IDs to the module in which the 591a8235d6c4093cd38dcf742909651f867de62e55bDouglas Gregor /// macro resides along with the offset that should be added to the 592a8235d6c4093cd38dcf742909651f867de62e55bDouglas Gregor /// global macro ID to produce a local ID. 593a8235d6c4093cd38dcf742909651f867de62e55bDouglas Gregor GlobalMacroMapType GlobalMacroMap; 594a8235d6c4093cd38dcf742909651f867de62e55bDouglas Gregor 59526ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor /// \brief A vector containing submodules that have already been loaded. 59626ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor /// 59726ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor /// This vector is indexed by the Submodule ID (-1). NULL submodule entries 59826ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor /// indicate that the particular submodule ID has not yet been loaded. 59926ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor SmallVector<Module *, 2> SubmodulesLoaded; 60026ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor 60126ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor typedef ContinuousRangeMap<serialization::SubmoduleID, ModuleFile *, 4> 60226ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor GlobalSubmoduleMapType; 60326ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor 60426ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor /// \brief Mapping from global submodule IDs to the module file in which the 60526ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor /// submodule resides along with the offset that should be added to the 60626ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor /// global submodule ID to produce a local ID. 60726ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor GlobalSubmoduleMapType GlobalSubmoduleMap; 60826ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor 609ecc2c090e7146c029dd9ee9a5a2fd66b275c01c0Douglas Gregor /// \brief A set of hidden declarations. 610b6d6993e6e6d3daf4d9876794254d20a134e37c2Pirama Arumuga Nainar typedef SmallVector<Decl*, 2> HiddenNames; 611ecc2c090e7146c029dd9ee9a5a2fd66b275c01c0Douglas Gregor typedef llvm::DenseMap<Module *, HiddenNames> HiddenNamesMapType; 612ecc2c090e7146c029dd9ee9a5a2fd66b275c01c0Douglas Gregor 613ecc2c090e7146c029dd9ee9a5a2fd66b275c01c0Douglas Gregor /// \brief A mapping from each of the hidden submodules to the deserialized 614ecc2c090e7146c029dd9ee9a5a2fd66b275c01c0Douglas Gregor /// declarations in that submodule that could be made visible. 615ecc2c090e7146c029dd9ee9a5a2fd66b275c01c0Douglas Gregor HiddenNamesMapType HiddenNamesMap; 616ecc2c090e7146c029dd9ee9a5a2fd66b275c01c0Douglas Gregor 61755988680ece66b8e505ee136b35e74fcb1173aeeDouglas Gregor 618906d66acc5cf2679453e10a4f0a67feedd765b21Douglas Gregor /// \brief A module import, export, or conflict that hasn't yet been resolved. 619906d66acc5cf2679453e10a4f0a67feedd765b21Douglas Gregor struct UnresolvedModuleRef { 620af13bfc3b40aa4a46f4e71d200ecfb10f45297fcDouglas Gregor /// \brief The file in which this module resides. 621af13bfc3b40aa4a46f4e71d200ecfb10f45297fcDouglas Gregor ModuleFile *File; 622af13bfc3b40aa4a46f4e71d200ecfb10f45297fcDouglas Gregor 62355988680ece66b8e505ee136b35e74fcb1173aeeDouglas Gregor /// \brief The module that is importing or exporting. 62455988680ece66b8e505ee136b35e74fcb1173aeeDouglas Gregor Module *Mod; 625906d66acc5cf2679453e10a4f0a67feedd765b21Douglas Gregor 626906d66acc5cf2679453e10a4f0a67feedd765b21Douglas Gregor /// \brief The kind of module reference. 627906d66acc5cf2679453e10a4f0a67feedd765b21Douglas Gregor enum { Import, Export, Conflict } Kind; 628906d66acc5cf2679453e10a4f0a67feedd765b21Douglas Gregor 629af13bfc3b40aa4a46f4e71d200ecfb10f45297fcDouglas Gregor /// \brief The local ID of the module that is being exported. 63055988680ece66b8e505ee136b35e74fcb1173aeeDouglas Gregor unsigned ID; 631906d66acc5cf2679453e10a4f0a67feedd765b21Douglas Gregor 63255988680ece66b8e505ee136b35e74fcb1173aeeDouglas Gregor /// \brief Whether this is a wildcard export. 63355988680ece66b8e505ee136b35e74fcb1173aeeDouglas Gregor unsigned IsWildcard : 1; 634906d66acc5cf2679453e10a4f0a67feedd765b21Douglas Gregor 635906d66acc5cf2679453e10a4f0a67feedd765b21Douglas Gregor /// \brief String data. 636906d66acc5cf2679453e10a4f0a67feedd765b21Douglas Gregor StringRef String; 637af13bfc3b40aa4a46f4e71d200ecfb10f45297fcDouglas Gregor }; 638af13bfc3b40aa4a46f4e71d200ecfb10f45297fcDouglas Gregor 63955988680ece66b8e505ee136b35e74fcb1173aeeDouglas Gregor /// \brief The set of module imports and exports that still need to be 64055988680ece66b8e505ee136b35e74fcb1173aeeDouglas Gregor /// resolved. 641906d66acc5cf2679453e10a4f0a67feedd765b21Douglas Gregor SmallVector<UnresolvedModuleRef, 2> UnresolvedModuleRefs; 642af13bfc3b40aa4a46f4e71d200ecfb10f45297fcDouglas Gregor 6431eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// \brief A vector containing selectors that have already been loaded. 64483941df2745d69c05acee3174c7a265c206f70d9Douglas Gregor /// 64583941df2745d69c05acee3174c7a265c206f70d9Douglas Gregor /// This vector is indexed by the Selector ID (-1). NULL selector 64683941df2745d69c05acee3174c7a265c206f70d9Douglas Gregor /// entries indicate that the particular selector ID has not yet 64783941df2745d69c05acee3174c7a265c206f70d9Douglas Gregor /// been loaded. 648686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVector<Selector, 16> SelectorsLoaded; 649725cd9686a0f5bb6c994cb3e43f58b63567c6860Sebastian Redl 6501a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor typedef ContinuousRangeMap<serialization::SelectorID, ModuleFile *, 4> 65196958cbe6fb423ab2446629ead5f1b138398433cDouglas Gregor GlobalSelectorMapType; 652ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 65396958cbe6fb423ab2446629ead5f1b138398433cDouglas Gregor /// \brief Mapping from global selector IDs to the module in which the 65495fb36ebddcbdcd6b801c5d3d2d85dac315b4127Douglas Gregor 65596958cbe6fb423ab2446629ead5f1b138398433cDouglas Gregor /// global selector ID to produce a local ID. 65696958cbe6fb423ab2446629ead5f1b138398433cDouglas Gregor GlobalSelectorMapType GlobalSelectorMap; 65796958cbe6fb423ab2446629ead5f1b138398433cDouglas Gregor 6588efca6bb688d32fd7c0d91b504ef3307f97ee66aDouglas Gregor /// \brief The generation number of the last time we loaded data from the 6598efca6bb688d32fd7c0d91b504ef3307f97ee66aDouglas Gregor /// global method pool for this selector. 6608efca6bb688d32fd7c0d91b504ef3307f97ee66aDouglas Gregor llvm::DenseMap<Selector, unsigned> SelectorGeneration; 6618efca6bb688d32fd7c0d91b504ef3307f97ee66aDouglas Gregor 6624967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar /// Whether a selector is out of date. We mark a selector as out of date 6634967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar /// if we load another module after the method pool entry was pulled in. 6644967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar llvm::DenseMap<Selector, bool> SelectorOutOfDate; 6654967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar 6669317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis struct PendingMacroInfo { 6679317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis ModuleFile *M; 668b6d6993e6e6d3daf4d9876794254d20a134e37c2Pirama Arumuga Nainar uint64_t MacroDirectivesOffset; 6699317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis 670b6d6993e6e6d3daf4d9876794254d20a134e37c2Pirama Arumuga Nainar PendingMacroInfo(ModuleFile *M, uint64_t MacroDirectivesOffset) 671b6d6993e6e6d3daf4d9876794254d20a134e37c2Pirama Arumuga Nainar : M(M), MacroDirectivesOffset(MacroDirectivesOffset) {} 6729317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis }; 6739317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis 6749317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis typedef llvm::MapVector<IdentifierInfo *, SmallVector<PendingMacroInfo, 2> > 6756c6c54a59a6e7dbe63ff6a9bbab76f6e0c7c8462Douglas Gregor PendingMacroIDsMap; 6766c6c54a59a6e7dbe63ff6a9bbab76f6e0c7c8462Douglas Gregor 6776c6c54a59a6e7dbe63ff6a9bbab76f6e0c7c8462Douglas Gregor /// \brief Mapping from identifiers that have a macro history to the global 6786c6c54a59a6e7dbe63ff6a9bbab76f6e0c7c8462Douglas Gregor /// IDs have not yet been deserialized to the global IDs of those macros. 6796c6c54a59a6e7dbe63ff6a9bbab76f6e0c7c8462Douglas Gregor PendingMacroIDsMap PendingMacroIDs; 6804c30bb148b53c8063e940ca3e049ba4d270dc9d5Douglas Gregor 6811a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor typedef ContinuousRangeMap<unsigned, ModuleFile *, 4> 6824c30bb148b53c8063e940ca3e049ba4d270dc9d5Douglas Gregor GlobalPreprocessedEntityMapType; 683ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 6844c30bb148b53c8063e940ca3e049ba4d270dc9d5Douglas Gregor /// \brief Mapping from global preprocessing entity IDs to the module in 6854c30bb148b53c8063e940ca3e049ba4d270dc9d5Douglas Gregor /// which the preprocessed entity resides along with the offset that should be 6864c30bb148b53c8063e940ca3e049ba4d270dc9d5Douglas Gregor /// added to the global preprocessing entitiy ID to produce a local ID. 6874c30bb148b53c8063e940ca3e049ba4d270dc9d5Douglas Gregor GlobalPreprocessedEntityMapType GlobalPreprocessedEntityMap; 688ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 689892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// \name CodeGen-relevant special data 690892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// \brief Fields containing data that is relevant to CodeGen. 691892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl //@{ 692892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl 693892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// \brief The IDs of all declarations that fulfill the criteria of 694892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// "interesting" decls. 695892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// 696651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines /// This contains the data loaded from all EAGERLY_DESERIALIZED_DECLS blocks 697651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines /// in the chain. The referenced declarations are deserialized and passed to 698651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines /// the consumer eagerly. 699651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines SmallVector<uint64_t, 16> EagerlyDeserializedDecls; 700fdd0172ca1b3c837f8c2b37d69cc2085234e09faDouglas Gregor 701bed28ac1d1463adca3ecf24fca5c30646fa9dbb2Sylvestre Ledru /// \brief The IDs of all tentative definitions stored in the chain. 702892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// 703892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// Sema keeps track of all tentative definitions in a TU because it has to 704892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// complete them and pass them on to CodeGen. Thus, tentative definitions in 705892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// the PCH chain must be eagerly deserialized. 706686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVector<uint64_t, 16> TentativeDefinitions; 707892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl 708892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// \brief The IDs of all CXXRecordDecls stored in the chain whose VTables are 709892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// used. 710892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// 711892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// CodeGen has to emit VTables for these records, so they have to be eagerly 712892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// deserialized. 713686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVector<uint64_t, 64> VTableUses; 714892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl 715f2abb52acbba25ad93a1ecdc24d994b9694803a1Douglas Gregor /// \brief A snapshot of the pending instantiations in the chain. 716f2abb52acbba25ad93a1ecdc24d994b9694803a1Douglas Gregor /// 717f2abb52acbba25ad93a1ecdc24d994b9694803a1Douglas Gregor /// This record tracks the instantiations that Sema has to perform at the 718f2abb52acbba25ad93a1ecdc24d994b9694803a1Douglas Gregor /// end of the TU. It consists of a pair of values for every pending 719f2abb52acbba25ad93a1ecdc24d994b9694803a1Douglas Gregor /// instantiation where the first value is the ID of the decl and the second 720f2abb52acbba25ad93a1ecdc24d994b9694803a1Douglas Gregor /// is the instantiation location. 721f2abb52acbba25ad93a1ecdc24d994b9694803a1Douglas Gregor SmallVector<uint64_t, 64> PendingInstantiations; 722f2abb52acbba25ad93a1ecdc24d994b9694803a1Douglas Gregor 723892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl //@} 724892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl 725d6471f7c1921c7802804ce3ff6fe9768310f72b9David Blaikie /// \name DiagnosticsEngine-relevant special data 726892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// \brief Fields containing data that is used for generating diagnostics 727892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl //@{ 728892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl 729892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// \brief A snapshot of Sema's unused file-scoped variable tracking, for 730892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// generating warnings. 731686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVector<uint64_t, 16> UnusedFileScopedDecls; 7324c0e86b392c5fb0cb771551fc877edb6979be69cDouglas Gregor 733ebcbe1d3dc7d4f0c1f540a632fa0684dd0a857d5Sean Hunt /// \brief A list of all the delegating constructors we've seen, to diagnose 734ebcbe1d3dc7d4f0c1f540a632fa0684dd0a857d5Sean Hunt /// cycles. 735686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVector<uint64_t, 4> DelegatingCtorDecls; 736ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 7378451ec7e709baf777bec07dc70653e0c523dd120Douglas Gregor /// \brief Method selectors used in a @selector expression. Used for 7388451ec7e709baf777bec07dc70653e0c523dd120Douglas Gregor /// implementation of -Wselector. 7398451ec7e709baf777bec07dc70653e0c523dd120Douglas Gregor SmallVector<uint64_t, 64> ReferencedSelectorsData; 740ebcbe1d3dc7d4f0c1f540a632fa0684dd0a857d5Sean Hunt 741892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// \brief A snapshot of Sema's weak undeclared identifier tracking, for 742892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// generating warnings. 743686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVector<uint64_t, 64> WeakUndeclaredIdentifiers; 74414c22f20c077cecd68581952a0c227f8c180be03Douglas Gregor 745892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// \brief The IDs of type aliases for ext_vectors that exist in the chain. 746892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// 747892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// Used by Sema for finding sugared names for ext_vectors in diagnostics. 748686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVector<uint64_t, 4> ExtVectorDecls; 749b81c17092039f39be60e9656a37cffbdf2e2c783Douglas Gregor 750892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl //@} 751d455add086f1dfa16ae87dc310e49493bbc2b0a6Argyrios Kyrtzidis 752892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// \name Sema-relevant special data 753892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// \brief Fields containing data that is used for semantic analysis 754892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl //@{ 755892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl 756176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines /// \brief The IDs of all potentially unused typedef names in the chain. 757176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines /// 758176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines /// Sema tracks these to emit warnings. 759176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines SmallVector<uint64_t, 16> UnusedLocalTypedefNameCandidates; 760176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines 761892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// \brief The IDs of the declarations Sema stores directly. 762892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// 763892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// Sema tracks a few important decls, such as namespace std, directly. 764686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVector<uint64_t, 4> SemaDeclRefs; 76576c38d385447b7acdff2d7e6b13fa8580e7174a7Argyrios Kyrtzidis 766e41f985c15d15fce8390ebffb49dc75447c8f0f6Sebastian Redl /// \brief The IDs of the types ASTContext stores directly. 767e41f985c15d15fce8390ebffb49dc75447c8f0f6Sebastian Redl /// 768e41f985c15d15fce8390ebffb49dc75447c8f0f6Sebastian Redl /// The AST context tracks a few important types, such as va_list, directly. 769686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVector<uint64_t, 16> SpecialTypes; 770e41f985c15d15fce8390ebffb49dc75447c8f0f6Sebastian Redl 77114b6ba77710d6431794d65c7d58c6f29c3dc956ePeter Collingbourne /// \brief The IDs of CUDA-specific declarations ASTContext stores directly. 77214b6ba77710d6431794d65c7d58c6f29c3dc956ePeter Collingbourne /// 77314b6ba77710d6431794d65c7d58c6f29c3dc956ePeter Collingbourne /// The AST context tracks a few important decls, currently cudaConfigureCall, 77414b6ba77710d6431794d65c7d58c6f29c3dc956ePeter Collingbourne /// directly. 775686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVector<uint64_t, 2> CUDASpecialDeclRefs; 77614b6ba77710d6431794d65c7d58c6f29c3dc956ePeter Collingbourne 77784bccea1ad9fd8bc1f4ec3d1fc5dd8d15dabffbcPeter Collingbourne /// \brief The floating point pragma option settings. 778686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVector<uint64_t, 1> FPPragmaOptions; 77984bccea1ad9fd8bc1f4ec3d1fc5dd8d15dabffbcPeter Collingbourne 7806bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines /// \brief The pragma clang optimize location (if the pragma state is "off"). 7816bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines SourceLocation OptimizeOffPragmaLocation; 7826bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines 7834967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar /// \brief The PragmaMSStructKind pragma ms_struct state if set, or -1. 7844967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar int PragmaMSStructState; 7854967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar 7864967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar /// \brief The PragmaMSPointersToMembersKind pragma pointers_to_members state. 7874967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar int PragmaMSPointersToMembersState; 7884967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar SourceLocation PointersToMembersPragmaLocation; 7894967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar 79084bccea1ad9fd8bc1f4ec3d1fc5dd8d15dabffbcPeter Collingbourne /// \brief The OpenCL extension settings. 791686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVector<uint64_t, 1> OpenCLExtensions; 79284bccea1ad9fd8bc1f4ec3d1fc5dd8d15dabffbcPeter Collingbourne 793d8bba9c15230d2b1b3893e272106aa79efc50251Douglas Gregor /// \brief A list of the namespaces we've seen. 794686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVector<uint64_t, 4> KnownNamespaces; 795d8bba9c15230d2b1b3893e272106aa79efc50251Douglas Gregor 796cd0655b17249c4c4908ca91462657f62285017e6Nick Lewycky /// \brief A list of undefined decls with internal linkage followed by the 797cd0655b17249c4c4908ca91462657f62285017e6Nick Lewycky /// SourceLocation of a matching ODR-use. 798cd0655b17249c4c4908ca91462657f62285017e6Nick Lewycky SmallVector<uint64_t, 8> UndefinedButUsed; 79901a41140cd8ec9475ed0c33384310fbdd3b6de11Nick Lewycky 800b6d6993e6e6d3daf4d9876794254d20a134e37c2Pirama Arumuga Nainar /// \brief Delete expressions to analyze at the end of translation unit. 801b6d6993e6e6d3daf4d9876794254d20a134e37c2Pirama Arumuga Nainar SmallVector<uint64_t, 8> DelayedDeleteExprs; 802b6d6993e6e6d3daf4d9876794254d20a134e37c2Pirama Arumuga Nainar 803ac32d9044b9c1e7492cef929a322d23ce899d276Richard Smith // \brief A list of late parsed template function data. 804ac32d9044b9c1e7492cef929a322d23ce899d276Richard Smith SmallVector<uint64_t, 1> LateParsedTemplates; 805ac32d9044b9c1e7492cef929a322d23ce899d276Richard Smith 806651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines struct ImportedSubmodule { 807651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines serialization::SubmoduleID ID; 808651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines SourceLocation ImportLoc; 809651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines 810651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines ImportedSubmodule(serialization::SubmoduleID ID, SourceLocation ImportLoc) 811651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines : ID(ID), ImportLoc(ImportLoc) {} 812651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines }; 813651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines 814f6137e4d15cb6bbd10547267babfc699c1945873Douglas Gregor /// \brief A list of modules that were imported by precompiled headers or 815f6137e4d15cb6bbd10547267babfc699c1945873Douglas Gregor /// any other non-module AST file. 816651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines SmallVector<ImportedSubmodule, 2> ImportedModules; 817892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl //@} 818892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl 8198e3df4d0864f0a966c20088ca1a29c3398b7639dArgyrios Kyrtzidis /// \brief The directory that the PCH we are reading is stored in. 8208e3df4d0864f0a966c20088ca1a29c3398b7639dArgyrios Kyrtzidis std::string CurrentDir; 8218e3df4d0864f0a966c20088ca1a29c3398b7639dArgyrios Kyrtzidis 8221eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// \brief The system include root to be used when loading the 823e650c8c3bca2f58cad8ffa8aab63126d26e890cdDouglas Gregor /// precompiled header. 824832d620b4ae0fc5fe28561b885b4cfc65cf5c9abDouglas Gregor std::string isysroot; 8251eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 826fae3b2f4743dad616623c4df2fdb0f5128bd36d9Douglas Gregor /// \brief Whether to disable the normal validation performed on precompiled 827fae3b2f4743dad616623c4df2fdb0f5128bd36d9Douglas Gregor /// headers when they are loaded. 828fae3b2f4743dad616623c4df2fdb0f5128bd36d9Douglas Gregor bool DisableValidation; 829ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 830bef35c91b594f66216f4aab303b71a6c5ab7abcfArgyrios Kyrtzidis /// \brief Whether to accept an AST file with compiler errors. 831bef35c91b594f66216f4aab303b71a6c5ab7abcfArgyrios Kyrtzidis bool AllowASTWithCompilerErrors; 832bef35c91b594f66216f4aab303b71a6c5ab7abcfArgyrios Kyrtzidis 833651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines /// \brief Whether to accept an AST file that has a different configuration 834651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines /// from the current compiler instance. 835651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines bool AllowConfigurationMismatch; 836651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines 837651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines /// \brief Whether validate system input files. 838651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines bool ValidateSystemInputs; 839651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines 840f575d6e7c3b887ea4c5394d2c7e322c7a929a57eDouglas Gregor /// \brief Whether we are allowed to use the global module index. 841f575d6e7c3b887ea4c5394d2c7e322c7a929a57eDouglas Gregor bool UseGlobalIndex; 842f575d6e7c3b887ea4c5394d2c7e322c7a929a57eDouglas Gregor 843f575d6e7c3b887ea4c5394d2c7e322c7a929a57eDouglas Gregor /// \brief Whether we have tried loading the global module index yet. 844f575d6e7c3b887ea4c5394d2c7e322c7a929a57eDouglas Gregor bool TriedLoadingGlobalIndex; 845f575d6e7c3b887ea4c5394d2c7e322c7a929a57eDouglas Gregor 84612dcc64eebf7aaffb71392fba74fcb69f35d3b2eArgyrios Kyrtzidis typedef llvm::DenseMap<unsigned, SwitchCase *> SwitchCaseMapTy; 8473c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// \brief Mapping from switch-case IDs in the chain to switch-case statements 848e41f985c15d15fce8390ebffb49dc75447c8f0f6Sebastian Redl /// 849e41f985c15d15fce8390ebffb49dc75447c8f0f6Sebastian Redl /// Statements usually don't have IDs, but switch cases need them, so that the 850e41f985c15d15fce8390ebffb49dc75447c8f0f6Sebastian Redl /// switch statement can refer to them. 85112dcc64eebf7aaffb71392fba74fcb69f35d3b2eArgyrios Kyrtzidis SwitchCaseMapTy SwitchCaseStmts; 852025452fa0eda63e150cfaeebe64f0a19c96b3a06Douglas Gregor 85312dcc64eebf7aaffb71392fba74fcb69f35d3b2eArgyrios Kyrtzidis SwitchCaseMapTy *CurrSwitchCaseStmts; 854b88acb018a0d5e897ce291da2664edfd7bd58f5cArgyrios Kyrtzidis 8557f94b0b0c6791013d2f72ced9b4bedd3b23673a6Douglas Gregor /// \brief The number of source location entries de-serialized from 8567f94b0b0c6791013d2f72ced9b4bedd3b23673a6Douglas Gregor /// the PCH file. 8577f94b0b0c6791013d2f72ced9b4bedd3b23673a6Douglas Gregor unsigned NumSLocEntriesRead; 8587f94b0b0c6791013d2f72ced9b4bedd3b23673a6Douglas Gregor 8593c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// \brief The number of source location entries in the chain. 860518d8cb31d26ea098eba79274abbfae1b4976853Sebastian Redl unsigned TotalNumSLocEntries; 861518d8cb31d26ea098eba79274abbfae1b4976853Sebastian Redl 8623e1af84bb0092a1aafb49deaa4ab6664c9a9071bDouglas Gregor /// \brief The number of statements (and expressions) de-serialized 8633c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// from the chain. 8643e1af84bb0092a1aafb49deaa4ab6664c9a9071bDouglas Gregor unsigned NumStatementsRead; 8653e1af84bb0092a1aafb49deaa4ab6664c9a9071bDouglas Gregor 8663e1af84bb0092a1aafb49deaa4ab6664c9a9071bDouglas Gregor /// \brief The total number of statements (and expressions) stored 8673c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// in the chain. 8683e1af84bb0092a1aafb49deaa4ab6664c9a9071bDouglas Gregor unsigned TotalNumStatements; 8693e1af84bb0092a1aafb49deaa4ab6664c9a9071bDouglas Gregor 8703c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// \brief The number of macros de-serialized from the chain. 87137e2684abfe38207fdb90620da062bb18c23f29aDouglas Gregor unsigned NumMacrosRead; 8722512308525ff328aa992da0b5ee14a488d2ea93aDouglas Gregor 8733c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// \brief The total number of macros stored in the chain. 874fa78dec572259aca763457b435744f79d822c5d4Sebastian Redl unsigned TotalNumMacros; 875fa78dec572259aca763457b435744f79d822c5d4Sebastian Redl 876e169807aaea2464cbe68305f013ec7b41625af30Douglas Gregor /// \brief The number of lookups into identifier tables. 877e169807aaea2464cbe68305f013ec7b41625af30Douglas Gregor unsigned NumIdentifierLookups; 878e169807aaea2464cbe68305f013ec7b41625af30Douglas Gregor 879e169807aaea2464cbe68305f013ec7b41625af30Douglas Gregor /// \brief The number of lookups into identifier tables that succeed. 880e169807aaea2464cbe68305f013ec7b41625af30Douglas Gregor unsigned NumIdentifierLookupHits; 881e169807aaea2464cbe68305f013ec7b41625af30Douglas Gregor 882725cd9686a0f5bb6c994cb3e43f58b63567c6860Sebastian Redl /// \brief The number of selectors that have been read. 883725cd9686a0f5bb6c994cb3e43f58b63567c6860Sebastian Redl unsigned NumSelectorsRead; 88483941df2745d69c05acee3174c7a265c206f70d9Douglas Gregor 885fa78dec572259aca763457b435744f79d822c5d4Sebastian Redl /// \brief The number of method pool entries that have been read. 886fa78dec572259aca763457b435744f79d822c5d4Sebastian Redl unsigned NumMethodPoolEntriesRead; 88783941df2745d69c05acee3174c7a265c206f70d9Douglas Gregor 888fa78dec572259aca763457b435744f79d822c5d4Sebastian Redl /// \brief The number of times we have looked up a selector in the method 88995fb36ebddcbdcd6b801c5d3d2d85dac315b4127Douglas Gregor /// pool. 89095fb36ebddcbdcd6b801c5d3d2d85dac315b4127Douglas Gregor unsigned NumMethodPoolLookups; 89195fb36ebddcbdcd6b801c5d3d2d85dac315b4127Douglas Gregor 89295fb36ebddcbdcd6b801c5d3d2d85dac315b4127Douglas Gregor /// \brief The number of times we have looked up a selector in the method 89395fb36ebddcbdcd6b801c5d3d2d85dac315b4127Douglas Gregor /// pool and found something. 89495fb36ebddcbdcd6b801c5d3d2d85dac315b4127Douglas Gregor unsigned NumMethodPoolHits; 89595fb36ebddcbdcd6b801c5d3d2d85dac315b4127Douglas Gregor 89695fb36ebddcbdcd6b801c5d3d2d85dac315b4127Douglas Gregor /// \brief The number of times we have looked up a selector in the method 89795fb36ebddcbdcd6b801c5d3d2d85dac315b4127Douglas Gregor /// pool within a specific module. 89895fb36ebddcbdcd6b801c5d3d2d85dac315b4127Douglas Gregor unsigned NumMethodPoolTableLookups; 89995fb36ebddcbdcd6b801c5d3d2d85dac315b4127Douglas Gregor 90095fb36ebddcbdcd6b801c5d3d2d85dac315b4127Douglas Gregor /// \brief The number of times we have looked up a selector in the method 90195fb36ebddcbdcd6b801c5d3d2d85dac315b4127Douglas Gregor /// pool within a specific module and found something. 90295fb36ebddcbdcd6b801c5d3d2d85dac315b4127Douglas Gregor unsigned NumMethodPoolTableHits; 903fa78dec572259aca763457b435744f79d822c5d4Sebastian Redl 904fa78dec572259aca763457b435744f79d822c5d4Sebastian Redl /// \brief The total number of method pool entries in the selector table. 905fa78dec572259aca763457b435744f79d822c5d4Sebastian Redl unsigned TotalNumMethodPoolEntries; 90637e2684abfe38207fdb90620da062bb18c23f29aDouglas Gregor 9072512308525ff328aa992da0b5ee14a488d2ea93aDouglas Gregor /// Number of lexical decl contexts read/total. 9082512308525ff328aa992da0b5ee14a488d2ea93aDouglas Gregor unsigned NumLexicalDeclContextsRead, TotalLexicalDeclContexts; 9092512308525ff328aa992da0b5ee14a488d2ea93aDouglas Gregor 9102512308525ff328aa992da0b5ee14a488d2ea93aDouglas Gregor /// Number of visible decl contexts read/total. 9112512308525ff328aa992da0b5ee14a488d2ea93aDouglas Gregor unsigned NumVisibleDeclContextsRead, TotalVisibleDeclContexts; 912ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 9131da901467f72d1733704b068e22089813a1962fdJonathan D. Turner /// Total size of modules, in bits, currently loaded 9141da901467f72d1733704b068e22089813a1962fdJonathan D. Turner uint64_t TotalModulesSizeInBits; 9151da901467f72d1733704b068e22089813a1962fdJonathan D. Turner 91629ee3a273f58e16df7f2c524ab62a869e44fc9b1Argyrios Kyrtzidis /// \brief Number of Decl/types that are currently deserializing. 91729ee3a273f58e16df7f2c524ab62a869e44fc9b1Argyrios Kyrtzidis unsigned NumCurrentElementsDeserializing; 9181eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 91944d2dbdce49d1fca3826d543ba875bb82f759091Argyrios Kyrtzidis /// \brief Set true while we are in the process of passing deserialized 92044d2dbdce49d1fca3826d543ba875bb82f759091Argyrios Kyrtzidis /// "interesting" decls to consumer inside FinishedDeserializing(). 92144d2dbdce49d1fca3826d543ba875bb82f759091Argyrios Kyrtzidis /// This is used as a guard to avoid recursively repeating the process of 92244d2dbdce49d1fca3826d543ba875bb82f759091Argyrios Kyrtzidis /// passing decls to consumer. 92344d2dbdce49d1fca3826d543ba875bb82f759091Argyrios Kyrtzidis bool PassingDeclsToConsumer; 92444d2dbdce49d1fca3826d543ba875bb82f759091Argyrios Kyrtzidis 9253c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// \brief The set of identifiers that were read while the AST reader was 9261eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// (recursively) loading declarations. 9271eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// 928d89275bc865e2b552836c7b33e636d4f86b8de6dDouglas Gregor /// The declarations on the identifier chain for these identifiers will be 929d89275bc865e2b552836c7b33e636d4f86b8de6dDouglas Gregor /// loaded once the recursive loading has completed. 930aa945900d5438984bdcaac85c4f54868292231f4Douglas Gregor llvm::MapVector<IdentifierInfo *, SmallVector<uint32_t, 4> > 931aa945900d5438984bdcaac85c4f54868292231f4Douglas Gregor PendingIdentifierInfos; 9321eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 9333ea9e33ea25e0c2b12db56418ba3f994eb662c04Pirama Arumuga Nainar /// \brief The set of lookup results that we have faked in order to support 9343ea9e33ea25e0c2b12db56418ba3f994eb662c04Pirama Arumuga Nainar /// merging of partially deserialized decls but that we have not yet removed. 9353ea9e33ea25e0c2b12db56418ba3f994eb662c04Pirama Arumuga Nainar llvm::SmallMapVector<IdentifierInfo *, SmallVector<NamedDecl*, 2>, 16> 9363ea9e33ea25e0c2b12db56418ba3f994eb662c04Pirama Arumuga Nainar PendingFakeLookupResults; 9373ea9e33ea25e0c2b12db56418ba3f994eb662c04Pirama Arumuga Nainar 9388efca6bb688d32fd7c0d91b504ef3307f97ee66aDouglas Gregor /// \brief The generation number of each identifier, which keeps track of 9398efca6bb688d32fd7c0d91b504ef3307f97ee66aDouglas Gregor /// the last time we loaded information about this identifier. 940057df20b3107cef764052d271c89b8591b98b3ceDouglas Gregor llvm::DenseMap<IdentifierInfo *, unsigned> IdentifierGeneration; 941057df20b3107cef764052d271c89b8591b98b3ceDouglas Gregor 942c62a2fe1957626bc4b29402b2d0a3694dfaa3280Douglas Gregor /// \brief Contains declarations and definitions that will be 943c62a2fe1957626bc4b29402b2d0a3694dfaa3280Douglas Gregor /// "interesting" to the ASTConsumer, when we get that AST consumer. 944c62a2fe1957626bc4b29402b2d0a3694dfaa3280Douglas Gregor /// 945c62a2fe1957626bc4b29402b2d0a3694dfaa3280Douglas Gregor /// "Interesting" declarations are those that have data that may 946c62a2fe1957626bc4b29402b2d0a3694dfaa3280Douglas Gregor /// need to be emitted, such as inline function definitions or 947c62a2fe1957626bc4b29402b2d0a3694dfaa3280Douglas Gregor /// Objective-C protocols. 948bb80a8e8887c1ec74ee135d4ad9455eafedf1508Argyrios Kyrtzidis std::deque<Decl *> InterestingDecls; 949c62a2fe1957626bc4b29402b2d0a3694dfaa3280Douglas Gregor 950a1be278c4f3a234ff61f04018d26c6beecde1654Douglas Gregor /// \brief The list of redeclaration chains that still need to be 95187d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar /// reconstructed, and the local offset to the corresponding list 95287d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar /// of redeclarations. 95387d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar SmallVector<std::pair<Decl *, uint64_t>, 16> PendingDeclChains; 954a1be278c4f3a234ff61f04018d26c6beecde1654Douglas Gregor 9556bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines /// \brief The list of canonical declarations whose redeclaration chains 9566bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines /// need to be marked as incomplete once we're done deserializing things. 9576bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines SmallVector<Decl *, 16> PendingIncompleteDeclChains; 9586bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines 9597640b02a561fd2b2c58a227b262b0c1ba93622aeArgyrios Kyrtzidis /// \brief The Decl IDs for the Sema/Lexical DeclContext of a Decl that has 9607640b02a561fd2b2c58a227b262b0c1ba93622aeArgyrios Kyrtzidis /// been loaded but its DeclContext was not set yet. 9617640b02a561fd2b2c58a227b262b0c1ba93622aeArgyrios Kyrtzidis struct PendingDeclContextInfo { 9627640b02a561fd2b2c58a227b262b0c1ba93622aeArgyrios Kyrtzidis Decl *D; 9637640b02a561fd2b2c58a227b262b0c1ba93622aeArgyrios Kyrtzidis serialization::GlobalDeclID SemaDC; 9647640b02a561fd2b2c58a227b262b0c1ba93622aeArgyrios Kyrtzidis serialization::GlobalDeclID LexicalDC; 9657640b02a561fd2b2c58a227b262b0c1ba93622aeArgyrios Kyrtzidis }; 9667640b02a561fd2b2c58a227b262b0c1ba93622aeArgyrios Kyrtzidis 9677640b02a561fd2b2c58a227b262b0c1ba93622aeArgyrios Kyrtzidis /// \brief The set of Decls that have been loaded but their DeclContexts are 9687640b02a561fd2b2c58a227b262b0c1ba93622aeArgyrios Kyrtzidis /// not set yet. 9697640b02a561fd2b2c58a227b262b0c1ba93622aeArgyrios Kyrtzidis /// 9707640b02a561fd2b2c58a227b262b0c1ba93622aeArgyrios Kyrtzidis /// The DeclContexts for these Decls will be set once recursive loading has 9717640b02a561fd2b2c58a227b262b0c1ba93622aeArgyrios Kyrtzidis /// been completed. 9727640b02a561fd2b2c58a227b262b0c1ba93622aeArgyrios Kyrtzidis std::deque<PendingDeclContextInfo> PendingDeclContextInfos; 9737640b02a561fd2b2c58a227b262b0c1ba93622aeArgyrios Kyrtzidis 9743c40a28aa3dde7c5f7e1520c32e7515eda830fefRichard Smith /// \brief The set of NamedDecls that have been loaded, but are members of a 9753c40a28aa3dde7c5f7e1520c32e7515eda830fefRichard Smith /// context that has been merged into another context where the corresponding 9763c40a28aa3dde7c5f7e1520c32e7515eda830fefRichard Smith /// declaration is either missing or has not yet been loaded. 9773c40a28aa3dde7c5f7e1520c32e7515eda830fefRichard Smith /// 9783c40a28aa3dde7c5f7e1520c32e7515eda830fefRichard Smith /// We will check whether the corresponding declaration is in fact missing 9793c40a28aa3dde7c5f7e1520c32e7515eda830fefRichard Smith /// once recursing loading has been completed. 9803c40a28aa3dde7c5f7e1520c32e7515eda830fefRichard Smith llvm::SmallVector<NamedDecl *, 16> PendingOdrMergeChecks; 9813c40a28aa3dde7c5f7e1520c32e7515eda830fefRichard Smith 9826bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines /// \brief Record definitions in which we found an ODR violation. 9836bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines llvm::SmallDenseMap<CXXRecordDecl *, llvm::TinyPtrVector<CXXRecordDecl *>, 2> 9846bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines PendingOdrMergeFailures; 9856bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines 9866bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines /// \brief DeclContexts in which we have diagnosed an ODR violation. 9876bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines llvm::SmallPtrSet<DeclContext*, 2> DiagnosedOdrMergeFailures; 9886bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines 989cff9f26ce0ed76d555cd33b3dca84dd5cdf376afDouglas Gregor /// \brief The set of Objective-C categories that have been deserialized 990cff9f26ce0ed76d555cd33b3dca84dd5cdf376afDouglas Gregor /// since the last time the declaration chains were linked. 991cff9f26ce0ed76d555cd33b3dca84dd5cdf376afDouglas Gregor llvm::SmallPtrSet<ObjCCategoryDecl *, 16> CategoriesDeserialized; 992cff9f26ce0ed76d555cd33b3dca84dd5cdf376afDouglas Gregor 993cff9f26ce0ed76d555cd33b3dca84dd5cdf376afDouglas Gregor /// \brief The set of Objective-C class definitions that have already been 994cff9f26ce0ed76d555cd33b3dca84dd5cdf376afDouglas Gregor /// loaded, for which we will need to check for categories whenever a new 995cff9f26ce0ed76d555cd33b3dca84dd5cdf376afDouglas Gregor /// module is loaded. 996cfa88f893915ceb8ae4ce2f17c46c24a4d67502fDmitri Gribenko SmallVector<ObjCInterfaceDecl *, 16> ObjCClassesLoaded; 9976bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines 998cfa88f893915ceb8ae4ce2f17c46c24a4d67502fDmitri Gribenko typedef llvm::DenseMap<Decl *, SmallVector<serialization::DeclID, 2> > 99987d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar KeyDeclsMap; 10000f75323264b93a318ac9007eb5ec5b233c444068Douglas Gregor 100187d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar /// \brief A mapping from canonical declarations to the set of global 100287d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar /// declaration IDs for key declaration that have been merged with that 100387d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar /// canonical declaration. A key declaration is a formerly-canonical 100487d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar /// declaration whose module did not import any other key declaration for that 100587d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar /// entity. These are the IDs that we use as keys when finding redecl chains. 100687d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar KeyDeclsMap KeyDecls; 10070f75323264b93a318ac9007eb5ec5b233c444068Douglas Gregor 1008b60fae50d38a0291e1c5731b2fb22849d26ca342Richard Smith /// \brief A mapping from DeclContexts to the semantic DeclContext that we 1009b60fae50d38a0291e1c5731b2fb22849d26ca342Richard Smith /// are treating as the definition of the entity. This is used, for instance, 1010b60fae50d38a0291e1c5731b2fb22849d26ca342Richard Smith /// when merging implicit instantiations of class templates across modules. 1011b60fae50d38a0291e1c5731b2fb22849d26ca342Richard Smith llvm::DenseMap<DeclContext *, DeclContext *> MergedDeclContexts; 1012b60fae50d38a0291e1c5731b2fb22849d26ca342Richard Smith 1013d692a84e18fb48e6442bee83364f1d301f5b8404Richard Smith /// \brief A mapping from canonical declarations of enums to their canonical 1014d692a84e18fb48e6442bee83364f1d301f5b8404Richard Smith /// definitions. Only populated when using modules in C++. 1015d692a84e18fb48e6442bee83364f1d301f5b8404Richard Smith llvm::DenseMap<EnumDecl *, EnumDecl *> EnumDefinitions; 1016d692a84e18fb48e6442bee83364f1d301f5b8404Richard Smith 1017919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis /// \brief When reading a Stmt tree, Stmt operands are placed in this stack. 1018686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVector<Stmt *, 16> StmtStack; 1019919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis 1020919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis /// \brief What kind of records we are reading. 1021919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis enum ReadingKind { 1022afb90df95223a2b48f22a3d950328d1d915691f5Richard Smith Read_None, Read_Decl, Read_Type, Read_Stmt 1023919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis }; 1024919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis 1025ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie /// \brief What kind of records we are reading. 1026919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis ReadingKind ReadingKind; 1027919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis 1028919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis /// \brief RAII object to change the reading kind. 1029919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis class ReadingKindTracker { 1030c43b54cbc10654ed59de797898042e1a05265246Sebastian Redl ASTReader &Reader; 1031919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis enum ReadingKind PrevKind; 1032919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis 10330e2c34f92f00628d48968dfea096d36381f494cbStephen Hines ReadingKindTracker(const ReadingKindTracker &) = delete; 10340e2c34f92f00628d48968dfea096d36381f494cbStephen Hines void operator=(const ReadingKindTracker &) = delete; 1035919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis 1036919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis public: 1037c43b54cbc10654ed59de797898042e1a05265246Sebastian Redl ReadingKindTracker(enum ReadingKind newKind, ASTReader &reader) 1038919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis : Reader(reader), PrevKind(Reader.ReadingKind) { 1039919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis Reader.ReadingKind = newKind; 1040919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis } 1041919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis 1042919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis ~ReadingKindTracker() { Reader.ReadingKind = PrevKind; } 1043919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis }; 1044919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis 1045e721f95069d42b899c20c1caabdc6184dd42b820Douglas Gregor /// \brief Suggested contents of the predefines buffer, after this 1046e721f95069d42b899c20c1caabdc6184dd42b820Douglas Gregor /// PCH file has been processed. 1047e721f95069d42b899c20c1caabdc6184dd42b820Douglas Gregor /// 1048e721f95069d42b899c20c1caabdc6184dd42b820Douglas Gregor /// In most cases, this string will be empty, because the predefines 1049e721f95069d42b899c20c1caabdc6184dd42b820Douglas Gregor /// buffer computed to build the PCH file will be identical to the 1050e721f95069d42b899c20c1caabdc6184dd42b820Douglas Gregor /// predefines buffer computed from the command line. However, when 1051e721f95069d42b899c20c1caabdc6184dd42b820Douglas Gregor /// there are differences that the PCH reader can work around, this 1052e721f95069d42b899c20c1caabdc6184dd42b820Douglas Gregor /// predefines buffer may contain additional definitions. 1053e721f95069d42b899c20c1caabdc6184dd42b820Douglas Gregor std::string SuggestedPredefines; 10541eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1055919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis /// \brief Reads a statement from the specified cursor. 10561a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor Stmt *ReadStmtFromStream(ModuleFile &F); 1057919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis 1058651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines struct InputFileInfo { 1059651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines std::string Filename; 1060651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines off_t StoredSize; 1061651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines time_t StoredTime; 1062651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines bool Overridden; 106387d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar bool Transient; 1064651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines }; 1065651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines 1066651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines /// \brief Reads the stored information about an input file. 1067651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines InputFileInfo readInputFileInfo(ModuleFile &F, unsigned ID); 1068651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines 1069a930dc9b46572cb6e5bb54f3d724e8fe23a6b66eDouglas Gregor /// \brief Retrieve the file entry and 'overridden' bit for an input 1070a930dc9b46572cb6e5bb54f3d724e8fe23a6b66eDouglas Gregor /// file in the given module file. 10718504b7b8102a52b2a16231d459fb3cfab4784c38Argyrios Kyrtzidis serialization::InputFile getInputFile(ModuleFile &F, unsigned ID, 10728504b7b8102a52b2a16231d459fb3cfab4784c38Argyrios Kyrtzidis bool Complain = true); 1073a930dc9b46572cb6e5bb54f3d724e8fe23a6b66eDouglas Gregor 10740e2c34f92f00628d48968dfea096d36381f494cbStephen Hinespublic: 10750e2c34f92f00628d48968dfea096d36381f494cbStephen Hines void ResolveImportedPath(ModuleFile &M, std::string &Filename); 10760e2c34f92f00628d48968dfea096d36381f494cbStephen Hines static void ResolveImportedPath(std::string &Filename, StringRef Prefix); 10771eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 107887d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar /// \brief Returns the first key declaration for the given declaration. This 107987d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar /// is one that is formerly-canonical (or still canonical) and whose module 108087d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar /// did not import any other key declaration of the entity. 108187d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar Decl *getKeyDeclaration(Decl *D) { 108287d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar D = D->getCanonicalDecl(); 108387d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar if (D->isFromASTFile()) 108487d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar return D; 108587d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar 108687d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar auto I = KeyDecls.find(D); 108787d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar if (I == KeyDecls.end() || I->second.empty()) 108887d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar return D; 108987d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar return GetExistingDecl(I->second[0]); 109087d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar } 109187d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar const Decl *getKeyDeclaration(const Decl *D) { 109287d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar return getKeyDeclaration(const_cast<Decl*>(D)); 109387d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar } 109487d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar 109587d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar /// \brief Run a callback on each imported key declaration of \p D. 109687d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar template <typename Fn> 109787d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar void forEachImportedKeyDecl(const Decl *D, Fn Visit) { 109887d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar D = D->getCanonicalDecl(); 109987d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar if (D->isFromASTFile()) 110087d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar Visit(D); 110187d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar 110287d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar auto It = KeyDecls.find(const_cast<Decl*>(D)); 110387d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar if (It != KeyDecls.end()) 110487d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar for (auto ID : It->second) 110587d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar Visit(GetExistingDecl(ID)); 110687d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar } 110787d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar 110887d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar /// \brief Get the loaded lookup tables for \p Primary, if any. 110987d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar const serialization::reader::DeclContextLookupTable * 111087d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar getLoadedLookupTables(DeclContext *Primary) const; 111187d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar 11120e2c34f92f00628d48968dfea096d36381f494cbStephen Hinesprivate: 1113958bcaf3d4e0c1ae46de3e84e7c2a7638c3c5286Argyrios Kyrtzidis struct ImportedModule { 1114958bcaf3d4e0c1ae46de3e84e7c2a7638c3c5286Argyrios Kyrtzidis ModuleFile *Mod; 1115958bcaf3d4e0c1ae46de3e84e7c2a7638c3c5286Argyrios Kyrtzidis ModuleFile *ImportedBy; 1116958bcaf3d4e0c1ae46de3e84e7c2a7638c3c5286Argyrios Kyrtzidis SourceLocation ImportLoc; 1117958bcaf3d4e0c1ae46de3e84e7c2a7638c3c5286Argyrios Kyrtzidis 1118958bcaf3d4e0c1ae46de3e84e7c2a7638c3c5286Argyrios Kyrtzidis ImportedModule(ModuleFile *Mod, 1119958bcaf3d4e0c1ae46de3e84e7c2a7638c3c5286Argyrios Kyrtzidis ModuleFile *ImportedBy, 1120958bcaf3d4e0c1ae46de3e84e7c2a7638c3c5286Argyrios Kyrtzidis SourceLocation ImportLoc) 1121958bcaf3d4e0c1ae46de3e84e7c2a7638c3c5286Argyrios Kyrtzidis : Mod(Mod), ImportedBy(ImportedBy), ImportLoc(ImportLoc) { } 1122958bcaf3d4e0c1ae46de3e84e7c2a7638c3c5286Argyrios Kyrtzidis }; 1123958bcaf3d4e0c1ae46de3e84e7c2a7638c3c5286Argyrios Kyrtzidis 112410bc00fd45824f9b5cd139d63af8b0f6d28aaddaDouglas Gregor ASTReadResult ReadASTCore(StringRef FileName, ModuleKind Type, 1125958bcaf3d4e0c1ae46de3e84e7c2a7638c3c5286Argyrios Kyrtzidis SourceLocation ImportLoc, ModuleFile *ImportedBy, 1126cfa88f893915ceb8ae4ce2f17c46c24a4d67502fDmitri Gribenko SmallVectorImpl<ImportedModule> &Loaded, 1127677e15ffee2ecc9c1c8f46fd77cab4b5afb59640Douglas Gregor off_t ExpectedSize, time_t ExpectedModTime, 1128176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines serialization::ASTFileSignature ExpectedSignature, 112938295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor unsigned ClientLoadCapabilities); 11301d9d9898ce2b338314161d92f39561a09a2a8b6fDouglas Gregor ASTReadResult ReadControlBlock(ModuleFile &F, 1131cfa88f893915ceb8ae4ce2f17c46c24a4d67502fDmitri Gribenko SmallVectorImpl<ImportedModule> &Loaded, 11326bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines const ModuleFile *ImportedBy, 113338295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor unsigned ClientLoadCapabilities); 113487d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar static ASTReadResult ReadOptionsBlock( 113587d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar llvm::BitstreamCursor &Stream, unsigned ClientLoadCapabilities, 113687d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar bool AllowCompatibleConfigurationMismatch, ASTReaderListener &Listener, 113787d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar std::string &SuggestedPredefines); 11386bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines ASTReadResult ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities); 113987d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar ASTReadResult ReadExtensionBlock(ModuleFile &F); 11400e2c34f92f00628d48968dfea096d36381f494cbStephen Hines bool ParseLineTable(ModuleFile &F, const RecordData &Record); 11414825fd7fbb3fe87cdf8da9bccc1361fac45bdf2dDouglas Gregor bool ReadSourceManagerBlock(ModuleFile &F); 1142f62d43d2afe1960755a1b5813cae1e5983bcac1bDouglas Gregor llvm::BitstreamCursor &SLocCursorForID(int ID); 11431a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor SourceLocation getImportLocation(ModuleFile *F); 1144176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines ASTReadResult ReadModuleMapFileBlock(RecordData &Record, ModuleFile &F, 1145176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines const ModuleFile *ImportedBy, 1146176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines unsigned ClientLoadCapabilities); 11476bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines ASTReadResult ReadSubmoduleBlock(ModuleFile &F, 11486bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines unsigned ClientLoadCapabilities); 114927ffa6caf965ef20fdef5ae23b81cdc3d05e7afbDouglas Gregor static bool ParseLanguageOptions(const RecordData &Record, bool Complain, 1150176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines ASTReaderListener &Listener, 1151176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines bool AllowCompatibleDifferences); 115227ffa6caf965ef20fdef5ae23b81cdc3d05e7afbDouglas Gregor static bool ParseTargetOptions(const RecordData &Record, bool Complain, 11533ea9e33ea25e0c2b12db56418ba3f994eb662c04Pirama Arumuga Nainar ASTReaderListener &Listener, 11543ea9e33ea25e0c2b12db56418ba3f994eb662c04Pirama Arumuga Nainar bool AllowCompatibleDifferences); 11555f3d8224af99ad0d9107601c0c31b74693371cc1Douglas Gregor static bool ParseDiagnosticOptions(const RecordData &Record, bool Complain, 11565f3d8224af99ad0d9107601c0c31b74693371cc1Douglas Gregor ASTReaderListener &Listener); 11571b2c3c0884e917ae5d59edde7d93b2af33c6a1b6Douglas Gregor static bool ParseFileSystemOptions(const RecordData &Record, bool Complain, 11581b2c3c0884e917ae5d59edde7d93b2af33c6a1b6Douglas Gregor ASTReaderListener &Listener); 1159bbf38319edd4eddc55ec273934e990d7e84991deDouglas Gregor static bool ParseHeaderSearchOptions(const RecordData &Record, bool Complain, 1160bbf38319edd4eddc55ec273934e990d7e84991deDouglas Gregor ASTReaderListener &Listener); 1161a71a7d8a1ce4474e7bdb680658fb58b6caf391d3Douglas Gregor static bool ParsePreprocessorOptions(const RecordData &Record, bool Complain, 11628769924c97ecf2af88f7f3aa6754d381b30d1c5fDouglas Gregor ASTReaderListener &Listener, 11638769924c97ecf2af88f7f3aa6754d381b30d1c5fDouglas Gregor std::string &SuggestedPredefines); 116427ffa6caf965ef20fdef5ae23b81cdc3d05e7afbDouglas Gregor 1165c3632730cc83ed7b51f0ab5c38997ae5a9439b0cSebastian Redl struct RecordLocation { 11661a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor RecordLocation(ModuleFile *M, uint64_t O) 1167c3632730cc83ed7b51f0ab5c38997ae5a9439b0cSebastian Redl : F(M), Offset(O) {} 11681a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor ModuleFile *F; 1169c3632730cc83ed7b51f0ab5c38997ae5a9439b0cSebastian Redl uint64_t Offset; 1170c3632730cc83ed7b51f0ab5c38997ae5a9439b0cSebastian Redl }; 1171aaec0aa844781dc7c3462ba140e004e589ccd355Sebastian Redl 1172393f249399fe30e9580e1529a7479489e90f3a57Douglas Gregor QualType readTypeRecord(unsigned Index); 1173651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void readExceptionSpec(ModuleFile &ModuleFile, 1174651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines SmallVectorImpl<QualType> &ExceptionStorage, 1175176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines FunctionProtoType::ExceptionSpecInfo &ESI, 1176651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines const RecordData &Record, unsigned &Index); 1177aaec0aa844781dc7c3462ba140e004e589ccd355Sebastian Redl RecordLocation TypeCursorForIndex(unsigned Index); 11782cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor void LoadedDecl(unsigned Index, Decl *D); 1179496c709a6f08f5c502b6f592ddd9ed40f953a5e5Douglas Gregor Decl *ReadDeclRecord(serialization::DeclID ID); 11806bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines void markIncompleteDeclChain(Decl *Canon); 11813ea9e33ea25e0c2b12db56418ba3f994eb662c04Pirama Arumuga Nainar 11823ea9e33ea25e0c2b12db56418ba3f994eb662c04Pirama Arumuga Nainar /// \brief Returns the most recent declaration of a declaration (which must be 11833ea9e33ea25e0c2b12db56418ba3f994eb662c04Pirama Arumuga Nainar /// of a redeclarable kind) that is either local or has already been loaded 11843ea9e33ea25e0c2b12db56418ba3f994eb662c04Pirama Arumuga Nainar /// merged into its redecl chain. 11853ea9e33ea25e0c2b12db56418ba3f994eb662c04Pirama Arumuga Nainar Decl *getMostRecentExistingDecl(Decl *D); 11863ea9e33ea25e0c2b12db56418ba3f994eb662c04Pirama Arumuga Nainar 11879d31fa75bc05fe4cb903a7701550f22cfb73ea8bArgyrios Kyrtzidis RecordLocation DeclCursorForID(serialization::DeclID ID, 11884967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar SourceLocation &Location); 11896bf2b9fbd3e3adc38d4712de79aeaa81d651aa08Douglas Gregor void loadDeclUpdateRecords(serialization::DeclID ID, Decl *D); 119087d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar void loadPendingDeclChain(Decl *D, uint64_t LocalOffset); 1191cff9f26ce0ed76d555cd33b3dca84dd5cdf376afDouglas Gregor void loadObjCCategories(serialization::GlobalDeclID ID, ObjCInterfaceDecl *D, 1192cff9f26ce0ed76d555cd33b3dca84dd5cdf376afDouglas Gregor unsigned PreviousGeneration = 0); 1193ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 11948f1231b70c2b1f6fe0cee097b447487b26810301Douglas Gregor RecordLocation getLocalBitOffset(uint64_t GlobalOffset); 11951a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor uint64_t getGlobalBitOffset(ModuleFile &M, uint32_t LocalOffset); 11962dbaca748bc3eb6539f417bd8354c930bdf88fa4Argyrios Kyrtzidis 11976bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines /// \brief Returns the first preprocessed entity ID that begins or ends after 11986bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines /// \arg Loc. 11992dbaca748bc3eb6539f417bd8354c930bdf88fa4Argyrios Kyrtzidis serialization::PreprocessedEntityID 12006bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines findPreprocessedEntity(SourceLocation Loc, bool EndsAfter) const; 12012dbaca748bc3eb6539f417bd8354c930bdf88fa4Argyrios Kyrtzidis 1202a7b7d1a7394394d33c18f7dda400a9a12cae2c78James Dennett /// \brief Find the next module that contains entities and return the ID 12032dbaca748bc3eb6539f417bd8354c930bdf88fa4Argyrios Kyrtzidis /// of the first entry. 12041824d54df85a462ada812dadda18130f951d40f3Dmitri Gribenko /// 12051824d54df85a462ada812dadda18130f951d40f3Dmitri Gribenko /// \param SLocMapI points at a chunk of a module that contains no 1206a7b7d1a7394394d33c18f7dda400a9a12cae2c78James Dennett /// preprocessed entities or the entities it contains are not the 1207a7b7d1a7394394d33c18f7dda400a9a12cae2c78James Dennett /// ones we are looking for. 12082dbaca748bc3eb6539f417bd8354c930bdf88fa4Argyrios Kyrtzidis serialization::PreprocessedEntityID 12092dbaca748bc3eb6539f417bd8354c930bdf88fa4Argyrios Kyrtzidis findNextPreprocessedEntity( 12102dbaca748bc3eb6539f417bd8354c930bdf88fa4Argyrios Kyrtzidis GlobalSLocOffsetMapType::const_iterator SLocMapI) const; 12112dbaca748bc3eb6539f417bd8354c930bdf88fa4Argyrios Kyrtzidis 12121824d54df85a462ada812dadda18130f951d40f3Dmitri Gribenko /// \brief Returns (ModuleFile, Local index) pair for \p GlobalIndex of a 1213f226ff9fe8c8db6c5b74a61ce649eda1491c3502Argyrios Kyrtzidis /// preprocessed entity. 12141a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor std::pair<ModuleFile *, unsigned> 1215f226ff9fe8c8db6c5b74a61ce649eda1491c3502Argyrios Kyrtzidis getModulePreprocessedEntity(unsigned GlobalIndex); 1216f226ff9fe8c8db6c5b74a61ce649eda1491c3502Argyrios Kyrtzidis 1217632dcc92f60ab7f806a89c5bca3a0951763a9219Argyrios Kyrtzidis /// \brief Returns (begin, end) pair for the preprocessed entities of a 1218632dcc92f60ab7f806a89c5bca3a0951763a9219Argyrios Kyrtzidis /// particular module. 12190e2c34f92f00628d48968dfea096d36381f494cbStephen Hines llvm::iterator_range<PreprocessingRecord::iterator> 12200e2c34f92f00628d48968dfea096d36381f494cbStephen Hines getModulePreprocessedEntities(ModuleFile &Mod) const; 12210e2c34f92f00628d48968dfea096d36381f494cbStephen Hines 12220e2c34f92f00628d48968dfea096d36381f494cbStephen Hines class ModuleDeclIterator 12230e2c34f92f00628d48968dfea096d36381f494cbStephen Hines : public llvm::iterator_adaptor_base< 12240e2c34f92f00628d48968dfea096d36381f494cbStephen Hines ModuleDeclIterator, const serialization::LocalDeclID *, 12250e2c34f92f00628d48968dfea096d36381f494cbStephen Hines std::random_access_iterator_tag, const Decl *, ptrdiff_t, 12260e2c34f92f00628d48968dfea096d36381f494cbStephen Hines const Decl *, const Decl *> { 12272093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis ASTReader *Reader; 12282093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis ModuleFile *Mod; 12292093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis 12302093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis public: 12310e2c34f92f00628d48968dfea096d36381f494cbStephen Hines ModuleDeclIterator() 12320e2c34f92f00628d48968dfea096d36381f494cbStephen Hines : iterator_adaptor_base(nullptr), Reader(nullptr), Mod(nullptr) {} 12332093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis 12342093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis ModuleDeclIterator(ASTReader *Reader, ModuleFile *Mod, 12352093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis const serialization::LocalDeclID *Pos) 12360e2c34f92f00628d48968dfea096d36381f494cbStephen Hines : iterator_adaptor_base(Pos), Reader(Reader), Mod(Mod) {} 12372093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis 12382093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis value_type operator*() const { 12390e2c34f92f00628d48968dfea096d36381f494cbStephen Hines return Reader->GetDecl(Reader->getGlobalDeclID(*Mod, *I)); 12402093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis } 12410e2c34f92f00628d48968dfea096d36381f494cbStephen Hines value_type operator->() const { return **this; } 12422093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis 12430e2c34f92f00628d48968dfea096d36381f494cbStephen Hines bool operator==(const ModuleDeclIterator &RHS) const { 12440e2c34f92f00628d48968dfea096d36381f494cbStephen Hines assert(Reader == RHS.Reader && Mod == RHS.Mod); 12450e2c34f92f00628d48968dfea096d36381f494cbStephen Hines return I == RHS.I; 12462093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis } 12472093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis }; 12482093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis 12490e2c34f92f00628d48968dfea096d36381f494cbStephen Hines llvm::iterator_range<ModuleDeclIterator> 12500e2c34f92f00628d48968dfea096d36381f494cbStephen Hines getModuleFileLevelDecls(ModuleFile &Mod); 12512093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis 1252bb80a8e8887c1ec74ee135d4ad9455eafedf1508Argyrios Kyrtzidis void PassInterestingDeclsToConsumer(); 12538d39c3ddfc17d9e768a17eb0ce9f11c33bf9d50aArgyrios Kyrtzidis void PassInterestingDeclToConsumer(Decl *D); 1254bb80a8e8887c1ec74ee135d4ad9455eafedf1508Argyrios Kyrtzidis 1255917078386b9b5113f33c093e296e10927b00b37eArgyrios Kyrtzidis void finishPendingActions(); 1256176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines void diagnoseOdrViolations(); 1257917078386b9b5113f33c093e296e10927b00b37eArgyrios Kyrtzidis 12580532df02a72a32a6042e961b71989db73d0d0a22Argyrios Kyrtzidis void pushExternalDeclIntoScope(NamedDecl *D, DeclarationName Name); 12590532df02a72a32a6042e961b71989db73d0d0a22Argyrios Kyrtzidis 12607640b02a561fd2b2c58a227b262b0c1ba93622aeArgyrios Kyrtzidis void addPendingDeclContextInfo(Decl *D, 12617640b02a561fd2b2c58a227b262b0c1ba93622aeArgyrios Kyrtzidis serialization::GlobalDeclID SemaDC, 12627640b02a561fd2b2c58a227b262b0c1ba93622aeArgyrios Kyrtzidis serialization::GlobalDeclID LexicalDC) { 12637640b02a561fd2b2c58a227b262b0c1ba93622aeArgyrios Kyrtzidis assert(D); 12647640b02a561fd2b2c58a227b262b0c1ba93622aeArgyrios Kyrtzidis PendingDeclContextInfo Info = { D, SemaDC, LexicalDC }; 12657640b02a561fd2b2c58a227b262b0c1ba93622aeArgyrios Kyrtzidis PendingDeclContextInfos.push_back(Info); 12667640b02a561fd2b2c58a227b262b0c1ba93622aeArgyrios Kyrtzidis } 12677640b02a561fd2b2c58a227b262b0c1ba93622aeArgyrios Kyrtzidis 1268a02b147b66ff9f1a22bac4ec7fd1b0d54a40e5bfDouglas Gregor /// \brief Produce an error diagnostic and return true. 1269a02b147b66ff9f1a22bac4ec7fd1b0d54a40e5bfDouglas Gregor /// 1270a02b147b66ff9f1a22bac4ec7fd1b0d54a40e5bfDouglas Gregor /// This routine should only be used for fatal errors that have to 12713c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// do with non-routine failures (e.g., corrupted AST file). 1272686775deca8b8685eb90801495880e3abdd844c2Chris Lattner void Error(StringRef Msg); 1273686775deca8b8685eb90801495880e3abdd844c2Chris Lattner void Error(unsigned DiagID, StringRef Arg1 = StringRef(), 1274686775deca8b8685eb90801495880e3abdd844c2Chris Lattner StringRef Arg2 = StringRef()); 1275a02b147b66ff9f1a22bac4ec7fd1b0d54a40e5bfDouglas Gregor 12760e2c34f92f00628d48968dfea096d36381f494cbStephen Hines ASTReader(const ASTReader &) = delete; 12770e2c34f92f00628d48968dfea096d36381f494cbStephen Hines void operator=(const ASTReader &) = delete; 12782cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregorpublic: 12793c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// \brief Load the AST file and validate its contents against the given 128011e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis /// Preprocessor. 1281e650c8c3bca2f58cad8ffa8aab63126d26e890cdDouglas Gregor /// 1282e650c8c3bca2f58cad8ffa8aab63126d26e890cdDouglas Gregor /// \param PP the preprocessor associated with the context in which this 1283e650c8c3bca2f58cad8ffa8aab63126d26e890cdDouglas Gregor /// precompiled header will be loaded. 1284e650c8c3bca2f58cad8ffa8aab63126d26e890cdDouglas Gregor /// 1285e650c8c3bca2f58cad8ffa8aab63126d26e890cdDouglas Gregor /// \param Context the AST context that this precompiled header will be 1286e650c8c3bca2f58cad8ffa8aab63126d26e890cdDouglas Gregor /// loaded into. 1287e650c8c3bca2f58cad8ffa8aab63126d26e890cdDouglas Gregor /// 128887d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar /// \param PCHContainerRdr the PCHContainerOperations to use for loading and 128987d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar /// creating modules. 129087d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar /// 129187d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar /// \param Extensions the list of module file extensions that can be loaded 129287d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar /// from the AST files. 129387d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar /// 1294e650c8c3bca2f58cad8ffa8aab63126d26e890cdDouglas Gregor /// \param isysroot If non-NULL, the system include path specified by the 1295e650c8c3bca2f58cad8ffa8aab63126d26e890cdDouglas Gregor /// user. This is only used with relocatable PCH files. If non-NULL, 1296e650c8c3bca2f58cad8ffa8aab63126d26e890cdDouglas Gregor /// a relocatable PCH file will use the default path "/". 1297fae3b2f4743dad616623c4df2fdb0f5128bd36d9Douglas Gregor /// 12983c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// \param DisableValidation If true, the AST reader will suppress most 1299fae3b2f4743dad616623c4df2fdb0f5128bd36d9Douglas Gregor /// of its regular consistency checking, allowing the use of precompiled 1300fae3b2f4743dad616623c4df2fdb0f5128bd36d9Douglas Gregor /// headers that cannot be determined to be compatible. 13018ef6c8cb6c5627240e2339fd7062c9873f821d7eDouglas Gregor /// 1302bef35c91b594f66216f4aab303b71a6c5ab7abcfArgyrios Kyrtzidis /// \param AllowASTWithCompilerErrors If true, the AST reader will accept an 1303bef35c91b594f66216f4aab303b71a6c5ab7abcfArgyrios Kyrtzidis /// AST file the was created out of an AST with compiler errors, 1304bef35c91b594f66216f4aab303b71a6c5ab7abcfArgyrios Kyrtzidis /// otherwise it will reject it. 1305f575d6e7c3b887ea4c5394d2c7e322c7a929a57eDouglas Gregor /// 1306651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines /// \param AllowConfigurationMismatch If true, the AST reader will not check 1307651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines /// for configuration differences between the AST file and the invocation. 1308651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines /// 1309651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines /// \param ValidateSystemInputs If true, the AST reader will validate 1310651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines /// system input files in addition to user input files. This is only 1311651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines /// meaningful if \p DisableValidation is false. 1312651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines /// 1313f575d6e7c3b887ea4c5394d2c7e322c7a929a57eDouglas Gregor /// \param UseGlobalIndex If true, the AST reader will try to load and use 1314f575d6e7c3b887ea4c5394d2c7e322c7a929a57eDouglas Gregor /// the global module index. 131587d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar /// 131687d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar /// \param ReadTimer If non-null, a timer used to track the time spent 131787d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar /// deserializing. 131887d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar ASTReader(Preprocessor &PP, ASTContext &Context, 131987d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar const PCHContainerReader &PCHContainerRdr, 132087d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar ArrayRef<IntrusiveRefCntPtr<ModuleFileExtension>> Extensions, 132187d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar StringRef isysroot = "", bool DisableValidation = false, 1322f575d6e7c3b887ea4c5394d2c7e322c7a929a57eDouglas Gregor bool AllowASTWithCompilerErrors = false, 1323651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines bool AllowConfigurationMismatch = false, 132487d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar bool ValidateSystemInputs = false, bool UseGlobalIndex = true, 132587d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar std::unique_ptr<llvm::Timer> ReadTimer = {}); 13261eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 132758878f85ab89b13e9eea4af3ccf055e42c557bc8Pirama Arumuga Nainar ~ASTReader() override; 13282cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor 13292dbaca748bc3eb6539f417bd8354c930bdf88fa4Argyrios Kyrtzidis SourceManager &getSourceManager() const { return SourceMgr; } 13301c1508b37bc2a9419b2e22beef9e788eb74203f4Argyrios Kyrtzidis FileManager &getFileManager() const { return FileMgr; } 133187d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar DiagnosticsEngine &getDiags() const { return Diags; } 1332ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 133338295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor /// \brief Flags that indicate what kind of AST loading failures the client 133438295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor /// of the AST reader can directly handle. 133538295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor /// 133638295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor /// When a client states that it can handle a particular kind of failure, 133738295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor /// the AST reader will not emit errors when producing that kind of failure. 133838295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor enum LoadFailureCapabilities { 133938295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor /// \brief The client can't handle any AST loading failures. 134038295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor ARR_None = 0, 134138295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor /// \brief The client can handle an AST file that cannot load because it 1342677e15ffee2ecc9c1c8f46fd77cab4b5afb59640Douglas Gregor /// is missing. 1343677e15ffee2ecc9c1c8f46fd77cab4b5afb59640Douglas Gregor ARR_Missing = 0x1, 1344677e15ffee2ecc9c1c8f46fd77cab4b5afb59640Douglas Gregor /// \brief The client can handle an AST file that cannot load because it 134538295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor /// is out-of-date relative to its input files. 1346677e15ffee2ecc9c1c8f46fd77cab4b5afb59640Douglas Gregor ARR_OutOfDate = 0x2, 134738295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor /// \brief The client can handle an AST file that cannot load because it 134838295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor /// was built with a different version of Clang. 1349677e15ffee2ecc9c1c8f46fd77cab4b5afb59640Douglas Gregor ARR_VersionMismatch = 0x4, 135038295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor /// \brief The client can handle an AST file that cannot load because it's 135138295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor /// compiled configuration doesn't match that of the context it was 135238295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor /// loaded into. 1353677e15ffee2ecc9c1c8f46fd77cab4b5afb59640Douglas Gregor ARR_ConfigurationMismatch = 0x8 135438295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor }; 135538295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor 135610bc00fd45824f9b5cd139d63af8b0f6d28aaddaDouglas Gregor /// \brief Load the AST file designated by the given file name. 135738295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor /// 135838295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor /// \param FileName The name of the AST file to load. 135938295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor /// 136038295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor /// \param Type The kind of AST being loaded, e.g., PCH, module, main file, 136138295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor /// or preamble. 136238295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor /// 1363958bcaf3d4e0c1ae46de3e84e7c2a7638c3c5286Argyrios Kyrtzidis /// \param ImportLoc the location where the module file will be considered as 1364958bcaf3d4e0c1ae46de3e84e7c2a7638c3c5286Argyrios Kyrtzidis /// imported from. For non-module AST types it should be invalid. 1365958bcaf3d4e0c1ae46de3e84e7c2a7638c3c5286Argyrios Kyrtzidis /// 136638295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor /// \param ClientLoadCapabilities The set of client load-failure 136738295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor /// capabilities, represented as a bitset of the enumerators of 136838295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor /// LoadFailureCapabilities. 13694967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar ASTReadResult ReadAST(StringRef FileName, ModuleKind Type, 1370958bcaf3d4e0c1ae46de3e84e7c2a7638c3c5286Argyrios Kyrtzidis SourceLocation ImportLoc, 137138295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor unsigned ClientLoadCapabilities); 13721eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 13735e35693721364673f8196e4f5a370f56b92e6053Douglas Gregor /// \brief Make the entities in the given module and any of its (non-explicit) 13745e35693721364673f8196e4f5a370f56b92e6053Douglas Gregor /// submodules visible to name lookup. 13755e35693721364673f8196e4f5a370f56b92e6053Douglas Gregor /// 13765e35693721364673f8196e4f5a370f56b92e6053Douglas Gregor /// \param Mod The module whose names should be made visible. 13775e35693721364673f8196e4f5a370f56b92e6053Douglas Gregor /// 137816ae9de07730832945204877d752db7f1c070962James Dennett /// \param NameVisibility The level of visibility to give the names in the 137916ae9de07730832945204877d752db7f1c070962James Dennett /// module. Visibility can only be increased over time. 1380906d66acc5cf2679453e10a4f0a67feedd765b21Douglas Gregor /// 1381906d66acc5cf2679453e10a4f0a67feedd765b21Douglas Gregor /// \param ImportLoc The location at which the import occurs. 1382651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void makeModuleVisible(Module *Mod, 13835ebcb20b0331a6e64c213f0bb5f4bed9a9e8eb34Argyrios Kyrtzidis Module::NameVisibilityKind NameVisibility, 1384b6d6993e6e6d3daf4d9876794254d20a134e37c2Pirama Arumuga Nainar SourceLocation ImportLoc); 1385651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines 1386ecc2c090e7146c029dd9ee9a5a2fd66b275c01c0Douglas Gregor /// \brief Make the names within this set of hidden names visible. 1387b6d6993e6e6d3daf4d9876794254d20a134e37c2Pirama Arumuga Nainar void makeNamesVisible(const HiddenNames &Names, Module *Owner); 1388176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines 1389176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines /// \brief Take the AST callbacks listener. 1390176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines std::unique_ptr<ASTReaderListener> takeListener() { 1391176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines return std::move(Listener); 1392176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines } 1393651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines 13943c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// \brief Set the AST callbacks listener. 1395176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines void setListener(std::unique_ptr<ASTReaderListener> Listener) { 1396176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines this->Listener = std::move(Listener); 139711e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis } 13981eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1399176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines /// \brief Add an AST callback listener. 1400651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines /// 1401651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines /// Takes ownership of \p L. 1402176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines void addListener(std::unique_ptr<ASTReaderListener> L) { 1403651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines if (Listener) 1404176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines L = llvm::make_unique<ChainedASTReaderListener>(std::move(L), 1405176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines std::move(Listener)); 1406176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines Listener = std::move(L); 1407651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines } 1408651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines 1409176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines /// RAII object to temporarily add an AST callback listener. 1410176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines class ListenerScope { 1411176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines ASTReader &Reader; 1412176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines bool Chained; 1413176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines 1414176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines public: 1415176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines ListenerScope(ASTReader &Reader, std::unique_ptr<ASTReaderListener> L) 1416176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines : Reader(Reader), Chained(false) { 1417176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines auto Old = Reader.takeListener(); 1418176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines if (Old) { 1419176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines Chained = true; 1420176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines L = llvm::make_unique<ChainedASTReaderListener>(std::move(L), 1421176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines std::move(Old)); 1422176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines } 1423176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines Reader.setListener(std::move(L)); 1424176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines } 1425176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines ~ListenerScope() { 1426176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines auto New = Reader.takeListener(); 1427176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines if (Chained) 1428176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines Reader.setListener(static_cast<ChainedASTReaderListener *>(New.get()) 1429176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines ->takeSecond()); 1430176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines } 1431176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines }; 1432176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines 14333c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// \brief Set the AST deserialization listener. 14346bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines void setDeserializationListener(ASTDeserializationListener *Listener, 14356bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines bool TakeOwnership = false); 143630c514c225342844700ed4640ec6d90ddf0e12b2Sebastian Redl 14371a49d97d762570027863e9209af81d445e4f1502Douglas Gregor /// \brief Determine whether this AST reader has a global index. 1438651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines bool hasGlobalIndex() const { return (bool)GlobalIndex; } 14391a49d97d762570027863e9209af81d445e4f1502Douglas Gregor 14406bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines /// \brief Return global module index. 14416bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines GlobalModuleIndex *getGlobalIndex() { return GlobalIndex.get(); } 14426bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines 14436bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines /// \brief Reset reader for a reload try. 14446bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines void resetForReload() { TriedLoadingGlobalIndex = false; } 14456bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines 14461a49d97d762570027863e9209af81d445e4f1502Douglas Gregor /// \brief Attempts to load the global index. 14471a49d97d762570027863e9209af81d445e4f1502Douglas Gregor /// 14481a49d97d762570027863e9209af81d445e4f1502Douglas Gregor /// \returns true if loading the global index has failed for any reason. 14491a49d97d762570027863e9209af81d445e4f1502Douglas Gregor bool loadGlobalIndex(); 14501a49d97d762570027863e9209af81d445e4f1502Douglas Gregor 14511a49d97d762570027863e9209af81d445e4f1502Douglas Gregor /// \brief Determine whether we tried to load the global index, but failed, 14521a49d97d762570027863e9209af81d445e4f1502Douglas Gregor /// e.g., because it is out-of-date or does not exist. 14531a49d97d762570027863e9209af81d445e4f1502Douglas Gregor bool isGlobalIndexUnavailable() const; 14541a49d97d762570027863e9209af81d445e4f1502Douglas Gregor 1455359427794704666ff7a5a933ace11c5256fa3af7Douglas Gregor /// \brief Initializes the ASTContext 1456359427794704666ff7a5a933ace11c5256fa3af7Douglas Gregor void InitializeContext(); 14572cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor 14589b6711873cbba149dd50cedcfdf31f9dd254df50Richard Smith /// \brief Update the state of Sema after loading some additional modules. 14599b6711873cbba149dd50cedcfdf31f9dd254df50Richard Smith void UpdateSema(); 14609b6711873cbba149dd50cedcfdf31f9dd254df50Richard Smith 1461c24a1eef40207457692a1ad597cefdd0dc8fa149Jonathan D. Turner /// \brief Add in-memory (virtual file) buffer. 1462176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines void addInMemoryBuffer(StringRef &FileName, 1463176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines std::unique_ptr<llvm::MemoryBuffer> Buffer) { 1464176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines ModuleMgr.addInMemoryBuffer(FileName, std::move(Buffer)); 1465b0f4b9a558933b307073f7cd7753602f94354ae9Argyrios Kyrtzidis } 1466b0f4b9a558933b307073f7cd7753602f94354ae9Argyrios Kyrtzidis 1467ecc2c090e7146c029dd9ee9a5a2fd66b275c01c0Douglas Gregor /// \brief Finalizes the AST reader's state before writing an AST file to 1468ecc2c090e7146c029dd9ee9a5a2fd66b275c01c0Douglas Gregor /// disk. 1469ecc2c090e7146c029dd9ee9a5a2fd66b275c01c0Douglas Gregor /// 1470ecc2c090e7146c029dd9ee9a5a2fd66b275c01c0Douglas Gregor /// This operation may undo temporary state in the AST that should not be 1471ecc2c090e7146c029dd9ee9a5a2fd66b275c01c0Douglas Gregor /// emitted. 1472ecc2c090e7146c029dd9ee9a5a2fd66b275c01c0Douglas Gregor void finalizeForWriting(); 1473ecc2c090e7146c029dd9ee9a5a2fd66b275c01c0Douglas Gregor 1474e95b9198b8b70ce0219cfb89483b41102e02dbf5Douglas Gregor /// \brief Retrieve the module manager. 1475e95b9198b8b70ce0219cfb89483b41102e02dbf5Douglas Gregor ModuleManager &getModuleManager() { return ModuleMgr; } 1476e19944c93961b7618f4f3f3185f698f46369ea54Steve Naroff 1477d10a381d92a60d4f4c126c4e81045c8ad4636a0bDouglas Gregor /// \brief Retrieve the preprocessor. 1478712f2fcb70ae2eb0cb684d565e7d2cb76881006bDouglas Gregor Preprocessor &getPreprocessor() const { return PP; } 1479ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 148011407b89c9d7ce8bc31869b0a7aae06add49e3dcDouglas Gregor /// \brief Retrieve the name of the original source file name for the primary 148111407b89c9d7ce8bc31869b0a7aae06add49e3dcDouglas Gregor /// module file. 1482848bc3a5db57fb267e2b2541cb55e71dba4bf228Rafael Espindola StringRef getOriginalSourceFile() { 148311407b89c9d7ce8bc31869b0a7aae06add49e3dcDouglas Gregor return ModuleMgr.getPrimaryModule().OriginalSourceFileName; 148411407b89c9d7ce8bc31869b0a7aae06add49e3dcDouglas Gregor } 1485b64c19365deab788753d29c9bc881253c3f16f37Douglas Gregor 14863c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// \brief Retrieve the name of the original source file name directly from 14873c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// the AST file, without actually loading the AST file. 148887d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar static std::string 148987d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar getOriginalSourceFile(const std::string &ASTFileName, FileManager &FileMgr, 149087d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar const PCHContainerReader &PCHContainerRdr, 149187d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar DiagnosticsEngine &Diags); 1492b64c19365deab788753d29c9bc881253c3f16f37Douglas Gregor 14939e60371ba07faa2f173ab614ceaad0332518c8dcDouglas Gregor /// \brief Read the control block for the named AST file. 14949e60371ba07faa2f173ab614ceaad0332518c8dcDouglas Gregor /// 14959e60371ba07faa2f173ab614ceaad0332518c8dcDouglas Gregor /// \returns true if an error occurred, false otherwise. 149687d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar static bool 149787d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar readASTFileControlBlock(StringRef Filename, FileManager &FileMgr, 149887d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar const PCHContainerReader &PCHContainerRdr, 149987d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar bool FindModuleFileExtensions, 150087d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar ASTReaderListener &Listener); 15019e60371ba07faa2f173ab614ceaad0332518c8dcDouglas Gregor 150227ffa6caf965ef20fdef5ae23b81cdc3d05e7afbDouglas Gregor /// \brief Determine whether the given AST file is acceptable to load into a 150327ffa6caf965ef20fdef5ae23b81cdc3d05e7afbDouglas Gregor /// translation unit with the given language and target options. 150487d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar static bool isAcceptableASTFile(StringRef Filename, FileManager &FileMgr, 150587d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar const PCHContainerReader &PCHContainerRdr, 150627ffa6caf965ef20fdef5ae23b81cdc3d05e7afbDouglas Gregor const LangOptions &LangOpts, 15074c0c7e86645dfa1719d17d70e009ab49347aba62Douglas Gregor const TargetOptions &TargetOpts, 15080e2c34f92f00628d48968dfea096d36381f494cbStephen Hines const PreprocessorOptions &PPOpts, 15090e2c34f92f00628d48968dfea096d36381f494cbStephen Hines std::string ExistingModuleCachePath); 151027ffa6caf965ef20fdef5ae23b81cdc3d05e7afbDouglas Gregor 1511e721f95069d42b899c20c1caabdc6184dd42b820Douglas Gregor /// \brief Returns the suggested contents of the predefines buffer, 1512e721f95069d42b899c20c1caabdc6184dd42b820Douglas Gregor /// which contains a (typically-empty) subset of the predefines 1513e721f95069d42b899c20c1caabdc6184dd42b820Douglas Gregor /// build prior to including the precompiled header. 1514e721f95069d42b899c20c1caabdc6184dd42b820Douglas Gregor const std::string &getSuggestedPredefines() { return SuggestedPredefines; } 1515e24692b30adbe8144597678a0e3354912e99c747Argyrios Kyrtzidis 1516e24692b30adbe8144597678a0e3354912e99c747Argyrios Kyrtzidis /// \brief Read a preallocated preprocessed entity from the external source. 1517e24692b30adbe8144597678a0e3354912e99c747Argyrios Kyrtzidis /// 1518e24692b30adbe8144597678a0e3354912e99c747Argyrios Kyrtzidis /// \returns null if an error occurred that prevented the preprocessed 1519e24692b30adbe8144597678a0e3354912e99c747Argyrios Kyrtzidis /// entity from being loaded. 1520651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines PreprocessedEntity *ReadPreprocessedEntity(unsigned Index) override; 1521e721f95069d42b899c20c1caabdc6184dd42b820Douglas Gregor 15222dbaca748bc3eb6539f417bd8354c930bdf88fa4Argyrios Kyrtzidis /// \brief Returns a pair of [Begin, End) indices of preallocated 15231824d54df85a462ada812dadda18130f951d40f3Dmitri Gribenko /// preprocessed entities that \p Range encompasses. 1524651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines std::pair<unsigned, unsigned> 1525651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines findPreprocessedEntitiesInRange(SourceRange Range) override; 1526ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1527f226ff9fe8c8db6c5b74a61ce649eda1491c3502Argyrios Kyrtzidis /// \brief Optionally returns true or false if the preallocated preprocessed 15281824d54df85a462ada812dadda18130f951d40f3Dmitri Gribenko /// entity with index \p Index came from file \p FID. 1529651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines Optional<bool> isPreprocessedEntityInFileID(unsigned Index, 1530651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines FileID FID) override; 15312dbaca748bc3eb6539f417bd8354c930bdf88fa4Argyrios Kyrtzidis 1532cfbf1c7536e016dc275139dd842d4a5f059a749fDouglas Gregor /// \brief Read the header file information for the given file entry. 1533651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines HeaderFileInfo GetHeaderFileInfo(const FileEntry *FE) override; 1534cfbf1c7536e016dc275139dd842d4a5f059a749fDouglas Gregor 1535d6471f7c1921c7802804ce3ff6fe9768310f72b9David Blaikie void ReadPragmaDiagnosticMappings(DiagnosticsEngine &Diag); 1536f41d3be39980d40849850d3fb90403623cc8459eArgyrios Kyrtzidis 1537f2f0f03d08c6143137a79a8edffc7d41823bc3c7Sebastian Redl /// \brief Returns the number of source locations found in the chain. 15380fa7d0b15ea2a224bfe43ac745d411f915da87ddSebastian Redl unsigned getTotalNumSLocs() const { 15390fa7d0b15ea2a224bfe43ac745d411f915da87ddSebastian Redl return TotalNumSLocEntries; 15400fa7d0b15ea2a224bfe43ac745d411f915da87ddSebastian Redl } 15410fa7d0b15ea2a224bfe43ac745d411f915da87ddSebastian Redl 1542f2f0f03d08c6143137a79a8edffc7d41823bc3c7Sebastian Redl /// \brief Returns the number of identifiers found in the chain. 1543f2f0f03d08c6143137a79a8edffc7d41823bc3c7Sebastian Redl unsigned getTotalNumIdentifiers() const { 1544f2f0f03d08c6143137a79a8edffc7d41823bc3c7Sebastian Redl return static_cast<unsigned>(IdentifiersLoaded.size()); 1545f2f0f03d08c6143137a79a8edffc7d41823bc3c7Sebastian Redl } 1546f2f0f03d08c6143137a79a8edffc7d41823bc3c7Sebastian Redl 1547a8235d6c4093cd38dcf742909651f867de62e55bDouglas Gregor /// \brief Returns the number of macros found in the chain. 1548a8235d6c4093cd38dcf742909651f867de62e55bDouglas Gregor unsigned getTotalNumMacros() const { 1549a8235d6c4093cd38dcf742909651f867de62e55bDouglas Gregor return static_cast<unsigned>(MacrosLoaded.size()); 1550a8235d6c4093cd38dcf742909651f867de62e55bDouglas Gregor } 1551a8235d6c4093cd38dcf742909651f867de62e55bDouglas Gregor 1552e58aa890e8de55bb3146e6ea9fbbba3a58ce30c6Sebastian Redl /// \brief Returns the number of types found in the chain. 155377a3c9ede5cdb26b5eb3001e82bb0a36ca997e1fSebastian Redl unsigned getTotalNumTypes() const { 155477a3c9ede5cdb26b5eb3001e82bb0a36ca997e1fSebastian Redl return static_cast<unsigned>(TypesLoaded.size()); 155577a3c9ede5cdb26b5eb3001e82bb0a36ca997e1fSebastian Redl } 155677a3c9ede5cdb26b5eb3001e82bb0a36ca997e1fSebastian Redl 1557e58aa890e8de55bb3146e6ea9fbbba3a58ce30c6Sebastian Redl /// \brief Returns the number of declarations found in the chain. 155877a3c9ede5cdb26b5eb3001e82bb0a36ca997e1fSebastian Redl unsigned getTotalNumDecls() const { 155977a3c9ede5cdb26b5eb3001e82bb0a36ca997e1fSebastian Redl return static_cast<unsigned>(DeclsLoaded.size()); 156077a3c9ede5cdb26b5eb3001e82bb0a36ca997e1fSebastian Redl } 156177a3c9ede5cdb26b5eb3001e82bb0a36ca997e1fSebastian Redl 156226ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor /// \brief Returns the number of submodules known. 156326ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor unsigned getTotalNumSubmodules() const { 156426ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor return static_cast<unsigned>(SubmodulesLoaded.size()); 156526ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor } 156626ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor 1567e58aa890e8de55bb3146e6ea9fbbba3a58ce30c6Sebastian Redl /// \brief Returns the number of selectors found in the chain. 1568e58aa890e8de55bb3146e6ea9fbbba3a58ce30c6Sebastian Redl unsigned getTotalNumSelectors() const { 1569e58aa890e8de55bb3146e6ea9fbbba3a58ce30c6Sebastian Redl return static_cast<unsigned>(SelectorsLoaded.size()); 1570e58aa890e8de55bb3146e6ea9fbbba3a58ce30c6Sebastian Redl } 1571e58aa890e8de55bb3146e6ea9fbbba3a58ce30c6Sebastian Redl 15724c30bb148b53c8063e940ca3e049ba4d270dc9d5Douglas Gregor /// \brief Returns the number of preprocessed entities known to the AST 15734c30bb148b53c8063e940ca3e049ba4d270dc9d5Douglas Gregor /// reader. 15744c30bb148b53c8063e940ca3e049ba4d270dc9d5Douglas Gregor unsigned getTotalNumPreprocessedEntities() const { 15754c30bb148b53c8063e940ca3e049ba4d270dc9d5Douglas Gregor unsigned Result = 0; 15765d6d89fef8c7fff8b1a67c943fb5557a2a803468Jonathan D. Turner for (ModuleConstIterator I = ModuleMgr.begin(), 15775d6d89fef8c7fff8b1a67c943fb5557a2a803468Jonathan D. Turner E = ModuleMgr.end(); I != E; ++I) { 1578e24692b30adbe8144597678a0e3354912e99c747Argyrios Kyrtzidis Result += (*I)->NumPreprocessedEntities; 15795d6d89fef8c7fff8b1a67c943fb5557a2a803468Jonathan D. Turner } 1580ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 15814c30bb148b53c8063e940ca3e049ba4d270dc9d5Douglas Gregor return Result; 15824c30bb148b53c8063e940ca3e049ba4d270dc9d5Douglas Gregor } 1583ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1584833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall /// \brief Reads a TemplateArgumentLocInfo appropriate for the 1585833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall /// given TemplateArgument kind. 1586833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall TemplateArgumentLocInfo 15871a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor GetTemplateArgumentLocInfo(ModuleFile &F, TemplateArgument::ArgKind Kind, 1588833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall const RecordData &Record, unsigned &Idx); 1589833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 159044f8c37e378f716e8cbb600e3800f437cf58f9e5Argyrios Kyrtzidis /// \brief Reads a TemplateArgumentLoc. 1591577d4796d358c0e72ebaa023113505226ab51b4fSebastian Redl TemplateArgumentLoc 15921a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor ReadTemplateArgumentLoc(ModuleFile &F, 1593577d4796d358c0e72ebaa023113505226ab51b4fSebastian Redl const RecordData &Record, unsigned &Idx); 159444f8c37e378f716e8cbb600e3800f437cf58f9e5Argyrios Kyrtzidis 1595c1cef0892e049fcd31084f02d1efdd9985d4dfa4Enea Zaffanella const ASTTemplateArgumentListInfo* 1596c1cef0892e049fcd31084f02d1efdd9985d4dfa4Enea Zaffanella ReadASTTemplateArgumentListInfo(ModuleFile &F, 1597c1cef0892e049fcd31084f02d1efdd9985d4dfa4Enea Zaffanella const RecordData &Record, unsigned &Index); 1598c1cef0892e049fcd31084f02d1efdd9985d4dfa4Enea Zaffanella 1599a1ee0c548b8aa4aaf93d1917e304e3da13171a08John McCall /// \brief Reads a declarator info from the given record. 16001a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor TypeSourceInfo *GetTypeSourceInfo(ModuleFile &F, 1601577d4796d358c0e72ebaa023113505226ab51b4fSebastian Redl const RecordData &Record, unsigned &Idx); 1602a1ee0c548b8aa4aaf93d1917e304e3da13171a08John McCall 16032cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor /// \brief Resolve a type ID into a type, potentially building a new 16042cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor /// type. 16058538e8d43a3a9bd439c987c0de37bcbf035dd391Sebastian Redl QualType GetType(serialization::TypeID ID); 16062cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor 1607393f249399fe30e9580e1529a7479489e90f3a57Douglas Gregor /// \brief Resolve a local type ID within a given AST file into a type. 16081a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor QualType getLocalType(ModuleFile &F, unsigned LocalID); 1609ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1610393f249399fe30e9580e1529a7479489e90f3a57Douglas Gregor /// \brief Map a local type ID within a given AST file into a global type ID. 16111a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor serialization::TypeID getGlobalTypeID(ModuleFile &F, unsigned LocalID) const; 1612ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1613ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie /// \brief Read a type from the current position in the given record, which 1614393f249399fe30e9580e1529a7479489e90f3a57Douglas Gregor /// was read from the given AST file. 16151a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor QualType readType(ModuleFile &F, const RecordData &Record, unsigned &Idx) { 1616393f249399fe30e9580e1529a7479489e90f3a57Douglas Gregor if (Idx >= Record.size()) 1617393f249399fe30e9580e1529a7479489e90f3a57Douglas Gregor return QualType(); 1618ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1619393f249399fe30e9580e1529a7479489e90f3a57Douglas Gregor return getLocalType(F, Record[Idx++]); 1620393f249399fe30e9580e1529a7479489e90f3a57Douglas Gregor } 1621ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1622ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie /// \brief Map from a local declaration ID within a given module to a 1623409448c832d27703146b70a1137d86b020f29863Douglas Gregor /// global declaration ID. 16242093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis serialization::DeclID getGlobalDeclID(ModuleFile &F, 16252093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis serialization::LocalDeclID LocalID) const; 1626e6b8d68a927368b06ac06cc9ac9e7f60aa966d5fArgyrios Kyrtzidis 16271824d54df85a462ada812dadda18130f951d40f3Dmitri Gribenko /// \brief Returns true if global DeclID \p ID originated from module \p M. 16281a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor bool isDeclIDFromModule(serialization::GlobalDeclID ID, ModuleFile &M) const; 1629dfb332d0081c6641d1dbae6a2aeff757c99cc740Argyrios Kyrtzidis 1630cff9f26ce0ed76d555cd33b3dca84dd5cdf376afDouglas Gregor /// \brief Retrieve the module file that owns the given declaration, or NULL 1631cff9f26ce0ed76d555cd33b3dca84dd5cdf376afDouglas Gregor /// if the declaration is not from a module file. 16325a04f9fc2b000da98fd903c8156034304bdadb2fDouglas Gregor ModuleFile *getOwningModuleFile(const Decl *D); 16336bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines 16346bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines /// \brief Get the best name we know for the module that owns the given 16356bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines /// declaration, or an empty string if the declaration is not from a module. 16366bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines std::string getOwningModuleNameForDiagnostic(const Decl *D); 16376bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines 16381824d54df85a462ada812dadda18130f951d40f3Dmitri Gribenko /// \brief Returns the source location for the decl \p ID. 1639dfb332d0081c6641d1dbae6a2aeff757c99cc740Argyrios Kyrtzidis SourceLocation getSourceLocationForDeclID(serialization::GlobalDeclID ID); 1640ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 16412cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor /// \brief Resolve a declaration ID into a declaration, potentially 16422cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor /// building a new declaration. 16438538e8d43a3a9bd439c987c0de37bcbf035dd391Sebastian Redl Decl *GetDecl(serialization::DeclID ID); 1644651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines Decl *GetExternalDecl(uint32_t ID) override; 16452cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor 16466bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines /// \brief Resolve a declaration ID into a declaration. Return 0 if it's not 16476bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines /// been loaded yet. 16486bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines Decl *GetExistingDecl(serialization::DeclID ID); 16496bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines 165043fd9388d374f29e908e611a686c6137553efa79Jonathan D. Turner /// \brief Reads a declaration with the given local ID in the given module. 16511a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor Decl *GetLocalDecl(ModuleFile &F, uint32_t LocalID) { 1652409448c832d27703146b70a1137d86b020f29863Douglas Gregor return GetDecl(getGlobalDeclID(F, LocalID)); 1653409448c832d27703146b70a1137d86b020f29863Douglas Gregor } 1654409448c832d27703146b70a1137d86b020f29863Douglas Gregor 165543fd9388d374f29e908e611a686c6137553efa79Jonathan D. Turner /// \brief Reads a declaration with the given local ID in the given module. 1656409448c832d27703146b70a1137d86b020f29863Douglas Gregor /// 1657409448c832d27703146b70a1137d86b020f29863Douglas Gregor /// \returns The requested declaration, casted to the given return type. 1658409448c832d27703146b70a1137d86b020f29863Douglas Gregor template<typename T> 16591a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor T *GetLocalDeclAs(ModuleFile &F, uint32_t LocalID) { 1660409448c832d27703146b70a1137d86b020f29863Douglas Gregor return cast_or_null<T>(GetLocalDecl(F, LocalID)); 1661409448c832d27703146b70a1137d86b020f29863Douglas Gregor } 1662409448c832d27703146b70a1137d86b020f29863Douglas Gregor 1663a1be278c4f3a234ff61f04018d26c6beecde1654Douglas Gregor /// \brief Map a global declaration ID into the declaration ID used to 1664a1be278c4f3a234ff61f04018d26c6beecde1654Douglas Gregor /// refer to this declaration within the given module fule. 1665a1be278c4f3a234ff61f04018d26c6beecde1654Douglas Gregor /// 1666a1be278c4f3a234ff61f04018d26c6beecde1654Douglas Gregor /// \returns the global ID of the given declaration as known in the given 1667a1be278c4f3a234ff61f04018d26c6beecde1654Douglas Gregor /// module file. 1668a1be278c4f3a234ff61f04018d26c6beecde1654Douglas Gregor serialization::DeclID 1669a1be278c4f3a234ff61f04018d26c6beecde1654Douglas Gregor mapGlobalIDToModuleFileGlobalID(ModuleFile &M, 1670a1be278c4f3a234ff61f04018d26c6beecde1654Douglas Gregor serialization::DeclID GlobalID); 1671a1be278c4f3a234ff61f04018d26c6beecde1654Douglas Gregor 1672ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie /// \brief Reads a declaration ID from the given position in a record in the 1673409448c832d27703146b70a1137d86b020f29863Douglas Gregor /// given module. 1674409448c832d27703146b70a1137d86b020f29863Douglas Gregor /// 1675409448c832d27703146b70a1137d86b020f29863Douglas Gregor /// \returns The declaration ID read from the record, adjusted to a global ID. 16761a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor serialization::DeclID ReadDeclID(ModuleFile &F, const RecordData &Record, 1677409448c832d27703146b70a1137d86b020f29863Douglas Gregor unsigned &Idx); 1678ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1679409448c832d27703146b70a1137d86b020f29863Douglas Gregor /// \brief Reads a declaration from the given position in a record in the 1680409448c832d27703146b70a1137d86b020f29863Douglas Gregor /// given module. 16811a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor Decl *ReadDecl(ModuleFile &F, const RecordData &R, unsigned &I) { 1682409448c832d27703146b70a1137d86b020f29863Douglas Gregor return GetDecl(ReadDeclID(F, R, I)); 1683409448c832d27703146b70a1137d86b020f29863Douglas Gregor } 1684ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1685409448c832d27703146b70a1137d86b020f29863Douglas Gregor /// \brief Reads a declaration from the given position in a record in the 1686409448c832d27703146b70a1137d86b020f29863Douglas Gregor /// given module. 1687409448c832d27703146b70a1137d86b020f29863Douglas Gregor /// 1688409448c832d27703146b70a1137d86b020f29863Douglas Gregor /// \returns The declaration read from this location, casted to the given 1689409448c832d27703146b70a1137d86b020f29863Douglas Gregor /// result type. 1690409448c832d27703146b70a1137d86b020f29863Douglas Gregor template<typename T> 16911a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor T *ReadDeclAs(ModuleFile &F, const RecordData &R, unsigned &I) { 1692409448c832d27703146b70a1137d86b020f29863Douglas Gregor return cast_or_null<T>(GetDecl(ReadDeclID(F, R, I))); 1693409448c832d27703146b70a1137d86b020f29863Douglas Gregor } 1694409448c832d27703146b70a1137d86b020f29863Douglas Gregor 16956bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines /// \brief If any redeclarations of \p D have been imported since it was 16966bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines /// last checked, this digs out those redeclarations and adds them to the 16976bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines /// redeclaration chain for \p D. 16986bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines void CompleteRedeclChain(const Decl *D) override; 16996bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines 1700651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines CXXBaseSpecifier *GetExternalCXXBaseSpecifiers(uint64_t Offset) override; 1701ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1702250fc9c859fdeed3f200ae911a7e7ea338f38436Douglas Gregor /// \brief Resolve the offset of a statement into a statement. 1703250fc9c859fdeed3f200ae911a7e7ea338f38436Douglas Gregor /// 1704250fc9c859fdeed3f200ae911a7e7ea338f38436Douglas Gregor /// This operation will read a new statement from the external 1705250fc9c859fdeed3f200ae911a7e7ea338f38436Douglas Gregor /// source each time it is called, and is meant to be used via a 1706887e2b375fc5e00084ec7bf3dd050c2ca399a6d2Chris Lattner /// LazyOffsetPtr (which is used by Decls for the body of functions, etc). 1707651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines Stmt *GetExternalDeclStmt(uint64_t Offset) override; 1708250fc9c859fdeed3f200ae911a7e7ea338f38436Douglas Gregor 17096367f6d06308ef29c28d2c1604ded45625caeec9Chris Lattner /// ReadBlockAbbrevs - Enter a subblock of the specified BlockID with the 17106367f6d06308ef29c28d2c1604ded45625caeec9Chris Lattner /// specified cursor. Read the abbreviations that are at the top of the block 17116367f6d06308ef29c28d2c1604ded45625caeec9Chris Lattner /// and then leave the cursor pointing into the block. 171287d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar static bool ReadBlockAbbrevs(llvm::BitstreamCursor &Cursor, unsigned BlockID); 17136367f6d06308ef29c28d2c1604ded45625caeec9Chris Lattner 171476bd1f387e6a7b7abfe53f63b3bd429b97bb80f0John McCall /// \brief Finds all the visible declarations with a given name. 171576bd1f387e6a7b7abfe53f63b3bd429b97bb80f0John McCall /// The current implementation of this method just loads the entire 171676bd1f387e6a7b7abfe53f63b3bd429b97bb80f0John McCall /// lookup table as unmaterialized references. 1717651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines bool FindExternalVisibleDeclsByName(const DeclContext *DC, 1718651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines DeclarationName Name) override; 171976bd1f387e6a7b7abfe53f63b3bd429b97bb80f0John McCall 17202cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor /// \brief Read all of the declarations lexically stored in a 17212cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor /// declaration context. 17222cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor /// 17232cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor /// \param DC The declaration context whose declarations will be 17242cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor /// read. 17252cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor /// 172687d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar /// \param IsKindWeWant A predicate indicating which declaration kinds 172787d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar /// we are interested in. 172887d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar /// 17292cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor /// \param Decls Vector that will contain the declarations loaded 17302cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor /// from the external source. The caller is responsible for merging 17312cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor /// these declarations with any declarations already stored in the 17322cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor /// declaration context. 173387d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar void 173487d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar FindExternalLexicalDecls(const DeclContext *DC, 173587d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar llvm::function_ref<bool(Decl::Kind)> IsKindWeWant, 173687d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar SmallVectorImpl<Decl *> &Decls) override; 17372cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor 1738dfb332d0081c6641d1dbae6a2aeff757c99cc740Argyrios Kyrtzidis /// \brief Get the decls that are contained in a file in the Offset/Length 17391824d54df85a462ada812dadda18130f951d40f3Dmitri Gribenko /// range. \p Length can be 0 to indicate a point at \p Offset instead of 1740ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie /// a range. 1741651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void FindFileRegionDecls(FileID File, unsigned Offset, unsigned Length, 1742651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines SmallVectorImpl<Decl *> &Decls) override; 1743dfb332d0081c6641d1dbae6a2aeff757c99cc740Argyrios Kyrtzidis 1744c43b54cbc10654ed59de797898042e1a05265246Sebastian Redl /// \brief Notify ASTReader that we started deserialization of 174529ee3a273f58e16df7f2c524ab62a869e44fc9b1Argyrios Kyrtzidis /// a decl or type so until FinishedDeserializing is called there may be 174629ee3a273f58e16df7f2c524ab62a869e44fc9b1Argyrios Kyrtzidis /// decls that are initializing. Must be paired with FinishedDeserializing. 174787d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar void StartedDeserializing() override; 174829ee3a273f58e16df7f2c524ab62a869e44fc9b1Argyrios Kyrtzidis 1749c43b54cbc10654ed59de797898042e1a05265246Sebastian Redl /// \brief Notify ASTReader that we finished the deserialization of 175029ee3a273f58e16df7f2c524ab62a869e44fc9b1Argyrios Kyrtzidis /// a decl or type. Must be paired with StartedDeserializing. 1751651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void FinishedDeserializing() override; 175229ee3a273f58e16df7f2c524ab62a869e44fc9b1Argyrios Kyrtzidis 1753fdd0172ca1b3c837f8c2b37d69cc2085234e09faDouglas Gregor /// \brief Function that will be invoked when we begin parsing a new 1754fdd0172ca1b3c837f8c2b37d69cc2085234e09faDouglas Gregor /// translation unit involving this external AST source. 1755fdd0172ca1b3c837f8c2b37d69cc2085234e09faDouglas Gregor /// 1756fdd0172ca1b3c837f8c2b37d69cc2085234e09faDouglas Gregor /// This function will provide all of the external definitions to 1757fdd0172ca1b3c837f8c2b37d69cc2085234e09faDouglas Gregor /// the ASTConsumer. 1758651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void StartTranslationUnit(ASTConsumer *Consumer) override; 1759fdd0172ca1b3c837f8c2b37d69cc2085234e09faDouglas Gregor 17603c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// \brief Print some statistics about AST usage. 1761651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void PrintStats() override; 17622cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor 176323d7df5ce30f4a068e13ad6cb81d473365d260dbDouglas Gregor /// \brief Dump information about the AST reader to standard error. 176423d7df5ce30f4a068e13ad6cb81d473365d260dbDouglas Gregor void dump(); 1765ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1766e9b5f3d4acfc2ad6e8b65a4072464e997dea9ed3Ted Kremenek /// Return the amount of memory used by memory buffers, breaking down 1767e9b5f3d4acfc2ad6e8b65a4072464e997dea9ed3Ted Kremenek /// by heap-backed versus mmap'ed memory. 1768651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void getMemoryBufferSizes(MemoryBufferSizes &sizes) const override; 1769e9b5f3d4acfc2ad6e8b65a4072464e997dea9ed3Ted Kremenek 1770668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor /// \brief Initialize the semantic source with the Sema instance 1771668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor /// being used to perform semantic analysis on the abstract syntax 1772668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor /// tree. 1773651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void InitializeSema(Sema &S) override; 1774668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor 1775ec2a4ed278a1112ebf84fdcb80ed66f53d8ec8baDaniel Dunbar /// \brief Inform the semantic consumer that Sema is no longer available. 17766bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines void ForgetSema() override { SemaObj = nullptr; } 1777ec2a4ed278a1112ebf84fdcb80ed66f53d8ec8baDaniel Dunbar 1778668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor /// \brief Retrieve the IdentifierInfo for the named identifier. 1779668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor /// 17804d5936aaa4e4e2d41fe79101ac9c09444951448fDaniel Dunbar /// This routine builds a new IdentifierInfo for the given identifier. If any 17814d5936aaa4e4e2d41fe79101ac9c09444951448fDaniel Dunbar /// declarations with this name are visible from translation unit scope, their 17824d5936aaa4e4e2d41fe79101ac9c09444951448fDaniel Dunbar /// declarations will be deserialized and introduced into the declaration 178388a35862fbe473f2a4f0c19f24dbe536937e1dc6Douglas Gregor /// chain of the identifier. 178487d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar IdentifierInfo *get(StringRef Name) override; 1785668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor 178695f4292cc526c629fead321c7fcfd4fe0f3bc66eDouglas Gregor /// \brief Retrieve an iterator into the set of all identifiers 178795f4292cc526c629fead321c7fcfd4fe0f3bc66eDouglas Gregor /// in all loaded AST files. 1788651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines IdentifierIterator *getIdentifiers() override; 178995f4292cc526c629fead321c7fcfd4fe0f3bc66eDouglas Gregor 1790f0aaf7a59729a4ae0146e3464ee987745be95829Douglas Gregor /// \brief Load the contents of the global method pool for a given 1791f0aaf7a59729a4ae0146e3464ee987745be95829Douglas Gregor /// selector. 1792651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void ReadMethodPool(Selector Sel) override; 1793f0aaf7a59729a4ae0146e3464ee987745be95829Douglas Gregor 17944967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar /// Load the contents of the global method pool for a given 17954967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar /// selector if necessary. 17964967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar void updateOutOfDateSelector(Selector Sel) override; 17974967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar 1798d8bba9c15230d2b1b3893e272106aa79efc50251Douglas Gregor /// \brief Load the set of namespaces that are known to the external source, 1799d8bba9c15230d2b1b3893e272106aa79efc50251Douglas Gregor /// which will be used during typo correction. 1800651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void ReadKnownNamespaces( 1801651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines SmallVectorImpl<NamespaceDecl *> &Namespaces) override; 1802d8bba9c15230d2b1b3893e272106aa79efc50251Douglas Gregor 1803651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void ReadUndefinedButUsed( 18044967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar llvm::MapVector<NamedDecl *, SourceLocation> &Undefined) override; 180501a41140cd8ec9475ed0c33384310fbdd3b6de11Nick Lewycky 1806b6d6993e6e6d3daf4d9876794254d20a134e37c2Pirama Arumuga Nainar void ReadMismatchingDeleteExpressions(llvm::MapVector< 1807b6d6993e6e6d3daf4d9876794254d20a134e37c2Pirama Arumuga Nainar FieldDecl *, llvm::SmallVector<std::pair<SourceLocation, bool>, 4>> & 1808b6d6993e6e6d3daf4d9876794254d20a134e37c2Pirama Arumuga Nainar Exprs) override; 1809b6d6993e6e6d3daf4d9876794254d20a134e37c2Pirama Arumuga Nainar 1810651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void ReadTentativeDefinitions( 1811651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines SmallVectorImpl<VarDecl *> &TentativeDefs) override; 1812a862320972e63349524dc9aa744dec1b95f54ba1Douglas Gregor 1813651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void ReadUnusedFileScopedDecls( 1814651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines SmallVectorImpl<const DeclaratorDecl *> &Decls) override; 1815a2ee20aa9660851080135219cac5b31fbac08b78Douglas Gregor 1816651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void ReadDelegatingConstructors( 1817651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines SmallVectorImpl<CXXConstructorDecl *> &Decls) override; 18180129b561a1452bf057f6b18b6a1de815d487ab81Douglas Gregor 1819651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void ReadExtVectorDecls(SmallVectorImpl<TypedefNameDecl *> &Decls) override; 1820d58a0a55e64a7c410a80e9d6dcd899e61e99cc4dDouglas Gregor 1821176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines void ReadUnusedLocalTypedefNameCandidates( 1822176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines llvm::SmallSetVector<const TypedefNameDecl *, 4> &Decls) override; 1823176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines 1824651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void ReadReferencedSelectors( 1825651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines SmallVectorImpl<std::pair<Selector, SourceLocation> > &Sels) override; 18265b9dc7caaef0469babc45dd8e713727a136ce517Douglas Gregor 1827651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void ReadWeakUndeclaredIdentifiers( 1828651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines SmallVectorImpl<std::pair<IdentifierInfo *, WeakInfo> > &WI) override; 182931e37b2d7b4815fdea6a35d49f33005562f0d494Douglas Gregor 1830651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void ReadUsedVTables(SmallVectorImpl<ExternalVTableUse> &VTables) override; 1831dfe6543e12eca5c79421378b7fa6b3e8fc403e63Douglas Gregor 1832651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void ReadPendingInstantiations( 1833ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie SmallVectorImpl<std::pair<ValueDecl *, 1834651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines SourceLocation> > &Pending) override; 18356e4a3f5c59664af13e02e9bb58c2810b830e3b96Douglas Gregor 1836651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void ReadLateParsedTemplates( 18373ea9e33ea25e0c2b12db56418ba3f994eb662c04Pirama Arumuga Nainar llvm::MapVector<const FunctionDecl *, LateParsedTemplate *> &LPTMap) 18383ea9e33ea25e0c2b12db56418ba3f994eb662c04Pirama Arumuga Nainar override; 1839ac32d9044b9c1e7492cef929a322d23ce899d276Richard Smith 1840e58aa890e8de55bb3146e6ea9fbbba3a58ce30c6Sebastian Redl /// \brief Load a selector from disk, registering its ID if it exists. 1841e58aa890e8de55bb3146e6ea9fbbba3a58ce30c6Sebastian Redl void LoadSelector(Selector Sel); 1842e58aa890e8de55bb3146e6ea9fbbba3a58ce30c6Sebastian Redl 18432b3a5a83ea30bde7fa8f9d8e9a0cb12623759bfbDouglas Gregor void SetIdentifierInfo(unsigned ID, IdentifierInfo *II); 18441eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump void SetGloballyVisibleDecls(IdentifierInfo *II, 1845686775deca8b8685eb90801495880e3abdd844c2Chris Lattner const SmallVectorImpl<uint32_t> &DeclIDs, 18466bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines SmallVectorImpl<Decl *> *Decls = nullptr); 18471eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 18480a0428e96c6f1e8bef7a481a9eb69a6f6df38951Douglas Gregor /// \brief Report a diagnostic. 18490a0428e96c6f1e8bef7a481a9eb69a6f6df38951Douglas Gregor DiagnosticBuilder Diag(unsigned DiagID); 18500a0428e96c6f1e8bef7a481a9eb69a6f6df38951Douglas Gregor 1851e1d918e9fe55e3b34401fd5d420c47ea0f9572c9Douglas Gregor /// \brief Report a diagnostic. 1852e1d918e9fe55e3b34401fd5d420c47ea0f9572c9Douglas Gregor DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID); 1853e1d918e9fe55e3b34401fd5d420c47ea0f9572c9Douglas Gregor 18548222b8951da749d4f086d7b39de5ff0221297509Douglas Gregor IdentifierInfo *DecodeIdentifierInfo(serialization::IdentifierID ID); 18551eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 18561a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor IdentifierInfo *GetIdentifierInfo(ModuleFile &M, const RecordData &Record, 18578222b8951da749d4f086d7b39de5ff0221297509Douglas Gregor unsigned &Idx) { 18588222b8951da749d4f086d7b39de5ff0221297509Douglas Gregor return DecodeIdentifierInfo(getGlobalIdentifierID(M, Record[Idx++])); 18597356a31327be9b3c3434a0c88746028980da5684Chris Lattner } 18601eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1861651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines IdentifierInfo *GetIdentifier(serialization::IdentifierID ID) override { 18626c6c54a59a6e7dbe63ff6a9bbab76f6e0c7c8462Douglas Gregor // Note that we are loading an identifier. 18636c6c54a59a6e7dbe63ff6a9bbab76f6e0c7c8462Douglas Gregor Deserializing AnIdentifier(this); 18646c6c54a59a6e7dbe63ff6a9bbab76f6e0c7c8462Douglas Gregor 18658c5a760b82e73ed90b560090772db97e2ae27b09Douglas Gregor return DecodeIdentifierInfo(ID); 18668c5a760b82e73ed90b560090772db97e2ae27b09Douglas Gregor } 18678c5a760b82e73ed90b560090772db97e2ae27b09Douglas Gregor 18688222b8951da749d4f086d7b39de5ff0221297509Douglas Gregor IdentifierInfo *getLocalIdentifier(ModuleFile &M, unsigned LocalID); 1869ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 18701a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor serialization::IdentifierID getGlobalIdentifierID(ModuleFile &M, 187195eab176f51beed44a9bc14c0dcdd37844b23740Douglas Gregor unsigned LocalID); 1872ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 18739317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis void resolvePendingMacro(IdentifierInfo *II, const PendingMacroInfo &PMInfo); 18749317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis 1875a8235d6c4093cd38dcf742909651f867de62e55bDouglas Gregor /// \brief Retrieve the macro with the given ID. 18769317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis MacroInfo *getMacro(serialization::MacroID ID); 1877a8235d6c4093cd38dcf742909651f867de62e55bDouglas Gregor 1878a8235d6c4093cd38dcf742909651f867de62e55bDouglas Gregor /// \brief Retrieve the global macro ID corresponding to the given local 1879a8235d6c4093cd38dcf742909651f867de62e55bDouglas Gregor /// ID within the given module file. 1880a8235d6c4093cd38dcf742909651f867de62e55bDouglas Gregor serialization::MacroID getGlobalMacroID(ModuleFile &M, unsigned LocalID); 1881a8235d6c4093cd38dcf742909651f867de62e55bDouglas Gregor 18827f94b0b0c6791013d2f72ced9b4bedd3b23673a6Douglas Gregor /// \brief Read the source location entry with index ID. 1883651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines bool ReadSLocEntry(int ID) override; 18847f94b0b0c6791013d2f72ced9b4bedd3b23673a6Douglas Gregor 18856c3254316de2d0d554b19702f4b10117ae46b77bDouglas Gregor /// \brief Retrieve the module import location and module name for the 18866c3254316de2d0d554b19702f4b10117ae46b77bDouglas Gregor /// given source manager entry ID. 1887651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines std::pair<SourceLocation, StringRef> getModuleImportLoc(int ID) override; 18886c3254316de2d0d554b19702f4b10117ae46b77bDouglas Gregor 188926ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor /// \brief Retrieve the global submodule ID given a module and its local ID 189026ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor /// number. 189126ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor serialization::SubmoduleID 189226ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor getGlobalSubmoduleID(ModuleFile &M, unsigned LocalID); 189326ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor 189426ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor /// \brief Retrieve the submodule that corresponds to a global submodule ID. 189526ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor /// 189626ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor Module *getSubmodule(serialization::SubmoduleID GlobalID); 1897ca2ab45341c448284cf93770018c717810575f86Douglas Gregor 1898ca2ab45341c448284cf93770018c717810575f86Douglas Gregor /// \brief Retrieve the module that corresponds to the given module ID. 1899ca2ab45341c448284cf93770018c717810575f86Douglas Gregor /// 1900ca2ab45341c448284cf93770018c717810575f86Douglas Gregor /// Note: overrides method in ExternalASTSource 1901651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines Module *getModule(unsigned ID) override; 1902ca2ab45341c448284cf93770018c717810575f86Douglas Gregor 190387d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar /// \brief Retrieve the module file with a given local ID within the specified 190487d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar /// ModuleFile. 190587d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar ModuleFile *getLocalModuleFile(ModuleFile &M, unsigned ID); 190687d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar 190787d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar /// \brief Get an ID for the given module file. 190887d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar unsigned getModuleFileID(ModuleFile *M); 190987d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar 191087d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar /// \brief Return a descriptor for the corresponding module. 191187d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar llvm::Optional<ASTSourceDescriptor> getSourceDescriptor(unsigned ID) override; 191287d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar 19132d2689ab787c6d54cb985c28ff3f16370bc01b0fDouglas Gregor /// \brief Retrieve a selector from the given module with its local ID 19142d2689ab787c6d54cb985c28ff3f16370bc01b0fDouglas Gregor /// number. 19151a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor Selector getLocalSelector(ModuleFile &M, unsigned LocalID); 19162d2689ab787c6d54cb985c28ff3f16370bc01b0fDouglas Gregor 19172d2689ab787c6d54cb985c28ff3f16370bc01b0fDouglas Gregor Selector DecodeSelector(serialization::SelectorID Idx); 19181eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1919651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines Selector GetExternalSelector(serialization::SelectorID ID) override; 1920651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines uint32_t GetNumExternalSelectors() override; 1921719770dcfcb3987e8a2377dcca97955301445eb5Douglas Gregor 19221a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor Selector ReadSelector(ModuleFile &M, const RecordData &Record, unsigned &Idx) { 19232d2689ab787c6d54cb985c28ff3f16370bc01b0fDouglas Gregor return getLocalSelector(M, Record[Idx++]); 192490cd1bb1baac2a0221f3642de0cbea3244b116e5Steve Naroff } 1925ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 19268451ec7e709baf777bec07dc70653e0c523dd120Douglas Gregor /// \brief Retrieve the global selector ID that corresponds to this 19278451ec7e709baf777bec07dc70653e0c523dd120Douglas Gregor /// the local selector ID in a given module. 19281a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor serialization::SelectorID getGlobalSelectorID(ModuleFile &F, 19298451ec7e709baf777bec07dc70653e0c523dd120Douglas Gregor unsigned LocalID) const; 19306ad9ac097918fbdeb443ea7b99d4db9e49b28534Chris Lattner 19316ad9ac097918fbdeb443ea7b99d4db9e49b28534Chris Lattner /// \brief Read a declaration name. 19321a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor DeclarationName ReadDeclarationName(ModuleFile &F, 1933393f249399fe30e9580e1529a7479489e90f3a57Douglas Gregor const RecordData &Record, unsigned &Idx); 19341a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor void ReadDeclarationNameLoc(ModuleFile &F, 19354045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis DeclarationNameLoc &DNLoc, DeclarationName Name, 19364045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis const RecordData &Record, unsigned &Idx); 19371a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor void ReadDeclarationNameInfo(ModuleFile &F, DeclarationNameInfo &NameInfo, 19384045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis const RecordData &Record, unsigned &Idx); 19394045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis 19401a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor void ReadQualifierInfo(ModuleFile &F, QualifierInfo &Info, 19414045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis const RecordData &Record, unsigned &Idx); 19420a2b45e5885b6b8477b167042c0f6cd1d99a1f13Douglas Gregor 19431a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor NestedNameSpecifier *ReadNestedNameSpecifier(ModuleFile &F, 1944409448c832d27703146b70a1137d86b020f29863Douglas Gregor const RecordData &Record, 19456ad9ac097918fbdeb443ea7b99d4db9e49b28534Chris Lattner unsigned &Idx); 19466ad9ac097918fbdeb443ea7b99d4db9e49b28534Chris Lattner 19471a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor NestedNameSpecifierLoc ReadNestedNameSpecifierLoc(ModuleFile &F, 1948dc355713be51fcb4ee52d9fd6b4548ceff47fadfDouglas Gregor const RecordData &Record, 1949dc355713be51fcb4ee52d9fd6b4548ceff47fadfDouglas Gregor unsigned &Idx); 1950dc355713be51fcb4ee52d9fd6b4548ceff47fadfDouglas Gregor 19518731ca76acf81826df7048bffd0c44c7c0f96c7fArgyrios Kyrtzidis /// \brief Read a template name. 19521a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor TemplateName ReadTemplateName(ModuleFile &F, const RecordData &Record, 19531aee05d08b2184acadeb36de300e216390780d6cDouglas Gregor unsigned &Idx); 19548731ca76acf81826df7048bffd0c44c7c0f96c7fArgyrios Kyrtzidis 19558731ca76acf81826df7048bffd0c44c7c0f96c7fArgyrios Kyrtzidis /// \brief Read a template argument. 195687d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar TemplateArgument ReadTemplateArgument(ModuleFile &F, const RecordData &Record, 195787d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar unsigned &Idx, 195887d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar bool Canonicalize = false); 1959ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1960dd41c14bfd7686b556de2acf6952e21a4f80b7aaArgyrios Kyrtzidis /// \brief Read a template parameter list. 19611a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor TemplateParameterList *ReadTemplateParameterList(ModuleFile &F, 1962c3632730cc83ed7b51f0ab5c38997ae5a9439b0cSebastian Redl const RecordData &Record, 1963dd41c14bfd7686b556de2acf6952e21a4f80b7aaArgyrios Kyrtzidis unsigned &Idx); 1964ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1965dd41c14bfd7686b556de2acf6952e21a4f80b7aaArgyrios Kyrtzidis /// \brief Read a template argument array. 196687d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar void ReadTemplateArgumentList(SmallVectorImpl<TemplateArgument> &TemplArgs, 196787d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar ModuleFile &F, const RecordData &Record, 196887d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar unsigned &Idx, bool Canonicalize = false); 19698731ca76acf81826df7048bffd0c44c7c0f96c7fArgyrios Kyrtzidis 197037ffed3b7f229844cae2463ff82b527506c86c74Argyrios Kyrtzidis /// \brief Read a UnresolvedSet structure. 1971c2d775714f79af977672e4f1dbc16ee9e02d1deaRichard Smith void ReadUnresolvedSet(ModuleFile &F, LazyASTUnresolvedSet &Set, 197237ffed3b7f229844cae2463ff82b527506c86c74Argyrios Kyrtzidis const RecordData &Record, unsigned &Idx); 197337ffed3b7f229844cae2463ff82b527506c86c74Argyrios Kyrtzidis 19740745d0a648b75bd304045309276c70a755adaafbArgyrios Kyrtzidis /// \brief Read a C++ base specifier. 19751a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor CXXBaseSpecifier ReadCXXBaseSpecifier(ModuleFile &F, 19765606220447c7901ba8d80147ddab893bb7949dd5Nick Lewycky const RecordData &Record,unsigned &Idx); 19770745d0a648b75bd304045309276c70a755adaafbArgyrios Kyrtzidis 1978cbb67480094b3bcb5b715acd827cbad55e2a204cSean Hunt /// \brief Read a CXXCtorInitializer array. 19793ea9e33ea25e0c2b12db56418ba3f994eb662c04Pirama Arumuga Nainar CXXCtorInitializer ** 19801a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor ReadCXXCtorInitializers(ModuleFile &F, const RecordData &Record, 1981cbb67480094b3bcb5b715acd827cbad55e2a204cSean Hunt unsigned &Idx); 19828e706f4b8da141612861e127610141b8d17a9667Argyrios Kyrtzidis 19833ea9e33ea25e0c2b12db56418ba3f994eb662c04Pirama Arumuga Nainar /// \brief Read the contents of a CXXCtorInitializer array. 19843ea9e33ea25e0c2b12db56418ba3f994eb662c04Pirama Arumuga Nainar CXXCtorInitializer **GetExternalCXXCtorInitializers(uint64_t Offset) override; 19853ea9e33ea25e0c2b12db56418ba3f994eb662c04Pirama Arumuga Nainar 19864967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar /// \brief Read a source location from raw form and return it in its 19874967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar /// originating module file's source location space. 19884967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar SourceLocation ReadUntranslatedSourceLocation(uint32_t Raw) const { 19894967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar return SourceLocation::getFromRawEncoding((Raw >> 1) | (Raw << 31)); 19904967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar } 19914967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar 1992c3632730cc83ed7b51f0ab5c38997ae5a9439b0cSebastian Redl /// \brief Read a source location from raw form. 19934967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar SourceLocation ReadSourceLocation(ModuleFile &ModuleFile, uint32_t Raw) const { 19944967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar SourceLocation Loc = ReadUntranslatedSourceLocation(Raw); 19954967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar return TranslateSourceLocation(ModuleFile, Loc); 19964967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar } 19974967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar 19984967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar /// \brief Translate a source location from another module file's source 19994967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar /// location space into ours. 20004967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar SourceLocation TranslateSourceLocation(ModuleFile &ModuleFile, 20014967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar SourceLocation Loc) const { 20024967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar assert(ModuleFile.SLocRemap.find(Loc.getOffset()) != 20034967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar ModuleFile.SLocRemap.end() && 2004f62d43d2afe1960755a1b5813cae1e5983bcac1bDouglas Gregor "Cannot find offset to remap."); 20051a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor int Remap = ModuleFile.SLocRemap.find(Loc.getOffset())->second; 2006a64ccefdf0ea4e03ec88805d71b0af74950c7472Argyrios Kyrtzidis return Loc.getLocWithOffset(Remap); 2007c3632730cc83ed7b51f0ab5c38997ae5a9439b0cSebastian Redl } 2008c3632730cc83ed7b51f0ab5c38997ae5a9439b0cSebastian Redl 20096ad9ac097918fbdeb443ea7b99d4db9e49b28534Chris Lattner /// \brief Read a source location. 20101a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor SourceLocation ReadSourceLocation(ModuleFile &ModuleFile, 2011ac32d9044b9c1e7492cef929a322d23ce899d276Richard Smith const RecordDataImpl &Record, 2012ac32d9044b9c1e7492cef929a322d23ce899d276Richard Smith unsigned &Idx) { 20131a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor return ReadSourceLocation(ModuleFile, Record[Idx++]); 20146ad9ac097918fbdeb443ea7b99d4db9e49b28534Chris Lattner } 20156ad9ac097918fbdeb443ea7b99d4db9e49b28534Chris Lattner 20166ad9ac097918fbdeb443ea7b99d4db9e49b28534Chris Lattner /// \brief Read a source range. 20171a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor SourceRange ReadSourceRange(ModuleFile &F, 201801a41140cd8ec9475ed0c33384310fbdd3b6de11Nick Lewycky const RecordData &Record, unsigned &Idx); 20196ad9ac097918fbdeb443ea7b99d4db9e49b28534Chris Lattner 20200a2b45e5885b6b8477b167042c0f6cd1d99a1f13Douglas Gregor /// \brief Read an integral value 20210a2b45e5885b6b8477b167042c0f6cd1d99a1f13Douglas Gregor llvm::APInt ReadAPInt(const RecordData &Record, unsigned &Idx); 20220a2b45e5885b6b8477b167042c0f6cd1d99a1f13Douglas Gregor 20230a2b45e5885b6b8477b167042c0f6cd1d99a1f13Douglas Gregor /// \brief Read a signed integral value 20240a2b45e5885b6b8477b167042c0f6cd1d99a1f13Douglas Gregor llvm::APSInt ReadAPSInt(const RecordData &Record, unsigned &Idx); 20253a2f7e42514ddbec983c61826ce85d3071e23e8eDouglas Gregor 202617fc223395d51be582fc666bb6ea21bd1dff26dcDouglas Gregor /// \brief Read a floating-point value 20279ec55f24b8f848bb37a9971100cf2fca379d5572Tim Northover llvm::APFloat ReadAPFloat(const RecordData &Record, 20289ec55f24b8f848bb37a9971100cf2fca379d5572Tim Northover const llvm::fltSemantics &Sem, unsigned &Idx); 202917fc223395d51be582fc666bb6ea21bd1dff26dcDouglas Gregor 203068a2eb0cc76267ba0615992fb5e0977853c397b2Douglas Gregor // \brief Read a string 203127ffa6caf965ef20fdef5ae23b81cdc3d05e7afbDouglas Gregor static std::string ReadString(const RecordData &Record, unsigned &Idx); 203268a2eb0cc76267ba0615992fb5e0977853c397b2Douglas Gregor 20330e2c34f92f00628d48968dfea096d36381f494cbStephen Hines // \brief Read a path 20340e2c34f92f00628d48968dfea096d36381f494cbStephen Hines std::string ReadPath(ModuleFile &F, const RecordData &Record, unsigned &Idx); 20350e2c34f92f00628d48968dfea096d36381f494cbStephen Hines 20360a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor /// \brief Read a version tuple. 203727ffa6caf965ef20fdef5ae23b81cdc3d05e7afbDouglas Gregor static VersionTuple ReadVersionTuple(const RecordData &Record, unsigned &Idx); 20380a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor 20391a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor CXXTemporary *ReadCXXTemporary(ModuleFile &F, const RecordData &Record, 2040409448c832d27703146b70a1137d86b020f29863Douglas Gregor unsigned &Idx); 2041ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 204268a2eb0cc76267ba0615992fb5e0977853c397b2Douglas Gregor /// \brief Reads attributes from the current stream position. 20431a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor void ReadAttributes(ModuleFile &F, AttrVec &Attrs, 20444eb9fc0449ddbd5239ddc3ae6b6e52880f47dcf7Argyrios Kyrtzidis const RecordData &Record, unsigned &Idx); 204568a2eb0cc76267ba0615992fb5e0977853c397b2Douglas Gregor 2046919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis /// \brief Reads a statement. 20471a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor Stmt *ReadStmt(ModuleFile &F); 20480b7489194f9f89fac39d57211c1e7953ae50251fDouglas Gregor 2049919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis /// \brief Reads an expression. 20501a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor Expr *ReadExpr(ModuleFile &F); 2051c9490c000f515c29f200a1215328d8ab9a0f3818Douglas Gregor 2052d98a2ab9275f896df49e42ea4e4b8871610e0f45Argyrios Kyrtzidis /// \brief Reads a sub-statement operand during statement reading. 2053d98a2ab9275f896df49e42ea4e4b8871610e0f45Argyrios Kyrtzidis Stmt *ReadSubStmt() { 2054d98a2ab9275f896df49e42ea4e4b8871610e0f45Argyrios Kyrtzidis assert(ReadingKind == Read_Stmt && 2055d98a2ab9275f896df49e42ea4e4b8871610e0f45Argyrios Kyrtzidis "Should be called only during statement reading!"); 2056d98a2ab9275f896df49e42ea4e4b8871610e0f45Argyrios Kyrtzidis // Subexpressions are stored from last to first, so the next Stmt we need 2057d98a2ab9275f896df49e42ea4e4b8871610e0f45Argyrios Kyrtzidis // is at the back of the stack. 2058651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines assert(!StmtStack.empty() && "Read too many sub-statements!"); 2059d98a2ab9275f896df49e42ea4e4b8871610e0f45Argyrios Kyrtzidis return StmtStack.pop_back_val(); 2060d98a2ab9275f896df49e42ea4e4b8871610e0f45Argyrios Kyrtzidis } 2061d98a2ab9275f896df49e42ea4e4b8871610e0f45Argyrios Kyrtzidis 2062d98a2ab9275f896df49e42ea4e4b8871610e0f45Argyrios Kyrtzidis /// \brief Reads a sub-expression operand during statement reading. 2063d98a2ab9275f896df49e42ea4e4b8871610e0f45Argyrios Kyrtzidis Expr *ReadSubExpr(); 2064d98a2ab9275f896df49e42ea4e4b8871610e0f45Argyrios Kyrtzidis 2065aeeacf725c9e0ddd64ea9764bd008e5b6873ce51John McCall /// \brief Reads a token out of a record. 2066ac32d9044b9c1e7492cef929a322d23ce899d276Richard Smith Token ReadToken(ModuleFile &M, const RecordDataImpl &Record, unsigned &Idx); 2067aeeacf725c9e0ddd64ea9764bd008e5b6873ce51John McCall 206837e2684abfe38207fdb90620da062bb18c23f29aDouglas Gregor /// \brief Reads the macro record located at the given offset. 20699317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis MacroInfo *ReadMacroRecord(ModuleFile &F, uint64_t Offset); 2070ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 207186c67d8802a9e0887c31c850188991465ac3c1bdDouglas Gregor /// \brief Determine the global preprocessed entity ID that corresponds to 207286c67d8802a9e0887c31c850188991465ac3c1bdDouglas Gregor /// the given local ID within the given module. 2073ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie serialization::PreprocessedEntityID 20741a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor getGlobalPreprocessedEntityID(ModuleFile &M, unsigned LocalID) const; 2075ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 2076b6d6993e6e6d3daf4d9876794254d20a134e37c2Pirama Arumuga Nainar /// \brief Add a macro to deserialize its macro directive history. 2077dc1088f6201c3fb8f3f97f54c343f7d163fbec06Argyrios Kyrtzidis /// 20789317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis /// \param II The name of the macro. 20799317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis /// \param M The module file. 20809317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis /// \param MacroDirectivesOffset Offset of the serialized macro directive 20819317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis /// history. 2082b6d6993e6e6d3daf4d9876794254d20a134e37c2Pirama Arumuga Nainar void addPendingMacro(IdentifierInfo *II, ModuleFile *M, 2083b6d6993e6e6d3daf4d9876794254d20a134e37c2Pirama Arumuga Nainar uint64_t MacroDirectivesOffset); 2084ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 208588a35862fbe473f2a4f0c19f24dbe536937e1dc6Douglas Gregor /// \brief Read the set of macros defined by this external macro source. 2086651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void ReadDefinedMacros() override; 208788a35862fbe473f2a4f0c19f24dbe536937e1dc6Douglas Gregor 2088eee242ff426bf79149f221798966e58688383c1eDouglas Gregor /// \brief Update an out-of-date identifier. 2089651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void updateOutOfDateIdentifier(IdentifierInfo &II) override; 2090eee242ff426bf79149f221798966e58688383c1eDouglas Gregor 2091057df20b3107cef764052d271c89b8591b98b3ceDouglas Gregor /// \brief Note that this identifier is up-to-date. 2092057df20b3107cef764052d271c89b8591b98b3ceDouglas Gregor void markIdentifierUpToDate(IdentifierInfo *II); 2093a8235d6c4093cd38dcf742909651f867de62e55bDouglas Gregor 2094643586fe4fcd42b0978efd3566832ab4dce50367Argyrios Kyrtzidis /// \brief Load all external visible decls in the given DeclContext. 2095651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void completeVisibleDeclsMap(const DeclContext *DC) override; 2096643586fe4fcd42b0978efd3566832ab4dce50367Argyrios Kyrtzidis 20973c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// \brief Retrieve the AST context that this AST reader supplements. 2098359427794704666ff7a5a933ace11c5256fa3af7Douglas Gregor ASTContext &getContext() { return Context; } 2099025452fa0eda63e150cfaeebe64f0a19c96b3a06Douglas Gregor 2100176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines // \brief Contains the IDs for declarations that were requested before we have 21016cfc1a8b7582b8433b61222502effb018c534393Douglas Gregor // access to a Sema object. 2102176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines SmallVector<uint64_t, 16> PreloadedDeclIDs; 2103668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor 2104668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor /// \brief Retrieve the semantic analysis object used to analyze the 2105668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor /// translation unit in which the precompiled header is being 2106668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor /// imported. 2107668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor Sema *getSema() { return SemaObj; } 2108668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor 21094967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar /// \brief Get the identifier resolver used for name lookup / updates 21104967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar /// in the translation unit scope. We have one of these even if we don't 21114967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar /// have a Sema object. 21124967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar IdentifierResolver &getIdResolver(); 21134967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar 2114668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor /// \brief Retrieve the identifier table associated with the 2115668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor /// preprocessor. 2116668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor IdentifierTable &getIdentifierTable(); 2117668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor 2118025452fa0eda63e150cfaeebe64f0a19c96b3a06Douglas Gregor /// \brief Record that the given ID maps to the given switch-case 2119025452fa0eda63e150cfaeebe64f0a19c96b3a06Douglas Gregor /// statement. 2120025452fa0eda63e150cfaeebe64f0a19c96b3a06Douglas Gregor void RecordSwitchCaseID(SwitchCase *SC, unsigned ID); 2121025452fa0eda63e150cfaeebe64f0a19c96b3a06Douglas Gregor 2122025452fa0eda63e150cfaeebe64f0a19c96b3a06Douglas Gregor /// \brief Retrieve the switch-case statement with the given ID. 2123025452fa0eda63e150cfaeebe64f0a19c96b3a06Douglas Gregor SwitchCase *getSwitchCaseWithID(unsigned ID); 21241de05feeeafe5b215fe7617594a7076a5192a6e2Douglas Gregor 2125e09a275444576deb2c8d9e2255554242f65d7c00Argyrios Kyrtzidis void ClearSwitchCaseIDs(); 2126aa0cd85838f2a024e589ea4e8c2094130065af21Dmitri Gribenko 2127aa0cd85838f2a024e589ea4e8c2094130065af21Dmitri Gribenko /// \brief Cursors for comments blocks. 2128aa0cd85838f2a024e589ea4e8c2094130065af21Dmitri Gribenko SmallVector<std::pair<llvm::BitstreamCursor, 2129aa0cd85838f2a024e589ea4e8c2094130065af21Dmitri Gribenko serialization::ModuleFile *>, 8> CommentsCursors; 2130aa0cd85838f2a024e589ea4e8c2094130065af21Dmitri Gribenko 213187d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar /// \brief Loads comments ranges. 2132651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void ReadComments() override; 21332cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor}; 21342cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor 213502602be3ccc3b29da5b91d2502c3419404992409Chris Lattner/// \brief Helper class that saves the current stream position and 213602602be3ccc3b29da5b91d2502c3419404992409Chris Lattner/// then restores it when destroyed. 213702602be3ccc3b29da5b91d2502c3419404992409Chris Lattnerstruct SavedStreamPosition { 213802602be3ccc3b29da5b91d2502c3419404992409Chris Lattner explicit SavedStreamPosition(llvm::BitstreamCursor &Cursor) 213999a5af0088b6340540912921cd0008ac75051a33Chris Lattner : Cursor(Cursor), Offset(Cursor.GetCurrentBitNo()) { } 21401eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 214102602be3ccc3b29da5b91d2502c3419404992409Chris Lattner ~SavedStreamPosition() { 214202602be3ccc3b29da5b91d2502c3419404992409Chris Lattner Cursor.JumpToBit(Offset); 214302602be3ccc3b29da5b91d2502c3419404992409Chris Lattner } 21441eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 214502602be3ccc3b29da5b91d2502c3419404992409Chris Lattnerprivate: 214602602be3ccc3b29da5b91d2502c3419404992409Chris Lattner llvm::BitstreamCursor &Cursor; 214702602be3ccc3b29da5b91d2502c3419404992409Chris Lattner uint64_t Offset; 214802602be3ccc3b29da5b91d2502c3419404992409Chris Lattner}; 21491eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2150d5d7b3f61f82b0fed9d6f02839bc72e528332911Ted Kremenekinline void PCHValidator::Error(const char *Msg) { 2151d5d7b3f61f82b0fed9d6f02839bc72e528332911Ted Kremenek Reader.Error(Msg); 2152d5d7b3f61f82b0fed9d6f02839bc72e528332911Ted Kremenek} 2153d5d7b3f61f82b0fed9d6f02839bc72e528332911Ted Kremenek 21542cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor} // end namespace clang 21552cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor 21562cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor#endif 2157