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 14f29f0a28c4d9599b389bbb6d186e14af753dc5a3Sebastian Redl#ifndef LLVM_CLANG_FRONTEND_AST_READER_H 15f29f0a28c4d9599b389bbb6d186e14af753dc5a3Sebastian Redl#define LLVM_CLANG_FRONTEND_AST_READER_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" 3030a2e16f6c27f888dd11eba6bbbae1e980078fcbChandler Carruth#include "clang/Serialization/ASTBitCodes.h" 3130a2e16f6c27f888dd11eba6bbbae1e980078fcbChandler Carruth#include "clang/Serialization/ContinuousRangeMap.h" 3230a2e16f6c27f888dd11eba6bbbae1e980078fcbChandler Carruth#include "clang/Serialization/Module.h" 3330a2e16f6c27f888dd11eba6bbbae1e980078fcbChandler Carruth#include "clang/Serialization/ModuleManager.h" 3417fc223395d51be582fc666bb6ea21bd1dff26dcDouglas Gregor#include "llvm/ADT/APFloat.h" 350a2b45e5885b6b8477b167042c0f6cd1d99a1f13Douglas Gregor#include "llvm/ADT/APInt.h" 360a2b45e5885b6b8477b167042c0f6cd1d99a1f13Douglas Gregor#include "llvm/ADT/APSInt.h" 3730a2e16f6c27f888dd11eba6bbbae1e980078fcbChandler Carruth#include "llvm/ADT/DenseSet.h" 38ce12d2f8863588d408897602089d17c4d3c3d0e5Douglas Gregor#include "llvm/ADT/MapVector.h" 392cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor#include "llvm/ADT/OwningPtr.h" 400f75323264b93a318ac9007eb5ec5b233c444068Douglas Gregor#include "llvm/ADT/SmallPtrSet.h" 410f75323264b93a318ac9007eb5ec5b233c444068Douglas Gregor#include "llvm/ADT/SmallSet.h" 422cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor#include "llvm/ADT/SmallVector.h" 43dc3c0d20375bda7775b2fade05b20e315798b9feDaniel Dunbar#include "llvm/ADT/StringRef.h" 442cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor#include "llvm/Bitcode/BitstreamReader.h" 4503013fa9a0bf1ef4b907f5fec006c8f4000fdd21Michael J. Spencer#include "llvm/Support/DataTypes.h" 46d89275bc865e2b552836c7b33e636d4f86b8de6dDouglas Gregor#include <deque> 47025452fa0eda63e150cfaeebe64f0a19c96b3a06Douglas Gregor#include <map> 482cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor#include <string> 492cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor#include <utility> 502cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor#include <vector> 51677e15ffee2ecc9c1c8f46fd77cab4b5afb59640Douglas Gregor#include <sys/stat.h> 522cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor 532cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregornamespace llvm { 542cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor class MemoryBuffer; 552cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor} 562cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor 572cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregornamespace clang { 582cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor 597d5c2f241c74e5f8d9ec492e8f9f268e5e9ae41fDouglas Gregorclass AddrLabelExpr; 600af2ca4b6ddc788658069a0994941268ce250fc7Douglas Gregorclass ASTConsumer; 612cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregorclass ASTContext; 6295f4292cc526c629fead321c7fcfd4fe0f3bc66eDouglas Gregorclass ASTIdentifierIterator; 63f62d43d2afe1960755a1b5813cae1e5983bcac1bDouglas Gregorclass ASTUnit; // FIXME: Layering violation and egregious hack. 6468a2eb0cc76267ba0615992fb5e0977853c397b2Douglas Gregorclass Attr; 652cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregorclass Decl; 662cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregorclass DeclContext; 675f3d8224af99ad0d9107601c0c31b74693371cc1Douglas Gregorclass DiagnosticOptions; 686ad9ac097918fbdeb443ea7b99d4db9e49b28534Chris Lattnerclass NestedNameSpecifier; 696ad9ac097918fbdeb443ea7b99d4db9e49b28534Chris Lattnerclass CXXBaseSpecifier; 70ebcbe1d3dc7d4f0c1f540a632fa0684dd0a857d5Sean Huntclass CXXConstructorDecl; 71cbb67480094b3bcb5b715acd827cbad55e2a204cSean Huntclass CXXCtorInitializer; 721a49d97d762570027863e9209af81d445e4f1502Douglas Gregorclass GlobalModuleIndex; 731de05feeeafe5b215fe7617594a7076a5192a6e2Douglas Gregorclass GotoStmt; 746a5a23f8e7fb65e028c8092bc1d1a1d9dfe2e9bcDouglas Gregorclass MacroDefinition; 759818a1d443e97677dd3422305de9cc2b1fb2a8c1Argyrios Kyrtzidisclass MacroDirective; 76668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregorclass NamedDecl; 7756ca35d396d8692c384c785f9aeebcf22563fe1eJohn McCallclass OpaqueValueExpr; 7814f79002e58556798e86168c63e48d533287eda5Douglas Gregorclass Preprocessor; 79a71a7d8a1ce4474e7bdb680658fb58b6caf391d3Douglas Gregorclass PreprocessorOptions; 80668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregorclass Sema; 81025452fa0eda63e150cfaeebe64f0a19c96b3a06Douglas Gregorclass SwitchCase; 82c3632730cc83ed7b51f0ab5c38997ae5a9439b0cSebastian Redlclass ASTDeserializationListener; 83f62d43d2afe1960755a1b5813cae1e5983bcac1bDouglas Gregorclass ASTWriter; 84c43b54cbc10654ed59de797898042e1a05265246Sebastian Redlclass ASTReader; 85d527cc06d78fe5afa5f20105b51697637eb02c56Sebastian Redlclass ASTDeclReader; 86c3632730cc83ed7b51f0ab5c38997ae5a9439b0cSebastian Redlclass ASTStmtReader; 87c3632730cc83ed7b51f0ab5c38997ae5a9439b0cSebastian Redlclass TypeLocReader; 88eb19485625c7529ffa644e10829533157a8e8d4fDaniel Dunbarstruct HeaderFileInfo; 890a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregorclass VersionTuple; 9057016dda61498294120b1a881d9e6606337b29d9Douglas Gregorclass TargetOptions; 912a82ca255b0f99f6201a75ed52b91fc024f6e9cfArgyrios Kyrtzidisclass ASTUnresolvedSet; 9211e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis 93c43b54cbc10654ed59de797898042e1a05265246Sebastian Redl/// \brief Abstract interface for callback invocations by the ASTReader. 9411e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis/// 95c43b54cbc10654ed59de797898042e1a05265246Sebastian Redl/// While reading an AST file, the ASTReader will call the methods of the 9611e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis/// listener to pass on specific information. Some of the listener methods can 97c43b54cbc10654ed59de797898042e1a05265246Sebastian Redl/// return true to indicate to the ASTReader that the information (and 98571db7f0cb31789737be92fce1c1b738e6dbe795Sebastian Redl/// consequently the AST file) is invalid. 99571db7f0cb31789737be92fce1c1b738e6dbe795Sebastian Redlclass ASTReaderListener { 10011e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidispublic: 101571db7f0cb31789737be92fce1c1b738e6dbe795Sebastian Redl virtual ~ASTReaderListener(); 1021eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 103c544ba09695e300f31355af342258bd57619e737Douglas Gregor /// \brief Receives the full Clang version information. 104c544ba09695e300f31355af342258bd57619e737Douglas Gregor /// 105c544ba09695e300f31355af342258bd57619e737Douglas Gregor /// \returns true to indicate that the version is invalid. Subclasses should 106c544ba09695e300f31355af342258bd57619e737Douglas Gregor /// generally defer to this implementation. 107c544ba09695e300f31355af342258bd57619e737Douglas Gregor virtual bool ReadFullVersionInformation(StringRef FullVersion) { 108c544ba09695e300f31355af342258bd57619e737Douglas Gregor return FullVersion != getClangFullRepositoryVersion(); 109c544ba09695e300f31355af342258bd57619e737Douglas Gregor } 110c544ba09695e300f31355af342258bd57619e737Douglas Gregor 11111e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis /// \brief Receives the language options. 11211e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis /// 11311e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis /// \returns true to indicate the options are invalid or false otherwise. 11427ffa6caf965ef20fdef5ae23b81cdc3d05e7afbDouglas Gregor virtual bool ReadLanguageOptions(const LangOptions &LangOpts, 11538295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor bool Complain) { 11611e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis return false; 11711e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis } 1181eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 11957016dda61498294120b1a881d9e6606337b29d9Douglas Gregor /// \brief Receives the target options. 12011e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis /// 12157016dda61498294120b1a881d9e6606337b29d9Douglas Gregor /// \returns true to indicate the target options are invalid, or false 12257016dda61498294120b1a881d9e6606337b29d9Douglas Gregor /// otherwise. 12327ffa6caf965ef20fdef5ae23b81cdc3d05e7afbDouglas Gregor virtual bool ReadTargetOptions(const TargetOptions &TargetOpts, 12438295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor bool Complain) { 12511e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis return false; 12611e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis } 1271eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1285f3d8224af99ad0d9107601c0c31b74693371cc1Douglas Gregor /// \brief Receives the diagnostic options. 1295f3d8224af99ad0d9107601c0c31b74693371cc1Douglas Gregor /// 1305f3d8224af99ad0d9107601c0c31b74693371cc1Douglas Gregor /// \returns true to indicate the diagnostic options are invalid, or false 1315f3d8224af99ad0d9107601c0c31b74693371cc1Douglas Gregor /// otherwise. 1325f3d8224af99ad0d9107601c0c31b74693371cc1Douglas Gregor virtual bool ReadDiagnosticOptions(const DiagnosticOptions &DiagOpts, 1335f3d8224af99ad0d9107601c0c31b74693371cc1Douglas Gregor bool Complain) { 1345f3d8224af99ad0d9107601c0c31b74693371cc1Douglas Gregor return false; 1355f3d8224af99ad0d9107601c0c31b74693371cc1Douglas Gregor } 1365f3d8224af99ad0d9107601c0c31b74693371cc1Douglas Gregor 1371b2c3c0884e917ae5d59edde7d93b2af33c6a1b6Douglas Gregor /// \brief Receives the file system options. 1381b2c3c0884e917ae5d59edde7d93b2af33c6a1b6Douglas Gregor /// 1391b2c3c0884e917ae5d59edde7d93b2af33c6a1b6Douglas Gregor /// \returns true to indicate the file system options are invalid, or false 1401b2c3c0884e917ae5d59edde7d93b2af33c6a1b6Douglas Gregor /// otherwise. 1411b2c3c0884e917ae5d59edde7d93b2af33c6a1b6Douglas Gregor virtual bool ReadFileSystemOptions(const FileSystemOptions &FSOpts, 1421b2c3c0884e917ae5d59edde7d93b2af33c6a1b6Douglas Gregor bool Complain) { 1431b2c3c0884e917ae5d59edde7d93b2af33c6a1b6Douglas Gregor return false; 1441b2c3c0884e917ae5d59edde7d93b2af33c6a1b6Douglas Gregor } 1451b2c3c0884e917ae5d59edde7d93b2af33c6a1b6Douglas Gregor 146bbf38319edd4eddc55ec273934e990d7e84991deDouglas Gregor /// \brief Receives the header search options. 147bbf38319edd4eddc55ec273934e990d7e84991deDouglas Gregor /// 148bbf38319edd4eddc55ec273934e990d7e84991deDouglas Gregor /// \returns true to indicate the header search options are invalid, or false 149bbf38319edd4eddc55ec273934e990d7e84991deDouglas Gregor /// otherwise. 150bbf38319edd4eddc55ec273934e990d7e84991deDouglas Gregor virtual bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts, 151bbf38319edd4eddc55ec273934e990d7e84991deDouglas Gregor bool Complain) { 152bbf38319edd4eddc55ec273934e990d7e84991deDouglas Gregor return false; 153bbf38319edd4eddc55ec273934e990d7e84991deDouglas Gregor } 154bbf38319edd4eddc55ec273934e990d7e84991deDouglas Gregor 155a71a7d8a1ce4474e7bdb680658fb58b6caf391d3Douglas Gregor /// \brief Receives the preprocessor options. 156a71a7d8a1ce4474e7bdb680658fb58b6caf391d3Douglas Gregor /// 1578769924c97ecf2af88f7f3aa6754d381b30d1c5fDouglas Gregor /// \param SuggestedPredefines Can be filled in with the set of predefines 1588769924c97ecf2af88f7f3aa6754d381b30d1c5fDouglas Gregor /// that are suggested by the preprocessor options. Typically only used when 1598769924c97ecf2af88f7f3aa6754d381b30d1c5fDouglas Gregor /// loading a precompiled header. 1608769924c97ecf2af88f7f3aa6754d381b30d1c5fDouglas Gregor /// 161a71a7d8a1ce4474e7bdb680658fb58b6caf391d3Douglas Gregor /// \returns true to indicate the preprocessor options are invalid, or false 162a71a7d8a1ce4474e7bdb680658fb58b6caf391d3Douglas Gregor /// otherwise. 163a71a7d8a1ce4474e7bdb680658fb58b6caf391d3Douglas Gregor virtual bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, 1648769924c97ecf2af88f7f3aa6754d381b30d1c5fDouglas Gregor bool Complain, 1658769924c97ecf2af88f7f3aa6754d381b30d1c5fDouglas Gregor std::string &SuggestedPredefines) { 166a71a7d8a1ce4474e7bdb680658fb58b6caf391d3Douglas Gregor return false; 167a71a7d8a1ce4474e7bdb680658fb58b6caf391d3Douglas Gregor } 168a71a7d8a1ce4474e7bdb680658fb58b6caf391d3Douglas Gregor 16911e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis /// \brief Receives __COUNTER__ value. 17062288edde26ff4af9fc079c979a0e1bdc577ce9dArgyrios Kyrtzidis virtual void ReadCounter(const serialization::ModuleFile &M, 17162288edde26ff4af9fc079c979a0e1bdc577ce9dArgyrios Kyrtzidis unsigned Value) {} 172bdfdb1da9763b3d0966eb61e9fa0fa7804f9eb9bArgyrios Kyrtzidis 173bdfdb1da9763b3d0966eb61e9fa0fa7804f9eb9bArgyrios Kyrtzidis /// \brief Returns true if this \c ASTReaderListener wants to receive the 174bdfdb1da9763b3d0966eb61e9fa0fa7804f9eb9bArgyrios Kyrtzidis /// input files of the AST file via \c visitInputFile, false otherwise. 175bdfdb1da9763b3d0966eb61e9fa0fa7804f9eb9bArgyrios Kyrtzidis virtual bool needsInputFileVisitation() { return false; } 176bdfdb1da9763b3d0966eb61e9fa0fa7804f9eb9bArgyrios Kyrtzidis 177bdfdb1da9763b3d0966eb61e9fa0fa7804f9eb9bArgyrios Kyrtzidis /// \brief if \c needsInputFileVisitation returns true, this is called for each 178bdfdb1da9763b3d0966eb61e9fa0fa7804f9eb9bArgyrios Kyrtzidis /// input file of the AST file. 179bdfdb1da9763b3d0966eb61e9fa0fa7804f9eb9bArgyrios Kyrtzidis /// 180bdfdb1da9763b3d0966eb61e9fa0fa7804f9eb9bArgyrios Kyrtzidis /// \returns true to continue receiving the next input file, false to stop. 181bdfdb1da9763b3d0966eb61e9fa0fa7804f9eb9bArgyrios Kyrtzidis virtual bool visitInputFile(StringRef Filename, bool isSystem) { return true;} 18211e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis}; 18311e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis 184571db7f0cb31789737be92fce1c1b738e6dbe795Sebastian Redl/// \brief ASTReaderListener implementation to validate the information of 18511e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis/// the PCH file against an initialized Preprocessor. 186571db7f0cb31789737be92fce1c1b738e6dbe795Sebastian Redlclass PCHValidator : public ASTReaderListener { 18711e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis Preprocessor &PP; 188c43b54cbc10654ed59de797898042e1a05265246Sebastian Redl ASTReader &Reader; 1891eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 19011e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidispublic: 191c43b54cbc10654ed59de797898042e1a05265246Sebastian Redl PCHValidator(Preprocessor &PP, ASTReader &Reader) 192f9ba851c9b5db8ea30846215e737702a1cc2c194Argyrios Kyrtzidis : PP(PP), Reader(Reader) {} 1931eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 19427ffa6caf965ef20fdef5ae23b81cdc3d05e7afbDouglas Gregor virtual bool ReadLanguageOptions(const LangOptions &LangOpts, 19538295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor bool Complain); 19627ffa6caf965ef20fdef5ae23b81cdc3d05e7afbDouglas Gregor virtual bool ReadTargetOptions(const TargetOptions &TargetOpts, 19738295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor bool Complain); 1984c0c7e86645dfa1719d17d70e009ab49347aba62Douglas Gregor virtual bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, 1998769924c97ecf2af88f7f3aa6754d381b30d1c5fDouglas Gregor bool Complain, 2008769924c97ecf2af88f7f3aa6754d381b30d1c5fDouglas Gregor std::string &SuggestedPredefines); 20162288edde26ff4af9fc079c979a0e1bdc577ce9dArgyrios Kyrtzidis virtual void ReadCounter(const serialization::ModuleFile &M, unsigned Value); 202d5d7b3f61f82b0fed9d6f02839bc72e528332911Ted Kremenek 203d5d7b3f61f82b0fed9d6f02839bc72e528332911Ted Kremenekprivate: 204d5d7b3f61f82b0fed9d6f02839bc72e528332911Ted Kremenek void Error(const char *Msg); 20511e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis}; 2062cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor 207ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikienamespace serialization { 2085d6d89fef8c7fff8b1a67c943fb5557a2a803468Jonathan D. Turner 2093d15ab8d0822637ff5e39594c4f34172241cad2eDouglas Gregorclass ReadMethodPoolVisitor; 210ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 21198339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregornamespace reader { 21298339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor class ASTIdentifierLookupTrait; 213b1758c662524e18d65d260188fdcbbdee6a9316bBenjamin Kramer /// \brief The on-disk hash table used for the DeclContext's Name lookup table. 214b1758c662524e18d65d260188fdcbbdee6a9316bBenjamin Kramer typedef OnDiskChainedHashTable<ASTDeclContextNameLookupTrait> 215b1758c662524e18d65d260188fdcbbdee6a9316bBenjamin Kramer ASTDeclContextNameLookupTable; 21698339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor} 217ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 21872a9ae18553bf8b6bdad84d2c54f73741a47e275Douglas Gregor} // end namespace serialization 219ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 220c43b54cbc10654ed59de797898042e1a05265246Sebastian Redl/// \brief Reads an AST files chain containing the contents of a translation 221c43b54cbc10654ed59de797898042e1a05265246Sebastian Redl/// unit. 2222cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor/// 223c43b54cbc10654ed59de797898042e1a05265246Sebastian Redl/// The ASTReader class reads bitstreams (produced by the ASTWriter 2242cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor/// class) containing the serialized representation of a given 2252cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor/// abstract syntax tree and its supporting data structures. An 226c43b54cbc10654ed59de797898042e1a05265246Sebastian Redl/// instance of the ASTReader can be attached to an ASTContext object, 227c43b54cbc10654ed59de797898042e1a05265246Sebastian Redl/// which will provide access to the contents of the AST files. 2282cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor/// 229c43b54cbc10654ed59de797898042e1a05265246Sebastian Redl/// The AST reader provides lazy de-serialization of declarations, as 2302cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor/// required when traversing the AST. Only those AST nodes that are 2312cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor/// actually required will be de-serialized. 232c43b54cbc10654ed59de797898042e1a05265246Sebastian Redlclass ASTReader 23388a35862fbe473f2a4f0c19f24dbe536937e1dc6Douglas Gregor : public ExternalPreprocessorSource, 2346a5a23f8e7fb65e028c8092bc1d1a1d9dfe2e9bcDouglas Gregor public ExternalPreprocessingRecordSource, 235cfbf1c7536e016dc275139dd842d4a5f059a749fDouglas Gregor public ExternalHeaderFileInfoSource, 23688a35862fbe473f2a4f0c19f24dbe536937e1dc6Douglas Gregor public ExternalSemaSource, 2378c5a760b82e73ed90b560090772db97e2ae27b09Douglas Gregor public IdentifierInfoLookup, 2387f94b0b0c6791013d2f72ced9b4bedd3b23673a6Douglas Gregor public ExternalIdentifierLookup, 239ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie public ExternalSLocEntrySource 240cfbf1c7536e016dc275139dd842d4a5f059a749fDouglas Gregor{ 241e1d918e9fe55e3b34401fd5d420c47ea0f9572c9Douglas Gregorpublic: 242260611a32535c851237926bfcf78869b13c07d5bJohn McCall typedef SmallVector<uint64_t, 64> RecordData; 243260611a32535c851237926bfcf78869b13c07d5bJohn McCall 2444825fd7fbb3fe87cdf8da9bccc1361fac45bdf2dDouglas Gregor /// \brief The result of reading the control block of an AST file, which 2454825fd7fbb3fe87cdf8da9bccc1361fac45bdf2dDouglas Gregor /// can fail for various reasons. 2464825fd7fbb3fe87cdf8da9bccc1361fac45bdf2dDouglas Gregor enum ASTReadResult { 2474825fd7fbb3fe87cdf8da9bccc1361fac45bdf2dDouglas Gregor /// \brief The control block was read successfully. Aside from failures, 2484825fd7fbb3fe87cdf8da9bccc1361fac45bdf2dDouglas Gregor /// the AST file is safe to read into the current context. 2494825fd7fbb3fe87cdf8da9bccc1361fac45bdf2dDouglas Gregor Success, 2504825fd7fbb3fe87cdf8da9bccc1361fac45bdf2dDouglas Gregor /// \brief The AST file itself appears corrupted. 2514825fd7fbb3fe87cdf8da9bccc1361fac45bdf2dDouglas Gregor Failure, 252677e15ffee2ecc9c1c8f46fd77cab4b5afb59640Douglas Gregor /// \brief The AST file was missing. 253677e15ffee2ecc9c1c8f46fd77cab4b5afb59640Douglas Gregor Missing, 2544825fd7fbb3fe87cdf8da9bccc1361fac45bdf2dDouglas Gregor /// \brief The AST file is out-of-date relative to its input files, 2554825fd7fbb3fe87cdf8da9bccc1361fac45bdf2dDouglas Gregor /// and needs to be regenerated. 2564825fd7fbb3fe87cdf8da9bccc1361fac45bdf2dDouglas Gregor OutOfDate, 2574825fd7fbb3fe87cdf8da9bccc1361fac45bdf2dDouglas Gregor /// \brief The AST file was written by a different version of Clang. 2584825fd7fbb3fe87cdf8da9bccc1361fac45bdf2dDouglas Gregor VersionMismatch, 2594825fd7fbb3fe87cdf8da9bccc1361fac45bdf2dDouglas Gregor /// \brief The AST file was writtten with a different language/target 2604825fd7fbb3fe87cdf8da9bccc1361fac45bdf2dDouglas Gregor /// configuration. 2614825fd7fbb3fe87cdf8da9bccc1361fac45bdf2dDouglas Gregor ConfigurationMismatch, 2624825fd7fbb3fe87cdf8da9bccc1361fac45bdf2dDouglas Gregor /// \brief The AST file has errors. 2634825fd7fbb3fe87cdf8da9bccc1361fac45bdf2dDouglas Gregor HadErrors 2644825fd7fbb3fe87cdf8da9bccc1361fac45bdf2dDouglas Gregor }; 2654825fd7fbb3fe87cdf8da9bccc1361fac45bdf2dDouglas Gregor 2661d9f1fe7173e3084325f43c78af812a36d8a2a7cSebastian Redl /// \brief Types of AST files. 267d5d7b3f61f82b0fed9d6f02839bc72e528332911Ted Kremenek friend class PCHValidator; 268d527cc06d78fe5afa5f20105b51697637eb02c56Sebastian Redl friend class ASTDeclReader; 269c3632730cc83ed7b51f0ab5c38997ae5a9439b0cSebastian Redl friend class ASTStmtReader; 27095f4292cc526c629fead321c7fcfd4fe0f3bc66eDouglas Gregor friend class ASTIdentifierIterator; 27198339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor friend class serialization::reader::ASTIdentifierLookupTrait; 272c3632730cc83ed7b51f0ab5c38997ae5a9439b0cSebastian Redl friend class TypeLocReader; 273f62d43d2afe1960755a1b5813cae1e5983bcac1bDouglas Gregor friend class ASTWriter; 274f62d43d2afe1960755a1b5813cae1e5983bcac1bDouglas Gregor friend class ASTUnit; // ASTUnit needs to remap source locations. 2753d15ab8d0822637ff5e39594c4f34172241cad2eDouglas Gregor friend class serialization::ReadMethodPoolVisitor; 276ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 2771a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor typedef serialization::ModuleFile ModuleFile; 27872a9ae18553bf8b6bdad84d2c54f73741a47e275Douglas Gregor typedef serialization::ModuleKind ModuleKind; 2795d6d89fef8c7fff8b1a67c943fb5557a2a803468Jonathan D. Turner typedef serialization::ModuleManager ModuleManager; 280ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 2815d6d89fef8c7fff8b1a67c943fb5557a2a803468Jonathan D. Turner typedef ModuleManager::ModuleIterator ModuleIterator; 2825d6d89fef8c7fff8b1a67c943fb5557a2a803468Jonathan D. Turner typedef ModuleManager::ModuleConstIterator ModuleConstIterator; 2835d6d89fef8c7fff8b1a67c943fb5557a2a803468Jonathan D. Turner typedef ModuleManager::ModuleReverseIterator ModuleReverseIterator; 2845d6d89fef8c7fff8b1a67c943fb5557a2a803468Jonathan D. Turner 285e1d918e9fe55e3b34401fd5d420c47ea0f9572c9Douglas Gregorprivate: 286c43b54cbc10654ed59de797898042e1a05265246Sebastian Redl /// \brief The receiver of some callbacks invoked by ASTReader. 2876f42b62b6194f53bcbc349f5d17388e1936535d7Dylan Noblesmith OwningPtr<ASTReaderListener> Listener; 2881eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 28930c514c225342844700ed4640ec6d90ddf0e12b2Sebastian Redl /// \brief The receiver of deserialization events. 290571db7f0cb31789737be92fce1c1b738e6dbe795Sebastian Redl ASTDeserializationListener *DeserializationListener; 29130c514c225342844700ed4640ec6d90ddf0e12b2Sebastian Redl 29211e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis SourceManager &SourceMgr; 29311e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis FileManager &FileMgr; 294d6471f7c1921c7802804ce3ff6fe9768310f72b9David Blaikie DiagnosticsEngine &Diags; 295ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 296668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor /// \brief The semantic analysis object that will be processing the 2973c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// AST files and the translation unit that uses it. 298668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor Sema *SemaObj; 299668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor 30014f79002e58556798e86168c63e48d533287eda5Douglas Gregor /// \brief The preprocessor that will be loading the source file. 301712f2fcb70ae2eb0cb684d565e7d2cb76881006bDouglas Gregor Preprocessor &PP; 30214f79002e58556798e86168c63e48d533287eda5Douglas Gregor 3033c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// \brief The AST context into which we'll read the AST files. 304359427794704666ff7a5a933ace11c5256fa3af7Douglas Gregor ASTContext &Context; 305ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 3060af2ca4b6ddc788658069a0994941268ce250fc7Douglas Gregor /// \brief The AST consumer. 3070af2ca4b6ddc788658069a0994941268ce250fc7Douglas Gregor ASTConsumer *Consumer; 3080af2ca4b6ddc788658069a0994941268ce250fc7Douglas Gregor 3095d6d89fef8c7fff8b1a67c943fb5557a2a803468Jonathan D. Turner /// \brief The module manager which manages modules and their dependencies 3105d6d89fef8c7fff8b1a67c943fb5557a2a803468Jonathan D. Turner ModuleManager ModuleMgr; 3119137a5230d3164b96beb14ffb87863234b7d240fSebastian Redl 3123b7deda7137e62810a810ce25b062927a9fc7c71Argyrios Kyrtzidis /// \brief The location where the module file will be considered as 3133b7deda7137e62810a810ce25b062927a9fc7c71Argyrios Kyrtzidis /// imported from. For non-module AST types it should be invalid. 3143b7deda7137e62810a810ce25b062927a9fc7c71Argyrios Kyrtzidis SourceLocation CurrentImportLoc; 3153b7deda7137e62810a810ce25b062927a9fc7c71Argyrios Kyrtzidis 3161a49d97d762570027863e9209af81d445e4f1502Douglas Gregor /// \brief The global module index, if loaded. 3171a49d97d762570027863e9209af81d445e4f1502Douglas Gregor llvm::OwningPtr<GlobalModuleIndex> GlobalIndex; 3181a49d97d762570027863e9209af81d445e4f1502Douglas Gregor 3198f1231b70c2b1f6fe0cee097b447487b26810301Douglas Gregor /// \brief A map of global bit offsets to the module that stores entities 3208f1231b70c2b1f6fe0cee097b447487b26810301Douglas Gregor /// at those bit offsets. 3211a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor ContinuousRangeMap<uint64_t, ModuleFile*, 4> GlobalBitOffsetsMap; 3228f1231b70c2b1f6fe0cee097b447487b26810301Douglas Gregor 323f62d43d2afe1960755a1b5813cae1e5983bcac1bDouglas Gregor /// \brief A map of negated SLocEntryIDs to the modules containing them. 3241a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor ContinuousRangeMap<unsigned, ModuleFile*, 64> GlobalSLocEntryMap; 3254ee5a6f9bd82ab3c1a4bdacc0caefe7d5f8bd37aSebastian Redl 3261a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor typedef ContinuousRangeMap<unsigned, ModuleFile*, 64> GlobalSLocOffsetMapType; 327ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 328a68c4aff8cd3aada697ad36dc6582d0e09b4b0d2Argyrios Kyrtzidis /// \brief A map of reversed (SourceManager::MaxLoadedOffset - SLocOffset) 329a68c4aff8cd3aada697ad36dc6582d0e09b4b0d2Argyrios Kyrtzidis /// SourceLocation offsets to the modules containing them. 3302dbaca748bc3eb6539f417bd8354c930bdf88fa4Argyrios Kyrtzidis GlobalSLocOffsetMapType GlobalSLocOffsetMap; 331ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 3323c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// \brief Types that have already been loaded from the chain. 3331eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// 3341eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// When the pointer at index I is non-NULL, the type with 3353c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// ID = (I + 1) << FastQual::Width has already been loaded 3360953e767ff7817f97b3ab20896b229891eeff45bJohn McCall std::vector<QualType> TypesLoaded; 3372cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor 3381a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor typedef ContinuousRangeMap<serialization::TypeID, ModuleFile *, 4> 339e9b76c11a88d0af98f32d11a6668d03d45be3123Jonathan D. Turner GlobalTypeMapType; 340e9b76c11a88d0af98f32d11a6668d03d45be3123Jonathan D. Turner 341e9b76c11a88d0af98f32d11a6668d03d45be3123Jonathan D. Turner /// \brief Mapping from global type IDs to the module in which the 342e9b76c11a88d0af98f32d11a6668d03d45be3123Jonathan D. Turner /// type resides along with the offset that should be added to the 343e9b76c11a88d0af98f32d11a6668d03d45be3123Jonathan D. Turner /// global type ID to produce a local ID. 344e9b76c11a88d0af98f32d11a6668d03d45be3123Jonathan D. Turner GlobalTypeMapType GlobalTypeMap; 345e9b76c11a88d0af98f32d11a6668d03d45be3123Jonathan D. Turner 3463c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// \brief Declarations that have already been loaded from the chain. 3472cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor /// 3488f5dc7fe4d42cea78fa92d1638f753cf65b54cb5Douglas Gregor /// When the pointer at index I is non-NULL, the declaration with ID 3498f5dc7fe4d42cea78fa92d1638f753cf65b54cb5Douglas Gregor /// = I + 1 has already been loaded. 3508f5dc7fe4d42cea78fa92d1638f753cf65b54cb5Douglas Gregor std::vector<Decl *> DeclsLoaded; 3512cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor 3521a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor typedef ContinuousRangeMap<serialization::DeclID, ModuleFile *, 4> 35396e973f2be14c9b82136f74b4108465d24894feaDouglas Gregor GlobalDeclMapType; 354ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 35596e973f2be14c9b82136f74b4108465d24894feaDouglas Gregor /// \brief Mapping from global declaration IDs to the module in which the 3569827a8049a793f23c62ade8f24f0c66c2dbf6741Douglas Gregor /// declaration resides. 35796e973f2be14c9b82136f74b4108465d24894feaDouglas Gregor GlobalDeclMapType GlobalDeclMap; 358ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 3591a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor typedef std::pair<ModuleFile *, uint64_t> FileOffset; 360686775deca8b8685eb90801495880e3abdd844c2Chris Lattner typedef SmallVector<FileOffset, 2> FileOffsetsTy; 3617b90340c9c7d07aef4e301e72b5e8a30d5f4f0c8Argyrios Kyrtzidis typedef llvm::DenseMap<serialization::DeclID, FileOffsetsTy> 3627b90340c9c7d07aef4e301e72b5e8a30d5f4f0c8Argyrios Kyrtzidis DeclUpdateOffsetsMap; 363ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 3647b90340c9c7d07aef4e301e72b5e8a30d5f4f0c8Argyrios Kyrtzidis /// \brief Declarations that have modifications residing in a later file 3657b90340c9c7d07aef4e301e72b5e8a30d5f4f0c8Argyrios Kyrtzidis /// in the chain. 3667b90340c9c7d07aef4e301e72b5e8a30d5f4f0c8Argyrios Kyrtzidis DeclUpdateOffsetsMap DeclUpdateOffsets; 3677b90340c9c7d07aef4e301e72b5e8a30d5f4f0c8Argyrios Kyrtzidis 368ef23b6001e8d9715246ca23bd8c3a6887d7844cbArgyrios Kyrtzidis struct ReplacedDeclInfo { 3691a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor ModuleFile *Mod; 370ef23b6001e8d9715246ca23bd8c3a6887d7844cbArgyrios Kyrtzidis uint64_t Offset; 371ef23b6001e8d9715246ca23bd8c3a6887d7844cbArgyrios Kyrtzidis unsigned RawLoc; 372ef23b6001e8d9715246ca23bd8c3a6887d7844cbArgyrios Kyrtzidis 373ef23b6001e8d9715246ca23bd8c3a6887d7844cbArgyrios Kyrtzidis ReplacedDeclInfo() : Mod(0), Offset(0), RawLoc(0) {} 3741a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor ReplacedDeclInfo(ModuleFile *Mod, uint64_t Offset, unsigned RawLoc) 375ef23b6001e8d9715246ca23bd8c3a6887d7844cbArgyrios Kyrtzidis : Mod(Mod), Offset(Offset), RawLoc(RawLoc) {} 376ef23b6001e8d9715246ca23bd8c3a6887d7844cbArgyrios Kyrtzidis }; 377ef23b6001e8d9715246ca23bd8c3a6887d7844cbArgyrios Kyrtzidis 378ef23b6001e8d9715246ca23bd8c3a6887d7844cbArgyrios Kyrtzidis typedef llvm::DenseMap<serialization::DeclID, ReplacedDeclInfo> 3790b17c61e8f143901ce11b4a6e5129ac63aaeee04Sebastian Redl DeclReplacementMap; 3800b17c61e8f143901ce11b4a6e5129ac63aaeee04Sebastian Redl /// \brief Declarations that have been replaced in a later file in the chain. 3810b17c61e8f143901ce11b4a6e5129ac63aaeee04Sebastian Redl DeclReplacementMap ReplacedDecls; 3820b17c61e8f143901ce11b4a6e5129ac63aaeee04Sebastian Redl 3839d128d04578c62675eeb0cce83066052f9c19c9aArgyrios Kyrtzidis struct FileDeclsInfo { 3841a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor ModuleFile *Mod; 3859d128d04578c62675eeb0cce83066052f9c19c9aArgyrios Kyrtzidis ArrayRef<serialization::LocalDeclID> Decls; 3869d128d04578c62675eeb0cce83066052f9c19c9aArgyrios Kyrtzidis 3879d128d04578c62675eeb0cce83066052f9c19c9aArgyrios Kyrtzidis FileDeclsInfo() : Mod(0) {} 3881a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor FileDeclsInfo(ModuleFile *Mod, ArrayRef<serialization::LocalDeclID> Decls) 3899d128d04578c62675eeb0cce83066052f9c19c9aArgyrios Kyrtzidis : Mod(Mod), Decls(Decls) {} 3909d128d04578c62675eeb0cce83066052f9c19c9aArgyrios Kyrtzidis }; 3919d128d04578c62675eeb0cce83066052f9c19c9aArgyrios Kyrtzidis 39210f3df54486385e6497c9e5f229ff816e5a6c511Argyrios Kyrtzidis /// \brief Map from a FileID to the file-level declarations that it contains. 3939d128d04578c62675eeb0cce83066052f9c19c9aArgyrios Kyrtzidis llvm::DenseMap<FileID, FileDeclsInfo> FileDeclIDs; 39410f3df54486385e6497c9e5f229ff816e5a6c511Argyrios Kyrtzidis 395e1dde811b38e779894150cb1093d57f8411a84f7Sebastian Redl // Updates for visible decls can occur for other contexts than just the 396e1dde811b38e779894150cb1093d57f8411a84f7Sebastian Redl // TU, and when we read those update records, the actual context will not 397e1dde811b38e779894150cb1093d57f8411a84f7Sebastian Redl // be available yet (unless it's the TU), so have this pending map using the 398e1dde811b38e779894150cb1093d57f8411a84f7Sebastian Redl // ID as a key. It will be realized when the context is actually loaded. 399b1758c662524e18d65d260188fdcbbdee6a9316bBenjamin Kramer typedef 400b1758c662524e18d65d260188fdcbbdee6a9316bBenjamin Kramer SmallVector<std::pair<serialization::reader::ASTDeclContextNameLookupTable *, 401b1758c662524e18d65d260188fdcbbdee6a9316bBenjamin Kramer ModuleFile*>, 1> DeclContextVisibleUpdates; 402e1dde811b38e779894150cb1093d57f8411a84f7Sebastian Redl typedef llvm::DenseMap<serialization::DeclID, DeclContextVisibleUpdates> 403e1dde811b38e779894150cb1093d57f8411a84f7Sebastian Redl DeclContextVisibleUpdatesPending; 4042cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor 405e1dde811b38e779894150cb1093d57f8411a84f7Sebastian Redl /// \brief Updates to the visible declarations of declaration contexts that 406e1dde811b38e779894150cb1093d57f8411a84f7Sebastian Redl /// haven't been loaded yet. 407e1dde811b38e779894150cb1093d57f8411a84f7Sebastian Redl DeclContextVisibleUpdatesPending PendingVisibleUpdates; 4082e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor 409fc529f7fcafe7da0b8a32621e13685891e8ce52aDouglas Gregor /// \brief The set of C++ or Objective-C classes that have forward 410fc529f7fcafe7da0b8a32621e13685891e8ce52aDouglas Gregor /// declarations that have not yet been linked to their definitions. 411fc529f7fcafe7da0b8a32621e13685891e8ce52aDouglas Gregor llvm::SmallPtrSet<Decl *, 4> PendingDefinitions; 4125456b0fe40714a78cd0ba7c1a5b7dc34eda385afDouglas Gregor 413ce12d2f8863588d408897602089d17c4d3c3d0e5Douglas Gregor typedef llvm::MapVector<Decl *, uint64_t, 414ce12d2f8863588d408897602089d17c4d3c3d0e5Douglas Gregor llvm::SmallDenseMap<Decl *, unsigned, 4>, 415cfa88f893915ceb8ae4ce2f17c46c24a4d67502fDmitri Gribenko SmallVector<std::pair<Decl *, uint64_t>, 4> > 416ce12d2f8863588d408897602089d17c4d3c3d0e5Douglas Gregor PendingBodiesMap; 417ce12d2f8863588d408897602089d17c4d3c3d0e5Douglas Gregor 4185456b0fe40714a78cd0ba7c1a5b7dc34eda385afDouglas Gregor /// \brief Functions or methods that have bodies that will be attached. 419ce12d2f8863588d408897602089d17c4d3c3d0e5Douglas Gregor PendingBodiesMap PendingBodies; 4205456b0fe40714a78cd0ba7c1a5b7dc34eda385afDouglas Gregor 421681d7237e1014bf64dd5ead6bf74ae55cdd19e61Sebastian Redl /// \brief Read the records that describe the contents of declcontexts. 4221a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor bool ReadDeclContextStorage(ModuleFile &M, 4230d95f77ba180aee35b74f3bf9f8543477f3af543Douglas Gregor llvm::BitstreamCursor &Cursor, 424681d7237e1014bf64dd5ead6bf74ae55cdd19e61Sebastian Redl const std::pair<uint64_t, uint64_t> &Offsets, 4250d95f77ba180aee35b74f3bf9f8543477f3af543Douglas Gregor serialization::DeclContextInfo &Info); 426681d7237e1014bf64dd5ead6bf74ae55cdd19e61Sebastian Redl 4272b3a5a83ea30bde7fa8f9d8e9a0cb12623759bfbDouglas Gregor /// \brief A vector containing identifiers that have already been 4282b3a5a83ea30bde7fa8f9d8e9a0cb12623759bfbDouglas Gregor /// loaded. 4292b3a5a83ea30bde7fa8f9d8e9a0cb12623759bfbDouglas Gregor /// 4302b3a5a83ea30bde7fa8f9d8e9a0cb12623759bfbDouglas Gregor /// If the pointer at index I is non-NULL, then it refers to the 4312b3a5a83ea30bde7fa8f9d8e9a0cb12623759bfbDouglas Gregor /// IdentifierInfo for the identifier with ID=I+1 that has already 4322b3a5a83ea30bde7fa8f9d8e9a0cb12623759bfbDouglas Gregor /// been loaded. 4332b3a5a83ea30bde7fa8f9d8e9a0cb12623759bfbDouglas Gregor std::vector<IdentifierInfo *> IdentifiersLoaded; 434afaf308b779cd8e8fc8c42601b9f383423c15c2dDouglas Gregor 4351a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor typedef ContinuousRangeMap<serialization::IdentID, ModuleFile *, 4> 43667268d02388d3d25107fa9cf4998c35246255a65Douglas Gregor GlobalIdentifierMapType; 437ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 438a8235d6c4093cd38dcf742909651f867de62e55bDouglas Gregor /// \brief Mapping from global identifier IDs to the module in which the 43967268d02388d3d25107fa9cf4998c35246255a65Douglas Gregor /// identifier resides along with the offset that should be added to the 44067268d02388d3d25107fa9cf4998c35246255a65Douglas Gregor /// global identifier ID to produce a local ID. 44167268d02388d3d25107fa9cf4998c35246255a65Douglas Gregor GlobalIdentifierMapType GlobalIdentifierMap; 44267268d02388d3d25107fa9cf4998c35246255a65Douglas Gregor 443a8235d6c4093cd38dcf742909651f867de62e55bDouglas Gregor /// \brief A vector containing macros that have already been 444a8235d6c4093cd38dcf742909651f867de62e55bDouglas Gregor /// loaded. 445a8235d6c4093cd38dcf742909651f867de62e55bDouglas Gregor /// 446a8235d6c4093cd38dcf742909651f867de62e55bDouglas Gregor /// If the pointer at index I is non-NULL, then it refers to the 447a8235d6c4093cd38dcf742909651f867de62e55bDouglas Gregor /// MacroInfo for the identifier with ID=I+1 that has already 448a8235d6c4093cd38dcf742909651f867de62e55bDouglas Gregor /// been loaded. 4499317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis std::vector<MacroInfo *> MacrosLoaded; 450a8235d6c4093cd38dcf742909651f867de62e55bDouglas Gregor 451a8235d6c4093cd38dcf742909651f867de62e55bDouglas Gregor typedef ContinuousRangeMap<serialization::MacroID, ModuleFile *, 4> 452a8235d6c4093cd38dcf742909651f867de62e55bDouglas Gregor GlobalMacroMapType; 453a8235d6c4093cd38dcf742909651f867de62e55bDouglas Gregor 454a8235d6c4093cd38dcf742909651f867de62e55bDouglas Gregor /// \brief Mapping from global macro IDs to the module in which the 455a8235d6c4093cd38dcf742909651f867de62e55bDouglas Gregor /// macro resides along with the offset that should be added to the 456a8235d6c4093cd38dcf742909651f867de62e55bDouglas Gregor /// global macro ID to produce a local ID. 457a8235d6c4093cd38dcf742909651f867de62e55bDouglas Gregor GlobalMacroMapType GlobalMacroMap; 458a8235d6c4093cd38dcf742909651f867de62e55bDouglas Gregor 45926ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor /// \brief A vector containing submodules that have already been loaded. 46026ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor /// 46126ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor /// This vector is indexed by the Submodule ID (-1). NULL submodule entries 46226ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor /// indicate that the particular submodule ID has not yet been loaded. 46326ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor SmallVector<Module *, 2> SubmodulesLoaded; 46426ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor 46526ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor typedef ContinuousRangeMap<serialization::SubmoduleID, ModuleFile *, 4> 46626ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor GlobalSubmoduleMapType; 46726ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor 46826ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor /// \brief Mapping from global submodule IDs to the module file in which the 46926ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor /// submodule resides along with the offset that should be added to the 47026ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor /// global submodule ID to produce a local ID. 47126ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor GlobalSubmoduleMapType GlobalSubmoduleMap; 47226ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor 4736c6c54a59a6e7dbe63ff6a9bbab76f6e0c7c8462Douglas Gregor /// \brief An entity that has been hidden. 4746c6c54a59a6e7dbe63ff6a9bbab76f6e0c7c8462Douglas Gregor class HiddenName { 47554c8a40ed658676b1f3f983728feae488c501477Douglas Gregor public: 47654c8a40ed658676b1f3f983728feae488c501477Douglas Gregor enum NameKind { 47754c8a40ed658676b1f3f983728feae488c501477Douglas Gregor Declaration, 47889b8f06ed79ddca7f8f8064525781eb3434ac166Argyrios Kyrtzidis MacroVisibility 47954c8a40ed658676b1f3f983728feae488c501477Douglas Gregor } Kind; 48054c8a40ed658676b1f3f983728feae488c501477Douglas Gregor 48154c8a40ed658676b1f3f983728feae488c501477Douglas Gregor private: 48254c8a40ed658676b1f3f983728feae488c501477Douglas Gregor union { 48354c8a40ed658676b1f3f983728feae488c501477Douglas Gregor Decl *D; 4849818a1d443e97677dd3422305de9cc2b1fb2a8c1Argyrios Kyrtzidis MacroDirective *MD; 48554c8a40ed658676b1f3f983728feae488c501477Douglas Gregor }; 4866c6c54a59a6e7dbe63ff6a9bbab76f6e0c7c8462Douglas Gregor 48754c8a40ed658676b1f3f983728feae488c501477Douglas Gregor IdentifierInfo *Id; 4886c6c54a59a6e7dbe63ff6a9bbab76f6e0c7c8462Douglas Gregor 4896c6c54a59a6e7dbe63ff6a9bbab76f6e0c7c8462Douglas Gregor public: 49089b8f06ed79ddca7f8f8064525781eb3434ac166Argyrios Kyrtzidis HiddenName(Decl *D) : Kind(Declaration), D(D), Id() { } 49154c8a40ed658676b1f3f983728feae488c501477Douglas Gregor 4929818a1d443e97677dd3422305de9cc2b1fb2a8c1Argyrios Kyrtzidis HiddenName(IdentifierInfo *II, MacroDirective *MD) 49389b8f06ed79ddca7f8f8064525781eb3434ac166Argyrios Kyrtzidis : Kind(MacroVisibility), MD(MD), Id(II) { } 4946c6c54a59a6e7dbe63ff6a9bbab76f6e0c7c8462Douglas Gregor 49554c8a40ed658676b1f3f983728feae488c501477Douglas Gregor NameKind getKind() const { return Kind; } 4966c6c54a59a6e7dbe63ff6a9bbab76f6e0c7c8462Douglas Gregor 4976c6c54a59a6e7dbe63ff6a9bbab76f6e0c7c8462Douglas Gregor Decl *getDecl() const { 49854c8a40ed658676b1f3f983728feae488c501477Douglas Gregor assert(getKind() == Declaration && "Hidden name is not a declaration"); 49954c8a40ed658676b1f3f983728feae488c501477Douglas Gregor return D; 5006c6c54a59a6e7dbe63ff6a9bbab76f6e0c7c8462Douglas Gregor } 5016c6c54a59a6e7dbe63ff6a9bbab76f6e0c7c8462Douglas Gregor 5029818a1d443e97677dd3422305de9cc2b1fb2a8c1Argyrios Kyrtzidis std::pair<IdentifierInfo *, MacroDirective *> getMacro() const { 50389b8f06ed79ddca7f8f8064525781eb3434ac166Argyrios Kyrtzidis assert(getKind() == MacroVisibility && "Hidden name is not a macro!"); 5049818a1d443e97677dd3422305de9cc2b1fb2a8c1Argyrios Kyrtzidis return std::make_pair(Id, MD); 5056c6c54a59a6e7dbe63ff6a9bbab76f6e0c7c8462Douglas Gregor } 50654c8a40ed658676b1f3f983728feae488c501477Douglas Gregor}; 5076c6c54a59a6e7dbe63ff6a9bbab76f6e0c7c8462Douglas Gregor 508ecc2c090e7146c029dd9ee9a5a2fd66b275c01c0Douglas Gregor /// \brief A set of hidden declarations. 509cfa88f893915ceb8ae4ce2f17c46c24a4d67502fDmitri Gribenko typedef SmallVector<HiddenName, 2> HiddenNames; 510ecc2c090e7146c029dd9ee9a5a2fd66b275c01c0Douglas Gregor 511ecc2c090e7146c029dd9ee9a5a2fd66b275c01c0Douglas Gregor typedef llvm::DenseMap<Module *, HiddenNames> HiddenNamesMapType; 512ecc2c090e7146c029dd9ee9a5a2fd66b275c01c0Douglas Gregor 513ecc2c090e7146c029dd9ee9a5a2fd66b275c01c0Douglas Gregor /// \brief A mapping from each of the hidden submodules to the deserialized 514ecc2c090e7146c029dd9ee9a5a2fd66b275c01c0Douglas Gregor /// declarations in that submodule that could be made visible. 515ecc2c090e7146c029dd9ee9a5a2fd66b275c01c0Douglas Gregor HiddenNamesMapType HiddenNamesMap; 516ecc2c090e7146c029dd9ee9a5a2fd66b275c01c0Douglas Gregor 51755988680ece66b8e505ee136b35e74fcb1173aeeDouglas Gregor 518906d66acc5cf2679453e10a4f0a67feedd765b21Douglas Gregor /// \brief A module import, export, or conflict that hasn't yet been resolved. 519906d66acc5cf2679453e10a4f0a67feedd765b21Douglas Gregor struct UnresolvedModuleRef { 520af13bfc3b40aa4a46f4e71d200ecfb10f45297fcDouglas Gregor /// \brief The file in which this module resides. 521af13bfc3b40aa4a46f4e71d200ecfb10f45297fcDouglas Gregor ModuleFile *File; 522af13bfc3b40aa4a46f4e71d200ecfb10f45297fcDouglas Gregor 52355988680ece66b8e505ee136b35e74fcb1173aeeDouglas Gregor /// \brief The module that is importing or exporting. 52455988680ece66b8e505ee136b35e74fcb1173aeeDouglas Gregor Module *Mod; 525906d66acc5cf2679453e10a4f0a67feedd765b21Douglas Gregor 526906d66acc5cf2679453e10a4f0a67feedd765b21Douglas Gregor /// \brief The kind of module reference. 527906d66acc5cf2679453e10a4f0a67feedd765b21Douglas Gregor enum { Import, Export, Conflict } Kind; 528906d66acc5cf2679453e10a4f0a67feedd765b21Douglas Gregor 529af13bfc3b40aa4a46f4e71d200ecfb10f45297fcDouglas Gregor /// \brief The local ID of the module that is being exported. 53055988680ece66b8e505ee136b35e74fcb1173aeeDouglas Gregor unsigned ID; 531906d66acc5cf2679453e10a4f0a67feedd765b21Douglas Gregor 53255988680ece66b8e505ee136b35e74fcb1173aeeDouglas Gregor /// \brief Whether this is a wildcard export. 53355988680ece66b8e505ee136b35e74fcb1173aeeDouglas Gregor unsigned IsWildcard : 1; 534906d66acc5cf2679453e10a4f0a67feedd765b21Douglas Gregor 535906d66acc5cf2679453e10a4f0a67feedd765b21Douglas Gregor /// \brief String data. 536906d66acc5cf2679453e10a4f0a67feedd765b21Douglas Gregor StringRef String; 537af13bfc3b40aa4a46f4e71d200ecfb10f45297fcDouglas Gregor }; 538af13bfc3b40aa4a46f4e71d200ecfb10f45297fcDouglas Gregor 53955988680ece66b8e505ee136b35e74fcb1173aeeDouglas Gregor /// \brief The set of module imports and exports that still need to be 54055988680ece66b8e505ee136b35e74fcb1173aeeDouglas Gregor /// resolved. 541906d66acc5cf2679453e10a4f0a67feedd765b21Douglas Gregor SmallVector<UnresolvedModuleRef, 2> UnresolvedModuleRefs; 542af13bfc3b40aa4a46f4e71d200ecfb10f45297fcDouglas Gregor 5431eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// \brief A vector containing selectors that have already been loaded. 54483941df2745d69c05acee3174c7a265c206f70d9Douglas Gregor /// 54583941df2745d69c05acee3174c7a265c206f70d9Douglas Gregor /// This vector is indexed by the Selector ID (-1). NULL selector 54683941df2745d69c05acee3174c7a265c206f70d9Douglas Gregor /// entries indicate that the particular selector ID has not yet 54783941df2745d69c05acee3174c7a265c206f70d9Douglas Gregor /// been loaded. 548686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVector<Selector, 16> SelectorsLoaded; 549725cd9686a0f5bb6c994cb3e43f58b63567c6860Sebastian Redl 5501a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor typedef ContinuousRangeMap<serialization::SelectorID, ModuleFile *, 4> 55196958cbe6fb423ab2446629ead5f1b138398433cDouglas Gregor GlobalSelectorMapType; 552ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 55396958cbe6fb423ab2446629ead5f1b138398433cDouglas Gregor /// \brief Mapping from global selector IDs to the module in which the 55495fb36ebddcbdcd6b801c5d3d2d85dac315b4127Douglas Gregor 55596958cbe6fb423ab2446629ead5f1b138398433cDouglas Gregor /// global selector ID to produce a local ID. 55696958cbe6fb423ab2446629ead5f1b138398433cDouglas Gregor GlobalSelectorMapType GlobalSelectorMap; 55796958cbe6fb423ab2446629ead5f1b138398433cDouglas Gregor 5588efca6bb688d32fd7c0d91b504ef3307f97ee66aDouglas Gregor /// \brief The generation number of the last time we loaded data from the 5598efca6bb688d32fd7c0d91b504ef3307f97ee66aDouglas Gregor /// global method pool for this selector. 5608efca6bb688d32fd7c0d91b504ef3307f97ee66aDouglas Gregor llvm::DenseMap<Selector, unsigned> SelectorGeneration; 5618efca6bb688d32fd7c0d91b504ef3307f97ee66aDouglas Gregor 5629317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis struct PendingMacroInfo { 5639317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis ModuleFile *M; 5649317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis 5659317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis struct ModuleMacroDataTy { 5669317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis serialization::GlobalMacroID GMacID; 5679317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis unsigned ImportLoc; 5689317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis }; 5699317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis struct PCHMacroDataTy { 5709317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis uint64_t MacroDirectivesOffset; 5719317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis }; 5729317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis 5739317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis union { 5749317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis ModuleMacroDataTy ModuleMacroData; 5759317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis PCHMacroDataTy PCHMacroData; 5769317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis }; 5779317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis 5789317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis PendingMacroInfo(ModuleFile *M, 5799317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis serialization::GlobalMacroID GMacID, 5809317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis SourceLocation ImportLoc) : M(M) { 5819317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis ModuleMacroData.GMacID = GMacID; 5829317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis ModuleMacroData.ImportLoc = ImportLoc.getRawEncoding(); 5839317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis } 5849317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis 5859317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis PendingMacroInfo(ModuleFile *M, uint64_t MacroDirectivesOffset) : M(M) { 5869317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis PCHMacroData.MacroDirectivesOffset = MacroDirectivesOffset; 5879317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis } 5889317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis }; 5899317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis 5909317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis typedef llvm::MapVector<IdentifierInfo *, SmallVector<PendingMacroInfo, 2> > 5916c6c54a59a6e7dbe63ff6a9bbab76f6e0c7c8462Douglas Gregor PendingMacroIDsMap; 5926c6c54a59a6e7dbe63ff6a9bbab76f6e0c7c8462Douglas Gregor 5936c6c54a59a6e7dbe63ff6a9bbab76f6e0c7c8462Douglas Gregor /// \brief Mapping from identifiers that have a macro history to the global 5946c6c54a59a6e7dbe63ff6a9bbab76f6e0c7c8462Douglas Gregor /// IDs have not yet been deserialized to the global IDs of those macros. 5956c6c54a59a6e7dbe63ff6a9bbab76f6e0c7c8462Douglas Gregor PendingMacroIDsMap PendingMacroIDs; 5964c30bb148b53c8063e940ca3e049ba4d270dc9d5Douglas Gregor 5971a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor typedef ContinuousRangeMap<unsigned, ModuleFile *, 4> 5984c30bb148b53c8063e940ca3e049ba4d270dc9d5Douglas Gregor GlobalPreprocessedEntityMapType; 599ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 6004c30bb148b53c8063e940ca3e049ba4d270dc9d5Douglas Gregor /// \brief Mapping from global preprocessing entity IDs to the module in 6014c30bb148b53c8063e940ca3e049ba4d270dc9d5Douglas Gregor /// which the preprocessed entity resides along with the offset that should be 6024c30bb148b53c8063e940ca3e049ba4d270dc9d5Douglas Gregor /// added to the global preprocessing entitiy ID to produce a local ID. 6034c30bb148b53c8063e940ca3e049ba4d270dc9d5Douglas Gregor GlobalPreprocessedEntityMapType GlobalPreprocessedEntityMap; 604ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 605892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// \name CodeGen-relevant special data 606892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// \brief Fields containing data that is relevant to CodeGen. 607892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl //@{ 608892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl 609892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// \brief The IDs of all declarations that fulfill the criteria of 610892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// "interesting" decls. 611892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// 612892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// This contains the data loaded from all EXTERNAL_DEFINITIONS blocks in the 613892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// chain. The referenced declarations are deserialized and passed to the 614892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// consumer eagerly. 615686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVector<uint64_t, 16> ExternalDefinitions; 616fdd0172ca1b3c837f8c2b37d69cc2085234e09faDouglas Gregor 617bed28ac1d1463adca3ecf24fca5c30646fa9dbb2Sylvestre Ledru /// \brief The IDs of all tentative definitions stored in the chain. 618892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// 619892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// Sema keeps track of all tentative definitions in a TU because it has to 620892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// complete them and pass them on to CodeGen. Thus, tentative definitions in 621892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// the PCH chain must be eagerly deserialized. 622686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVector<uint64_t, 16> TentativeDefinitions; 623892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl 624892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// \brief The IDs of all CXXRecordDecls stored in the chain whose VTables are 625892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// used. 626892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// 627892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// CodeGen has to emit VTables for these records, so they have to be eagerly 628892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// deserialized. 629686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVector<uint64_t, 64> VTableUses; 630892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl 631f2abb52acbba25ad93a1ecdc24d994b9694803a1Douglas Gregor /// \brief A snapshot of the pending instantiations in the chain. 632f2abb52acbba25ad93a1ecdc24d994b9694803a1Douglas Gregor /// 633f2abb52acbba25ad93a1ecdc24d994b9694803a1Douglas Gregor /// This record tracks the instantiations that Sema has to perform at the 634f2abb52acbba25ad93a1ecdc24d994b9694803a1Douglas Gregor /// end of the TU. It consists of a pair of values for every pending 635f2abb52acbba25ad93a1ecdc24d994b9694803a1Douglas Gregor /// instantiation where the first value is the ID of the decl and the second 636f2abb52acbba25ad93a1ecdc24d994b9694803a1Douglas Gregor /// is the instantiation location. 637f2abb52acbba25ad93a1ecdc24d994b9694803a1Douglas Gregor SmallVector<uint64_t, 64> PendingInstantiations; 638f2abb52acbba25ad93a1ecdc24d994b9694803a1Douglas Gregor 639892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl //@} 640892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl 641d6471f7c1921c7802804ce3ff6fe9768310f72b9David Blaikie /// \name DiagnosticsEngine-relevant special data 642892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// \brief Fields containing data that is used for generating diagnostics 643892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl //@{ 644892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl 645892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// \brief A snapshot of Sema's unused file-scoped variable tracking, for 646892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// generating warnings. 647686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVector<uint64_t, 16> UnusedFileScopedDecls; 6484c0e86b392c5fb0cb771551fc877edb6979be69cDouglas Gregor 649ebcbe1d3dc7d4f0c1f540a632fa0684dd0a857d5Sean Hunt /// \brief A list of all the delegating constructors we've seen, to diagnose 650ebcbe1d3dc7d4f0c1f540a632fa0684dd0a857d5Sean Hunt /// cycles. 651686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVector<uint64_t, 4> DelegatingCtorDecls; 652ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 6538451ec7e709baf777bec07dc70653e0c523dd120Douglas Gregor /// \brief Method selectors used in a @selector expression. Used for 6548451ec7e709baf777bec07dc70653e0c523dd120Douglas Gregor /// implementation of -Wselector. 6558451ec7e709baf777bec07dc70653e0c523dd120Douglas Gregor SmallVector<uint64_t, 64> ReferencedSelectorsData; 656ebcbe1d3dc7d4f0c1f540a632fa0684dd0a857d5Sean Hunt 657892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// \brief A snapshot of Sema's weak undeclared identifier tracking, for 658892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// generating warnings. 659686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVector<uint64_t, 64> WeakUndeclaredIdentifiers; 66014c22f20c077cecd68581952a0c227f8c180be03Douglas Gregor 661892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// \brief The IDs of type aliases for ext_vectors that exist in the chain. 662892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// 663892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// Used by Sema for finding sugared names for ext_vectors in diagnostics. 664686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVector<uint64_t, 4> ExtVectorDecls; 665b81c17092039f39be60e9656a37cffbdf2e2c783Douglas Gregor 666892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl //@} 667d455add086f1dfa16ae87dc310e49493bbc2b0a6Argyrios Kyrtzidis 668892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// \name Sema-relevant special data 669892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// \brief Fields containing data that is used for semantic analysis 670892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl //@{ 671892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl 6725ea6ef490547917426d5e2ed14c9f36521bbeacfRichard Smith /// \brief The IDs of all locally scoped extern "C" decls in the chain. 673892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// 674892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// Sema tracks these to validate that the types are consistent across all 6755ea6ef490547917426d5e2ed14c9f36521bbeacfRichard Smith /// local extern "C" declarations. 6765ea6ef490547917426d5e2ed14c9f36521bbeacfRichard Smith SmallVector<uint64_t, 16> LocallyScopedExternCDecls; 677d455add086f1dfa16ae87dc310e49493bbc2b0a6Argyrios Kyrtzidis 678892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// \brief The IDs of all dynamic class declarations in the chain. 679892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// 680892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// Sema tracks these because it checks for the key functions being defined 681892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// at the end of the TU, in which case it directs CodeGen to emit the VTable. 682686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVector<uint64_t, 16> DynamicClasses; 683892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl 684892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// \brief The IDs of the declarations Sema stores directly. 685892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// 686892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// Sema tracks a few important decls, such as namespace std, directly. 687686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVector<uint64_t, 4> SemaDeclRefs; 68876c38d385447b7acdff2d7e6b13fa8580e7174a7Argyrios Kyrtzidis 689e41f985c15d15fce8390ebffb49dc75447c8f0f6Sebastian Redl /// \brief The IDs of the types ASTContext stores directly. 690e41f985c15d15fce8390ebffb49dc75447c8f0f6Sebastian Redl /// 691e41f985c15d15fce8390ebffb49dc75447c8f0f6Sebastian Redl /// The AST context tracks a few important types, such as va_list, directly. 692686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVector<uint64_t, 16> SpecialTypes; 693e41f985c15d15fce8390ebffb49dc75447c8f0f6Sebastian Redl 69414b6ba77710d6431794d65c7d58c6f29c3dc956ePeter Collingbourne /// \brief The IDs of CUDA-specific declarations ASTContext stores directly. 69514b6ba77710d6431794d65c7d58c6f29c3dc956ePeter Collingbourne /// 69614b6ba77710d6431794d65c7d58c6f29c3dc956ePeter Collingbourne /// The AST context tracks a few important decls, currently cudaConfigureCall, 69714b6ba77710d6431794d65c7d58c6f29c3dc956ePeter Collingbourne /// directly. 698686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVector<uint64_t, 2> CUDASpecialDeclRefs; 69914b6ba77710d6431794d65c7d58c6f29c3dc956ePeter Collingbourne 70084bccea1ad9fd8bc1f4ec3d1fc5dd8d15dabffbcPeter Collingbourne /// \brief The floating point pragma option settings. 701686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVector<uint64_t, 1> FPPragmaOptions; 70284bccea1ad9fd8bc1f4ec3d1fc5dd8d15dabffbcPeter Collingbourne 70384bccea1ad9fd8bc1f4ec3d1fc5dd8d15dabffbcPeter Collingbourne /// \brief The OpenCL extension settings. 704686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVector<uint64_t, 1> OpenCLExtensions; 70584bccea1ad9fd8bc1f4ec3d1fc5dd8d15dabffbcPeter Collingbourne 706d8bba9c15230d2b1b3893e272106aa79efc50251Douglas Gregor /// \brief A list of the namespaces we've seen. 707686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVector<uint64_t, 4> KnownNamespaces; 708d8bba9c15230d2b1b3893e272106aa79efc50251Douglas Gregor 709cd0655b17249c4c4908ca91462657f62285017e6Nick Lewycky /// \brief A list of undefined decls with internal linkage followed by the 710cd0655b17249c4c4908ca91462657f62285017e6Nick Lewycky /// SourceLocation of a matching ODR-use. 711cd0655b17249c4c4908ca91462657f62285017e6Nick Lewycky SmallVector<uint64_t, 8> UndefinedButUsed; 71201a41140cd8ec9475ed0c33384310fbdd3b6de11Nick Lewycky 713f6137e4d15cb6bbd10547267babfc699c1945873Douglas Gregor /// \brief A list of modules that were imported by precompiled headers or 714f6137e4d15cb6bbd10547267babfc699c1945873Douglas Gregor /// any other non-module AST file. 715f6137e4d15cb6bbd10547267babfc699c1945873Douglas Gregor SmallVector<serialization::SubmoduleID, 2> ImportedModules; 716892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl //@} 717892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl 7188e3df4d0864f0a966c20088ca1a29c3398b7639dArgyrios Kyrtzidis /// \brief The directory that the PCH we are reading is stored in. 7198e3df4d0864f0a966c20088ca1a29c3398b7639dArgyrios Kyrtzidis std::string CurrentDir; 7208e3df4d0864f0a966c20088ca1a29c3398b7639dArgyrios Kyrtzidis 7211eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// \brief The system include root to be used when loading the 722e650c8c3bca2f58cad8ffa8aab63126d26e890cdDouglas Gregor /// precompiled header. 723832d620b4ae0fc5fe28561b885b4cfc65cf5c9abDouglas Gregor std::string isysroot; 7241eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 725fae3b2f4743dad616623c4df2fdb0f5128bd36d9Douglas Gregor /// \brief Whether to disable the normal validation performed on precompiled 726fae3b2f4743dad616623c4df2fdb0f5128bd36d9Douglas Gregor /// headers when they are loaded. 727fae3b2f4743dad616623c4df2fdb0f5128bd36d9Douglas Gregor bool DisableValidation; 728ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 729bef35c91b594f66216f4aab303b71a6c5ab7abcfArgyrios Kyrtzidis /// \brief Whether to accept an AST file with compiler errors. 730bef35c91b594f66216f4aab303b71a6c5ab7abcfArgyrios Kyrtzidis bool AllowASTWithCompilerErrors; 731bef35c91b594f66216f4aab303b71a6c5ab7abcfArgyrios Kyrtzidis 732f575d6e7c3b887ea4c5394d2c7e322c7a929a57eDouglas Gregor /// \brief Whether we are allowed to use the global module index. 733f575d6e7c3b887ea4c5394d2c7e322c7a929a57eDouglas Gregor bool UseGlobalIndex; 734f575d6e7c3b887ea4c5394d2c7e322c7a929a57eDouglas Gregor 735f575d6e7c3b887ea4c5394d2c7e322c7a929a57eDouglas Gregor /// \brief Whether we have tried loading the global module index yet. 736f575d6e7c3b887ea4c5394d2c7e322c7a929a57eDouglas Gregor bool TriedLoadingGlobalIndex; 737f575d6e7c3b887ea4c5394d2c7e322c7a929a57eDouglas Gregor 738057df20b3107cef764052d271c89b8591b98b3ceDouglas Gregor /// \brief The current "generation" of the module file import stack, which 739057df20b3107cef764052d271c89b8591b98b3ceDouglas Gregor /// indicates how many separate module file load operations have occurred. 740057df20b3107cef764052d271c89b8591b98b3ceDouglas Gregor unsigned CurrentGeneration; 741057df20b3107cef764052d271c89b8591b98b3ceDouglas Gregor 74212dcc64eebf7aaffb71392fba74fcb69f35d3b2eArgyrios Kyrtzidis typedef llvm::DenseMap<unsigned, SwitchCase *> SwitchCaseMapTy; 7433c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// \brief Mapping from switch-case IDs in the chain to switch-case statements 744e41f985c15d15fce8390ebffb49dc75447c8f0f6Sebastian Redl /// 745e41f985c15d15fce8390ebffb49dc75447c8f0f6Sebastian Redl /// Statements usually don't have IDs, but switch cases need them, so that the 746e41f985c15d15fce8390ebffb49dc75447c8f0f6Sebastian Redl /// switch statement can refer to them. 74712dcc64eebf7aaffb71392fba74fcb69f35d3b2eArgyrios Kyrtzidis SwitchCaseMapTy SwitchCaseStmts; 748025452fa0eda63e150cfaeebe64f0a19c96b3a06Douglas Gregor 74912dcc64eebf7aaffb71392fba74fcb69f35d3b2eArgyrios Kyrtzidis SwitchCaseMapTy *CurrSwitchCaseStmts; 750b88acb018a0d5e897ce291da2664edfd7bd58f5cArgyrios Kyrtzidis 7517f94b0b0c6791013d2f72ced9b4bedd3b23673a6Douglas Gregor /// \brief The number of source location entries de-serialized from 7527f94b0b0c6791013d2f72ced9b4bedd3b23673a6Douglas Gregor /// the PCH file. 7537f94b0b0c6791013d2f72ced9b4bedd3b23673a6Douglas Gregor unsigned NumSLocEntriesRead; 7547f94b0b0c6791013d2f72ced9b4bedd3b23673a6Douglas Gregor 7553c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// \brief The number of source location entries in the chain. 756518d8cb31d26ea098eba79274abbfae1b4976853Sebastian Redl unsigned TotalNumSLocEntries; 757518d8cb31d26ea098eba79274abbfae1b4976853Sebastian Redl 7583e1af84bb0092a1aafb49deaa4ab6664c9a9071bDouglas Gregor /// \brief The number of statements (and expressions) de-serialized 7593c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// from the chain. 7603e1af84bb0092a1aafb49deaa4ab6664c9a9071bDouglas Gregor unsigned NumStatementsRead; 7613e1af84bb0092a1aafb49deaa4ab6664c9a9071bDouglas Gregor 7623e1af84bb0092a1aafb49deaa4ab6664c9a9071bDouglas Gregor /// \brief The total number of statements (and expressions) stored 7633c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// in the chain. 7643e1af84bb0092a1aafb49deaa4ab6664c9a9071bDouglas Gregor unsigned TotalNumStatements; 7653e1af84bb0092a1aafb49deaa4ab6664c9a9071bDouglas Gregor 7663c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// \brief The number of macros de-serialized from the chain. 76737e2684abfe38207fdb90620da062bb18c23f29aDouglas Gregor unsigned NumMacrosRead; 7682512308525ff328aa992da0b5ee14a488d2ea93aDouglas Gregor 7693c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// \brief The total number of macros stored in the chain. 770fa78dec572259aca763457b435744f79d822c5d4Sebastian Redl unsigned TotalNumMacros; 771fa78dec572259aca763457b435744f79d822c5d4Sebastian Redl 772e169807aaea2464cbe68305f013ec7b41625af30Douglas Gregor /// \brief The number of lookups into identifier tables. 773e169807aaea2464cbe68305f013ec7b41625af30Douglas Gregor unsigned NumIdentifierLookups; 774e169807aaea2464cbe68305f013ec7b41625af30Douglas Gregor 775e169807aaea2464cbe68305f013ec7b41625af30Douglas Gregor /// \brief The number of lookups into identifier tables that succeed. 776e169807aaea2464cbe68305f013ec7b41625af30Douglas Gregor unsigned NumIdentifierLookupHits; 777e169807aaea2464cbe68305f013ec7b41625af30Douglas Gregor 778725cd9686a0f5bb6c994cb3e43f58b63567c6860Sebastian Redl /// \brief The number of selectors that have been read. 779725cd9686a0f5bb6c994cb3e43f58b63567c6860Sebastian Redl unsigned NumSelectorsRead; 78083941df2745d69c05acee3174c7a265c206f70d9Douglas Gregor 781fa78dec572259aca763457b435744f79d822c5d4Sebastian Redl /// \brief The number of method pool entries that have been read. 782fa78dec572259aca763457b435744f79d822c5d4Sebastian Redl unsigned NumMethodPoolEntriesRead; 78383941df2745d69c05acee3174c7a265c206f70d9Douglas Gregor 784fa78dec572259aca763457b435744f79d822c5d4Sebastian Redl /// \brief The number of times we have looked up a selector in the method 78595fb36ebddcbdcd6b801c5d3d2d85dac315b4127Douglas Gregor /// pool. 78695fb36ebddcbdcd6b801c5d3d2d85dac315b4127Douglas Gregor unsigned NumMethodPoolLookups; 78795fb36ebddcbdcd6b801c5d3d2d85dac315b4127Douglas Gregor 78895fb36ebddcbdcd6b801c5d3d2d85dac315b4127Douglas Gregor /// \brief The number of times we have looked up a selector in the method 78995fb36ebddcbdcd6b801c5d3d2d85dac315b4127Douglas Gregor /// pool and found something. 79095fb36ebddcbdcd6b801c5d3d2d85dac315b4127Douglas Gregor unsigned NumMethodPoolHits; 79195fb36ebddcbdcd6b801c5d3d2d85dac315b4127Douglas Gregor 79295fb36ebddcbdcd6b801c5d3d2d85dac315b4127Douglas Gregor /// \brief The number of times we have looked up a selector in the method 79395fb36ebddcbdcd6b801c5d3d2d85dac315b4127Douglas Gregor /// pool within a specific module. 79495fb36ebddcbdcd6b801c5d3d2d85dac315b4127Douglas Gregor unsigned NumMethodPoolTableLookups; 79595fb36ebddcbdcd6b801c5d3d2d85dac315b4127Douglas Gregor 79695fb36ebddcbdcd6b801c5d3d2d85dac315b4127Douglas Gregor /// \brief The number of times we have looked up a selector in the method 79795fb36ebddcbdcd6b801c5d3d2d85dac315b4127Douglas Gregor /// pool within a specific module and found something. 79895fb36ebddcbdcd6b801c5d3d2d85dac315b4127Douglas Gregor unsigned NumMethodPoolTableHits; 799fa78dec572259aca763457b435744f79d822c5d4Sebastian Redl 800fa78dec572259aca763457b435744f79d822c5d4Sebastian Redl /// \brief The total number of method pool entries in the selector table. 801fa78dec572259aca763457b435744f79d822c5d4Sebastian Redl unsigned TotalNumMethodPoolEntries; 80237e2684abfe38207fdb90620da062bb18c23f29aDouglas Gregor 8032512308525ff328aa992da0b5ee14a488d2ea93aDouglas Gregor /// Number of lexical decl contexts read/total. 8042512308525ff328aa992da0b5ee14a488d2ea93aDouglas Gregor unsigned NumLexicalDeclContextsRead, TotalLexicalDeclContexts; 8052512308525ff328aa992da0b5ee14a488d2ea93aDouglas Gregor 8062512308525ff328aa992da0b5ee14a488d2ea93aDouglas Gregor /// Number of visible decl contexts read/total. 8072512308525ff328aa992da0b5ee14a488d2ea93aDouglas Gregor unsigned NumVisibleDeclContextsRead, TotalVisibleDeclContexts; 808ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 8091da901467f72d1733704b068e22089813a1962fdJonathan D. Turner /// Total size of modules, in bits, currently loaded 8101da901467f72d1733704b068e22089813a1962fdJonathan D. Turner uint64_t TotalModulesSizeInBits; 8111da901467f72d1733704b068e22089813a1962fdJonathan D. Turner 81229ee3a273f58e16df7f2c524ab62a869e44fc9b1Argyrios Kyrtzidis /// \brief Number of Decl/types that are currently deserializing. 81329ee3a273f58e16df7f2c524ab62a869e44fc9b1Argyrios Kyrtzidis unsigned NumCurrentElementsDeserializing; 8141eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 81544d2dbdce49d1fca3826d543ba875bb82f759091Argyrios Kyrtzidis /// \brief Set true while we are in the process of passing deserialized 81644d2dbdce49d1fca3826d543ba875bb82f759091Argyrios Kyrtzidis /// "interesting" decls to consumer inside FinishedDeserializing(). 81744d2dbdce49d1fca3826d543ba875bb82f759091Argyrios Kyrtzidis /// This is used as a guard to avoid recursively repeating the process of 81844d2dbdce49d1fca3826d543ba875bb82f759091Argyrios Kyrtzidis /// passing decls to consumer. 81944d2dbdce49d1fca3826d543ba875bb82f759091Argyrios Kyrtzidis bool PassingDeclsToConsumer; 82044d2dbdce49d1fca3826d543ba875bb82f759091Argyrios Kyrtzidis 8211da901467f72d1733704b068e22089813a1962fdJonathan D. Turner /// Number of CXX base specifiers currently loaded 8221da901467f72d1733704b068e22089813a1962fdJonathan D. Turner unsigned NumCXXBaseSpecifiersLoaded; 8231da901467f72d1733704b068e22089813a1962fdJonathan D. Turner 8243c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// \brief The set of identifiers that were read while the AST reader was 8251eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// (recursively) loading declarations. 8261eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// 827d89275bc865e2b552836c7b33e636d4f86b8de6dDouglas Gregor /// The declarations on the identifier chain for these identifiers will be 828d89275bc865e2b552836c7b33e636d4f86b8de6dDouglas Gregor /// loaded once the recursive loading has completed. 829aa945900d5438984bdcaac85c4f54868292231f4Douglas Gregor llvm::MapVector<IdentifierInfo *, SmallVector<uint32_t, 4> > 830aa945900d5438984bdcaac85c4f54868292231f4Douglas Gregor PendingIdentifierInfos; 8311eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 8328efca6bb688d32fd7c0d91b504ef3307f97ee66aDouglas Gregor /// \brief The generation number of each identifier, which keeps track of 8338efca6bb688d32fd7c0d91b504ef3307f97ee66aDouglas Gregor /// the last time we loaded information about this identifier. 834057df20b3107cef764052d271c89b8591b98b3ceDouglas Gregor llvm::DenseMap<IdentifierInfo *, unsigned> IdentifierGeneration; 835057df20b3107cef764052d271c89b8591b98b3ceDouglas Gregor 836c62a2fe1957626bc4b29402b2d0a3694dfaa3280Douglas Gregor /// \brief Contains declarations and definitions that will be 837c62a2fe1957626bc4b29402b2d0a3694dfaa3280Douglas Gregor /// "interesting" to the ASTConsumer, when we get that AST consumer. 838c62a2fe1957626bc4b29402b2d0a3694dfaa3280Douglas Gregor /// 839c62a2fe1957626bc4b29402b2d0a3694dfaa3280Douglas Gregor /// "Interesting" declarations are those that have data that may 840c62a2fe1957626bc4b29402b2d0a3694dfaa3280Douglas Gregor /// need to be emitted, such as inline function definitions or 841c62a2fe1957626bc4b29402b2d0a3694dfaa3280Douglas Gregor /// Objective-C protocols. 842bb80a8e8887c1ec74ee135d4ad9455eafedf1508Argyrios Kyrtzidis std::deque<Decl *> InterestingDecls; 843c62a2fe1957626bc4b29402b2d0a3694dfaa3280Douglas Gregor 84439d26c3e499470cd80a3e6f26f11ac681cd9712cAxel Naumann /// \brief The set of redeclarable declarations that have been deserialized 8452171bf1caba4d4b9eeb6a91efac4300b41f38b07Douglas Gregor /// since the last time the declaration chains were linked. 8462171bf1caba4d4b9eeb6a91efac4300b41f38b07Douglas Gregor llvm::SmallPtrSet<Decl *, 16> RedeclsDeserialized; 8472171bf1caba4d4b9eeb6a91efac4300b41f38b07Douglas Gregor 848a1be278c4f3a234ff61f04018d26c6beecde1654Douglas Gregor /// \brief The list of redeclaration chains that still need to be 849a1be278c4f3a234ff61f04018d26c6beecde1654Douglas Gregor /// reconstructed. 850a1be278c4f3a234ff61f04018d26c6beecde1654Douglas Gregor /// 851a1be278c4f3a234ff61f04018d26c6beecde1654Douglas Gregor /// Each element is the global declaration ID of the first declaration in 852a1be278c4f3a234ff61f04018d26c6beecde1654Douglas Gregor /// the chain. Elements in this vector should be unique; use 853a1be278c4f3a234ff61f04018d26c6beecde1654Douglas Gregor /// PendingDeclChainsKnown to ensure uniqueness. 854cfa88f893915ceb8ae4ce2f17c46c24a4d67502fDmitri Gribenko SmallVector<serialization::DeclID, 16> PendingDeclChains; 855a1be278c4f3a234ff61f04018d26c6beecde1654Douglas Gregor 856a1be278c4f3a234ff61f04018d26c6beecde1654Douglas Gregor /// \brief Keeps track of the elements added to PendingDeclChains. 857a1be278c4f3a234ff61f04018d26c6beecde1654Douglas Gregor llvm::SmallSet<serialization::DeclID, 16> PendingDeclChainsKnown; 858a1be278c4f3a234ff61f04018d26c6beecde1654Douglas Gregor 8597640b02a561fd2b2c58a227b262b0c1ba93622aeArgyrios Kyrtzidis /// \brief The Decl IDs for the Sema/Lexical DeclContext of a Decl that has 8607640b02a561fd2b2c58a227b262b0c1ba93622aeArgyrios Kyrtzidis /// been loaded but its DeclContext was not set yet. 8617640b02a561fd2b2c58a227b262b0c1ba93622aeArgyrios Kyrtzidis struct PendingDeclContextInfo { 8627640b02a561fd2b2c58a227b262b0c1ba93622aeArgyrios Kyrtzidis Decl *D; 8637640b02a561fd2b2c58a227b262b0c1ba93622aeArgyrios Kyrtzidis serialization::GlobalDeclID SemaDC; 8647640b02a561fd2b2c58a227b262b0c1ba93622aeArgyrios Kyrtzidis serialization::GlobalDeclID LexicalDC; 8657640b02a561fd2b2c58a227b262b0c1ba93622aeArgyrios Kyrtzidis }; 8667640b02a561fd2b2c58a227b262b0c1ba93622aeArgyrios Kyrtzidis 8677640b02a561fd2b2c58a227b262b0c1ba93622aeArgyrios Kyrtzidis /// \brief The set of Decls that have been loaded but their DeclContexts are 8687640b02a561fd2b2c58a227b262b0c1ba93622aeArgyrios Kyrtzidis /// not set yet. 8697640b02a561fd2b2c58a227b262b0c1ba93622aeArgyrios Kyrtzidis /// 8707640b02a561fd2b2c58a227b262b0c1ba93622aeArgyrios Kyrtzidis /// The DeclContexts for these Decls will be set once recursive loading has 8717640b02a561fd2b2c58a227b262b0c1ba93622aeArgyrios Kyrtzidis /// been completed. 8727640b02a561fd2b2c58a227b262b0c1ba93622aeArgyrios Kyrtzidis std::deque<PendingDeclContextInfo> PendingDeclContextInfos; 8737640b02a561fd2b2c58a227b262b0c1ba93622aeArgyrios Kyrtzidis 874cff9f26ce0ed76d555cd33b3dca84dd5cdf376afDouglas Gregor /// \brief The set of Objective-C categories that have been deserialized 875cff9f26ce0ed76d555cd33b3dca84dd5cdf376afDouglas Gregor /// since the last time the declaration chains were linked. 876cff9f26ce0ed76d555cd33b3dca84dd5cdf376afDouglas Gregor llvm::SmallPtrSet<ObjCCategoryDecl *, 16> CategoriesDeserialized; 877cff9f26ce0ed76d555cd33b3dca84dd5cdf376afDouglas Gregor 878cff9f26ce0ed76d555cd33b3dca84dd5cdf376afDouglas Gregor /// \brief The set of Objective-C class definitions that have already been 879cff9f26ce0ed76d555cd33b3dca84dd5cdf376afDouglas Gregor /// loaded, for which we will need to check for categories whenever a new 880cff9f26ce0ed76d555cd33b3dca84dd5cdf376afDouglas Gregor /// module is loaded. 881cfa88f893915ceb8ae4ce2f17c46c24a4d67502fDmitri Gribenko SmallVector<ObjCInterfaceDecl *, 16> ObjCClassesLoaded; 882cff9f26ce0ed76d555cd33b3dca84dd5cdf376afDouglas Gregor 883cfa88f893915ceb8ae4ce2f17c46c24a4d67502fDmitri Gribenko typedef llvm::DenseMap<Decl *, SmallVector<serialization::DeclID, 2> > 8840f75323264b93a318ac9007eb5ec5b233c444068Douglas Gregor MergedDeclsMap; 8850f75323264b93a318ac9007eb5ec5b233c444068Douglas Gregor 8860f75323264b93a318ac9007eb5ec5b233c444068Douglas Gregor /// \brief A mapping from canonical declarations to the set of additional 8870f75323264b93a318ac9007eb5ec5b233c444068Douglas Gregor /// (global, previously-canonical) declaration IDs that have been merged with 8880f75323264b93a318ac9007eb5ec5b233c444068Douglas Gregor /// that canonical declaration. 8890f75323264b93a318ac9007eb5ec5b233c444068Douglas Gregor MergedDeclsMap MergedDecls; 8900f75323264b93a318ac9007eb5ec5b233c444068Douglas Gregor 891c3cfd2ab3338d47861ece597212f21b972ebe727Douglas Gregor typedef llvm::DenseMap<serialization::GlobalDeclID, 892cfa88f893915ceb8ae4ce2f17c46c24a4d67502fDmitri Gribenko SmallVector<serialization::DeclID, 2> > 893c3cfd2ab3338d47861ece597212f21b972ebe727Douglas Gregor StoredMergedDeclsMap; 894c3cfd2ab3338d47861ece597212f21b972ebe727Douglas Gregor 895c3cfd2ab3338d47861ece597212f21b972ebe727Douglas Gregor /// \brief A mapping from canonical declaration IDs to the set of additional 896c3cfd2ab3338d47861ece597212f21b972ebe727Douglas Gregor /// declaration IDs that have been merged with that canonical declaration. 897c3cfd2ab3338d47861ece597212f21b972ebe727Douglas Gregor /// 898c3cfd2ab3338d47861ece597212f21b972ebe727Douglas Gregor /// This is the deserialized representation of the entries in MergedDecls. 899c3cfd2ab3338d47861ece597212f21b972ebe727Douglas Gregor /// When we query entries in MergedDecls, they will be augmented with entries 900c3cfd2ab3338d47861ece597212f21b972ebe727Douglas Gregor /// from StoredMergedDecls. 901c3cfd2ab3338d47861ece597212f21b972ebe727Douglas Gregor StoredMergedDeclsMap StoredMergedDecls; 902c3cfd2ab3338d47861ece597212f21b972ebe727Douglas Gregor 903c3cfd2ab3338d47861ece597212f21b972ebe727Douglas Gregor /// \brief Combine the stored merged declarations for the given canonical 904c3cfd2ab3338d47861ece597212f21b972ebe727Douglas Gregor /// declaration into the set of merged declarations. 905c3cfd2ab3338d47861ece597212f21b972ebe727Douglas Gregor /// 906c3cfd2ab3338d47861ece597212f21b972ebe727Douglas Gregor /// \returns An iterator into MergedDecls that corresponds to the position of 907c3cfd2ab3338d47861ece597212f21b972ebe727Douglas Gregor /// the given canonical declaration. 908c3cfd2ab3338d47861ece597212f21b972ebe727Douglas Gregor MergedDeclsMap::iterator 909c3cfd2ab3338d47861ece597212f21b972ebe727Douglas Gregor combineStoredMergedDecls(Decl *Canon, serialization::GlobalDeclID CanonID); 9100895d1513772eca5a20c552976209fd7f58b993fArgyrios Kyrtzidis 911919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis /// \brief When reading a Stmt tree, Stmt operands are placed in this stack. 912686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVector<Stmt *, 16> StmtStack; 913919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis 914919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis /// \brief What kind of records we are reading. 915919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis enum ReadingKind { 916afb90df95223a2b48f22a3d950328d1d915691f5Richard Smith Read_None, Read_Decl, Read_Type, Read_Stmt 917919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis }; 918919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis 919ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie /// \brief What kind of records we are reading. 920919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis ReadingKind ReadingKind; 921919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis 922919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis /// \brief RAII object to change the reading kind. 923919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis class ReadingKindTracker { 924c43b54cbc10654ed59de797898042e1a05265246Sebastian Redl ASTReader &Reader; 925919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis enum ReadingKind PrevKind; 926919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis 927f56faa01936b9cf909623d7f06e3c2569ca4a78eDmitri Gribenko ReadingKindTracker(const ReadingKindTracker &) LLVM_DELETED_FUNCTION; 928f56faa01936b9cf909623d7f06e3c2569ca4a78eDmitri Gribenko void operator=(const ReadingKindTracker &) LLVM_DELETED_FUNCTION; 929919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis 930919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis public: 931c43b54cbc10654ed59de797898042e1a05265246Sebastian Redl ReadingKindTracker(enum ReadingKind newKind, ASTReader &reader) 932919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis : Reader(reader), PrevKind(Reader.ReadingKind) { 933919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis Reader.ReadingKind = newKind; 934919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis } 935919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis 936919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis ~ReadingKindTracker() { Reader.ReadingKind = PrevKind; } 937919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis }; 938919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis 939e721f95069d42b899c20c1caabdc6184dd42b820Douglas Gregor /// \brief Suggested contents of the predefines buffer, after this 940e721f95069d42b899c20c1caabdc6184dd42b820Douglas Gregor /// PCH file has been processed. 941e721f95069d42b899c20c1caabdc6184dd42b820Douglas Gregor /// 942e721f95069d42b899c20c1caabdc6184dd42b820Douglas Gregor /// In most cases, this string will be empty, because the predefines 943e721f95069d42b899c20c1caabdc6184dd42b820Douglas Gregor /// buffer computed to build the PCH file will be identical to the 944e721f95069d42b899c20c1caabdc6184dd42b820Douglas Gregor /// predefines buffer computed from the command line. However, when 945e721f95069d42b899c20c1caabdc6184dd42b820Douglas Gregor /// there are differences that the PCH reader can work around, this 946e721f95069d42b899c20c1caabdc6184dd42b820Douglas Gregor /// predefines buffer may contain additional definitions. 947e721f95069d42b899c20c1caabdc6184dd42b820Douglas Gregor std::string SuggestedPredefines; 9481eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 949919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis /// \brief Reads a statement from the specified cursor. 9501a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor Stmt *ReadStmtFromStream(ModuleFile &F); 951919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis 952a930dc9b46572cb6e5bb54f3d724e8fe23a6b66eDouglas Gregor /// \brief Retrieve the file entry and 'overridden' bit for an input 953a930dc9b46572cb6e5bb54f3d724e8fe23a6b66eDouglas Gregor /// file in the given module file. 9548504b7b8102a52b2a16231d459fb3cfab4784c38Argyrios Kyrtzidis serialization::InputFile getInputFile(ModuleFile &F, unsigned ID, 9558504b7b8102a52b2a16231d459fb3cfab4784c38Argyrios Kyrtzidis bool Complain = true); 956a930dc9b46572cb6e5bb54f3d724e8fe23a6b66eDouglas Gregor 957b68ffb107a86f5e3851e8108c712b64dd16ba258Argyrios Kyrtzidis /// \brief Get a FileEntry out of stored-in-PCH filename, making sure we take 958b68ffb107a86f5e3851e8108c712b64dd16ba258Argyrios Kyrtzidis /// into account all the necessary relocations. 959686775deca8b8685eb90801495880e3abdd844c2Chris Lattner const FileEntry *getFileEntry(StringRef filename); 960b68ffb107a86f5e3851e8108c712b64dd16ba258Argyrios Kyrtzidis 961848bc3a5db57fb267e2b2541cb55e71dba4bf228Rafael Espindola void MaybeAddSystemRootToFilename(ModuleFile &M, std::string &Filename); 9621eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 963958bcaf3d4e0c1ae46de3e84e7c2a7638c3c5286Argyrios Kyrtzidis struct ImportedModule { 964958bcaf3d4e0c1ae46de3e84e7c2a7638c3c5286Argyrios Kyrtzidis ModuleFile *Mod; 965958bcaf3d4e0c1ae46de3e84e7c2a7638c3c5286Argyrios Kyrtzidis ModuleFile *ImportedBy; 966958bcaf3d4e0c1ae46de3e84e7c2a7638c3c5286Argyrios Kyrtzidis SourceLocation ImportLoc; 967958bcaf3d4e0c1ae46de3e84e7c2a7638c3c5286Argyrios Kyrtzidis 968958bcaf3d4e0c1ae46de3e84e7c2a7638c3c5286Argyrios Kyrtzidis ImportedModule(ModuleFile *Mod, 969958bcaf3d4e0c1ae46de3e84e7c2a7638c3c5286Argyrios Kyrtzidis ModuleFile *ImportedBy, 970958bcaf3d4e0c1ae46de3e84e7c2a7638c3c5286Argyrios Kyrtzidis SourceLocation ImportLoc) 971958bcaf3d4e0c1ae46de3e84e7c2a7638c3c5286Argyrios Kyrtzidis : Mod(Mod), ImportedBy(ImportedBy), ImportLoc(ImportLoc) { } 972958bcaf3d4e0c1ae46de3e84e7c2a7638c3c5286Argyrios Kyrtzidis }; 973958bcaf3d4e0c1ae46de3e84e7c2a7638c3c5286Argyrios Kyrtzidis 97410bc00fd45824f9b5cd139d63af8b0f6d28aaddaDouglas Gregor ASTReadResult ReadASTCore(StringRef FileName, ModuleKind Type, 975958bcaf3d4e0c1ae46de3e84e7c2a7638c3c5286Argyrios Kyrtzidis SourceLocation ImportLoc, ModuleFile *ImportedBy, 976cfa88f893915ceb8ae4ce2f17c46c24a4d67502fDmitri Gribenko SmallVectorImpl<ImportedModule> &Loaded, 977677e15ffee2ecc9c1c8f46fd77cab4b5afb59640Douglas Gregor off_t ExpectedSize, time_t ExpectedModTime, 97838295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor unsigned ClientLoadCapabilities); 9791d9d9898ce2b338314161d92f39561a09a2a8b6fDouglas Gregor ASTReadResult ReadControlBlock(ModuleFile &F, 980cfa88f893915ceb8ae4ce2f17c46c24a4d67502fDmitri Gribenko SmallVectorImpl<ImportedModule> &Loaded, 98138295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor unsigned ClientLoadCapabilities); 9824825fd7fbb3fe87cdf8da9bccc1361fac45bdf2dDouglas Gregor bool ReadASTBlock(ModuleFile &F); 9831a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor bool ParseLineTable(ModuleFile &F, SmallVectorImpl<uint64_t> &Record); 9844825fd7fbb3fe87cdf8da9bccc1361fac45bdf2dDouglas Gregor bool ReadSourceManagerBlock(ModuleFile &F); 985f62d43d2afe1960755a1b5813cae1e5983bcac1bDouglas Gregor llvm::BitstreamCursor &SLocCursorForID(int ID); 9861a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor SourceLocation getImportLocation(ModuleFile *F); 9874825fd7fbb3fe87cdf8da9bccc1361fac45bdf2dDouglas Gregor bool ReadSubmoduleBlock(ModuleFile &F); 98827ffa6caf965ef20fdef5ae23b81cdc3d05e7afbDouglas Gregor static bool ParseLanguageOptions(const RecordData &Record, bool Complain, 98927ffa6caf965ef20fdef5ae23b81cdc3d05e7afbDouglas Gregor ASTReaderListener &Listener); 99027ffa6caf965ef20fdef5ae23b81cdc3d05e7afbDouglas Gregor static bool ParseTargetOptions(const RecordData &Record, bool Complain, 99127ffa6caf965ef20fdef5ae23b81cdc3d05e7afbDouglas Gregor ASTReaderListener &Listener); 9925f3d8224af99ad0d9107601c0c31b74693371cc1Douglas Gregor static bool ParseDiagnosticOptions(const RecordData &Record, bool Complain, 9935f3d8224af99ad0d9107601c0c31b74693371cc1Douglas Gregor ASTReaderListener &Listener); 9941b2c3c0884e917ae5d59edde7d93b2af33c6a1b6Douglas Gregor static bool ParseFileSystemOptions(const RecordData &Record, bool Complain, 9951b2c3c0884e917ae5d59edde7d93b2af33c6a1b6Douglas Gregor ASTReaderListener &Listener); 996bbf38319edd4eddc55ec273934e990d7e84991deDouglas Gregor static bool ParseHeaderSearchOptions(const RecordData &Record, bool Complain, 997bbf38319edd4eddc55ec273934e990d7e84991deDouglas Gregor ASTReaderListener &Listener); 998a71a7d8a1ce4474e7bdb680658fb58b6caf391d3Douglas Gregor static bool ParsePreprocessorOptions(const RecordData &Record, bool Complain, 9998769924c97ecf2af88f7f3aa6754d381b30d1c5fDouglas Gregor ASTReaderListener &Listener, 10008769924c97ecf2af88f7f3aa6754d381b30d1c5fDouglas Gregor std::string &SuggestedPredefines); 100127ffa6caf965ef20fdef5ae23b81cdc3d05e7afbDouglas Gregor 1002c3632730cc83ed7b51f0ab5c38997ae5a9439b0cSebastian Redl struct RecordLocation { 10031a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor RecordLocation(ModuleFile *M, uint64_t O) 1004c3632730cc83ed7b51f0ab5c38997ae5a9439b0cSebastian Redl : F(M), Offset(O) {} 10051a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor ModuleFile *F; 1006c3632730cc83ed7b51f0ab5c38997ae5a9439b0cSebastian Redl uint64_t Offset; 1007c3632730cc83ed7b51f0ab5c38997ae5a9439b0cSebastian Redl }; 1008aaec0aa844781dc7c3462ba140e004e589ccd355Sebastian Redl 1009393f249399fe30e9580e1529a7479489e90f3a57Douglas Gregor QualType readTypeRecord(unsigned Index); 1010aaec0aa844781dc7c3462ba140e004e589ccd355Sebastian Redl RecordLocation TypeCursorForIndex(unsigned Index); 10112cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor void LoadedDecl(unsigned Index, Decl *D); 1012496c709a6f08f5c502b6f592ddd9ed40f953a5e5Douglas Gregor Decl *ReadDeclRecord(serialization::DeclID ID); 10139d31fa75bc05fe4cb903a7701550f22cfb73ea8bArgyrios Kyrtzidis RecordLocation DeclCursorForID(serialization::DeclID ID, 10149d31fa75bc05fe4cb903a7701550f22cfb73ea8bArgyrios Kyrtzidis unsigned &RawLocation); 10156bf2b9fbd3e3adc38d4712de79aeaa81d651aa08Douglas Gregor void loadDeclUpdateRecords(serialization::DeclID ID, Decl *D); 1016a1be278c4f3a234ff61f04018d26c6beecde1654Douglas Gregor void loadPendingDeclChain(serialization::GlobalDeclID ID); 1017cff9f26ce0ed76d555cd33b3dca84dd5cdf376afDouglas Gregor void loadObjCCategories(serialization::GlobalDeclID ID, ObjCInterfaceDecl *D, 1018cff9f26ce0ed76d555cd33b3dca84dd5cdf376afDouglas Gregor unsigned PreviousGeneration = 0); 1019ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 10208f1231b70c2b1f6fe0cee097b447487b26810301Douglas Gregor RecordLocation getLocalBitOffset(uint64_t GlobalOffset); 10211a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor uint64_t getGlobalBitOffset(ModuleFile &M, uint32_t LocalOffset); 10222dbaca748bc3eb6539f417bd8354c930bdf88fa4Argyrios Kyrtzidis 1023a7b7d1a7394394d33c18f7dda400a9a12cae2c78James Dennett /// \brief Returns the first preprocessed entity ID that ends after BLoc. 10242dbaca748bc3eb6539f417bd8354c930bdf88fa4Argyrios Kyrtzidis serialization::PreprocessedEntityID 10252dbaca748bc3eb6539f417bd8354c930bdf88fa4Argyrios Kyrtzidis findBeginPreprocessedEntity(SourceLocation BLoc) const; 10262dbaca748bc3eb6539f417bd8354c930bdf88fa4Argyrios Kyrtzidis 1027a7b7d1a7394394d33c18f7dda400a9a12cae2c78James Dennett /// \brief Returns the first preprocessed entity ID that begins after ELoc. 10282dbaca748bc3eb6539f417bd8354c930bdf88fa4Argyrios Kyrtzidis serialization::PreprocessedEntityID 10292dbaca748bc3eb6539f417bd8354c930bdf88fa4Argyrios Kyrtzidis findEndPreprocessedEntity(SourceLocation ELoc) const; 10302dbaca748bc3eb6539f417bd8354c930bdf88fa4Argyrios Kyrtzidis 1031a7b7d1a7394394d33c18f7dda400a9a12cae2c78James Dennett /// \brief Find the next module that contains entities and return the ID 10322dbaca748bc3eb6539f417bd8354c930bdf88fa4Argyrios Kyrtzidis /// of the first entry. 10331824d54df85a462ada812dadda18130f951d40f3Dmitri Gribenko /// 10341824d54df85a462ada812dadda18130f951d40f3Dmitri Gribenko /// \param SLocMapI points at a chunk of a module that contains no 1035a7b7d1a7394394d33c18f7dda400a9a12cae2c78James Dennett /// preprocessed entities or the entities it contains are not the 1036a7b7d1a7394394d33c18f7dda400a9a12cae2c78James Dennett /// ones we are looking for. 10372dbaca748bc3eb6539f417bd8354c930bdf88fa4Argyrios Kyrtzidis serialization::PreprocessedEntityID 10382dbaca748bc3eb6539f417bd8354c930bdf88fa4Argyrios Kyrtzidis findNextPreprocessedEntity( 10392dbaca748bc3eb6539f417bd8354c930bdf88fa4Argyrios Kyrtzidis GlobalSLocOffsetMapType::const_iterator SLocMapI) const; 10402dbaca748bc3eb6539f417bd8354c930bdf88fa4Argyrios Kyrtzidis 10411824d54df85a462ada812dadda18130f951d40f3Dmitri Gribenko /// \brief Returns (ModuleFile, Local index) pair for \p GlobalIndex of a 1042f226ff9fe8c8db6c5b74a61ce649eda1491c3502Argyrios Kyrtzidis /// preprocessed entity. 10431a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor std::pair<ModuleFile *, unsigned> 1044f226ff9fe8c8db6c5b74a61ce649eda1491c3502Argyrios Kyrtzidis getModulePreprocessedEntity(unsigned GlobalIndex); 1045f226ff9fe8c8db6c5b74a61ce649eda1491c3502Argyrios Kyrtzidis 1046632dcc92f60ab7f806a89c5bca3a0951763a9219Argyrios Kyrtzidis /// \brief Returns (begin, end) pair for the preprocessed entities of a 1047632dcc92f60ab7f806a89c5bca3a0951763a9219Argyrios Kyrtzidis /// particular module. 1048632dcc92f60ab7f806a89c5bca3a0951763a9219Argyrios Kyrtzidis std::pair<PreprocessingRecord::iterator, PreprocessingRecord::iterator> 1049632dcc92f60ab7f806a89c5bca3a0951763a9219Argyrios Kyrtzidis getModulePreprocessedEntities(ModuleFile &Mod) const; 1050632dcc92f60ab7f806a89c5bca3a0951763a9219Argyrios Kyrtzidis 10512093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis class ModuleDeclIterator { 10522093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis ASTReader *Reader; 10532093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis ModuleFile *Mod; 10542093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis const serialization::LocalDeclID *Pos; 10552093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis 10562093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis public: 10572093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis typedef const Decl *value_type; 10582093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis typedef value_type& reference; 10592093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis typedef value_type* pointer; 10602093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis 10612093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis ModuleDeclIterator() : Reader(0), Mod(0), Pos(0) { } 10622093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis 10632093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis ModuleDeclIterator(ASTReader *Reader, ModuleFile *Mod, 10642093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis const serialization::LocalDeclID *Pos) 10652093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis : Reader(Reader), Mod(Mod), Pos(Pos) { } 10662093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis 10672093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis value_type operator*() const { 10682093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis return Reader->GetDecl(Reader->getGlobalDeclID(*Mod, *Pos)); 10692093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis } 10702093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis 10712093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis ModuleDeclIterator &operator++() { 10722093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis ++Pos; 10732093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis return *this; 10742093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis } 10752093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis 10762093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis ModuleDeclIterator operator++(int) { 10772093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis ModuleDeclIterator Prev(*this); 10782093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis ++Pos; 10792093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis return Prev; 10802093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis } 10812093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis 10822093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis ModuleDeclIterator &operator--() { 10832093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis --Pos; 10842093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis return *this; 10852093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis } 10862093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis 10872093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis ModuleDeclIterator operator--(int) { 10882093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis ModuleDeclIterator Prev(*this); 10892093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis --Pos; 10902093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis return Prev; 10912093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis } 10922093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis 10932093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis friend bool operator==(const ModuleDeclIterator &LHS, 10942093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis const ModuleDeclIterator &RHS) { 10952093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis assert(LHS.Reader == RHS.Reader && LHS.Mod == RHS.Mod); 10962093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis return LHS.Pos == RHS.Pos; 10972093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis } 10982093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis 10992093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis friend bool operator!=(const ModuleDeclIterator &LHS, 11002093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis const ModuleDeclIterator &RHS) { 11012093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis assert(LHS.Reader == RHS.Reader && LHS.Mod == RHS.Mod); 11022093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis return LHS.Pos != RHS.Pos; 11032093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis } 11042093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis }; 11052093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis 11062093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis std::pair<ModuleDeclIterator, ModuleDeclIterator> 11072093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis getModuleFileLevelDecls(ModuleFile &Mod); 11082093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis 1109bb80a8e8887c1ec74ee135d4ad9455eafedf1508Argyrios Kyrtzidis void PassInterestingDeclsToConsumer(); 11108d39c3ddfc17d9e768a17eb0ce9f11c33bf9d50aArgyrios Kyrtzidis void PassInterestingDeclToConsumer(Decl *D); 1111bb80a8e8887c1ec74ee135d4ad9455eafedf1508Argyrios Kyrtzidis 1112917078386b9b5113f33c093e296e10927b00b37eArgyrios Kyrtzidis void finishPendingActions(); 1113917078386b9b5113f33c093e296e10927b00b37eArgyrios Kyrtzidis 11140532df02a72a32a6042e961b71989db73d0d0a22Argyrios Kyrtzidis void pushExternalDeclIntoScope(NamedDecl *D, DeclarationName Name); 11150532df02a72a32a6042e961b71989db73d0d0a22Argyrios Kyrtzidis 11167640b02a561fd2b2c58a227b262b0c1ba93622aeArgyrios Kyrtzidis void addPendingDeclContextInfo(Decl *D, 11177640b02a561fd2b2c58a227b262b0c1ba93622aeArgyrios Kyrtzidis serialization::GlobalDeclID SemaDC, 11187640b02a561fd2b2c58a227b262b0c1ba93622aeArgyrios Kyrtzidis serialization::GlobalDeclID LexicalDC) { 11197640b02a561fd2b2c58a227b262b0c1ba93622aeArgyrios Kyrtzidis assert(D); 11207640b02a561fd2b2c58a227b262b0c1ba93622aeArgyrios Kyrtzidis PendingDeclContextInfo Info = { D, SemaDC, LexicalDC }; 11217640b02a561fd2b2c58a227b262b0c1ba93622aeArgyrios Kyrtzidis PendingDeclContextInfos.push_back(Info); 11227640b02a561fd2b2c58a227b262b0c1ba93622aeArgyrios Kyrtzidis } 11237640b02a561fd2b2c58a227b262b0c1ba93622aeArgyrios Kyrtzidis 1124a02b147b66ff9f1a22bac4ec7fd1b0d54a40e5bfDouglas Gregor /// \brief Produce an error diagnostic and return true. 1125a02b147b66ff9f1a22bac4ec7fd1b0d54a40e5bfDouglas Gregor /// 1126a02b147b66ff9f1a22bac4ec7fd1b0d54a40e5bfDouglas Gregor /// This routine should only be used for fatal errors that have to 11273c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// do with non-routine failures (e.g., corrupted AST file). 1128686775deca8b8685eb90801495880e3abdd844c2Chris Lattner void Error(StringRef Msg); 1129686775deca8b8685eb90801495880e3abdd844c2Chris Lattner void Error(unsigned DiagID, StringRef Arg1 = StringRef(), 1130686775deca8b8685eb90801495880e3abdd844c2Chris Lattner StringRef Arg2 = StringRef()); 1131a02b147b66ff9f1a22bac4ec7fd1b0d54a40e5bfDouglas Gregor 1132f56faa01936b9cf909623d7f06e3c2569ca4a78eDmitri Gribenko ASTReader(const ASTReader &) LLVM_DELETED_FUNCTION; 1133f56faa01936b9cf909623d7f06e3c2569ca4a78eDmitri Gribenko void operator=(const ASTReader &) LLVM_DELETED_FUNCTION; 11342cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregorpublic: 11353c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// \brief Load the AST file and validate its contents against the given 113611e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis /// Preprocessor. 1137e650c8c3bca2f58cad8ffa8aab63126d26e890cdDouglas Gregor /// 1138e650c8c3bca2f58cad8ffa8aab63126d26e890cdDouglas Gregor /// \param PP the preprocessor associated with the context in which this 1139e650c8c3bca2f58cad8ffa8aab63126d26e890cdDouglas Gregor /// precompiled header will be loaded. 1140e650c8c3bca2f58cad8ffa8aab63126d26e890cdDouglas Gregor /// 1141e650c8c3bca2f58cad8ffa8aab63126d26e890cdDouglas Gregor /// \param Context the AST context that this precompiled header will be 1142e650c8c3bca2f58cad8ffa8aab63126d26e890cdDouglas Gregor /// loaded into. 1143e650c8c3bca2f58cad8ffa8aab63126d26e890cdDouglas Gregor /// 1144e650c8c3bca2f58cad8ffa8aab63126d26e890cdDouglas Gregor /// \param isysroot If non-NULL, the system include path specified by the 1145e650c8c3bca2f58cad8ffa8aab63126d26e890cdDouglas Gregor /// user. This is only used with relocatable PCH files. If non-NULL, 1146e650c8c3bca2f58cad8ffa8aab63126d26e890cdDouglas Gregor /// a relocatable PCH file will use the default path "/". 1147fae3b2f4743dad616623c4df2fdb0f5128bd36d9Douglas Gregor /// 11483c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// \param DisableValidation If true, the AST reader will suppress most 1149fae3b2f4743dad616623c4df2fdb0f5128bd36d9Douglas Gregor /// of its regular consistency checking, allowing the use of precompiled 1150fae3b2f4743dad616623c4df2fdb0f5128bd36d9Douglas Gregor /// headers that cannot be determined to be compatible. 11518ef6c8cb6c5627240e2339fd7062c9873f821d7eDouglas Gregor /// 1152bef35c91b594f66216f4aab303b71a6c5ab7abcfArgyrios Kyrtzidis /// \param AllowASTWithCompilerErrors If true, the AST reader will accept an 1153bef35c91b594f66216f4aab303b71a6c5ab7abcfArgyrios Kyrtzidis /// AST file the was created out of an AST with compiler errors, 1154bef35c91b594f66216f4aab303b71a6c5ab7abcfArgyrios Kyrtzidis /// otherwise it will reject it. 1155f575d6e7c3b887ea4c5394d2c7e322c7a929a57eDouglas Gregor /// 1156f575d6e7c3b887ea4c5394d2c7e322c7a929a57eDouglas Gregor /// \param UseGlobalIndex If true, the AST reader will try to load and use 1157f575d6e7c3b887ea4c5394d2c7e322c7a929a57eDouglas Gregor /// the global module index. 1158f8a1e51c48761ee1d7803c3fa35ac94f42ebb55eDouglas Gregor ASTReader(Preprocessor &PP, ASTContext &Context, StringRef isysroot = "", 11594182ed686283b72736b287cbe28583cb641f8934Argyrios Kyrtzidis bool DisableValidation = false, 1160f575d6e7c3b887ea4c5394d2c7e322c7a929a57eDouglas Gregor bool AllowASTWithCompilerErrors = false, 1161f575d6e7c3b887ea4c5394d2c7e322c7a929a57eDouglas Gregor bool UseGlobalIndex = true); 11621eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1163c43b54cbc10654ed59de797898042e1a05265246Sebastian Redl ~ASTReader(); 11642cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor 11652dbaca748bc3eb6539f417bd8354c930bdf88fa4Argyrios Kyrtzidis SourceManager &getSourceManager() const { return SourceMgr; } 11661c1508b37bc2a9419b2e22beef9e788eb74203f4Argyrios Kyrtzidis FileManager &getFileManager() const { return FileMgr; } 1167ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 116838295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor /// \brief Flags that indicate what kind of AST loading failures the client 116938295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor /// of the AST reader can directly handle. 117038295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor /// 117138295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor /// When a client states that it can handle a particular kind of failure, 117238295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor /// the AST reader will not emit errors when producing that kind of failure. 117338295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor enum LoadFailureCapabilities { 117438295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor /// \brief The client can't handle any AST loading failures. 117538295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor ARR_None = 0, 117638295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor /// \brief The client can handle an AST file that cannot load because it 1177677e15ffee2ecc9c1c8f46fd77cab4b5afb59640Douglas Gregor /// is missing. 1178677e15ffee2ecc9c1c8f46fd77cab4b5afb59640Douglas Gregor ARR_Missing = 0x1, 1179677e15ffee2ecc9c1c8f46fd77cab4b5afb59640Douglas Gregor /// \brief The client can handle an AST file that cannot load because it 118038295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor /// is out-of-date relative to its input files. 1181677e15ffee2ecc9c1c8f46fd77cab4b5afb59640Douglas Gregor ARR_OutOfDate = 0x2, 118238295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor /// \brief The client can handle an AST file that cannot load because it 118338295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor /// was built with a different version of Clang. 1184677e15ffee2ecc9c1c8f46fd77cab4b5afb59640Douglas Gregor ARR_VersionMismatch = 0x4, 118538295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor /// \brief The client can handle an AST file that cannot load because it's 118638295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor /// compiled configuration doesn't match that of the context it was 118738295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor /// loaded into. 1188677e15ffee2ecc9c1c8f46fd77cab4b5afb59640Douglas Gregor ARR_ConfigurationMismatch = 0x8 118938295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor }; 119038295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor 119110bc00fd45824f9b5cd139d63af8b0f6d28aaddaDouglas Gregor /// \brief Load the AST file designated by the given file name. 119238295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor /// 119338295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor /// \param FileName The name of the AST file to load. 119438295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor /// 119538295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor /// \param Type The kind of AST being loaded, e.g., PCH, module, main file, 119638295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor /// or preamble. 119738295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor /// 1198958bcaf3d4e0c1ae46de3e84e7c2a7638c3c5286Argyrios Kyrtzidis /// \param ImportLoc the location where the module file will be considered as 1199958bcaf3d4e0c1ae46de3e84e7c2a7638c3c5286Argyrios Kyrtzidis /// imported from. For non-module AST types it should be invalid. 1200958bcaf3d4e0c1ae46de3e84e7c2a7638c3c5286Argyrios Kyrtzidis /// 120138295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor /// \param ClientLoadCapabilities The set of client load-failure 120238295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor /// capabilities, represented as a bitset of the enumerators of 120338295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor /// LoadFailureCapabilities. 120438295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor ASTReadResult ReadAST(const std::string &FileName, ModuleKind Type, 1205958bcaf3d4e0c1ae46de3e84e7c2a7638c3c5286Argyrios Kyrtzidis SourceLocation ImportLoc, 120638295beb73db5f90bfcf31625fb81dbc3b96290aDouglas Gregor unsigned ClientLoadCapabilities); 12071eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 12085e35693721364673f8196e4f5a370f56b92e6053Douglas Gregor /// \brief Make the entities in the given module and any of its (non-explicit) 12095e35693721364673f8196e4f5a370f56b92e6053Douglas Gregor /// submodules visible to name lookup. 12105e35693721364673f8196e4f5a370f56b92e6053Douglas Gregor /// 12115e35693721364673f8196e4f5a370f56b92e6053Douglas Gregor /// \param Mod The module whose names should be made visible. 12125e35693721364673f8196e4f5a370f56b92e6053Douglas Gregor /// 121316ae9de07730832945204877d752db7f1c070962James Dennett /// \param NameVisibility The level of visibility to give the names in the 121416ae9de07730832945204877d752db7f1c070962James Dennett /// module. Visibility can only be increased over time. 1215906d66acc5cf2679453e10a4f0a67feedd765b21Douglas Gregor /// 1216906d66acc5cf2679453e10a4f0a67feedd765b21Douglas Gregor /// \param ImportLoc The location at which the import occurs. 1217906d66acc5cf2679453e10a4f0a67feedd765b21Douglas Gregor /// 1218906d66acc5cf2679453e10a4f0a67feedd765b21Douglas Gregor /// \param Complain Whether to complain about conflicting module imports. 12195e35693721364673f8196e4f5a370f56b92e6053Douglas Gregor void makeModuleVisible(Module *Mod, 12205ebcb20b0331a6e64c213f0bb5f4bed9a9e8eb34Argyrios Kyrtzidis Module::NameVisibilityKind NameVisibility, 1221906d66acc5cf2679453e10a4f0a67feedd765b21Douglas Gregor SourceLocation ImportLoc, 1222906d66acc5cf2679453e10a4f0a67feedd765b21Douglas Gregor bool Complain); 12235e35693721364673f8196e4f5a370f56b92e6053Douglas Gregor 1224ecc2c090e7146c029dd9ee9a5a2fd66b275c01c0Douglas Gregor /// \brief Make the names within this set of hidden names visible. 122552151fd57eaf40603fa8f1cd34dcb4ad5f7701b3Argyrios Kyrtzidis void makeNamesVisible(const HiddenNames &Names, Module *Owner); 1226ecc2c090e7146c029dd9ee9a5a2fd66b275c01c0Douglas Gregor 12273c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// \brief Set the AST callbacks listener. 1228571db7f0cb31789737be92fce1c1b738e6dbe795Sebastian Redl void setListener(ASTReaderListener *listener) { 122911e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis Listener.reset(listener); 123011e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis } 12311eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 12323c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// \brief Set the AST deserialization listener. 1233571db7f0cb31789737be92fce1c1b738e6dbe795Sebastian Redl void setDeserializationListener(ASTDeserializationListener *Listener); 123430c514c225342844700ed4640ec6d90ddf0e12b2Sebastian Redl 12351a49d97d762570027863e9209af81d445e4f1502Douglas Gregor /// \brief Determine whether this AST reader has a global index. 12367247c88d1e41514a41085f83ebf03dd5220e054aDavid Blaikie bool hasGlobalIndex() const { return GlobalIndex.isValid(); } 12371a49d97d762570027863e9209af81d445e4f1502Douglas Gregor 12381a49d97d762570027863e9209af81d445e4f1502Douglas Gregor /// \brief Attempts to load the global index. 12391a49d97d762570027863e9209af81d445e4f1502Douglas Gregor /// 12401a49d97d762570027863e9209af81d445e4f1502Douglas Gregor /// \returns true if loading the global index has failed for any reason. 12411a49d97d762570027863e9209af81d445e4f1502Douglas Gregor bool loadGlobalIndex(); 12421a49d97d762570027863e9209af81d445e4f1502Douglas Gregor 12431a49d97d762570027863e9209af81d445e4f1502Douglas Gregor /// \brief Determine whether we tried to load the global index, but failed, 12441a49d97d762570027863e9209af81d445e4f1502Douglas Gregor /// e.g., because it is out-of-date or does not exist. 12451a49d97d762570027863e9209af81d445e4f1502Douglas Gregor bool isGlobalIndexUnavailable() const; 12461a49d97d762570027863e9209af81d445e4f1502Douglas Gregor 1247359427794704666ff7a5a933ace11c5256fa3af7Douglas Gregor /// \brief Initializes the ASTContext 1248359427794704666ff7a5a933ace11c5256fa3af7Douglas Gregor void InitializeContext(); 12492cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor 1250c24a1eef40207457692a1ad597cefdd0dc8fa149Jonathan D. Turner /// \brief Add in-memory (virtual file) buffer. 1251c24a1eef40207457692a1ad597cefdd0dc8fa149Jonathan D. Turner void addInMemoryBuffer(StringRef &FileName, llvm::MemoryBuffer *Buffer) { 1252c24a1eef40207457692a1ad597cefdd0dc8fa149Jonathan D. Turner ModuleMgr.addInMemoryBuffer(FileName, Buffer); 1253b0f4b9a558933b307073f7cd7753602f94354ae9Argyrios Kyrtzidis } 1254b0f4b9a558933b307073f7cd7753602f94354ae9Argyrios Kyrtzidis 1255ecc2c090e7146c029dd9ee9a5a2fd66b275c01c0Douglas Gregor /// \brief Finalizes the AST reader's state before writing an AST file to 1256ecc2c090e7146c029dd9ee9a5a2fd66b275c01c0Douglas Gregor /// disk. 1257ecc2c090e7146c029dd9ee9a5a2fd66b275c01c0Douglas Gregor /// 1258ecc2c090e7146c029dd9ee9a5a2fd66b275c01c0Douglas Gregor /// This operation may undo temporary state in the AST that should not be 1259ecc2c090e7146c029dd9ee9a5a2fd66b275c01c0Douglas Gregor /// emitted. 1260ecc2c090e7146c029dd9ee9a5a2fd66b275c01c0Douglas Gregor void finalizeForWriting(); 1261ecc2c090e7146c029dd9ee9a5a2fd66b275c01c0Douglas Gregor 1262e95b9198b8b70ce0219cfb89483b41102e02dbf5Douglas Gregor /// \brief Retrieve the module manager. 1263e95b9198b8b70ce0219cfb89483b41102e02dbf5Douglas Gregor ModuleManager &getModuleManager() { return ModuleMgr; } 1264e19944c93961b7618f4f3f3185f698f46369ea54Steve Naroff 1265d10a381d92a60d4f4c126c4e81045c8ad4636a0bDouglas Gregor /// \brief Retrieve the preprocessor. 1266712f2fcb70ae2eb0cb684d565e7d2cb76881006bDouglas Gregor Preprocessor &getPreprocessor() const { return PP; } 1267ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 126811407b89c9d7ce8bc31869b0a7aae06add49e3dcDouglas Gregor /// \brief Retrieve the name of the original source file name for the primary 126911407b89c9d7ce8bc31869b0a7aae06add49e3dcDouglas Gregor /// module file. 1270848bc3a5db57fb267e2b2541cb55e71dba4bf228Rafael Espindola StringRef getOriginalSourceFile() { 127111407b89c9d7ce8bc31869b0a7aae06add49e3dcDouglas Gregor return ModuleMgr.getPrimaryModule().OriginalSourceFileName; 127211407b89c9d7ce8bc31869b0a7aae06add49e3dcDouglas Gregor } 1273b64c19365deab788753d29c9bc881253c3f16f37Douglas Gregor 12743c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// \brief Retrieve the name of the original source file name directly from 12753c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// the AST file, without actually loading the AST file. 12763c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl static std::string getOriginalSourceFile(const std::string &ASTFileName, 1277389db16c63eec6ecfa9b235155252d8da766e94eArgyrios Kyrtzidis FileManager &FileMgr, 1278d6471f7c1921c7802804ce3ff6fe9768310f72b9David Blaikie DiagnosticsEngine &Diags); 1279b64c19365deab788753d29c9bc881253c3f16f37Douglas Gregor 12809e60371ba07faa2f173ab614ceaad0332518c8dcDouglas Gregor /// \brief Read the control block for the named AST file. 12819e60371ba07faa2f173ab614ceaad0332518c8dcDouglas Gregor /// 12829e60371ba07faa2f173ab614ceaad0332518c8dcDouglas Gregor /// \returns true if an error occurred, false otherwise. 12839e60371ba07faa2f173ab614ceaad0332518c8dcDouglas Gregor static bool readASTFileControlBlock(StringRef Filename, 12849e60371ba07faa2f173ab614ceaad0332518c8dcDouglas Gregor FileManager &FileMgr, 12859e60371ba07faa2f173ab614ceaad0332518c8dcDouglas Gregor ASTReaderListener &Listener); 12869e60371ba07faa2f173ab614ceaad0332518c8dcDouglas Gregor 128727ffa6caf965ef20fdef5ae23b81cdc3d05e7afbDouglas Gregor /// \brief Determine whether the given AST file is acceptable to load into a 128827ffa6caf965ef20fdef5ae23b81cdc3d05e7afbDouglas Gregor /// translation unit with the given language and target options. 128927ffa6caf965ef20fdef5ae23b81cdc3d05e7afbDouglas Gregor static bool isAcceptableASTFile(StringRef Filename, 129027ffa6caf965ef20fdef5ae23b81cdc3d05e7afbDouglas Gregor FileManager &FileMgr, 129127ffa6caf965ef20fdef5ae23b81cdc3d05e7afbDouglas Gregor const LangOptions &LangOpts, 12924c0c7e86645dfa1719d17d70e009ab49347aba62Douglas Gregor const TargetOptions &TargetOpts, 12934c0c7e86645dfa1719d17d70e009ab49347aba62Douglas Gregor const PreprocessorOptions &PPOpts); 129427ffa6caf965ef20fdef5ae23b81cdc3d05e7afbDouglas Gregor 1295e721f95069d42b899c20c1caabdc6184dd42b820Douglas Gregor /// \brief Returns the suggested contents of the predefines buffer, 1296e721f95069d42b899c20c1caabdc6184dd42b820Douglas Gregor /// which contains a (typically-empty) subset of the predefines 1297e721f95069d42b899c20c1caabdc6184dd42b820Douglas Gregor /// build prior to including the precompiled header. 1298e721f95069d42b899c20c1caabdc6184dd42b820Douglas Gregor const std::string &getSuggestedPredefines() { return SuggestedPredefines; } 1299e24692b30adbe8144597678a0e3354912e99c747Argyrios Kyrtzidis 1300e24692b30adbe8144597678a0e3354912e99c747Argyrios Kyrtzidis /// \brief Read a preallocated preprocessed entity from the external source. 1301e24692b30adbe8144597678a0e3354912e99c747Argyrios Kyrtzidis /// 1302e24692b30adbe8144597678a0e3354912e99c747Argyrios Kyrtzidis /// \returns null if an error occurred that prevented the preprocessed 1303e24692b30adbe8144597678a0e3354912e99c747Argyrios Kyrtzidis /// entity from being loaded. 1304e24692b30adbe8144597678a0e3354912e99c747Argyrios Kyrtzidis virtual PreprocessedEntity *ReadPreprocessedEntity(unsigned Index); 1305e721f95069d42b899c20c1caabdc6184dd42b820Douglas Gregor 13062dbaca748bc3eb6539f417bd8354c930bdf88fa4Argyrios Kyrtzidis /// \brief Returns a pair of [Begin, End) indices of preallocated 13071824d54df85a462ada812dadda18130f951d40f3Dmitri Gribenko /// preprocessed entities that \p Range encompasses. 13082dbaca748bc3eb6539f417bd8354c930bdf88fa4Argyrios Kyrtzidis virtual std::pair<unsigned, unsigned> 13092dbaca748bc3eb6539f417bd8354c930bdf88fa4Argyrios Kyrtzidis findPreprocessedEntitiesInRange(SourceRange Range); 1310ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1311f226ff9fe8c8db6c5b74a61ce649eda1491c3502Argyrios Kyrtzidis /// \brief Optionally returns true or false if the preallocated preprocessed 13121824d54df85a462ada812dadda18130f951d40f3Dmitri Gribenko /// entity with index \p Index came from file \p FID. 1313dc84cd5efdd3430efb22546b4ac656aa0540b210David Blaikie virtual Optional<bool> isPreprocessedEntityInFileID(unsigned Index, 1314dc84cd5efdd3430efb22546b4ac656aa0540b210David Blaikie FileID FID); 13152dbaca748bc3eb6539f417bd8354c930bdf88fa4Argyrios Kyrtzidis 1316cfbf1c7536e016dc275139dd842d4a5f059a749fDouglas Gregor /// \brief Read the header file information for the given file entry. 1317cfbf1c7536e016dc275139dd842d4a5f059a749fDouglas Gregor virtual HeaderFileInfo GetHeaderFileInfo(const FileEntry *FE); 1318cfbf1c7536e016dc275139dd842d4a5f059a749fDouglas Gregor 1319d6471f7c1921c7802804ce3ff6fe9768310f72b9David Blaikie void ReadPragmaDiagnosticMappings(DiagnosticsEngine &Diag); 1320f41d3be39980d40849850d3fb90403623cc8459eArgyrios Kyrtzidis 1321f2f0f03d08c6143137a79a8edffc7d41823bc3c7Sebastian Redl /// \brief Returns the number of source locations found in the chain. 13220fa7d0b15ea2a224bfe43ac745d411f915da87ddSebastian Redl unsigned getTotalNumSLocs() const { 13230fa7d0b15ea2a224bfe43ac745d411f915da87ddSebastian Redl return TotalNumSLocEntries; 13240fa7d0b15ea2a224bfe43ac745d411f915da87ddSebastian Redl } 13250fa7d0b15ea2a224bfe43ac745d411f915da87ddSebastian Redl 1326f2f0f03d08c6143137a79a8edffc7d41823bc3c7Sebastian Redl /// \brief Returns the number of identifiers found in the chain. 1327f2f0f03d08c6143137a79a8edffc7d41823bc3c7Sebastian Redl unsigned getTotalNumIdentifiers() const { 1328f2f0f03d08c6143137a79a8edffc7d41823bc3c7Sebastian Redl return static_cast<unsigned>(IdentifiersLoaded.size()); 1329f2f0f03d08c6143137a79a8edffc7d41823bc3c7Sebastian Redl } 1330f2f0f03d08c6143137a79a8edffc7d41823bc3c7Sebastian Redl 1331a8235d6c4093cd38dcf742909651f867de62e55bDouglas Gregor /// \brief Returns the number of macros found in the chain. 1332a8235d6c4093cd38dcf742909651f867de62e55bDouglas Gregor unsigned getTotalNumMacros() const { 1333a8235d6c4093cd38dcf742909651f867de62e55bDouglas Gregor return static_cast<unsigned>(MacrosLoaded.size()); 1334a8235d6c4093cd38dcf742909651f867de62e55bDouglas Gregor } 1335a8235d6c4093cd38dcf742909651f867de62e55bDouglas Gregor 1336e58aa890e8de55bb3146e6ea9fbbba3a58ce30c6Sebastian Redl /// \brief Returns the number of types found in the chain. 133777a3c9ede5cdb26b5eb3001e82bb0a36ca997e1fSebastian Redl unsigned getTotalNumTypes() const { 133877a3c9ede5cdb26b5eb3001e82bb0a36ca997e1fSebastian Redl return static_cast<unsigned>(TypesLoaded.size()); 133977a3c9ede5cdb26b5eb3001e82bb0a36ca997e1fSebastian Redl } 134077a3c9ede5cdb26b5eb3001e82bb0a36ca997e1fSebastian Redl 1341e58aa890e8de55bb3146e6ea9fbbba3a58ce30c6Sebastian Redl /// \brief Returns the number of declarations found in the chain. 134277a3c9ede5cdb26b5eb3001e82bb0a36ca997e1fSebastian Redl unsigned getTotalNumDecls() const { 134377a3c9ede5cdb26b5eb3001e82bb0a36ca997e1fSebastian Redl return static_cast<unsigned>(DeclsLoaded.size()); 134477a3c9ede5cdb26b5eb3001e82bb0a36ca997e1fSebastian Redl } 134577a3c9ede5cdb26b5eb3001e82bb0a36ca997e1fSebastian Redl 134626ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor /// \brief Returns the number of submodules known. 134726ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor unsigned getTotalNumSubmodules() const { 134826ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor return static_cast<unsigned>(SubmodulesLoaded.size()); 134926ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor } 135026ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor 1351e58aa890e8de55bb3146e6ea9fbbba3a58ce30c6Sebastian Redl /// \brief Returns the number of selectors found in the chain. 1352e58aa890e8de55bb3146e6ea9fbbba3a58ce30c6Sebastian Redl unsigned getTotalNumSelectors() const { 1353e58aa890e8de55bb3146e6ea9fbbba3a58ce30c6Sebastian Redl return static_cast<unsigned>(SelectorsLoaded.size()); 1354e58aa890e8de55bb3146e6ea9fbbba3a58ce30c6Sebastian Redl } 1355e58aa890e8de55bb3146e6ea9fbbba3a58ce30c6Sebastian Redl 13564c30bb148b53c8063e940ca3e049ba4d270dc9d5Douglas Gregor /// \brief Returns the number of preprocessed entities known to the AST 13574c30bb148b53c8063e940ca3e049ba4d270dc9d5Douglas Gregor /// reader. 13584c30bb148b53c8063e940ca3e049ba4d270dc9d5Douglas Gregor unsigned getTotalNumPreprocessedEntities() const { 13594c30bb148b53c8063e940ca3e049ba4d270dc9d5Douglas Gregor unsigned Result = 0; 13605d6d89fef8c7fff8b1a67c943fb5557a2a803468Jonathan D. Turner for (ModuleConstIterator I = ModuleMgr.begin(), 13615d6d89fef8c7fff8b1a67c943fb5557a2a803468Jonathan D. Turner E = ModuleMgr.end(); I != E; ++I) { 1362e24692b30adbe8144597678a0e3354912e99c747Argyrios Kyrtzidis Result += (*I)->NumPreprocessedEntities; 13635d6d89fef8c7fff8b1a67c943fb5557a2a803468Jonathan D. Turner } 1364ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 13654c30bb148b53c8063e940ca3e049ba4d270dc9d5Douglas Gregor return Result; 13664c30bb148b53c8063e940ca3e049ba4d270dc9d5Douglas Gregor } 1367ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 13687c789c1a3f77f24032aa0bed2afacdb9e094e952Douglas Gregor /// \brief Returns the number of C++ base specifiers found in the chain. 13691da901467f72d1733704b068e22089813a1962fdJonathan D. Turner unsigned getTotalNumCXXBaseSpecifiers() const { 13701da901467f72d1733704b068e22089813a1962fdJonathan D. Turner return NumCXXBaseSpecifiersLoaded; 13711da901467f72d1733704b068e22089813a1962fdJonathan D. Turner } 1372ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1373833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall /// \brief Reads a TemplateArgumentLocInfo appropriate for the 1374833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall /// given TemplateArgument kind. 1375833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall TemplateArgumentLocInfo 13761a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor GetTemplateArgumentLocInfo(ModuleFile &F, TemplateArgument::ArgKind Kind, 1377833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall const RecordData &Record, unsigned &Idx); 1378833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 137944f8c37e378f716e8cbb600e3800f437cf58f9e5Argyrios Kyrtzidis /// \brief Reads a TemplateArgumentLoc. 1380577d4796d358c0e72ebaa023113505226ab51b4fSebastian Redl TemplateArgumentLoc 13811a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor ReadTemplateArgumentLoc(ModuleFile &F, 1382577d4796d358c0e72ebaa023113505226ab51b4fSebastian Redl const RecordData &Record, unsigned &Idx); 138344f8c37e378f716e8cbb600e3800f437cf58f9e5Argyrios Kyrtzidis 1384a1ee0c548b8aa4aaf93d1917e304e3da13171a08John McCall /// \brief Reads a declarator info from the given record. 13851a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor TypeSourceInfo *GetTypeSourceInfo(ModuleFile &F, 1386577d4796d358c0e72ebaa023113505226ab51b4fSebastian Redl const RecordData &Record, unsigned &Idx); 1387a1ee0c548b8aa4aaf93d1917e304e3da13171a08John McCall 13882cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor /// \brief Resolve a type ID into a type, potentially building a new 13892cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor /// type. 13908538e8d43a3a9bd439c987c0de37bcbf035dd391Sebastian Redl QualType GetType(serialization::TypeID ID); 13912cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor 1392393f249399fe30e9580e1529a7479489e90f3a57Douglas Gregor /// \brief Resolve a local type ID within a given AST file into a type. 13931a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor QualType getLocalType(ModuleFile &F, unsigned LocalID); 1394ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1395393f249399fe30e9580e1529a7479489e90f3a57Douglas Gregor /// \brief Map a local type ID within a given AST file into a global type ID. 13961a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor serialization::TypeID getGlobalTypeID(ModuleFile &F, unsigned LocalID) const; 1397ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1398ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie /// \brief Read a type from the current position in the given record, which 1399393f249399fe30e9580e1529a7479489e90f3a57Douglas Gregor /// was read from the given AST file. 14001a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor QualType readType(ModuleFile &F, const RecordData &Record, unsigned &Idx) { 1401393f249399fe30e9580e1529a7479489e90f3a57Douglas Gregor if (Idx >= Record.size()) 1402393f249399fe30e9580e1529a7479489e90f3a57Douglas Gregor return QualType(); 1403ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1404393f249399fe30e9580e1529a7479489e90f3a57Douglas Gregor return getLocalType(F, Record[Idx++]); 1405393f249399fe30e9580e1529a7479489e90f3a57Douglas Gregor } 1406ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1407ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie /// \brief Map from a local declaration ID within a given module to a 1408409448c832d27703146b70a1137d86b020f29863Douglas Gregor /// global declaration ID. 14092093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis serialization::DeclID getGlobalDeclID(ModuleFile &F, 14102093e0bc4e436b1b2791d5423fb3274dd37231b8Argyrios Kyrtzidis serialization::LocalDeclID LocalID) const; 1411e6b8d68a927368b06ac06cc9ac9e7f60aa966d5fArgyrios Kyrtzidis 14121824d54df85a462ada812dadda18130f951d40f3Dmitri Gribenko /// \brief Returns true if global DeclID \p ID originated from module \p M. 14131a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor bool isDeclIDFromModule(serialization::GlobalDeclID ID, ModuleFile &M) const; 1414dfb332d0081c6641d1dbae6a2aeff757c99cc740Argyrios Kyrtzidis 1415cff9f26ce0ed76d555cd33b3dca84dd5cdf376afDouglas Gregor /// \brief Retrieve the module file that owns the given declaration, or NULL 1416cff9f26ce0ed76d555cd33b3dca84dd5cdf376afDouglas Gregor /// if the declaration is not from a module file. 14175a04f9fc2b000da98fd903c8156034304bdadb2fDouglas Gregor ModuleFile *getOwningModuleFile(const Decl *D); 1418cff9f26ce0ed76d555cd33b3dca84dd5cdf376afDouglas Gregor 14191824d54df85a462ada812dadda18130f951d40f3Dmitri Gribenko /// \brief Returns the source location for the decl \p ID. 1420dfb332d0081c6641d1dbae6a2aeff757c99cc740Argyrios Kyrtzidis SourceLocation getSourceLocationForDeclID(serialization::GlobalDeclID ID); 1421ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 14222cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor /// \brief Resolve a declaration ID into a declaration, potentially 14232cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor /// building a new declaration. 14248538e8d43a3a9bd439c987c0de37bcbf035dd391Sebastian Redl Decl *GetDecl(serialization::DeclID ID); 142576bd1f387e6a7b7abfe53f63b3bd429b97bb80f0John McCall virtual Decl *GetExternalDecl(uint32_t ID); 14262cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor 142743fd9388d374f29e908e611a686c6137553efa79Jonathan D. Turner /// \brief Reads a declaration with the given local ID in the given module. 14281a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor Decl *GetLocalDecl(ModuleFile &F, uint32_t LocalID) { 1429409448c832d27703146b70a1137d86b020f29863Douglas Gregor return GetDecl(getGlobalDeclID(F, LocalID)); 1430409448c832d27703146b70a1137d86b020f29863Douglas Gregor } 1431409448c832d27703146b70a1137d86b020f29863Douglas Gregor 143243fd9388d374f29e908e611a686c6137553efa79Jonathan D. Turner /// \brief Reads a declaration with the given local ID in the given module. 1433409448c832d27703146b70a1137d86b020f29863Douglas Gregor /// 1434409448c832d27703146b70a1137d86b020f29863Douglas Gregor /// \returns The requested declaration, casted to the given return type. 1435409448c832d27703146b70a1137d86b020f29863Douglas Gregor template<typename T> 14361a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor T *GetLocalDeclAs(ModuleFile &F, uint32_t LocalID) { 1437409448c832d27703146b70a1137d86b020f29863Douglas Gregor return cast_or_null<T>(GetLocalDecl(F, LocalID)); 1438409448c832d27703146b70a1137d86b020f29863Douglas Gregor } 1439409448c832d27703146b70a1137d86b020f29863Douglas Gregor 1440a1be278c4f3a234ff61f04018d26c6beecde1654Douglas Gregor /// \brief Map a global declaration ID into the declaration ID used to 1441a1be278c4f3a234ff61f04018d26c6beecde1654Douglas Gregor /// refer to this declaration within the given module fule. 1442a1be278c4f3a234ff61f04018d26c6beecde1654Douglas Gregor /// 1443a1be278c4f3a234ff61f04018d26c6beecde1654Douglas Gregor /// \returns the global ID of the given declaration as known in the given 1444a1be278c4f3a234ff61f04018d26c6beecde1654Douglas Gregor /// module file. 1445a1be278c4f3a234ff61f04018d26c6beecde1654Douglas Gregor serialization::DeclID 1446a1be278c4f3a234ff61f04018d26c6beecde1654Douglas Gregor mapGlobalIDToModuleFileGlobalID(ModuleFile &M, 1447a1be278c4f3a234ff61f04018d26c6beecde1654Douglas Gregor serialization::DeclID GlobalID); 1448a1be278c4f3a234ff61f04018d26c6beecde1654Douglas Gregor 1449ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie /// \brief Reads a declaration ID from the given position in a record in the 1450409448c832d27703146b70a1137d86b020f29863Douglas Gregor /// given module. 1451409448c832d27703146b70a1137d86b020f29863Douglas Gregor /// 1452409448c832d27703146b70a1137d86b020f29863Douglas Gregor /// \returns The declaration ID read from the record, adjusted to a global ID. 14531a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor serialization::DeclID ReadDeclID(ModuleFile &F, const RecordData &Record, 1454409448c832d27703146b70a1137d86b020f29863Douglas Gregor unsigned &Idx); 1455ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1456409448c832d27703146b70a1137d86b020f29863Douglas Gregor /// \brief Reads a declaration from the given position in a record in the 1457409448c832d27703146b70a1137d86b020f29863Douglas Gregor /// given module. 14581a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor Decl *ReadDecl(ModuleFile &F, const RecordData &R, unsigned &I) { 1459409448c832d27703146b70a1137d86b020f29863Douglas Gregor return GetDecl(ReadDeclID(F, R, I)); 1460409448c832d27703146b70a1137d86b020f29863Douglas Gregor } 1461ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1462409448c832d27703146b70a1137d86b020f29863Douglas Gregor /// \brief Reads a declaration from the given position in a record in the 1463409448c832d27703146b70a1137d86b020f29863Douglas Gregor /// given module. 1464409448c832d27703146b70a1137d86b020f29863Douglas Gregor /// 1465409448c832d27703146b70a1137d86b020f29863Douglas Gregor /// \returns The declaration read from this location, casted to the given 1466409448c832d27703146b70a1137d86b020f29863Douglas Gregor /// result type. 1467409448c832d27703146b70a1137d86b020f29863Douglas Gregor template<typename T> 14681a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor T *ReadDeclAs(ModuleFile &F, const RecordData &R, unsigned &I) { 1469409448c832d27703146b70a1137d86b020f29863Douglas Gregor return cast_or_null<T>(GetDecl(ReadDeclID(F, R, I))); 1470409448c832d27703146b70a1137d86b020f29863Douglas Gregor } 1471409448c832d27703146b70a1137d86b020f29863Douglas Gregor 1472e92b8a1dbba150e213c4980710fcb59ec5c5c570Douglas Gregor /// \brief Read a CXXBaseSpecifiers ID form the given record and 1473e92b8a1dbba150e213c4980710fcb59ec5c5c570Douglas Gregor /// return its global bit offset. 14741a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor uint64_t readCXXBaseSpecifiers(ModuleFile &M, const RecordData &Record, 1475e92b8a1dbba150e213c4980710fcb59ec5c5c570Douglas Gregor unsigned &Idx); 1476ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 14777c789c1a3f77f24032aa0bed2afacdb9e094e952Douglas Gregor virtual CXXBaseSpecifier *GetExternalCXXBaseSpecifiers(uint64_t Offset); 1478ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1479250fc9c859fdeed3f200ae911a7e7ea338f38436Douglas Gregor /// \brief Resolve the offset of a statement into a statement. 1480250fc9c859fdeed3f200ae911a7e7ea338f38436Douglas Gregor /// 1481250fc9c859fdeed3f200ae911a7e7ea338f38436Douglas Gregor /// This operation will read a new statement from the external 1482250fc9c859fdeed3f200ae911a7e7ea338f38436Douglas Gregor /// source each time it is called, and is meant to be used via a 1483887e2b375fc5e00084ec7bf3dd050c2ca399a6d2Chris Lattner /// LazyOffsetPtr (which is used by Decls for the body of functions, etc). 148476bd1f387e6a7b7abfe53f63b3bd429b97bb80f0John McCall virtual Stmt *GetExternalDeclStmt(uint64_t Offset); 1485250fc9c859fdeed3f200ae911a7e7ea338f38436Douglas Gregor 14866367f6d06308ef29c28d2c1604ded45625caeec9Chris Lattner /// ReadBlockAbbrevs - Enter a subblock of the specified BlockID with the 14876367f6d06308ef29c28d2c1604ded45625caeec9Chris Lattner /// specified cursor. Read the abbreviations that are at the top of the block 14886367f6d06308ef29c28d2c1604ded45625caeec9Chris Lattner /// and then leave the cursor pointing into the block. 14896367f6d06308ef29c28d2c1604ded45625caeec9Chris Lattner bool ReadBlockAbbrevs(llvm::BitstreamCursor &Cursor, unsigned BlockID); 14906367f6d06308ef29c28d2c1604ded45625caeec9Chris Lattner 149176bd1f387e6a7b7abfe53f63b3bd429b97bb80f0John McCall /// \brief Finds all the visible declarations with a given name. 149276bd1f387e6a7b7abfe53f63b3bd429b97bb80f0John McCall /// The current implementation of this method just loads the entire 149376bd1f387e6a7b7abfe53f63b3bd429b97bb80f0John McCall /// lookup table as unmaterialized references. 14943646c68676c3c46a026b23d52188ef6e0d856178Richard Smith virtual bool 149576bd1f387e6a7b7abfe53f63b3bd429b97bb80f0John McCall FindExternalVisibleDeclsByName(const DeclContext *DC, 149676bd1f387e6a7b7abfe53f63b3bd429b97bb80f0John McCall DeclarationName Name); 149776bd1f387e6a7b7abfe53f63b3bd429b97bb80f0John McCall 14982cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor /// \brief Read all of the declarations lexically stored in a 14992cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor /// declaration context. 15002cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor /// 15012cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor /// \param DC The declaration context whose declarations will be 15022cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor /// read. 15032cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor /// 15042cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor /// \param Decls Vector that will contain the declarations loaded 15052cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor /// from the external source. The caller is responsible for merging 15062cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor /// these declarations with any declarations already stored in the 15072cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor /// declaration context. 15082cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor /// 15092cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor /// \returns true if there was an error while reading the 15102cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor /// declarations for this declaration context. 1511ba6ffaf21e465c0926d7fc5fa294ea52f8d45fafDouglas Gregor virtual ExternalLoadResult FindExternalLexicalDecls(const DeclContext *DC, 1512eb5e9986e577b1e2bff3cca5973a2494fb593fbbArgyrios Kyrtzidis bool (*isKindWeWant)(Decl::Kind), 1513686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVectorImpl<Decl*> &Decls); 15142cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor 1515dfb332d0081c6641d1dbae6a2aeff757c99cc740Argyrios Kyrtzidis /// \brief Get the decls that are contained in a file in the Offset/Length 15161824d54df85a462ada812dadda18130f951d40f3Dmitri Gribenko /// range. \p Length can be 0 to indicate a point at \p Offset instead of 1517ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie /// a range. 1518dfb332d0081c6641d1dbae6a2aeff757c99cc740Argyrios Kyrtzidis virtual void FindFileRegionDecls(FileID File, unsigned Offset,unsigned Length, 1519dfb332d0081c6641d1dbae6a2aeff757c99cc740Argyrios Kyrtzidis SmallVectorImpl<Decl *> &Decls); 1520dfb332d0081c6641d1dbae6a2aeff757c99cc740Argyrios Kyrtzidis 1521c43b54cbc10654ed59de797898042e1a05265246Sebastian Redl /// \brief Notify ASTReader that we started deserialization of 152229ee3a273f58e16df7f2c524ab62a869e44fc9b1Argyrios Kyrtzidis /// a decl or type so until FinishedDeserializing is called there may be 152329ee3a273f58e16df7f2c524ab62a869e44fc9b1Argyrios Kyrtzidis /// decls that are initializing. Must be paired with FinishedDeserializing. 152429ee3a273f58e16df7f2c524ab62a869e44fc9b1Argyrios Kyrtzidis virtual void StartedDeserializing() { ++NumCurrentElementsDeserializing; } 152529ee3a273f58e16df7f2c524ab62a869e44fc9b1Argyrios Kyrtzidis 1526c43b54cbc10654ed59de797898042e1a05265246Sebastian Redl /// \brief Notify ASTReader that we finished the deserialization of 152729ee3a273f58e16df7f2c524ab62a869e44fc9b1Argyrios Kyrtzidis /// a decl or type. Must be paired with StartedDeserializing. 152829ee3a273f58e16df7f2c524ab62a869e44fc9b1Argyrios Kyrtzidis virtual void FinishedDeserializing(); 152929ee3a273f58e16df7f2c524ab62a869e44fc9b1Argyrios Kyrtzidis 1530fdd0172ca1b3c837f8c2b37d69cc2085234e09faDouglas Gregor /// \brief Function that will be invoked when we begin parsing a new 1531fdd0172ca1b3c837f8c2b37d69cc2085234e09faDouglas Gregor /// translation unit involving this external AST source. 1532fdd0172ca1b3c837f8c2b37d69cc2085234e09faDouglas Gregor /// 1533fdd0172ca1b3c837f8c2b37d69cc2085234e09faDouglas Gregor /// This function will provide all of the external definitions to 1534fdd0172ca1b3c837f8c2b37d69cc2085234e09faDouglas Gregor /// the ASTConsumer. 1535fdd0172ca1b3c837f8c2b37d69cc2085234e09faDouglas Gregor virtual void StartTranslationUnit(ASTConsumer *Consumer); 1536fdd0172ca1b3c837f8c2b37d69cc2085234e09faDouglas Gregor 15373c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// \brief Print some statistics about AST usage. 15382cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor virtual void PrintStats(); 15392cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor 154023d7df5ce30f4a068e13ad6cb81d473365d260dbDouglas Gregor /// \brief Dump information about the AST reader to standard error. 154123d7df5ce30f4a068e13ad6cb81d473365d260dbDouglas Gregor void dump(); 1542ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1543e9b5f3d4acfc2ad6e8b65a4072464e997dea9ed3Ted Kremenek /// Return the amount of memory used by memory buffers, breaking down 1544e9b5f3d4acfc2ad6e8b65a4072464e997dea9ed3Ted Kremenek /// by heap-backed versus mmap'ed memory. 1545e9b5f3d4acfc2ad6e8b65a4072464e997dea9ed3Ted Kremenek virtual void getMemoryBufferSizes(MemoryBufferSizes &sizes) const; 1546e9b5f3d4acfc2ad6e8b65a4072464e997dea9ed3Ted Kremenek 1547668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor /// \brief Initialize the semantic source with the Sema instance 1548668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor /// being used to perform semantic analysis on the abstract syntax 1549668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor /// tree. 1550668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor virtual void InitializeSema(Sema &S); 1551668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor 1552ec2a4ed278a1112ebf84fdcb80ed66f53d8ec8baDaniel Dunbar /// \brief Inform the semantic consumer that Sema is no longer available. 1553ec2a4ed278a1112ebf84fdcb80ed66f53d8ec8baDaniel Dunbar virtual void ForgetSema() { SemaObj = 0; } 1554ec2a4ed278a1112ebf84fdcb80ed66f53d8ec8baDaniel Dunbar 1555668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor /// \brief Retrieve the IdentifierInfo for the named identifier. 1556668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor /// 15574d5936aaa4e4e2d41fe79101ac9c09444951448fDaniel Dunbar /// This routine builds a new IdentifierInfo for the given identifier. If any 15584d5936aaa4e4e2d41fe79101ac9c09444951448fDaniel Dunbar /// declarations with this name are visible from translation unit scope, their 15594d5936aaa4e4e2d41fe79101ac9c09444951448fDaniel Dunbar /// declarations will be deserialized and introduced into the declaration 156088a35862fbe473f2a4f0c19f24dbe536937e1dc6Douglas Gregor /// chain of the identifier. 1561d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner virtual IdentifierInfo *get(const char *NameStart, const char *NameEnd); 1562686775deca8b8685eb90801495880e3abdd844c2Chris Lattner IdentifierInfo *get(StringRef Name) { 15634d5936aaa4e4e2d41fe79101ac9c09444951448fDaniel Dunbar return get(Name.begin(), Name.end()); 15644d5936aaa4e4e2d41fe79101ac9c09444951448fDaniel Dunbar } 1565668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor 156695f4292cc526c629fead321c7fcfd4fe0f3bc66eDouglas Gregor /// \brief Retrieve an iterator into the set of all identifiers 156795f4292cc526c629fead321c7fcfd4fe0f3bc66eDouglas Gregor /// in all loaded AST files. 156887f9d81d0ab806dcf6ca50a0c068dcb2ba7f51b3Argyrios Kyrtzidis virtual IdentifierIterator *getIdentifiers(); 156995f4292cc526c629fead321c7fcfd4fe0f3bc66eDouglas Gregor 1570f0aaf7a59729a4ae0146e3464ee987745be95829Douglas Gregor /// \brief Load the contents of the global method pool for a given 1571f0aaf7a59729a4ae0146e3464ee987745be95829Douglas Gregor /// selector. 15725ac4b6917aa34fae6da64036539023a6155a3d48Douglas Gregor virtual void ReadMethodPool(Selector Sel); 1573f0aaf7a59729a4ae0146e3464ee987745be95829Douglas Gregor 1574d8bba9c15230d2b1b3893e272106aa79efc50251Douglas Gregor /// \brief Load the set of namespaces that are known to the external source, 1575d8bba9c15230d2b1b3893e272106aa79efc50251Douglas Gregor /// which will be used during typo correction. 1576d8bba9c15230d2b1b3893e272106aa79efc50251Douglas Gregor virtual void ReadKnownNamespaces( 1577686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVectorImpl<NamespaceDecl *> &Namespaces); 1578d8bba9c15230d2b1b3893e272106aa79efc50251Douglas Gregor 1579cd0655b17249c4c4908ca91462657f62285017e6Nick Lewycky virtual void ReadUndefinedButUsed( 1580995e26b0523ac8e3b6199a509b871b81fa5df6eeNick Lewycky llvm::DenseMap<NamedDecl *, SourceLocation> &Undefined); 158101a41140cd8ec9475ed0c33384310fbdd3b6de11Nick Lewycky 1582a862320972e63349524dc9aa744dec1b95f54ba1Douglas Gregor virtual void ReadTentativeDefinitions( 1583a862320972e63349524dc9aa744dec1b95f54ba1Douglas Gregor SmallVectorImpl<VarDecl *> &TentativeDefs); 1584a862320972e63349524dc9aa744dec1b95f54ba1Douglas Gregor 1585a2ee20aa9660851080135219cac5b31fbac08b78Douglas Gregor virtual void ReadUnusedFileScopedDecls( 1586a2ee20aa9660851080135219cac5b31fbac08b78Douglas Gregor SmallVectorImpl<const DeclaratorDecl *> &Decls); 1587a2ee20aa9660851080135219cac5b31fbac08b78Douglas Gregor 15880129b561a1452bf057f6b18b6a1de815d487ab81Douglas Gregor virtual void ReadDelegatingConstructors( 15890129b561a1452bf057f6b18b6a1de815d487ab81Douglas Gregor SmallVectorImpl<CXXConstructorDecl *> &Decls); 15900129b561a1452bf057f6b18b6a1de815d487ab81Douglas Gregor 1591d58a0a55e64a7c410a80e9d6dcd899e61e99cc4dDouglas Gregor virtual void ReadExtVectorDecls(SmallVectorImpl<TypedefNameDecl *> &Decls); 1592d58a0a55e64a7c410a80e9d6dcd899e61e99cc4dDouglas Gregor 1593a126f17ca83b985300c1f65cee647bea108db657Douglas Gregor virtual void ReadDynamicClasses(SmallVectorImpl<CXXRecordDecl *> &Decls); 1594a126f17ca83b985300c1f65cee647bea108db657Douglas Gregor 15955ea6ef490547917426d5e2ed14c9f36521bbeacfRichard Smith virtual void ReadLocallyScopedExternCDecls( 1596ec12ce2f6da44bfc9048772327a3924498099d60Douglas Gregor SmallVectorImpl<NamedDecl *> &Decls); 1597ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 15985b9dc7caaef0469babc45dd8e713727a136ce517Douglas Gregor virtual void ReadReferencedSelectors( 15995b9dc7caaef0469babc45dd8e713727a136ce517Douglas Gregor SmallVectorImpl<std::pair<Selector, SourceLocation> > &Sels); 16005b9dc7caaef0469babc45dd8e713727a136ce517Douglas Gregor 160131e37b2d7b4815fdea6a35d49f33005562f0d494Douglas Gregor virtual void ReadWeakUndeclaredIdentifiers( 160231e37b2d7b4815fdea6a35d49f33005562f0d494Douglas Gregor SmallVectorImpl<std::pair<IdentifierInfo *, WeakInfo> > &WI); 160331e37b2d7b4815fdea6a35d49f33005562f0d494Douglas Gregor 1604dfe6543e12eca5c79421378b7fa6b3e8fc403e63Douglas Gregor virtual void ReadUsedVTables(SmallVectorImpl<ExternalVTableUse> &VTables); 1605dfe6543e12eca5c79421378b7fa6b3e8fc403e63Douglas Gregor 16066e4a3f5c59664af13e02e9bb58c2810b830e3b96Douglas Gregor virtual void ReadPendingInstantiations( 1607ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie SmallVectorImpl<std::pair<ValueDecl *, 16086e4a3f5c59664af13e02e9bb58c2810b830e3b96Douglas Gregor SourceLocation> > &Pending); 16096e4a3f5c59664af13e02e9bb58c2810b830e3b96Douglas Gregor 1610e58aa890e8de55bb3146e6ea9fbbba3a58ce30c6Sebastian Redl /// \brief Load a selector from disk, registering its ID if it exists. 1611e58aa890e8de55bb3146e6ea9fbbba3a58ce30c6Sebastian Redl void LoadSelector(Selector Sel); 1612e58aa890e8de55bb3146e6ea9fbbba3a58ce30c6Sebastian Redl 16132b3a5a83ea30bde7fa8f9d8e9a0cb12623759bfbDouglas Gregor void SetIdentifierInfo(unsigned ID, IdentifierInfo *II); 16141eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump void SetGloballyVisibleDecls(IdentifierInfo *II, 1615686775deca8b8685eb90801495880e3abdd844c2Chris Lattner const SmallVectorImpl<uint32_t> &DeclIDs, 1616aa945900d5438984bdcaac85c4f54868292231f4Douglas Gregor SmallVectorImpl<Decl *> *Decls = 0); 16171eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 16180a0428e96c6f1e8bef7a481a9eb69a6f6df38951Douglas Gregor /// \brief Report a diagnostic. 16190a0428e96c6f1e8bef7a481a9eb69a6f6df38951Douglas Gregor DiagnosticBuilder Diag(unsigned DiagID); 16200a0428e96c6f1e8bef7a481a9eb69a6f6df38951Douglas Gregor 1621e1d918e9fe55e3b34401fd5d420c47ea0f9572c9Douglas Gregor /// \brief Report a diagnostic. 1622e1d918e9fe55e3b34401fd5d420c47ea0f9572c9Douglas Gregor DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID); 1623e1d918e9fe55e3b34401fd5d420c47ea0f9572c9Douglas Gregor 16248222b8951da749d4f086d7b39de5ff0221297509Douglas Gregor IdentifierInfo *DecodeIdentifierInfo(serialization::IdentifierID ID); 16251eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 16261a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor IdentifierInfo *GetIdentifierInfo(ModuleFile &M, const RecordData &Record, 16278222b8951da749d4f086d7b39de5ff0221297509Douglas Gregor unsigned &Idx) { 16288222b8951da749d4f086d7b39de5ff0221297509Douglas Gregor return DecodeIdentifierInfo(getGlobalIdentifierID(M, Record[Idx++])); 16297356a31327be9b3c3434a0c88746028980da5684Chris Lattner } 16301eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 163195eab176f51beed44a9bc14c0dcdd37844b23740Douglas Gregor virtual IdentifierInfo *GetIdentifier(serialization::IdentifierID ID) { 16326c6c54a59a6e7dbe63ff6a9bbab76f6e0c7c8462Douglas Gregor // Note that we are loading an identifier. 16336c6c54a59a6e7dbe63ff6a9bbab76f6e0c7c8462Douglas Gregor Deserializing AnIdentifier(this); 16346c6c54a59a6e7dbe63ff6a9bbab76f6e0c7c8462Douglas Gregor 16358c5a760b82e73ed90b560090772db97e2ae27b09Douglas Gregor return DecodeIdentifierInfo(ID); 16368c5a760b82e73ed90b560090772db97e2ae27b09Douglas Gregor } 16378c5a760b82e73ed90b560090772db97e2ae27b09Douglas Gregor 16388222b8951da749d4f086d7b39de5ff0221297509Douglas Gregor IdentifierInfo *getLocalIdentifier(ModuleFile &M, unsigned LocalID); 1639ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 16401a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor serialization::IdentifierID getGlobalIdentifierID(ModuleFile &M, 164195eab176f51beed44a9bc14c0dcdd37844b23740Douglas Gregor unsigned LocalID); 1642ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 16439317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis void resolvePendingMacro(IdentifierInfo *II, const PendingMacroInfo &PMInfo); 16449317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis 16459317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis void installPCHMacroDirectives(IdentifierInfo *II, 16469317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis ModuleFile &M, uint64_t Offset); 16479317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis 164852151fd57eaf40603fa8f1cd34dcb4ad5f7701b3Argyrios Kyrtzidis void installImportedMacro(IdentifierInfo *II, MacroDirective *MD, 164952151fd57eaf40603fa8f1cd34dcb4ad5f7701b3Argyrios Kyrtzidis Module *Owner); 16509317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis 1651a8235d6c4093cd38dcf742909651f867de62e55bDouglas Gregor /// \brief Retrieve the macro with the given ID. 16529317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis MacroInfo *getMacro(serialization::MacroID ID); 1653a8235d6c4093cd38dcf742909651f867de62e55bDouglas Gregor 1654a8235d6c4093cd38dcf742909651f867de62e55bDouglas Gregor /// \brief Retrieve the global macro ID corresponding to the given local 1655a8235d6c4093cd38dcf742909651f867de62e55bDouglas Gregor /// ID within the given module file. 1656a8235d6c4093cd38dcf742909651f867de62e55bDouglas Gregor serialization::MacroID getGlobalMacroID(ModuleFile &M, unsigned LocalID); 1657a8235d6c4093cd38dcf742909651f867de62e55bDouglas Gregor 16587f94b0b0c6791013d2f72ced9b4bedd3b23673a6Douglas Gregor /// \brief Read the source location entry with index ID. 1659f62d43d2afe1960755a1b5813cae1e5983bcac1bDouglas Gregor virtual bool ReadSLocEntry(int ID); 16607f94b0b0c6791013d2f72ced9b4bedd3b23673a6Douglas Gregor 16616c3254316de2d0d554b19702f4b10117ae46b77bDouglas Gregor /// \brief Retrieve the module import location and module name for the 16626c3254316de2d0d554b19702f4b10117ae46b77bDouglas Gregor /// given source manager entry ID. 16636c3254316de2d0d554b19702f4b10117ae46b77bDouglas Gregor virtual std::pair<SourceLocation, StringRef> getModuleImportLoc(int ID); 16646c3254316de2d0d554b19702f4b10117ae46b77bDouglas Gregor 166526ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor /// \brief Retrieve the global submodule ID given a module and its local ID 166626ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor /// number. 166726ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor serialization::SubmoduleID 166826ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor getGlobalSubmoduleID(ModuleFile &M, unsigned LocalID); 166926ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor 167026ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor /// \brief Retrieve the submodule that corresponds to a global submodule ID. 167126ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor /// 167226ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor Module *getSubmodule(serialization::SubmoduleID GlobalID); 1673ca2ab45341c448284cf93770018c717810575f86Douglas Gregor 1674ca2ab45341c448284cf93770018c717810575f86Douglas Gregor /// \brief Retrieve the module that corresponds to the given module ID. 1675ca2ab45341c448284cf93770018c717810575f86Douglas Gregor /// 1676ca2ab45341c448284cf93770018c717810575f86Douglas Gregor /// Note: overrides method in ExternalASTSource 1677ca2ab45341c448284cf93770018c717810575f86Douglas Gregor virtual Module *getModule(unsigned ID); 1678ca2ab45341c448284cf93770018c717810575f86Douglas Gregor 16792d2689ab787c6d54cb985c28ff3f16370bc01b0fDouglas Gregor /// \brief Retrieve a selector from the given module with its local ID 16802d2689ab787c6d54cb985c28ff3f16370bc01b0fDouglas Gregor /// number. 16811a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor Selector getLocalSelector(ModuleFile &M, unsigned LocalID); 16822d2689ab787c6d54cb985c28ff3f16370bc01b0fDouglas Gregor 16832d2689ab787c6d54cb985c28ff3f16370bc01b0fDouglas Gregor Selector DecodeSelector(serialization::SelectorID Idx); 16841eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 16858451ec7e709baf777bec07dc70653e0c523dd120Douglas Gregor virtual Selector GetExternalSelector(serialization::SelectorID ID); 168676bd1f387e6a7b7abfe53f63b3bd429b97bb80f0John McCall uint32_t GetNumExternalSelectors(); 1687719770dcfcb3987e8a2377dcca97955301445eb5Douglas Gregor 16881a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor Selector ReadSelector(ModuleFile &M, const RecordData &Record, unsigned &Idx) { 16892d2689ab787c6d54cb985c28ff3f16370bc01b0fDouglas Gregor return getLocalSelector(M, Record[Idx++]); 169090cd1bb1baac2a0221f3642de0cbea3244b116e5Steve Naroff } 1691ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 16928451ec7e709baf777bec07dc70653e0c523dd120Douglas Gregor /// \brief Retrieve the global selector ID that corresponds to this 16938451ec7e709baf777bec07dc70653e0c523dd120Douglas Gregor /// the local selector ID in a given module. 16941a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor serialization::SelectorID getGlobalSelectorID(ModuleFile &F, 16958451ec7e709baf777bec07dc70653e0c523dd120Douglas Gregor unsigned LocalID) const; 16966ad9ac097918fbdeb443ea7b99d4db9e49b28534Chris Lattner 16976ad9ac097918fbdeb443ea7b99d4db9e49b28534Chris Lattner /// \brief Read a declaration name. 16981a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor DeclarationName ReadDeclarationName(ModuleFile &F, 1699393f249399fe30e9580e1529a7479489e90f3a57Douglas Gregor const RecordData &Record, unsigned &Idx); 17001a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor void ReadDeclarationNameLoc(ModuleFile &F, 17014045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis DeclarationNameLoc &DNLoc, DeclarationName Name, 17024045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis const RecordData &Record, unsigned &Idx); 17031a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor void ReadDeclarationNameInfo(ModuleFile &F, DeclarationNameInfo &NameInfo, 17044045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis const RecordData &Record, unsigned &Idx); 17054045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis 17061a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor void ReadQualifierInfo(ModuleFile &F, QualifierInfo &Info, 17074045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis const RecordData &Record, unsigned &Idx); 17080a2b45e5885b6b8477b167042c0f6cd1d99a1f13Douglas Gregor 17091a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor NestedNameSpecifier *ReadNestedNameSpecifier(ModuleFile &F, 1710409448c832d27703146b70a1137d86b020f29863Douglas Gregor const RecordData &Record, 17116ad9ac097918fbdeb443ea7b99d4db9e49b28534Chris Lattner unsigned &Idx); 17126ad9ac097918fbdeb443ea7b99d4db9e49b28534Chris Lattner 17131a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor NestedNameSpecifierLoc ReadNestedNameSpecifierLoc(ModuleFile &F, 1714dc355713be51fcb4ee52d9fd6b4548ceff47fadfDouglas Gregor const RecordData &Record, 1715dc355713be51fcb4ee52d9fd6b4548ceff47fadfDouglas Gregor unsigned &Idx); 1716dc355713be51fcb4ee52d9fd6b4548ceff47fadfDouglas Gregor 17178731ca76acf81826df7048bffd0c44c7c0f96c7fArgyrios Kyrtzidis /// \brief Read a template name. 17181a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor TemplateName ReadTemplateName(ModuleFile &F, const RecordData &Record, 17191aee05d08b2184acadeb36de300e216390780d6cDouglas Gregor unsigned &Idx); 17208731ca76acf81826df7048bffd0c44c7c0f96c7fArgyrios Kyrtzidis 17218731ca76acf81826df7048bffd0c44c7c0f96c7fArgyrios Kyrtzidis /// \brief Read a template argument. 17221a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor TemplateArgument ReadTemplateArgument(ModuleFile &F, 1723577d4796d358c0e72ebaa023113505226ab51b4fSebastian Redl const RecordData &Record,unsigned &Idx); 1724ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1725dd41c14bfd7686b556de2acf6952e21a4f80b7aaArgyrios Kyrtzidis /// \brief Read a template parameter list. 17261a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor TemplateParameterList *ReadTemplateParameterList(ModuleFile &F, 1727c3632730cc83ed7b51f0ab5c38997ae5a9439b0cSebastian Redl const RecordData &Record, 1728dd41c14bfd7686b556de2acf6952e21a4f80b7aaArgyrios Kyrtzidis unsigned &Idx); 1729ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1730dd41c14bfd7686b556de2acf6952e21a4f80b7aaArgyrios Kyrtzidis /// \brief Read a template argument array. 1731dd41c14bfd7686b556de2acf6952e21a4f80b7aaArgyrios Kyrtzidis void 17326b9240e058bf3451685df73fc8ce181b3046e92bCraig Topper ReadTemplateArgumentList(SmallVectorImpl<TemplateArgument> &TemplArgs, 17331a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor ModuleFile &F, const RecordData &Record, 1734c3632730cc83ed7b51f0ab5c38997ae5a9439b0cSebastian Redl unsigned &Idx); 17358731ca76acf81826df7048bffd0c44c7c0f96c7fArgyrios Kyrtzidis 173637ffed3b7f229844cae2463ff82b527506c86c74Argyrios Kyrtzidis /// \brief Read a UnresolvedSet structure. 17372a82ca255b0f99f6201a75ed52b91fc024f6e9cfArgyrios Kyrtzidis void ReadUnresolvedSet(ModuleFile &F, ASTUnresolvedSet &Set, 173837ffed3b7f229844cae2463ff82b527506c86c74Argyrios Kyrtzidis const RecordData &Record, unsigned &Idx); 173937ffed3b7f229844cae2463ff82b527506c86c74Argyrios Kyrtzidis 17400745d0a648b75bd304045309276c70a755adaafbArgyrios Kyrtzidis /// \brief Read a C++ base specifier. 17411a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor CXXBaseSpecifier ReadCXXBaseSpecifier(ModuleFile &F, 17425606220447c7901ba8d80147ddab893bb7949dd5Nick Lewycky const RecordData &Record,unsigned &Idx); 17430745d0a648b75bd304045309276c70a755adaafbArgyrios Kyrtzidis 1744cbb67480094b3bcb5b715acd827cbad55e2a204cSean Hunt /// \brief Read a CXXCtorInitializer array. 1745cbb67480094b3bcb5b715acd827cbad55e2a204cSean Hunt std::pair<CXXCtorInitializer **, unsigned> 17461a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor ReadCXXCtorInitializers(ModuleFile &F, const RecordData &Record, 1747cbb67480094b3bcb5b715acd827cbad55e2a204cSean Hunt unsigned &Idx); 17488e706f4b8da141612861e127610141b8d17a9667Argyrios Kyrtzidis 1749c3632730cc83ed7b51f0ab5c38997ae5a9439b0cSebastian Redl /// \brief Read a source location from raw form. 17501a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor SourceLocation ReadSourceLocation(ModuleFile &ModuleFile, unsigned Raw) const { 17515a4374812c56aa60672e291b07e14d3696bbb5a6Argyrios Kyrtzidis SourceLocation Loc = SourceLocation::getFromRawEncoding(Raw); 17521a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor assert(ModuleFile.SLocRemap.find(Loc.getOffset()) != ModuleFile.SLocRemap.end() && 1753f62d43d2afe1960755a1b5813cae1e5983bcac1bDouglas Gregor "Cannot find offset to remap."); 17541a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor int Remap = ModuleFile.SLocRemap.find(Loc.getOffset())->second; 1755a64ccefdf0ea4e03ec88805d71b0af74950c7472Argyrios Kyrtzidis return Loc.getLocWithOffset(Remap); 1756c3632730cc83ed7b51f0ab5c38997ae5a9439b0cSebastian Redl } 1757c3632730cc83ed7b51f0ab5c38997ae5a9439b0cSebastian Redl 17586ad9ac097918fbdeb443ea7b99d4db9e49b28534Chris Lattner /// \brief Read a source location. 17591a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor SourceLocation ReadSourceLocation(ModuleFile &ModuleFile, 176001a41140cd8ec9475ed0c33384310fbdd3b6de11Nick Lewycky const RecordData &Record, unsigned &Idx) { 17611a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor return ReadSourceLocation(ModuleFile, Record[Idx++]); 17626ad9ac097918fbdeb443ea7b99d4db9e49b28534Chris Lattner } 17636ad9ac097918fbdeb443ea7b99d4db9e49b28534Chris Lattner 17646ad9ac097918fbdeb443ea7b99d4db9e49b28534Chris Lattner /// \brief Read a source range. 17651a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor SourceRange ReadSourceRange(ModuleFile &F, 176601a41140cd8ec9475ed0c33384310fbdd3b6de11Nick Lewycky const RecordData &Record, unsigned &Idx); 17676ad9ac097918fbdeb443ea7b99d4db9e49b28534Chris Lattner 17680a2b45e5885b6b8477b167042c0f6cd1d99a1f13Douglas Gregor /// \brief Read an integral value 17690a2b45e5885b6b8477b167042c0f6cd1d99a1f13Douglas Gregor llvm::APInt ReadAPInt(const RecordData &Record, unsigned &Idx); 17700a2b45e5885b6b8477b167042c0f6cd1d99a1f13Douglas Gregor 17710a2b45e5885b6b8477b167042c0f6cd1d99a1f13Douglas Gregor /// \brief Read a signed integral value 17720a2b45e5885b6b8477b167042c0f6cd1d99a1f13Douglas Gregor llvm::APSInt ReadAPSInt(const RecordData &Record, unsigned &Idx); 17733a2f7e42514ddbec983c61826ce85d3071e23e8eDouglas Gregor 177417fc223395d51be582fc666bb6ea21bd1dff26dcDouglas Gregor /// \brief Read a floating-point value 17759ec55f24b8f848bb37a9971100cf2fca379d5572Tim Northover llvm::APFloat ReadAPFloat(const RecordData &Record, 17769ec55f24b8f848bb37a9971100cf2fca379d5572Tim Northover const llvm::fltSemantics &Sem, unsigned &Idx); 177717fc223395d51be582fc666bb6ea21bd1dff26dcDouglas Gregor 177868a2eb0cc76267ba0615992fb5e0977853c397b2Douglas Gregor // \brief Read a string 177927ffa6caf965ef20fdef5ae23b81cdc3d05e7afbDouglas Gregor static std::string ReadString(const RecordData &Record, unsigned &Idx); 178068a2eb0cc76267ba0615992fb5e0977853c397b2Douglas Gregor 17810a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor /// \brief Read a version tuple. 178227ffa6caf965ef20fdef5ae23b81cdc3d05e7afbDouglas Gregor static VersionTuple ReadVersionTuple(const RecordData &Record, unsigned &Idx); 17830a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor 17841a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor CXXTemporary *ReadCXXTemporary(ModuleFile &F, const RecordData &Record, 1785409448c832d27703146b70a1137d86b020f29863Douglas Gregor unsigned &Idx); 1786ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 178768a2eb0cc76267ba0615992fb5e0977853c397b2Douglas Gregor /// \brief Reads attributes from the current stream position. 17881a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor void ReadAttributes(ModuleFile &F, AttrVec &Attrs, 17894eb9fc0449ddbd5239ddc3ae6b6e52880f47dcf7Argyrios Kyrtzidis const RecordData &Record, unsigned &Idx); 179068a2eb0cc76267ba0615992fb5e0977853c397b2Douglas Gregor 1791919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis /// \brief Reads a statement. 17921a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor Stmt *ReadStmt(ModuleFile &F); 17930b7489194f9f89fac39d57211c1e7953ae50251fDouglas Gregor 1794919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis /// \brief Reads an expression. 17951a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor Expr *ReadExpr(ModuleFile &F); 1796c9490c000f515c29f200a1215328d8ab9a0f3818Douglas Gregor 1797d98a2ab9275f896df49e42ea4e4b8871610e0f45Argyrios Kyrtzidis /// \brief Reads a sub-statement operand during statement reading. 1798d98a2ab9275f896df49e42ea4e4b8871610e0f45Argyrios Kyrtzidis Stmt *ReadSubStmt() { 1799d98a2ab9275f896df49e42ea4e4b8871610e0f45Argyrios Kyrtzidis assert(ReadingKind == Read_Stmt && 1800d98a2ab9275f896df49e42ea4e4b8871610e0f45Argyrios Kyrtzidis "Should be called only during statement reading!"); 1801d98a2ab9275f896df49e42ea4e4b8871610e0f45Argyrios Kyrtzidis // Subexpressions are stored from last to first, so the next Stmt we need 1802d98a2ab9275f896df49e42ea4e4b8871610e0f45Argyrios Kyrtzidis // is at the back of the stack. 1803d98a2ab9275f896df49e42ea4e4b8871610e0f45Argyrios Kyrtzidis assert(!StmtStack.empty() && "Read too many sub statements!"); 1804d98a2ab9275f896df49e42ea4e4b8871610e0f45Argyrios Kyrtzidis return StmtStack.pop_back_val(); 1805d98a2ab9275f896df49e42ea4e4b8871610e0f45Argyrios Kyrtzidis } 1806d98a2ab9275f896df49e42ea4e4b8871610e0f45Argyrios Kyrtzidis 1807d98a2ab9275f896df49e42ea4e4b8871610e0f45Argyrios Kyrtzidis /// \brief Reads a sub-expression operand during statement reading. 1808d98a2ab9275f896df49e42ea4e4b8871610e0f45Argyrios Kyrtzidis Expr *ReadSubExpr(); 1809d98a2ab9275f896df49e42ea4e4b8871610e0f45Argyrios Kyrtzidis 1810aeeacf725c9e0ddd64ea9764bd008e5b6873ce51John McCall /// \brief Reads a token out of a record. 1811aeeacf725c9e0ddd64ea9764bd008e5b6873ce51John McCall Token ReadToken(ModuleFile &M, const RecordData &Record, unsigned &Idx); 1812aeeacf725c9e0ddd64ea9764bd008e5b6873ce51John McCall 181337e2684abfe38207fdb90620da062bb18c23f29aDouglas Gregor /// \brief Reads the macro record located at the given offset. 18149317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis MacroInfo *ReadMacroRecord(ModuleFile &F, uint64_t Offset); 1815ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 181686c67d8802a9e0887c31c850188991465ac3c1bdDouglas Gregor /// \brief Determine the global preprocessed entity ID that corresponds to 181786c67d8802a9e0887c31c850188991465ac3c1bdDouglas Gregor /// the given local ID within the given module. 1818ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie serialization::PreprocessedEntityID 18191a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor getGlobalPreprocessedEntityID(ModuleFile &M, unsigned LocalID) const; 1820ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 18219317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis /// \brief Add a macro to resolve imported from a module. 18221329264ce0922b3cec8c8c599108f082105fa0e1Douglas Gregor /// 18231329264ce0922b3cec8c8c599108f082105fa0e1Douglas Gregor /// \param II The name of the macro. 18249317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis /// \param M The module file. 18259317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis /// \param GMacID The global macro ID that is associated with this identifier. 18269317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis /// \param ImportLoc The location where the module is imported. 18279317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis void addPendingMacroFromModule(IdentifierInfo *II, 18289317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis ModuleFile *M, 18299317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis serialization::GlobalMacroID GMacID, 18309317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis SourceLocation ImportLoc); 18319317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis 18329317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis /// \brief Add a macro to deserialize its macro directive history from a PCH. 1833dc1088f6201c3fb8f3f97f54c343f7d163fbec06Argyrios Kyrtzidis /// 18349317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis /// \param II The name of the macro. 18359317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis /// \param M The module file. 18369317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis /// \param MacroDirectivesOffset Offset of the serialized macro directive 18379317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis /// history. 18389317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis void addPendingMacroFromPCH(IdentifierInfo *II, 18399317ab94bb68122ba6fc728eb73c1308fb913cd1Argyrios Kyrtzidis ModuleFile *M, uint64_t MacroDirectivesOffset); 1840ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 184188a35862fbe473f2a4f0c19f24dbe536937e1dc6Douglas Gregor /// \brief Read the set of macros defined by this external macro source. 184288a35862fbe473f2a4f0c19f24dbe536937e1dc6Douglas Gregor virtual void ReadDefinedMacros(); 184388a35862fbe473f2a4f0c19f24dbe536937e1dc6Douglas Gregor 1844eee242ff426bf79149f221798966e58688383c1eDouglas Gregor /// \brief Update an out-of-date identifier. 1845eee242ff426bf79149f221798966e58688383c1eDouglas Gregor virtual void updateOutOfDateIdentifier(IdentifierInfo &II); 1846eee242ff426bf79149f221798966e58688383c1eDouglas Gregor 1847057df20b3107cef764052d271c89b8591b98b3ceDouglas Gregor /// \brief Note that this identifier is up-to-date. 1848057df20b3107cef764052d271c89b8591b98b3ceDouglas Gregor void markIdentifierUpToDate(IdentifierInfo *II); 1849a8235d6c4093cd38dcf742909651f867de62e55bDouglas Gregor 1850643586fe4fcd42b0978efd3566832ab4dce50367Argyrios Kyrtzidis /// \brief Load all external visible decls in the given DeclContext. 1851b346d2f419ec7d7ce6b20780d518490338efa7deNick Lewycky void completeVisibleDeclsMap(const DeclContext *DC); 1852643586fe4fcd42b0978efd3566832ab4dce50367Argyrios Kyrtzidis 18533c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// \brief Retrieve the AST context that this AST reader supplements. 1854359427794704666ff7a5a933ace11c5256fa3af7Douglas Gregor ASTContext &getContext() { return Context; } 1855025452fa0eda63e150cfaeebe64f0a19c96b3a06Douglas Gregor 18566cfc1a8b7582b8433b61222502effb018c534393Douglas Gregor // \brief Contains declarations that were loaded before we have 18576cfc1a8b7582b8433b61222502effb018c534393Douglas Gregor // access to a Sema object. 1858686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVector<NamedDecl *, 16> PreloadedDecls; 1859668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor 1860668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor /// \brief Retrieve the semantic analysis object used to analyze the 1861668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor /// translation unit in which the precompiled header is being 1862668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor /// imported. 1863668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor Sema *getSema() { return SemaObj; } 1864668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor 1865668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor /// \brief Retrieve the identifier table associated with the 1866668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor /// preprocessor. 1867668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor IdentifierTable &getIdentifierTable(); 1868668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor 1869025452fa0eda63e150cfaeebe64f0a19c96b3a06Douglas Gregor /// \brief Record that the given ID maps to the given switch-case 1870025452fa0eda63e150cfaeebe64f0a19c96b3a06Douglas Gregor /// statement. 1871025452fa0eda63e150cfaeebe64f0a19c96b3a06Douglas Gregor void RecordSwitchCaseID(SwitchCase *SC, unsigned ID); 1872025452fa0eda63e150cfaeebe64f0a19c96b3a06Douglas Gregor 1873025452fa0eda63e150cfaeebe64f0a19c96b3a06Douglas Gregor /// \brief Retrieve the switch-case statement with the given ID. 1874025452fa0eda63e150cfaeebe64f0a19c96b3a06Douglas Gregor SwitchCase *getSwitchCaseWithID(unsigned ID); 18751de05feeeafe5b215fe7617594a7076a5192a6e2Douglas Gregor 1876e09a275444576deb2c8d9e2255554242f65d7c00Argyrios Kyrtzidis void ClearSwitchCaseIDs(); 1877aa0cd85838f2a024e589ea4e8c2094130065af21Dmitri Gribenko 1878aa0cd85838f2a024e589ea4e8c2094130065af21Dmitri Gribenko /// \brief Cursors for comments blocks. 1879aa0cd85838f2a024e589ea4e8c2094130065af21Dmitri Gribenko SmallVector<std::pair<llvm::BitstreamCursor, 1880aa0cd85838f2a024e589ea4e8c2094130065af21Dmitri Gribenko serialization::ModuleFile *>, 8> CommentsCursors; 1881aa0cd85838f2a024e589ea4e8c2094130065af21Dmitri Gribenko 1882aa0cd85838f2a024e589ea4e8c2094130065af21Dmitri Gribenko /// \brief Loads comments ranges. 1883aa0cd85838f2a024e589ea4e8c2094130065af21Dmitri Gribenko void ReadComments(); 18842cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor}; 18852cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor 188602602be3ccc3b29da5b91d2502c3419404992409Chris Lattner/// \brief Helper class that saves the current stream position and 188702602be3ccc3b29da5b91d2502c3419404992409Chris Lattner/// then restores it when destroyed. 188802602be3ccc3b29da5b91d2502c3419404992409Chris Lattnerstruct SavedStreamPosition { 188902602be3ccc3b29da5b91d2502c3419404992409Chris Lattner explicit SavedStreamPosition(llvm::BitstreamCursor &Cursor) 189099a5af0088b6340540912921cd0008ac75051a33Chris Lattner : Cursor(Cursor), Offset(Cursor.GetCurrentBitNo()) { } 18911eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 189202602be3ccc3b29da5b91d2502c3419404992409Chris Lattner ~SavedStreamPosition() { 189302602be3ccc3b29da5b91d2502c3419404992409Chris Lattner Cursor.JumpToBit(Offset); 189402602be3ccc3b29da5b91d2502c3419404992409Chris Lattner } 18951eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 189602602be3ccc3b29da5b91d2502c3419404992409Chris Lattnerprivate: 189702602be3ccc3b29da5b91d2502c3419404992409Chris Lattner llvm::BitstreamCursor &Cursor; 189802602be3ccc3b29da5b91d2502c3419404992409Chris Lattner uint64_t Offset; 189902602be3ccc3b29da5b91d2502c3419404992409Chris Lattner}; 19001eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1901d5d7b3f61f82b0fed9d6f02839bc72e528332911Ted Kremenekinline void PCHValidator::Error(const char *Msg) { 1902d5d7b3f61f82b0fed9d6f02839bc72e528332911Ted Kremenek Reader.Error(Msg); 1903d5d7b3f61f82b0fed9d6f02839bc72e528332911Ted Kremenek} 1904d5d7b3f61f82b0fed9d6f02839bc72e528332911Ted Kremenek 19052cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor} // end namespace clang 19062cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor 19072cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor#endif 1908