ASTReader.h revision 44d2dbdce49d1fca3826d543ba875bb82f759091
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 1705a07605322dfef2b017781042043a261c5a89cdSebastian Redl#include "clang/Serialization/ASTBitCodes.h" 18f62d43d2afe1960755a1b5813cae1e5983bcac1bDouglas Gregor#include "clang/Serialization/ContinuousRangeMap.h" 1998339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor#include "clang/Serialization/Module.h" 2098339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor#include "clang/Serialization/ModuleManager.h" 21668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor#include "clang/Sema/ExternalSemaSource.h" 22c43b54cbc10654ed59de797898042e1a05265246Sebastian Redl#include "clang/AST/DeclarationName.h" 23f0aaf7a59729a4ae0146e3464ee987745be95829Douglas Gregor#include "clang/AST/DeclObjC.h" 24833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall#include "clang/AST/TemplateBase.h" 2588a35862fbe473f2a4f0c19f24dbe536937e1dc6Douglas Gregor#include "clang/Lex/ExternalPreprocessorSource.h" 26cfbf1c7536e016dc275139dd842d4a5f059a749fDouglas Gregor#include "clang/Lex/HeaderSearch.h" 276a5a23f8e7fb65e028c8092bc1d1a1d9dfe2e9bcDouglas Gregor#include "clang/Lex/PreprocessingRecord.h" 280a0428e96c6f1e8bef7a481a9eb69a6f6df38951Douglas Gregor#include "clang/Basic/Diagnostic.h" 291afb661bc5444462a246cefa0effa61ef25fab29Jonathan D. Turner#include "clang/Basic/FileManager.h" 301afb661bc5444462a246cefa0effa61ef25fab29Jonathan D. Turner#include "clang/Basic/FileSystemOptions.h" 31668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor#include "clang/Basic/IdentifierTable.h" 327f94b0b0c6791013d2f72ced9b4bedd3b23673a6Douglas Gregor#include "clang/Basic/SourceManager.h" 3317fc223395d51be582fc666bb6ea21bd1dff26dcDouglas Gregor#include "llvm/ADT/APFloat.h" 340a2b45e5885b6b8477b167042c0f6cd1d99a1f13Douglas Gregor#include "llvm/ADT/APInt.h" 350a2b45e5885b6b8477b167042c0f6cd1d99a1f13Douglas Gregor#include "llvm/ADT/APSInt.h" 362cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor#include "llvm/ADT/OwningPtr.h" 370f75323264b93a318ac9007eb5ec5b233c444068Douglas Gregor#include "llvm/ADT/SmallPtrSet.h" 380f75323264b93a318ac9007eb5ec5b233c444068Douglas Gregor#include "llvm/ADT/SmallSet.h" 392cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor#include "llvm/ADT/SmallVector.h" 40dc3c0d20375bda7775b2fade05b20e315798b9feDaniel Dunbar#include "llvm/ADT/StringRef.h" 41e6b8d68a927368b06ac06cc9ac9e7f60aa966d5fArgyrios Kyrtzidis#include "llvm/ADT/DenseSet.h" 422cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor#include "llvm/Bitcode/BitstreamReader.h" 4303013fa9a0bf1ef4b907f5fec006c8f4000fdd21Michael J. Spencer#include "llvm/Support/DataTypes.h" 44d89275bc865e2b552836c7b33e636d4f86b8de6dDouglas Gregor#include <deque> 45025452fa0eda63e150cfaeebe64f0a19c96b3a06Douglas Gregor#include <map> 462cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor#include <string> 472cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor#include <utility> 482cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor#include <vector> 492cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor 502cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregornamespace llvm { 512cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor class MemoryBuffer; 522cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor} 532cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor 542cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregornamespace clang { 552cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor 567d5c2f241c74e5f8d9ec492e8f9f268e5e9ae41fDouglas Gregorclass AddrLabelExpr; 570af2ca4b6ddc788658069a0994941268ce250fc7Douglas Gregorclass ASTConsumer; 582cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregorclass ASTContext; 5995f4292cc526c629fead321c7fcfd4fe0f3bc66eDouglas Gregorclass ASTIdentifierIterator; 60f62d43d2afe1960755a1b5813cae1e5983bcac1bDouglas Gregorclass ASTUnit; // FIXME: Layering violation and egregious hack. 6168a2eb0cc76267ba0615992fb5e0977853c397b2Douglas Gregorclass Attr; 622cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregorclass Decl; 632cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregorclass DeclContext; 646ad9ac097918fbdeb443ea7b99d4db9e49b28534Chris Lattnerclass NestedNameSpecifier; 656ad9ac097918fbdeb443ea7b99d4db9e49b28534Chris Lattnerclass CXXBaseSpecifier; 66ebcbe1d3dc7d4f0c1f540a632fa0684dd0a857d5Sean Huntclass CXXConstructorDecl; 67cbb67480094b3bcb5b715acd827cbad55e2a204cSean Huntclass CXXCtorInitializer; 681de05feeeafe5b215fe7617594a7076a5192a6e2Douglas Gregorclass GotoStmt; 696a5a23f8e7fb65e028c8092bc1d1a1d9dfe2e9bcDouglas Gregorclass MacroDefinition; 70668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregorclass NamedDecl; 7156ca35d396d8692c384c785f9aeebcf22563fe1eJohn McCallclass OpaqueValueExpr; 7214f79002e58556798e86168c63e48d533287eda5Douglas Gregorclass Preprocessor; 73668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregorclass Sema; 74025452fa0eda63e150cfaeebe64f0a19c96b3a06Douglas Gregorclass SwitchCase; 75c3632730cc83ed7b51f0ab5c38997ae5a9439b0cSebastian Redlclass ASTDeserializationListener; 76f62d43d2afe1960755a1b5813cae1e5983bcac1bDouglas Gregorclass ASTWriter; 77c43b54cbc10654ed59de797898042e1a05265246Sebastian Redlclass ASTReader; 78d527cc06d78fe5afa5f20105b51697637eb02c56Sebastian Redlclass ASTDeclReader; 79c3632730cc83ed7b51f0ab5c38997ae5a9439b0cSebastian Redlclass ASTStmtReader; 80c3632730cc83ed7b51f0ab5c38997ae5a9439b0cSebastian Redlclass TypeLocReader; 81eb19485625c7529ffa644e10829533157a8e8d4fDaniel Dunbarstruct HeaderFileInfo; 820a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregorclass VersionTuple; 8311e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis 847e9ad8b4fd446ca7cc0e630edee56d8fcc4553deSebastian Redlstruct PCHPredefinesBlock { 857e9ad8b4fd446ca7cc0e630edee56d8fcc4553deSebastian Redl /// \brief The file ID for this predefines buffer in a PCH file. 867e9ad8b4fd446ca7cc0e630edee56d8fcc4553deSebastian Redl FileID BufferID; 877e9ad8b4fd446ca7cc0e630edee56d8fcc4553deSebastian Redl 887e9ad8b4fd446ca7cc0e630edee56d8fcc4553deSebastian Redl /// \brief This predefines buffer in a PCH file. 89686775deca8b8685eb90801495880e3abdd844c2Chris Lattner StringRef Data; 907e9ad8b4fd446ca7cc0e630edee56d8fcc4553deSebastian Redl}; 91686775deca8b8685eb90801495880e3abdd844c2Chris Lattnertypedef SmallVector<PCHPredefinesBlock, 2> PCHPredefinesBlocks; 927e9ad8b4fd446ca7cc0e630edee56d8fcc4553deSebastian Redl 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 10311e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis /// \brief Receives the language options. 10411e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis /// 10511e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis /// \returns true to indicate the options are invalid or false otherwise. 10611e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis virtual bool ReadLanguageOptions(const LangOptions &LangOpts) { 10711e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis return false; 10811e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis } 1091eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 11011e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis /// \brief Receives the target triple. 11111e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis /// 11211e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis /// \returns true to indicate the target triple is invalid or false otherwise. 113686775deca8b8685eb90801495880e3abdd844c2Chris Lattner virtual bool ReadTargetTriple(StringRef Triple) { 11411e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis return false; 11511e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis } 1161eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 11711e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis /// \brief Receives the contents of the predefines buffer. 11811e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis /// 11930c514c225342844700ed4640ec6d90ddf0e12b2Sebastian Redl /// \param Buffers Information about the predefines buffers. 12011e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis /// 1213c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// \param OriginalFileName The original file name for the AST file, which 1223c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// will appear as an entry in the predefines buffer. 1237b5a1210d93ca62ecd61800f245c87259b1f8f79Daniel Dunbar /// 12411e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis /// \param SuggestedPredefines If necessary, additional definitions are added 12511e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis /// here. 12611e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis /// 12711e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis /// \returns true to indicate the predefines are invalid or false otherwise. 1287e9ad8b4fd446ca7cc0e630edee56d8fcc4553deSebastian Redl virtual bool ReadPredefinesBuffer(const PCHPredefinesBlocks &Buffers, 129686775deca8b8685eb90801495880e3abdd844c2Chris Lattner StringRef OriginalFileName, 130277a6e752512cff286190d35cb353ce717e86b18Nick Lewycky std::string &SuggestedPredefines, 131277a6e752512cff286190d35cb353ce717e86b18Nick Lewycky FileManager &FileMgr) { 13211e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis return false; 13311e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis } 1341eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 13511e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis /// \brief Receives a HeaderFileInfo entry. 13612fab31aa5868b1a6b52246b5a87daa48a338fe2Douglas Gregor virtual void ReadHeaderFileInfo(const HeaderFileInfo &HFI, unsigned ID) {} 1371eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 13811e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis /// \brief Receives __COUNTER__ value. 13911e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis virtual void ReadCounter(unsigned Value) {} 14011e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis}; 14111e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis 142571db7f0cb31789737be92fce1c1b738e6dbe795Sebastian Redl/// \brief ASTReaderListener implementation to validate the information of 14311e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis/// the PCH file against an initialized Preprocessor. 144571db7f0cb31789737be92fce1c1b738e6dbe795Sebastian Redlclass PCHValidator : public ASTReaderListener { 14511e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis Preprocessor &PP; 146c43b54cbc10654ed59de797898042e1a05265246Sebastian Redl ASTReader &Reader; 1471eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 14811e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis unsigned NumHeaderInfos; 1491eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 15011e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidispublic: 151c43b54cbc10654ed59de797898042e1a05265246Sebastian Redl PCHValidator(Preprocessor &PP, ASTReader &Reader) 15211e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis : PP(PP), Reader(Reader), NumHeaderInfos(0) {} 1531eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 15411e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis virtual bool ReadLanguageOptions(const LangOptions &LangOpts); 155686775deca8b8685eb90801495880e3abdd844c2Chris Lattner virtual bool ReadTargetTriple(StringRef Triple); 1567e9ad8b4fd446ca7cc0e630edee56d8fcc4553deSebastian Redl virtual bool ReadPredefinesBuffer(const PCHPredefinesBlocks &Buffers, 157686775deca8b8685eb90801495880e3abdd844c2Chris Lattner StringRef OriginalFileName, 158277a6e752512cff286190d35cb353ce717e86b18Nick Lewycky std::string &SuggestedPredefines, 159277a6e752512cff286190d35cb353ce717e86b18Nick Lewycky FileManager &FileMgr); 16012fab31aa5868b1a6b52246b5a87daa48a338fe2Douglas Gregor virtual void ReadHeaderFileInfo(const HeaderFileInfo &HFI, unsigned ID); 16111e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis virtual void ReadCounter(unsigned Value); 162d5d7b3f61f82b0fed9d6f02839bc72e528332911Ted Kremenek 163d5d7b3f61f82b0fed9d6f02839bc72e528332911Ted Kremenekprivate: 164d5d7b3f61f82b0fed9d6f02839bc72e528332911Ted Kremenek void Error(const char *Msg); 16511e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis}; 1662cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor 167ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikienamespace serialization { 1685d6d89fef8c7fff8b1a67c943fb5557a2a803468Jonathan D. Turner 1693d15ab8d0822637ff5e39594c4f34172241cad2eDouglas Gregorclass ReadMethodPoolVisitor; 170ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 17198339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregornamespace reader { 17298339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor class ASTIdentifierLookupTrait; 17398339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor} 174ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 17572a9ae18553bf8b6bdad84d2c54f73741a47e275Douglas Gregor} // end namespace serialization 176ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 177c43b54cbc10654ed59de797898042e1a05265246Sebastian Redl/// \brief Reads an AST files chain containing the contents of a translation 178c43b54cbc10654ed59de797898042e1a05265246Sebastian Redl/// unit. 1792cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor/// 180c43b54cbc10654ed59de797898042e1a05265246Sebastian Redl/// The ASTReader class reads bitstreams (produced by the ASTWriter 1812cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor/// class) containing the serialized representation of a given 1822cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor/// abstract syntax tree and its supporting data structures. An 183c43b54cbc10654ed59de797898042e1a05265246Sebastian Redl/// instance of the ASTReader can be attached to an ASTContext object, 184c43b54cbc10654ed59de797898042e1a05265246Sebastian Redl/// which will provide access to the contents of the AST files. 1852cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor/// 186c43b54cbc10654ed59de797898042e1a05265246Sebastian Redl/// The AST reader provides lazy de-serialization of declarations, as 1872cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor/// required when traversing the AST. Only those AST nodes that are 1882cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor/// actually required will be de-serialized. 189c43b54cbc10654ed59de797898042e1a05265246Sebastian Redlclass ASTReader 19088a35862fbe473f2a4f0c19f24dbe536937e1dc6Douglas Gregor : public ExternalPreprocessorSource, 1916a5a23f8e7fb65e028c8092bc1d1a1d9dfe2e9bcDouglas Gregor public ExternalPreprocessingRecordSource, 192cfbf1c7536e016dc275139dd842d4a5f059a749fDouglas Gregor public ExternalHeaderFileInfoSource, 19388a35862fbe473f2a4f0c19f24dbe536937e1dc6Douglas Gregor public ExternalSemaSource, 1948c5a760b82e73ed90b560090772db97e2ae27b09Douglas Gregor public IdentifierInfoLookup, 1957f94b0b0c6791013d2f72ced9b4bedd3b23673a6Douglas Gregor public ExternalIdentifierLookup, 196ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie public ExternalSLocEntrySource 197cfbf1c7536e016dc275139dd842d4a5f059a749fDouglas Gregor{ 198e1d918e9fe55e3b34401fd5d420c47ea0f9572c9Douglas Gregorpublic: 199c43b54cbc10654ed59de797898042e1a05265246Sebastian Redl enum ASTReadResult { Success, Failure, IgnorePCH }; 2001d9f1fe7173e3084325f43c78af812a36d8a2a7cSebastian Redl /// \brief Types of AST files. 201d5d7b3f61f82b0fed9d6f02839bc72e528332911Ted Kremenek friend class PCHValidator; 202d527cc06d78fe5afa5f20105b51697637eb02c56Sebastian Redl friend class ASTDeclReader; 203c3632730cc83ed7b51f0ab5c38997ae5a9439b0cSebastian Redl friend class ASTStmtReader; 20495f4292cc526c629fead321c7fcfd4fe0f3bc66eDouglas Gregor friend class ASTIdentifierIterator; 20598339b96a8089a6da715487e432c5abfca0ca0dfDouglas Gregor friend class serialization::reader::ASTIdentifierLookupTrait; 206c3632730cc83ed7b51f0ab5c38997ae5a9439b0cSebastian Redl friend class TypeLocReader; 207f62d43d2afe1960755a1b5813cae1e5983bcac1bDouglas Gregor friend class ASTWriter; 208f62d43d2afe1960755a1b5813cae1e5983bcac1bDouglas Gregor friend class ASTUnit; // ASTUnit needs to remap source locations. 2093d15ab8d0822637ff5e39594c4f34172241cad2eDouglas Gregor friend class serialization::ReadMethodPoolVisitor; 210ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 2111a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor typedef serialization::ModuleFile ModuleFile; 21272a9ae18553bf8b6bdad84d2c54f73741a47e275Douglas Gregor typedef serialization::ModuleKind ModuleKind; 2135d6d89fef8c7fff8b1a67c943fb5557a2a803468Jonathan D. Turner typedef serialization::ModuleManager ModuleManager; 214ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 2155d6d89fef8c7fff8b1a67c943fb5557a2a803468Jonathan D. Turner typedef ModuleManager::ModuleIterator ModuleIterator; 2165d6d89fef8c7fff8b1a67c943fb5557a2a803468Jonathan D. Turner typedef ModuleManager::ModuleConstIterator ModuleConstIterator; 2175d6d89fef8c7fff8b1a67c943fb5557a2a803468Jonathan D. Turner typedef ModuleManager::ModuleReverseIterator ModuleReverseIterator; 2185d6d89fef8c7fff8b1a67c943fb5557a2a803468Jonathan D. Turner 219e1d918e9fe55e3b34401fd5d420c47ea0f9572c9Douglas Gregorprivate: 220c43b54cbc10654ed59de797898042e1a05265246Sebastian Redl /// \brief The receiver of some callbacks invoked by ASTReader. 2216f42b62b6194f53bcbc349f5d17388e1936535d7Dylan Noblesmith OwningPtr<ASTReaderListener> Listener; 2221eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 22330c514c225342844700ed4640ec6d90ddf0e12b2Sebastian Redl /// \brief The receiver of deserialization events. 224571db7f0cb31789737be92fce1c1b738e6dbe795Sebastian Redl ASTDeserializationListener *DeserializationListener; 22530c514c225342844700ed4640ec6d90ddf0e12b2Sebastian Redl 22611e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis SourceManager &SourceMgr; 22711e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis FileManager &FileMgr; 228d6471f7c1921c7802804ce3ff6fe9768310f72b9David Blaikie DiagnosticsEngine &Diags; 229ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 230668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor /// \brief The semantic analysis object that will be processing the 2313c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// AST files and the translation unit that uses it. 232668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor Sema *SemaObj; 233668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor 23414f79002e58556798e86168c63e48d533287eda5Douglas Gregor /// \brief The preprocessor that will be loading the source file. 235712f2fcb70ae2eb0cb684d565e7d2cb76881006bDouglas Gregor Preprocessor &PP; 23614f79002e58556798e86168c63e48d533287eda5Douglas Gregor 2373c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// \brief The AST context into which we'll read the AST files. 238359427794704666ff7a5a933ace11c5256fa3af7Douglas Gregor ASTContext &Context; 239ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 2400af2ca4b6ddc788658069a0994941268ce250fc7Douglas Gregor /// \brief The AST consumer. 2410af2ca4b6ddc788658069a0994941268ce250fc7Douglas Gregor ASTConsumer *Consumer; 2420af2ca4b6ddc788658069a0994941268ce250fc7Douglas Gregor 2435d6d89fef8c7fff8b1a67c943fb5557a2a803468Jonathan D. Turner /// \brief The module manager which manages modules and their dependencies 2445d6d89fef8c7fff8b1a67c943fb5557a2a803468Jonathan D. Turner ModuleManager ModuleMgr; 2459137a5230d3164b96beb14ffb87863234b7d240fSebastian Redl 2468f1231b70c2b1f6fe0cee097b447487b26810301Douglas Gregor /// \brief A map of global bit offsets to the module that stores entities 2478f1231b70c2b1f6fe0cee097b447487b26810301Douglas Gregor /// at those bit offsets. 2481a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor ContinuousRangeMap<uint64_t, ModuleFile*, 4> GlobalBitOffsetsMap; 2498f1231b70c2b1f6fe0cee097b447487b26810301Douglas Gregor 250f62d43d2afe1960755a1b5813cae1e5983bcac1bDouglas Gregor /// \brief A map of negated SLocEntryIDs to the modules containing them. 2511a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor ContinuousRangeMap<unsigned, ModuleFile*, 64> GlobalSLocEntryMap; 2524ee5a6f9bd82ab3c1a4bdacc0caefe7d5f8bd37aSebastian Redl 2531a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor typedef ContinuousRangeMap<unsigned, ModuleFile*, 64> GlobalSLocOffsetMapType; 254ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 255a68c4aff8cd3aada697ad36dc6582d0e09b4b0d2Argyrios Kyrtzidis /// \brief A map of reversed (SourceManager::MaxLoadedOffset - SLocOffset) 256a68c4aff8cd3aada697ad36dc6582d0e09b4b0d2Argyrios Kyrtzidis /// SourceLocation offsets to the modules containing them. 2572dbaca748bc3eb6539f417bd8354c930bdf88fa4Argyrios Kyrtzidis GlobalSLocOffsetMapType GlobalSLocOffsetMap; 258ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 2593c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// \brief Types that have already been loaded from the chain. 2601eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// 2611eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// When the pointer at index I is non-NULL, the type with 2623c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// ID = (I + 1) << FastQual::Width has already been loaded 2630953e767ff7817f97b3ab20896b229891eeff45bJohn McCall std::vector<QualType> TypesLoaded; 2642cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor 2651a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor typedef ContinuousRangeMap<serialization::TypeID, ModuleFile *, 4> 266e9b76c11a88d0af98f32d11a6668d03d45be3123Jonathan D. Turner GlobalTypeMapType; 267e9b76c11a88d0af98f32d11a6668d03d45be3123Jonathan D. Turner 268e9b76c11a88d0af98f32d11a6668d03d45be3123Jonathan D. Turner /// \brief Mapping from global type IDs to the module in which the 269e9b76c11a88d0af98f32d11a6668d03d45be3123Jonathan D. Turner /// type resides along with the offset that should be added to the 270e9b76c11a88d0af98f32d11a6668d03d45be3123Jonathan D. Turner /// global type ID to produce a local ID. 271e9b76c11a88d0af98f32d11a6668d03d45be3123Jonathan D. Turner GlobalTypeMapType GlobalTypeMap; 272e9b76c11a88d0af98f32d11a6668d03d45be3123Jonathan D. Turner 2733c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// \brief Declarations that have already been loaded from the chain. 2742cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor /// 2758f5dc7fe4d42cea78fa92d1638f753cf65b54cb5Douglas Gregor /// When the pointer at index I is non-NULL, the declaration with ID 2768f5dc7fe4d42cea78fa92d1638f753cf65b54cb5Douglas Gregor /// = I + 1 has already been loaded. 2778f5dc7fe4d42cea78fa92d1638f753cf65b54cb5Douglas Gregor std::vector<Decl *> DeclsLoaded; 2782cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor 2791a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor typedef ContinuousRangeMap<serialization::DeclID, ModuleFile *, 4> 28096e973f2be14c9b82136f74b4108465d24894feaDouglas Gregor GlobalDeclMapType; 281ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 28296e973f2be14c9b82136f74b4108465d24894feaDouglas Gregor /// \brief Mapping from global declaration IDs to the module in which the 2839827a8049a793f23c62ade8f24f0c66c2dbf6741Douglas Gregor /// declaration resides. 28496e973f2be14c9b82136f74b4108465d24894feaDouglas Gregor GlobalDeclMapType GlobalDeclMap; 285ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 2861a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor typedef std::pair<ModuleFile *, uint64_t> FileOffset; 287686775deca8b8685eb90801495880e3abdd844c2Chris Lattner typedef SmallVector<FileOffset, 2> FileOffsetsTy; 2887b90340c9c7d07aef4e301e72b5e8a30d5f4f0c8Argyrios Kyrtzidis typedef llvm::DenseMap<serialization::DeclID, FileOffsetsTy> 2897b90340c9c7d07aef4e301e72b5e8a30d5f4f0c8Argyrios Kyrtzidis DeclUpdateOffsetsMap; 290ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 2917b90340c9c7d07aef4e301e72b5e8a30d5f4f0c8Argyrios Kyrtzidis /// \brief Declarations that have modifications residing in a later file 2927b90340c9c7d07aef4e301e72b5e8a30d5f4f0c8Argyrios Kyrtzidis /// in the chain. 2937b90340c9c7d07aef4e301e72b5e8a30d5f4f0c8Argyrios Kyrtzidis DeclUpdateOffsetsMap DeclUpdateOffsets; 2947b90340c9c7d07aef4e301e72b5e8a30d5f4f0c8Argyrios Kyrtzidis 295ef23b6001e8d9715246ca23bd8c3a6887d7844cbArgyrios Kyrtzidis struct ReplacedDeclInfo { 2961a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor ModuleFile *Mod; 297ef23b6001e8d9715246ca23bd8c3a6887d7844cbArgyrios Kyrtzidis uint64_t Offset; 298ef23b6001e8d9715246ca23bd8c3a6887d7844cbArgyrios Kyrtzidis unsigned RawLoc; 299ef23b6001e8d9715246ca23bd8c3a6887d7844cbArgyrios Kyrtzidis 300ef23b6001e8d9715246ca23bd8c3a6887d7844cbArgyrios Kyrtzidis ReplacedDeclInfo() : Mod(0), Offset(0), RawLoc(0) {} 3011a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor ReplacedDeclInfo(ModuleFile *Mod, uint64_t Offset, unsigned RawLoc) 302ef23b6001e8d9715246ca23bd8c3a6887d7844cbArgyrios Kyrtzidis : Mod(Mod), Offset(Offset), RawLoc(RawLoc) {} 303ef23b6001e8d9715246ca23bd8c3a6887d7844cbArgyrios Kyrtzidis }; 304ef23b6001e8d9715246ca23bd8c3a6887d7844cbArgyrios Kyrtzidis 305ef23b6001e8d9715246ca23bd8c3a6887d7844cbArgyrios Kyrtzidis typedef llvm::DenseMap<serialization::DeclID, ReplacedDeclInfo> 3060b17c61e8f143901ce11b4a6e5129ac63aaeee04Sebastian Redl DeclReplacementMap; 3070b17c61e8f143901ce11b4a6e5129ac63aaeee04Sebastian Redl /// \brief Declarations that have been replaced in a later file in the chain. 3080b17c61e8f143901ce11b4a6e5129ac63aaeee04Sebastian Redl DeclReplacementMap ReplacedDecls; 3090b17c61e8f143901ce11b4a6e5129ac63aaeee04Sebastian Redl 3109d128d04578c62675eeb0cce83066052f9c19c9aArgyrios Kyrtzidis struct FileDeclsInfo { 3111a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor ModuleFile *Mod; 3129d128d04578c62675eeb0cce83066052f9c19c9aArgyrios Kyrtzidis ArrayRef<serialization::LocalDeclID> Decls; 3139d128d04578c62675eeb0cce83066052f9c19c9aArgyrios Kyrtzidis 3149d128d04578c62675eeb0cce83066052f9c19c9aArgyrios Kyrtzidis FileDeclsInfo() : Mod(0) {} 3151a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor FileDeclsInfo(ModuleFile *Mod, ArrayRef<serialization::LocalDeclID> Decls) 3169d128d04578c62675eeb0cce83066052f9c19c9aArgyrios Kyrtzidis : Mod(Mod), Decls(Decls) {} 3179d128d04578c62675eeb0cce83066052f9c19c9aArgyrios Kyrtzidis }; 3189d128d04578c62675eeb0cce83066052f9c19c9aArgyrios Kyrtzidis 31910f3df54486385e6497c9e5f229ff816e5a6c511Argyrios Kyrtzidis /// \brief Map from a FileID to the file-level declarations that it contains. 3209d128d04578c62675eeb0cce83066052f9c19c9aArgyrios Kyrtzidis llvm::DenseMap<FileID, FileDeclsInfo> FileDeclIDs; 32110f3df54486385e6497c9e5f229ff816e5a6c511Argyrios Kyrtzidis 322e1dde811b38e779894150cb1093d57f8411a84f7Sebastian Redl // Updates for visible decls can occur for other contexts than just the 323e1dde811b38e779894150cb1093d57f8411a84f7Sebastian Redl // TU, and when we read those update records, the actual context will not 324e1dde811b38e779894150cb1093d57f8411a84f7Sebastian Redl // be available yet (unless it's the TU), so have this pending map using the 325e1dde811b38e779894150cb1093d57f8411a84f7Sebastian Redl // ID as a key. It will be realized when the context is actually loaded. 3261a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor typedef SmallVector<std::pair<void *, ModuleFile*>, 1> DeclContextVisibleUpdates; 327e1dde811b38e779894150cb1093d57f8411a84f7Sebastian Redl typedef llvm::DenseMap<serialization::DeclID, DeclContextVisibleUpdates> 328e1dde811b38e779894150cb1093d57f8411a84f7Sebastian Redl DeclContextVisibleUpdatesPending; 3292cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor 330e1dde811b38e779894150cb1093d57f8411a84f7Sebastian Redl /// \brief Updates to the visible declarations of declaration contexts that 331e1dde811b38e779894150cb1093d57f8411a84f7Sebastian Redl /// haven't been loaded yet. 332e1dde811b38e779894150cb1093d57f8411a84f7Sebastian Redl DeclContextVisibleUpdatesPending PendingVisibleUpdates; 3332e5c15be82f362611c5928ce853d0685ff98c766Douglas Gregor 334fc529f7fcafe7da0b8a32621e13685891e8ce52aDouglas Gregor /// \brief The set of C++ or Objective-C classes that have forward 335fc529f7fcafe7da0b8a32621e13685891e8ce52aDouglas Gregor /// declarations that have not yet been linked to their definitions. 336fc529f7fcafe7da0b8a32621e13685891e8ce52aDouglas Gregor llvm::SmallPtrSet<Decl *, 4> PendingDefinitions; 337fc529f7fcafe7da0b8a32621e13685891e8ce52aDouglas Gregor 338681d7237e1014bf64dd5ead6bf74ae55cdd19e61Sebastian Redl /// \brief Read the records that describe the contents of declcontexts. 3391a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor bool ReadDeclContextStorage(ModuleFile &M, 3400d95f77ba180aee35b74f3bf9f8543477f3af543Douglas Gregor llvm::BitstreamCursor &Cursor, 341681d7237e1014bf64dd5ead6bf74ae55cdd19e61Sebastian Redl const std::pair<uint64_t, uint64_t> &Offsets, 3420d95f77ba180aee35b74f3bf9f8543477f3af543Douglas Gregor serialization::DeclContextInfo &Info); 343681d7237e1014bf64dd5ead6bf74ae55cdd19e61Sebastian Redl 3442b3a5a83ea30bde7fa8f9d8e9a0cb12623759bfbDouglas Gregor /// \brief A vector containing identifiers that have already been 3452b3a5a83ea30bde7fa8f9d8e9a0cb12623759bfbDouglas Gregor /// loaded. 3462b3a5a83ea30bde7fa8f9d8e9a0cb12623759bfbDouglas Gregor /// 3472b3a5a83ea30bde7fa8f9d8e9a0cb12623759bfbDouglas Gregor /// If the pointer at index I is non-NULL, then it refers to the 3482b3a5a83ea30bde7fa8f9d8e9a0cb12623759bfbDouglas Gregor /// IdentifierInfo for the identifier with ID=I+1 that has already 3492b3a5a83ea30bde7fa8f9d8e9a0cb12623759bfbDouglas Gregor /// been loaded. 3502b3a5a83ea30bde7fa8f9d8e9a0cb12623759bfbDouglas Gregor std::vector<IdentifierInfo *> IdentifiersLoaded; 351afaf308b779cd8e8fc8c42601b9f383423c15c2dDouglas Gregor 3521a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor typedef ContinuousRangeMap<serialization::IdentID, ModuleFile *, 4> 35367268d02388d3d25107fa9cf4998c35246255a65Douglas Gregor GlobalIdentifierMapType; 354ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 35567268d02388d3d25107fa9cf4998c35246255a65Douglas Gregor /// \brief Mapping from global identifer IDs to the module in which the 35667268d02388d3d25107fa9cf4998c35246255a65Douglas Gregor /// identifier resides along with the offset that should be added to the 35767268d02388d3d25107fa9cf4998c35246255a65Douglas Gregor /// global identifier ID to produce a local ID. 35867268d02388d3d25107fa9cf4998c35246255a65Douglas Gregor GlobalIdentifierMapType GlobalIdentifierMap; 35967268d02388d3d25107fa9cf4998c35246255a65Douglas Gregor 36026ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor /// \brief A vector containing submodules that have already been loaded. 36126ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor /// 36226ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor /// This vector is indexed by the Submodule ID (-1). NULL submodule entries 36326ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor /// indicate that the particular submodule ID has not yet been loaded. 36426ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor SmallVector<Module *, 2> SubmodulesLoaded; 36526ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor 36626ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor typedef ContinuousRangeMap<serialization::SubmoduleID, ModuleFile *, 4> 36726ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor GlobalSubmoduleMapType; 36826ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor 36926ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor /// \brief Mapping from global submodule IDs to the module file in which the 37026ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor /// submodule resides along with the offset that should be added to the 37126ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor /// global submodule ID to produce a local ID. 37226ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor GlobalSubmoduleMapType GlobalSubmoduleMap; 37326ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor 374ecc2c090e7146c029dd9ee9a5a2fd66b275c01c0Douglas Gregor /// \brief A set of hidden declarations. 3751329264ce0922b3cec8c8c599108f082105fa0e1Douglas Gregor typedef llvm::SmallVector<llvm::PointerUnion<Decl *, IdentifierInfo *>, 2> 3761329264ce0922b3cec8c8c599108f082105fa0e1Douglas Gregor HiddenNames; 377ecc2c090e7146c029dd9ee9a5a2fd66b275c01c0Douglas Gregor 378ecc2c090e7146c029dd9ee9a5a2fd66b275c01c0Douglas Gregor typedef llvm::DenseMap<Module *, HiddenNames> HiddenNamesMapType; 379ecc2c090e7146c029dd9ee9a5a2fd66b275c01c0Douglas Gregor 380ecc2c090e7146c029dd9ee9a5a2fd66b275c01c0Douglas Gregor /// \brief A mapping from each of the hidden submodules to the deserialized 381ecc2c090e7146c029dd9ee9a5a2fd66b275c01c0Douglas Gregor /// declarations in that submodule that could be made visible. 382ecc2c090e7146c029dd9ee9a5a2fd66b275c01c0Douglas Gregor HiddenNamesMapType HiddenNamesMap; 383ecc2c090e7146c029dd9ee9a5a2fd66b275c01c0Douglas Gregor 38455988680ece66b8e505ee136b35e74fcb1173aeeDouglas Gregor 38555988680ece66b8e505ee136b35e74fcb1173aeeDouglas Gregor /// \brief A module import or export that hasn't yet been resolved. 38655988680ece66b8e505ee136b35e74fcb1173aeeDouglas Gregor struct UnresolvedModuleImportExport { 387af13bfc3b40aa4a46f4e71d200ecfb10f45297fcDouglas Gregor /// \brief The file in which this module resides. 388af13bfc3b40aa4a46f4e71d200ecfb10f45297fcDouglas Gregor ModuleFile *File; 389af13bfc3b40aa4a46f4e71d200ecfb10f45297fcDouglas Gregor 39055988680ece66b8e505ee136b35e74fcb1173aeeDouglas Gregor /// \brief The module that is importing or exporting. 39155988680ece66b8e505ee136b35e74fcb1173aeeDouglas Gregor Module *Mod; 392af13bfc3b40aa4a46f4e71d200ecfb10f45297fcDouglas Gregor 393af13bfc3b40aa4a46f4e71d200ecfb10f45297fcDouglas Gregor /// \brief The local ID of the module that is being exported. 39455988680ece66b8e505ee136b35e74fcb1173aeeDouglas Gregor unsigned ID; 39555988680ece66b8e505ee136b35e74fcb1173aeeDouglas Gregor 39655988680ece66b8e505ee136b35e74fcb1173aeeDouglas Gregor /// \brief Whether this is an import (vs. an export). 39755988680ece66b8e505ee136b35e74fcb1173aeeDouglas Gregor unsigned IsImport : 1; 39855988680ece66b8e505ee136b35e74fcb1173aeeDouglas Gregor 39955988680ece66b8e505ee136b35e74fcb1173aeeDouglas Gregor /// \brief Whether this is a wildcard export. 40055988680ece66b8e505ee136b35e74fcb1173aeeDouglas Gregor unsigned IsWildcard : 1; 401af13bfc3b40aa4a46f4e71d200ecfb10f45297fcDouglas Gregor }; 402af13bfc3b40aa4a46f4e71d200ecfb10f45297fcDouglas Gregor 40355988680ece66b8e505ee136b35e74fcb1173aeeDouglas Gregor /// \brief The set of module imports and exports that still need to be 40455988680ece66b8e505ee136b35e74fcb1173aeeDouglas Gregor /// resolved. 40555988680ece66b8e505ee136b35e74fcb1173aeeDouglas Gregor llvm::SmallVector<UnresolvedModuleImportExport, 2> 40655988680ece66b8e505ee136b35e74fcb1173aeeDouglas Gregor UnresolvedModuleImportExports; 407af13bfc3b40aa4a46f4e71d200ecfb10f45297fcDouglas Gregor 4081eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// \brief A vector containing selectors that have already been loaded. 40983941df2745d69c05acee3174c7a265c206f70d9Douglas Gregor /// 41083941df2745d69c05acee3174c7a265c206f70d9Douglas Gregor /// This vector is indexed by the Selector ID (-1). NULL selector 41183941df2745d69c05acee3174c7a265c206f70d9Douglas Gregor /// entries indicate that the particular selector ID has not yet 41283941df2745d69c05acee3174c7a265c206f70d9Douglas Gregor /// been loaded. 413686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVector<Selector, 16> SelectorsLoaded; 414725cd9686a0f5bb6c994cb3e43f58b63567c6860Sebastian Redl 4151a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor typedef ContinuousRangeMap<serialization::SelectorID, ModuleFile *, 4> 41696958cbe6fb423ab2446629ead5f1b138398433cDouglas Gregor GlobalSelectorMapType; 417ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 41896958cbe6fb423ab2446629ead5f1b138398433cDouglas Gregor /// \brief Mapping from global selector IDs to the module in which the 41996958cbe6fb423ab2446629ead5f1b138398433cDouglas Gregor /// selector resides along with the offset that should be added to the 42096958cbe6fb423ab2446629ead5f1b138398433cDouglas Gregor /// global selector ID to produce a local ID. 42196958cbe6fb423ab2446629ead5f1b138398433cDouglas Gregor GlobalSelectorMapType GlobalSelectorMap; 42296958cbe6fb423ab2446629ead5f1b138398433cDouglas Gregor 4238efca6bb688d32fd7c0d91b504ef3307f97ee66aDouglas Gregor /// \brief The generation number of the last time we loaded data from the 4248efca6bb688d32fd7c0d91b504ef3307f97ee66aDouglas Gregor /// global method pool for this selector. 4258efca6bb688d32fd7c0d91b504ef3307f97ee66aDouglas Gregor llvm::DenseMap<Selector, unsigned> SelectorGeneration; 4268efca6bb688d32fd7c0d91b504ef3307f97ee66aDouglas Gregor 427295a2a617ac335f590e430ab7fcd98f8ce109251Douglas Gregor /// \brief Mapping from identifiers that represent macros whose definitions 428295a2a617ac335f590e430ab7fcd98f8ce109251Douglas Gregor /// have not yet been deserialized to the global offset where the macro 429295a2a617ac335f590e430ab7fcd98f8ce109251Douglas Gregor /// record resides. 430295a2a617ac335f590e430ab7fcd98f8ce109251Douglas Gregor llvm::DenseMap<IdentifierInfo *, uint64_t> UnreadMacroRecordOffsets; 4314c30bb148b53c8063e940ca3e049ba4d270dc9d5Douglas Gregor 4321a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor typedef ContinuousRangeMap<unsigned, ModuleFile *, 4> 4334c30bb148b53c8063e940ca3e049ba4d270dc9d5Douglas Gregor GlobalPreprocessedEntityMapType; 434ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 4354c30bb148b53c8063e940ca3e049ba4d270dc9d5Douglas Gregor /// \brief Mapping from global preprocessing entity IDs to the module in 4364c30bb148b53c8063e940ca3e049ba4d270dc9d5Douglas Gregor /// which the preprocessed entity resides along with the offset that should be 4374c30bb148b53c8063e940ca3e049ba4d270dc9d5Douglas Gregor /// added to the global preprocessing entitiy ID to produce a local ID. 4384c30bb148b53c8063e940ca3e049ba4d270dc9d5Douglas Gregor GlobalPreprocessedEntityMapType GlobalPreprocessedEntityMap; 439ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 440892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// \name CodeGen-relevant special data 441892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// \brief Fields containing data that is relevant to CodeGen. 442892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl //@{ 443892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl 444892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// \brief The IDs of all declarations that fulfill the criteria of 445892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// "interesting" decls. 446892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// 447892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// This contains the data loaded from all EXTERNAL_DEFINITIONS blocks in the 448892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// chain. The referenced declarations are deserialized and passed to the 449892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// consumer eagerly. 450686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVector<uint64_t, 16> ExternalDefinitions; 451fdd0172ca1b3c837f8c2b37d69cc2085234e09faDouglas Gregor 452892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// \brief The IDs of all tentative definitions stored in the the chain. 453892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// 454892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// Sema keeps track of all tentative definitions in a TU because it has to 455892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// complete them and pass them on to CodeGen. Thus, tentative definitions in 456892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// the PCH chain must be eagerly deserialized. 457686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVector<uint64_t, 16> TentativeDefinitions; 458892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl 459892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// \brief The IDs of all CXXRecordDecls stored in the chain whose VTables are 460892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// used. 461892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// 462892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// CodeGen has to emit VTables for these records, so they have to be eagerly 463892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// deserialized. 464686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVector<uint64_t, 64> VTableUses; 465892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl 466f2abb52acbba25ad93a1ecdc24d994b9694803a1Douglas Gregor /// \brief A snapshot of the pending instantiations in the chain. 467f2abb52acbba25ad93a1ecdc24d994b9694803a1Douglas Gregor /// 468f2abb52acbba25ad93a1ecdc24d994b9694803a1Douglas Gregor /// This record tracks the instantiations that Sema has to perform at the 469f2abb52acbba25ad93a1ecdc24d994b9694803a1Douglas Gregor /// end of the TU. It consists of a pair of values for every pending 470f2abb52acbba25ad93a1ecdc24d994b9694803a1Douglas Gregor /// instantiation where the first value is the ID of the decl and the second 471f2abb52acbba25ad93a1ecdc24d994b9694803a1Douglas Gregor /// is the instantiation location. 472f2abb52acbba25ad93a1ecdc24d994b9694803a1Douglas Gregor SmallVector<uint64_t, 64> PendingInstantiations; 473f2abb52acbba25ad93a1ecdc24d994b9694803a1Douglas Gregor 474892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl //@} 475892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl 476d6471f7c1921c7802804ce3ff6fe9768310f72b9David Blaikie /// \name DiagnosticsEngine-relevant special data 477892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// \brief Fields containing data that is used for generating diagnostics 478892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl //@{ 479892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl 480892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// \brief A snapshot of Sema's unused file-scoped variable tracking, for 481892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// generating warnings. 482686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVector<uint64_t, 16> UnusedFileScopedDecls; 4834c0e86b392c5fb0cb771551fc877edb6979be69cDouglas Gregor 484ebcbe1d3dc7d4f0c1f540a632fa0684dd0a857d5Sean Hunt /// \brief A list of all the delegating constructors we've seen, to diagnose 485ebcbe1d3dc7d4f0c1f540a632fa0684dd0a857d5Sean Hunt /// cycles. 486686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVector<uint64_t, 4> DelegatingCtorDecls; 487ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 4888451ec7e709baf777bec07dc70653e0c523dd120Douglas Gregor /// \brief Method selectors used in a @selector expression. Used for 4898451ec7e709baf777bec07dc70653e0c523dd120Douglas Gregor /// implementation of -Wselector. 4908451ec7e709baf777bec07dc70653e0c523dd120Douglas Gregor SmallVector<uint64_t, 64> ReferencedSelectorsData; 491ebcbe1d3dc7d4f0c1f540a632fa0684dd0a857d5Sean Hunt 492892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// \brief A snapshot of Sema's weak undeclared identifier tracking, for 493892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// generating warnings. 494686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVector<uint64_t, 64> WeakUndeclaredIdentifiers; 49514c22f20c077cecd68581952a0c227f8c180be03Douglas Gregor 496892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// \brief The IDs of type aliases for ext_vectors that exist in the chain. 497892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// 498892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// Used by Sema for finding sugared names for ext_vectors in diagnostics. 499686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVector<uint64_t, 4> ExtVectorDecls; 500b81c17092039f39be60e9656a37cffbdf2e2c783Douglas Gregor 501892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl //@} 502d455add086f1dfa16ae87dc310e49493bbc2b0a6Argyrios Kyrtzidis 503892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// \name Sema-relevant special data 504892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// \brief Fields containing data that is used for semantic analysis 505892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl //@{ 506892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl 507892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// \brief The IDs of all locally scoped external decls in the chain. 508892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// 509892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// Sema tracks these to validate that the types are consistent across all 510892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// local external declarations. 511686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVector<uint64_t, 16> LocallyScopedExternalDecls; 512d455add086f1dfa16ae87dc310e49493bbc2b0a6Argyrios Kyrtzidis 513892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// \brief The IDs of all dynamic class declarations in the chain. 514892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// 515892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// Sema tracks these because it checks for the key functions being defined 516892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// at the end of the TU, in which case it directs CodeGen to emit the VTable. 517686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVector<uint64_t, 16> DynamicClasses; 518892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl 519892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// \brief The IDs of the declarations Sema stores directly. 520892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// 521892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl /// Sema tracks a few important decls, such as namespace std, directly. 522686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVector<uint64_t, 4> SemaDeclRefs; 52376c38d385447b7acdff2d7e6b13fa8580e7174a7Argyrios Kyrtzidis 524e41f985c15d15fce8390ebffb49dc75447c8f0f6Sebastian Redl /// \brief The IDs of the types ASTContext stores directly. 525e41f985c15d15fce8390ebffb49dc75447c8f0f6Sebastian Redl /// 526e41f985c15d15fce8390ebffb49dc75447c8f0f6Sebastian Redl /// The AST context tracks a few important types, such as va_list, directly. 527686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVector<uint64_t, 16> SpecialTypes; 528e41f985c15d15fce8390ebffb49dc75447c8f0f6Sebastian Redl 52914b6ba77710d6431794d65c7d58c6f29c3dc956ePeter Collingbourne /// \brief The IDs of CUDA-specific declarations ASTContext stores directly. 53014b6ba77710d6431794d65c7d58c6f29c3dc956ePeter Collingbourne /// 53114b6ba77710d6431794d65c7d58c6f29c3dc956ePeter Collingbourne /// The AST context tracks a few important decls, currently cudaConfigureCall, 53214b6ba77710d6431794d65c7d58c6f29c3dc956ePeter Collingbourne /// directly. 533686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVector<uint64_t, 2> CUDASpecialDeclRefs; 53414b6ba77710d6431794d65c7d58c6f29c3dc956ePeter Collingbourne 53584bccea1ad9fd8bc1f4ec3d1fc5dd8d15dabffbcPeter Collingbourne /// \brief The floating point pragma option settings. 536686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVector<uint64_t, 1> FPPragmaOptions; 53784bccea1ad9fd8bc1f4ec3d1fc5dd8d15dabffbcPeter Collingbourne 53884bccea1ad9fd8bc1f4ec3d1fc5dd8d15dabffbcPeter Collingbourne /// \brief The OpenCL extension settings. 539686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVector<uint64_t, 1> OpenCLExtensions; 54084bccea1ad9fd8bc1f4ec3d1fc5dd8d15dabffbcPeter Collingbourne 541d8bba9c15230d2b1b3893e272106aa79efc50251Douglas Gregor /// \brief A list of the namespaces we've seen. 542686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVector<uint64_t, 4> KnownNamespaces; 543d8bba9c15230d2b1b3893e272106aa79efc50251Douglas Gregor 544f6137e4d15cb6bbd10547267babfc699c1945873Douglas Gregor /// \brief A list of modules that were imported by precompiled headers or 545f6137e4d15cb6bbd10547267babfc699c1945873Douglas Gregor /// any other non-module AST file. 546f6137e4d15cb6bbd10547267babfc699c1945873Douglas Gregor SmallVector<serialization::SubmoduleID, 2> ImportedModules; 547892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl //@} 548892ac04155aad22f8172d06a929e09cf51e8bc68Sebastian Redl 5493c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// \brief The original file name that was used to build the primary AST file, 5503c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// which may have been modified for relocatable-pch support. 551b64c19365deab788753d29c9bc881253c3f16f37Douglas Gregor std::string OriginalFileName; 552b64c19365deab788753d29c9bc881253c3f16f37Douglas Gregor 5533c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// \brief The actual original file name that was used to build the primary 5543c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// AST file. 5557b5a1210d93ca62ecd61800f245c87259b1f8f79Daniel Dunbar std::string ActualOriginalFileName; 5567b5a1210d93ca62ecd61800f245c87259b1f8f79Daniel Dunbar 55731d375f056447d4e2418275d4913661d3bfedb3eDouglas Gregor /// \brief The file ID for the original file that was used to build the 55831d375f056447d4e2418275d4913661d3bfedb3eDouglas Gregor /// primary AST file. 55931d375f056447d4e2418275d4913661d3bfedb3eDouglas Gregor FileID OriginalFileID; 560ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 5618e3df4d0864f0a966c20088ca1a29c3398b7639dArgyrios Kyrtzidis /// \brief The directory that the PCH was originally created in. Used to 5628e3df4d0864f0a966c20088ca1a29c3398b7639dArgyrios Kyrtzidis /// allow resolving headers even after headers+PCH was moved to a new path. 5638e3df4d0864f0a966c20088ca1a29c3398b7639dArgyrios Kyrtzidis std::string OriginalDir; 5648e3df4d0864f0a966c20088ca1a29c3398b7639dArgyrios Kyrtzidis 5658e3df4d0864f0a966c20088ca1a29c3398b7639dArgyrios Kyrtzidis /// \brief The directory that the PCH we are reading is stored in. 5668e3df4d0864f0a966c20088ca1a29c3398b7639dArgyrios Kyrtzidis std::string CurrentDir; 5678e3df4d0864f0a966c20088ca1a29c3398b7639dArgyrios Kyrtzidis 568e650c8c3bca2f58cad8ffa8aab63126d26e890cdDouglas Gregor /// \brief Whether this precompiled header is a relocatable PCH file. 569e650c8c3bca2f58cad8ffa8aab63126d26e890cdDouglas Gregor bool RelocatablePCH; 5701eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5711eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// \brief The system include root to be used when loading the 572e650c8c3bca2f58cad8ffa8aab63126d26e890cdDouglas Gregor /// precompiled header. 573832d620b4ae0fc5fe28561b885b4cfc65cf5c9abDouglas Gregor std::string isysroot; 5741eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 575fae3b2f4743dad616623c4df2fdb0f5128bd36d9Douglas Gregor /// \brief Whether to disable the normal validation performed on precompiled 576fae3b2f4743dad616623c4df2fdb0f5128bd36d9Douglas Gregor /// headers when they are loaded. 577fae3b2f4743dad616623c4df2fdb0f5128bd36d9Douglas Gregor bool DisableValidation; 578ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 5798ef6c8cb6c5627240e2339fd7062c9873f821d7eDouglas Gregor /// \brief Whether to disable the use of stat caches in AST files. 5808ef6c8cb6c5627240e2339fd7062c9873f821d7eDouglas Gregor bool DisableStatCache; 5818ef6c8cb6c5627240e2339fd7062c9873f821d7eDouglas Gregor 582057df20b3107cef764052d271c89b8591b98b3ceDouglas Gregor /// \brief The current "generation" of the module file import stack, which 583057df20b3107cef764052d271c89b8591b98b3ceDouglas Gregor /// indicates how many separate module file load operations have occurred. 584057df20b3107cef764052d271c89b8591b98b3ceDouglas Gregor unsigned CurrentGeneration; 585057df20b3107cef764052d271c89b8591b98b3ceDouglas Gregor 5863c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// \brief Mapping from switch-case IDs in the chain to switch-case statements 587e41f985c15d15fce8390ebffb49dc75447c8f0f6Sebastian Redl /// 588e41f985c15d15fce8390ebffb49dc75447c8f0f6Sebastian Redl /// Statements usually don't have IDs, but switch cases need them, so that the 589e41f985c15d15fce8390ebffb49dc75447c8f0f6Sebastian Redl /// switch statement can refer to them. 590025452fa0eda63e150cfaeebe64f0a19c96b3a06Douglas Gregor std::map<unsigned, SwitchCase *> SwitchCaseStmts; 591025452fa0eda63e150cfaeebe64f0a19c96b3a06Douglas Gregor 5924fed3f47f6b9e31d603c5c2d1f6d8ec2e1241e57Douglas Gregor /// \brief The number of stat() calls that hit/missed the stat 5934fed3f47f6b9e31d603c5c2d1f6d8ec2e1241e57Douglas Gregor /// cache. 5944fed3f47f6b9e31d603c5c2d1f6d8ec2e1241e57Douglas Gregor unsigned NumStatHits, NumStatMisses; 5954fed3f47f6b9e31d603c5c2d1f6d8ec2e1241e57Douglas Gregor 5967f94b0b0c6791013d2f72ced9b4bedd3b23673a6Douglas Gregor /// \brief The number of source location entries de-serialized from 5977f94b0b0c6791013d2f72ced9b4bedd3b23673a6Douglas Gregor /// the PCH file. 5987f94b0b0c6791013d2f72ced9b4bedd3b23673a6Douglas Gregor unsigned NumSLocEntriesRead; 5997f94b0b0c6791013d2f72ced9b4bedd3b23673a6Douglas Gregor 6003c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// \brief The number of source location entries in the chain. 601518d8cb31d26ea098eba79274abbfae1b4976853Sebastian Redl unsigned TotalNumSLocEntries; 602518d8cb31d26ea098eba79274abbfae1b4976853Sebastian Redl 6033e1af84bb0092a1aafb49deaa4ab6664c9a9071bDouglas Gregor /// \brief The number of statements (and expressions) de-serialized 6043c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// from the chain. 6053e1af84bb0092a1aafb49deaa4ab6664c9a9071bDouglas Gregor unsigned NumStatementsRead; 6063e1af84bb0092a1aafb49deaa4ab6664c9a9071bDouglas Gregor 6073e1af84bb0092a1aafb49deaa4ab6664c9a9071bDouglas Gregor /// \brief The total number of statements (and expressions) stored 6083c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// in the chain. 6093e1af84bb0092a1aafb49deaa4ab6664c9a9071bDouglas Gregor unsigned TotalNumStatements; 6103e1af84bb0092a1aafb49deaa4ab6664c9a9071bDouglas Gregor 6113c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// \brief The number of macros de-serialized from the chain. 61237e2684abfe38207fdb90620da062bb18c23f29aDouglas Gregor unsigned NumMacrosRead; 6132512308525ff328aa992da0b5ee14a488d2ea93aDouglas Gregor 6143c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// \brief The total number of macros stored in the chain. 615fa78dec572259aca763457b435744f79d822c5d4Sebastian Redl unsigned TotalNumMacros; 616fa78dec572259aca763457b435744f79d822c5d4Sebastian Redl 617725cd9686a0f5bb6c994cb3e43f58b63567c6860Sebastian Redl /// \brief The number of selectors that have been read. 618725cd9686a0f5bb6c994cb3e43f58b63567c6860Sebastian Redl unsigned NumSelectorsRead; 61983941df2745d69c05acee3174c7a265c206f70d9Douglas Gregor 620fa78dec572259aca763457b435744f79d822c5d4Sebastian Redl /// \brief The number of method pool entries that have been read. 621fa78dec572259aca763457b435744f79d822c5d4Sebastian Redl unsigned NumMethodPoolEntriesRead; 62283941df2745d69c05acee3174c7a265c206f70d9Douglas Gregor 623fa78dec572259aca763457b435744f79d822c5d4Sebastian Redl /// \brief The number of times we have looked up a selector in the method 624fa78dec572259aca763457b435744f79d822c5d4Sebastian Redl /// pool and not found anything interesting. 625fa78dec572259aca763457b435744f79d822c5d4Sebastian Redl unsigned NumMethodPoolMisses; 626fa78dec572259aca763457b435744f79d822c5d4Sebastian Redl 627fa78dec572259aca763457b435744f79d822c5d4Sebastian Redl /// \brief The total number of method pool entries in the selector table. 628fa78dec572259aca763457b435744f79d822c5d4Sebastian Redl unsigned TotalNumMethodPoolEntries; 62937e2684abfe38207fdb90620da062bb18c23f29aDouglas Gregor 6302512308525ff328aa992da0b5ee14a488d2ea93aDouglas Gregor /// Number of lexical decl contexts read/total. 6312512308525ff328aa992da0b5ee14a488d2ea93aDouglas Gregor unsigned NumLexicalDeclContextsRead, TotalLexicalDeclContexts; 6322512308525ff328aa992da0b5ee14a488d2ea93aDouglas Gregor 6332512308525ff328aa992da0b5ee14a488d2ea93aDouglas Gregor /// Number of visible decl contexts read/total. 6342512308525ff328aa992da0b5ee14a488d2ea93aDouglas Gregor unsigned NumVisibleDeclContextsRead, TotalVisibleDeclContexts; 635ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 6361da901467f72d1733704b068e22089813a1962fdJonathan D. Turner /// Total size of modules, in bits, currently loaded 6371da901467f72d1733704b068e22089813a1962fdJonathan D. Turner uint64_t TotalModulesSizeInBits; 6381da901467f72d1733704b068e22089813a1962fdJonathan D. Turner 63929ee3a273f58e16df7f2c524ab62a869e44fc9b1Argyrios Kyrtzidis /// \brief Number of Decl/types that are currently deserializing. 64029ee3a273f58e16df7f2c524ab62a869e44fc9b1Argyrios Kyrtzidis unsigned NumCurrentElementsDeserializing; 6411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 64244d2dbdce49d1fca3826d543ba875bb82f759091Argyrios Kyrtzidis /// \brief Set true while we are in the process of passing deserialized 64344d2dbdce49d1fca3826d543ba875bb82f759091Argyrios Kyrtzidis /// "interesting" decls to consumer inside FinishedDeserializing(). 64444d2dbdce49d1fca3826d543ba875bb82f759091Argyrios Kyrtzidis /// This is used as a guard to avoid recursively repeating the process of 64544d2dbdce49d1fca3826d543ba875bb82f759091Argyrios Kyrtzidis /// passing decls to consumer. 64644d2dbdce49d1fca3826d543ba875bb82f759091Argyrios Kyrtzidis bool PassingDeclsToConsumer; 64744d2dbdce49d1fca3826d543ba875bb82f759091Argyrios Kyrtzidis 6481da901467f72d1733704b068e22089813a1962fdJonathan D. Turner /// Number of CXX base specifiers currently loaded 6491da901467f72d1733704b068e22089813a1962fdJonathan D. Turner unsigned NumCXXBaseSpecifiersLoaded; 6501da901467f72d1733704b068e22089813a1962fdJonathan D. Turner 6511eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// \brief An IdentifierInfo that has been loaded but whose top-level 652d89275bc865e2b552836c7b33e636d4f86b8de6dDouglas Gregor /// declarations of the same name have not (yet) been loaded. 653d89275bc865e2b552836c7b33e636d4f86b8de6dDouglas Gregor struct PendingIdentifierInfo { 654d89275bc865e2b552836c7b33e636d4f86b8de6dDouglas Gregor IdentifierInfo *II; 655686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVector<uint32_t, 4> DeclIDs; 656d89275bc865e2b552836c7b33e636d4f86b8de6dDouglas Gregor }; 6571eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 6583c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// \brief The set of identifiers that were read while the AST reader was 6591eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// (recursively) loading declarations. 6601eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// 661d89275bc865e2b552836c7b33e636d4f86b8de6dDouglas Gregor /// The declarations on the identifier chain for these identifiers will be 662d89275bc865e2b552836c7b33e636d4f86b8de6dDouglas Gregor /// loaded once the recursive loading has completed. 663d89275bc865e2b552836c7b33e636d4f86b8de6dDouglas Gregor std::deque<PendingIdentifierInfo> PendingIdentifierInfos; 6641eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 6658efca6bb688d32fd7c0d91b504ef3307f97ee66aDouglas Gregor /// \brief The generation number of each identifier, which keeps track of 6668efca6bb688d32fd7c0d91b504ef3307f97ee66aDouglas Gregor /// the last time we loaded information about this identifier. 667057df20b3107cef764052d271c89b8591b98b3ceDouglas Gregor llvm::DenseMap<IdentifierInfo *, unsigned> IdentifierGeneration; 668057df20b3107cef764052d271c89b8591b98b3ceDouglas Gregor 669c62a2fe1957626bc4b29402b2d0a3694dfaa3280Douglas Gregor /// \brief Contains declarations and definitions that will be 670c62a2fe1957626bc4b29402b2d0a3694dfaa3280Douglas Gregor /// "interesting" to the ASTConsumer, when we get that AST consumer. 671c62a2fe1957626bc4b29402b2d0a3694dfaa3280Douglas Gregor /// 672c62a2fe1957626bc4b29402b2d0a3694dfaa3280Douglas Gregor /// "Interesting" declarations are those that have data that may 673c62a2fe1957626bc4b29402b2d0a3694dfaa3280Douglas Gregor /// need to be emitted, such as inline function definitions or 674c62a2fe1957626bc4b29402b2d0a3694dfaa3280Douglas Gregor /// Objective-C protocols. 675bb80a8e8887c1ec74ee135d4ad9455eafedf1508Argyrios Kyrtzidis std::deque<Decl *> InterestingDecls; 676c62a2fe1957626bc4b29402b2d0a3694dfaa3280Douglas Gregor 6772171bf1caba4d4b9eeb6a91efac4300b41f38b07Douglas Gregor /// \brief The set of redeclarable declaraations that have been deserialized 6782171bf1caba4d4b9eeb6a91efac4300b41f38b07Douglas Gregor /// since the last time the declaration chains were linked. 6792171bf1caba4d4b9eeb6a91efac4300b41f38b07Douglas Gregor llvm::SmallPtrSet<Decl *, 16> RedeclsDeserialized; 6802171bf1caba4d4b9eeb6a91efac4300b41f38b07Douglas Gregor 681a1be278c4f3a234ff61f04018d26c6beecde1654Douglas Gregor /// \brief The list of redeclaration chains that still need to be 682a1be278c4f3a234ff61f04018d26c6beecde1654Douglas Gregor /// reconstructed. 683a1be278c4f3a234ff61f04018d26c6beecde1654Douglas Gregor /// 684a1be278c4f3a234ff61f04018d26c6beecde1654Douglas Gregor /// Each element is the global declaration ID of the first declaration in 685a1be278c4f3a234ff61f04018d26c6beecde1654Douglas Gregor /// the chain. Elements in this vector should be unique; use 686a1be278c4f3a234ff61f04018d26c6beecde1654Douglas Gregor /// PendingDeclChainsKnown to ensure uniqueness. 687a1be278c4f3a234ff61f04018d26c6beecde1654Douglas Gregor llvm::SmallVector<serialization::DeclID, 16> PendingDeclChains; 688a1be278c4f3a234ff61f04018d26c6beecde1654Douglas Gregor 689a1be278c4f3a234ff61f04018d26c6beecde1654Douglas Gregor /// \brief Keeps track of the elements added to PendingDeclChains. 690a1be278c4f3a234ff61f04018d26c6beecde1654Douglas Gregor llvm::SmallSet<serialization::DeclID, 16> PendingDeclChainsKnown; 691a1be278c4f3a234ff61f04018d26c6beecde1654Douglas Gregor 692cff9f26ce0ed76d555cd33b3dca84dd5cdf376afDouglas Gregor /// \brief The set of Objective-C categories that have been deserialized 693cff9f26ce0ed76d555cd33b3dca84dd5cdf376afDouglas Gregor /// since the last time the declaration chains were linked. 694cff9f26ce0ed76d555cd33b3dca84dd5cdf376afDouglas Gregor llvm::SmallPtrSet<ObjCCategoryDecl *, 16> CategoriesDeserialized; 695cff9f26ce0ed76d555cd33b3dca84dd5cdf376afDouglas Gregor 696cff9f26ce0ed76d555cd33b3dca84dd5cdf376afDouglas Gregor /// \brief The set of Objective-C class definitions that have already been 697cff9f26ce0ed76d555cd33b3dca84dd5cdf376afDouglas Gregor /// loaded, for which we will need to check for categories whenever a new 698cff9f26ce0ed76d555cd33b3dca84dd5cdf376afDouglas Gregor /// module is loaded. 699cff9f26ce0ed76d555cd33b3dca84dd5cdf376afDouglas Gregor llvm::SmallVector<ObjCInterfaceDecl *, 16> ObjCClassesLoaded; 700cff9f26ce0ed76d555cd33b3dca84dd5cdf376afDouglas Gregor 7010f75323264b93a318ac9007eb5ec5b233c444068Douglas Gregor typedef llvm::DenseMap<Decl *, llvm::SmallVector<serialization::DeclID, 2> > 7020f75323264b93a318ac9007eb5ec5b233c444068Douglas Gregor MergedDeclsMap; 7030f75323264b93a318ac9007eb5ec5b233c444068Douglas Gregor 7040f75323264b93a318ac9007eb5ec5b233c444068Douglas Gregor /// \brief A mapping from canonical declarations to the set of additional 7050f75323264b93a318ac9007eb5ec5b233c444068Douglas Gregor /// (global, previously-canonical) declaration IDs that have been merged with 7060f75323264b93a318ac9007eb5ec5b233c444068Douglas Gregor /// that canonical declaration. 7070f75323264b93a318ac9007eb5ec5b233c444068Douglas Gregor MergedDeclsMap MergedDecls; 7080f75323264b93a318ac9007eb5ec5b233c444068Douglas Gregor 709c3cfd2ab3338d47861ece597212f21b972ebe727Douglas Gregor typedef llvm::DenseMap<serialization::GlobalDeclID, 710c3cfd2ab3338d47861ece597212f21b972ebe727Douglas Gregor llvm::SmallVector<serialization::DeclID, 2> > 711c3cfd2ab3338d47861ece597212f21b972ebe727Douglas Gregor StoredMergedDeclsMap; 712c3cfd2ab3338d47861ece597212f21b972ebe727Douglas Gregor 713c3cfd2ab3338d47861ece597212f21b972ebe727Douglas Gregor /// \brief A mapping from canonical declaration IDs to the set of additional 714c3cfd2ab3338d47861ece597212f21b972ebe727Douglas Gregor /// declaration IDs that have been merged with that canonical declaration. 715c3cfd2ab3338d47861ece597212f21b972ebe727Douglas Gregor /// 716c3cfd2ab3338d47861ece597212f21b972ebe727Douglas Gregor /// This is the deserialized representation of the entries in MergedDecls. 717c3cfd2ab3338d47861ece597212f21b972ebe727Douglas Gregor /// When we query entries in MergedDecls, they will be augmented with entries 718c3cfd2ab3338d47861ece597212f21b972ebe727Douglas Gregor /// from StoredMergedDecls. 719c3cfd2ab3338d47861ece597212f21b972ebe727Douglas Gregor StoredMergedDeclsMap StoredMergedDecls; 720c3cfd2ab3338d47861ece597212f21b972ebe727Douglas Gregor 721c3cfd2ab3338d47861ece597212f21b972ebe727Douglas Gregor /// \brief Combine the stored merged declarations for the given canonical 722c3cfd2ab3338d47861ece597212f21b972ebe727Douglas Gregor /// declaration into the set of merged declarations. 723c3cfd2ab3338d47861ece597212f21b972ebe727Douglas Gregor /// 724c3cfd2ab3338d47861ece597212f21b972ebe727Douglas Gregor /// \returns An iterator into MergedDecls that corresponds to the position of 725c3cfd2ab3338d47861ece597212f21b972ebe727Douglas Gregor /// the given canonical declaration. 726c3cfd2ab3338d47861ece597212f21b972ebe727Douglas Gregor MergedDeclsMap::iterator 727c3cfd2ab3338d47861ece597212f21b972ebe727Douglas Gregor combineStoredMergedDecls(Decl *Canon, serialization::GlobalDeclID CanonID); 728c3cfd2ab3338d47861ece597212f21b972ebe727Douglas Gregor 7290895d1513772eca5a20c552976209fd7f58b993fArgyrios Kyrtzidis /// \brief Ready to load the previous declaration of the given Decl. 7300895d1513772eca5a20c552976209fd7f58b993fArgyrios Kyrtzidis void loadAndAttachPreviousDecl(Decl *D, serialization::DeclID ID); 7310895d1513772eca5a20c552976209fd7f58b993fArgyrios Kyrtzidis 732919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis /// \brief When reading a Stmt tree, Stmt operands are placed in this stack. 733686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVector<Stmt *, 16> StmtStack; 734919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis 735919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis /// \brief What kind of records we are reading. 736919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis enum ReadingKind { 737919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis Read_Decl, Read_Type, Read_Stmt 738919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis }; 739919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis 740ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie /// \brief What kind of records we are reading. 741919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis ReadingKind ReadingKind; 742919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis 743919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis /// \brief RAII object to change the reading kind. 744919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis class ReadingKindTracker { 745c43b54cbc10654ed59de797898042e1a05265246Sebastian Redl ASTReader &Reader; 746919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis enum ReadingKind PrevKind; 747919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis 748919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis ReadingKindTracker(const ReadingKindTracker&); // do not implement 749919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis ReadingKindTracker &operator=(const ReadingKindTracker&);// do not implement 750919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis 751919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis public: 752c43b54cbc10654ed59de797898042e1a05265246Sebastian Redl ReadingKindTracker(enum ReadingKind newKind, ASTReader &reader) 753919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis : Reader(reader), PrevKind(Reader.ReadingKind) { 754919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis Reader.ReadingKind = newKind; 755919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis } 756919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis 757919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis ~ReadingKindTracker() { Reader.ReadingKind = PrevKind; } 758919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis }; 759919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis 7603c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// \brief All predefines buffers in the chain, to be treated as if 7617e9ad8b4fd446ca7cc0e630edee56d8fcc4553deSebastian Redl /// concatenated. 7627e9ad8b4fd446ca7cc0e630edee56d8fcc4553deSebastian Redl PCHPredefinesBlocks PCHPredefinesBuffers; 76392b059ea944adaa3e00bb53d63a09868a4752547Douglas Gregor 764e721f95069d42b899c20c1caabdc6184dd42b820Douglas Gregor /// \brief Suggested contents of the predefines buffer, after this 765e721f95069d42b899c20c1caabdc6184dd42b820Douglas Gregor /// PCH file has been processed. 766e721f95069d42b899c20c1caabdc6184dd42b820Douglas Gregor /// 767e721f95069d42b899c20c1caabdc6184dd42b820Douglas Gregor /// In most cases, this string will be empty, because the predefines 768e721f95069d42b899c20c1caabdc6184dd42b820Douglas Gregor /// buffer computed to build the PCH file will be identical to the 769e721f95069d42b899c20c1caabdc6184dd42b820Douglas Gregor /// predefines buffer computed from the command line. However, when 770e721f95069d42b899c20c1caabdc6184dd42b820Douglas Gregor /// there are differences that the PCH reader can work around, this 771e721f95069d42b899c20c1caabdc6184dd42b820Douglas Gregor /// predefines buffer may contain additional definitions. 772e721f95069d42b899c20c1caabdc6184dd42b820Douglas Gregor std::string SuggestedPredefines; 7731eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 774919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis /// \brief Reads a statement from the specified cursor. 7751a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor Stmt *ReadStmtFromStream(ModuleFile &F); 776919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis 777b68ffb107a86f5e3851e8108c712b64dd16ba258Argyrios Kyrtzidis /// \brief Get a FileEntry out of stored-in-PCH filename, making sure we take 778b68ffb107a86f5e3851e8108c712b64dd16ba258Argyrios Kyrtzidis /// into account all the necessary relocations. 779686775deca8b8685eb90801495880e3abdd844c2Chris Lattner const FileEntry *getFileEntry(StringRef filename); 780b68ffb107a86f5e3851e8108c712b64dd16ba258Argyrios Kyrtzidis 781e650c8c3bca2f58cad8ffa8aab63126d26e890cdDouglas Gregor void MaybeAddSystemRootToFilename(std::string &Filename); 7821eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 78310bc00fd45824f9b5cd139d63af8b0f6d28aaddaDouglas Gregor ASTReadResult ReadASTCore(StringRef FileName, ModuleKind Type, 7841a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor ModuleFile *ImportedBy); 7851a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor ASTReadResult ReadASTBlock(ModuleFile &F); 7867e9ad8b4fd446ca7cc0e630edee56d8fcc4553deSebastian Redl bool CheckPredefinesBuffers(); 7871a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor bool ParseLineTable(ModuleFile &F, SmallVectorImpl<uint64_t> &Record); 7881a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor ASTReadResult ReadSourceManagerBlock(ModuleFile &F); 789f62d43d2afe1960755a1b5813cae1e5983bcac1bDouglas Gregor ASTReadResult ReadSLocEntryRecord(int ID); 790f62d43d2afe1960755a1b5813cae1e5983bcac1bDouglas Gregor llvm::BitstreamCursor &SLocCursorForID(int ID); 7911a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor SourceLocation getImportLocation(ModuleFile *F); 7921a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor ASTReadResult ReadSubmoduleBlock(ModuleFile &F); 793686775deca8b8685eb90801495880e3abdd844c2Chris Lattner bool ParseLanguageOptions(const SmallVectorImpl<uint64_t> &Record); 794392ed2b717d86ebdd202cb9bb58d18d8b3b4cd87Douglas Gregor 795c3632730cc83ed7b51f0ab5c38997ae5a9439b0cSebastian Redl struct RecordLocation { 7961a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor RecordLocation(ModuleFile *M, uint64_t O) 797c3632730cc83ed7b51f0ab5c38997ae5a9439b0cSebastian Redl : F(M), Offset(O) {} 7981a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor ModuleFile *F; 799c3632730cc83ed7b51f0ab5c38997ae5a9439b0cSebastian Redl uint64_t Offset; 800c3632730cc83ed7b51f0ab5c38997ae5a9439b0cSebastian Redl }; 801aaec0aa844781dc7c3462ba140e004e589ccd355Sebastian Redl 802393f249399fe30e9580e1529a7479489e90f3a57Douglas Gregor QualType readTypeRecord(unsigned Index); 803aaec0aa844781dc7c3462ba140e004e589ccd355Sebastian Redl RecordLocation TypeCursorForIndex(unsigned Index); 8042cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor void LoadedDecl(unsigned Index, Decl *D); 805496c709a6f08f5c502b6f592ddd9ed40f953a5e5Douglas Gregor Decl *ReadDeclRecord(serialization::DeclID ID); 8069d31fa75bc05fe4cb903a7701550f22cfb73ea8bArgyrios Kyrtzidis RecordLocation DeclCursorForID(serialization::DeclID ID, 8079d31fa75bc05fe4cb903a7701550f22cfb73ea8bArgyrios Kyrtzidis unsigned &RawLocation); 8086bf2b9fbd3e3adc38d4712de79aeaa81d651aa08Douglas Gregor void loadDeclUpdateRecords(serialization::DeclID ID, Decl *D); 809a1be278c4f3a234ff61f04018d26c6beecde1654Douglas Gregor void loadPendingDeclChain(serialization::GlobalDeclID ID); 810cff9f26ce0ed76d555cd33b3dca84dd5cdf376afDouglas Gregor void loadObjCCategories(serialization::GlobalDeclID ID, ObjCInterfaceDecl *D, 811cff9f26ce0ed76d555cd33b3dca84dd5cdf376afDouglas Gregor unsigned PreviousGeneration = 0); 812ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 8138f1231b70c2b1f6fe0cee097b447487b26810301Douglas Gregor RecordLocation getLocalBitOffset(uint64_t GlobalOffset); 8141a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor uint64_t getGlobalBitOffset(ModuleFile &M, uint32_t LocalOffset); 8152dbaca748bc3eb6539f417bd8354c930bdf88fa4Argyrios Kyrtzidis 8162dbaca748bc3eb6539f417bd8354c930bdf88fa4Argyrios Kyrtzidis /// \brief Returns the first preprocessed entity ID that ends after \arg BLoc. 8172dbaca748bc3eb6539f417bd8354c930bdf88fa4Argyrios Kyrtzidis serialization::PreprocessedEntityID 8182dbaca748bc3eb6539f417bd8354c930bdf88fa4Argyrios Kyrtzidis findBeginPreprocessedEntity(SourceLocation BLoc) const; 8192dbaca748bc3eb6539f417bd8354c930bdf88fa4Argyrios Kyrtzidis 820ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie /// \brief Returns the first preprocessed entity ID that begins after \arg 821ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie /// ELoc. 8222dbaca748bc3eb6539f417bd8354c930bdf88fa4Argyrios Kyrtzidis serialization::PreprocessedEntityID 8232dbaca748bc3eb6539f417bd8354c930bdf88fa4Argyrios Kyrtzidis findEndPreprocessedEntity(SourceLocation ELoc) const; 8242dbaca748bc3eb6539f417bd8354c930bdf88fa4Argyrios Kyrtzidis 8252dbaca748bc3eb6539f417bd8354c930bdf88fa4Argyrios Kyrtzidis /// \brief \arg SLocMapI points at a chunk of a module that contains no 8262dbaca748bc3eb6539f417bd8354c930bdf88fa4Argyrios Kyrtzidis /// preprocessed entities or the entities it contains are not the ones we are 8272dbaca748bc3eb6539f417bd8354c930bdf88fa4Argyrios Kyrtzidis /// looking for. Find the next module that contains entities and return the ID 8282dbaca748bc3eb6539f417bd8354c930bdf88fa4Argyrios Kyrtzidis /// of the first entry. 8292dbaca748bc3eb6539f417bd8354c930bdf88fa4Argyrios Kyrtzidis serialization::PreprocessedEntityID 8302dbaca748bc3eb6539f417bd8354c930bdf88fa4Argyrios Kyrtzidis findNextPreprocessedEntity( 8312dbaca748bc3eb6539f417bd8354c930bdf88fa4Argyrios Kyrtzidis GlobalSLocOffsetMapType::const_iterator SLocMapI) const; 8322dbaca748bc3eb6539f417bd8354c930bdf88fa4Argyrios Kyrtzidis 8331a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor /// \brief Returns (ModuleFile, Local index) pair for \arg GlobalIndex of a 834f226ff9fe8c8db6c5b74a61ce649eda1491c3502Argyrios Kyrtzidis /// preprocessed entity. 8351a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor std::pair<ModuleFile *, unsigned> 836f226ff9fe8c8db6c5b74a61ce649eda1491c3502Argyrios Kyrtzidis getModulePreprocessedEntity(unsigned GlobalIndex); 837f226ff9fe8c8db6c5b74a61ce649eda1491c3502Argyrios Kyrtzidis 838bb80a8e8887c1ec74ee135d4ad9455eafedf1508Argyrios Kyrtzidis void PassInterestingDeclsToConsumer(); 8398d39c3ddfc17d9e768a17eb0ce9f11c33bf9d50aArgyrios Kyrtzidis void PassInterestingDeclToConsumer(Decl *D); 840bb80a8e8887c1ec74ee135d4ad9455eafedf1508Argyrios Kyrtzidis 841917078386b9b5113f33c093e296e10927b00b37eArgyrios Kyrtzidis void finishPendingActions(); 842917078386b9b5113f33c093e296e10927b00b37eArgyrios Kyrtzidis 843a02b147b66ff9f1a22bac4ec7fd1b0d54a40e5bfDouglas Gregor /// \brief Produce an error diagnostic and return true. 844a02b147b66ff9f1a22bac4ec7fd1b0d54a40e5bfDouglas Gregor /// 845a02b147b66ff9f1a22bac4ec7fd1b0d54a40e5bfDouglas Gregor /// This routine should only be used for fatal errors that have to 8463c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// do with non-routine failures (e.g., corrupted AST file). 847686775deca8b8685eb90801495880e3abdd844c2Chris Lattner void Error(StringRef Msg); 848686775deca8b8685eb90801495880e3abdd844c2Chris Lattner void Error(unsigned DiagID, StringRef Arg1 = StringRef(), 849686775deca8b8685eb90801495880e3abdd844c2Chris Lattner StringRef Arg2 = StringRef()); 850a02b147b66ff9f1a22bac4ec7fd1b0d54a40e5bfDouglas Gregor 851c43b54cbc10654ed59de797898042e1a05265246Sebastian Redl ASTReader(const ASTReader&); // do not implement 852c43b54cbc10654ed59de797898042e1a05265246Sebastian Redl ASTReader &operator=(const ASTReader &); // do not implement 8532cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregorpublic: 854686775deca8b8685eb90801495880e3abdd844c2Chris Lattner typedef SmallVector<uint64_t, 64> RecordData; 8552cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor 8563c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// \brief Load the AST file and validate its contents against the given 85711e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis /// Preprocessor. 858e650c8c3bca2f58cad8ffa8aab63126d26e890cdDouglas Gregor /// 859e650c8c3bca2f58cad8ffa8aab63126d26e890cdDouglas Gregor /// \param PP the preprocessor associated with the context in which this 860e650c8c3bca2f58cad8ffa8aab63126d26e890cdDouglas Gregor /// precompiled header will be loaded. 861e650c8c3bca2f58cad8ffa8aab63126d26e890cdDouglas Gregor /// 862e650c8c3bca2f58cad8ffa8aab63126d26e890cdDouglas Gregor /// \param Context the AST context that this precompiled header will be 863e650c8c3bca2f58cad8ffa8aab63126d26e890cdDouglas Gregor /// loaded into. 864e650c8c3bca2f58cad8ffa8aab63126d26e890cdDouglas Gregor /// 865e650c8c3bca2f58cad8ffa8aab63126d26e890cdDouglas Gregor /// \param isysroot If non-NULL, the system include path specified by the 866e650c8c3bca2f58cad8ffa8aab63126d26e890cdDouglas Gregor /// user. This is only used with relocatable PCH files. If non-NULL, 867e650c8c3bca2f58cad8ffa8aab63126d26e890cdDouglas Gregor /// a relocatable PCH file will use the default path "/". 868fae3b2f4743dad616623c4df2fdb0f5128bd36d9Douglas Gregor /// 8693c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// \param DisableValidation If true, the AST reader will suppress most 870fae3b2f4743dad616623c4df2fdb0f5128bd36d9Douglas Gregor /// of its regular consistency checking, allowing the use of precompiled 871fae3b2f4743dad616623c4df2fdb0f5128bd36d9Douglas Gregor /// headers that cannot be determined to be compatible. 8728ef6c8cb6c5627240e2339fd7062c9873f821d7eDouglas Gregor /// 8738ef6c8cb6c5627240e2339fd7062c9873f821d7eDouglas Gregor /// \param DisableStatCache If true, the AST reader will ignore the 8748ef6c8cb6c5627240e2339fd7062c9873f821d7eDouglas Gregor /// stat cache in the AST files. This performance pessimization can 8758ef6c8cb6c5627240e2339fd7062c9873f821d7eDouglas Gregor /// help when an AST file is being used in cases where the 8768ef6c8cb6c5627240e2339fd7062c9873f821d7eDouglas Gregor /// underlying files in the file system may have changed, but 8778ef6c8cb6c5627240e2339fd7062c9873f821d7eDouglas Gregor /// parsing should still continue. 878f8a1e51c48761ee1d7803c3fa35ac94f42ebb55eDouglas Gregor ASTReader(Preprocessor &PP, ASTContext &Context, StringRef isysroot = "", 8798ef6c8cb6c5627240e2339fd7062c9873f821d7eDouglas Gregor bool DisableValidation = false, bool DisableStatCache = false); 8801eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 881c43b54cbc10654ed59de797898042e1a05265246Sebastian Redl ~ASTReader(); 8822cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor 8832dbaca748bc3eb6539f417bd8354c930bdf88fa4Argyrios Kyrtzidis SourceManager &getSourceManager() const { return SourceMgr; } 884ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 88510bc00fd45824f9b5cd139d63af8b0f6d28aaddaDouglas Gregor /// \brief Load the AST file designated by the given file name. 88672a9ae18553bf8b6bdad84d2c54f73741a47e275Douglas Gregor ASTReadResult ReadAST(const std::string &FileName, ModuleKind Type); 8871eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 888b68ffb107a86f5e3851e8108c712b64dd16ba258Argyrios Kyrtzidis /// \brief Checks that no file that is stored in PCH is out-of-sync with 889b68ffb107a86f5e3851e8108c712b64dd16ba258Argyrios Kyrtzidis /// the actual file in the file system. 8901a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor ASTReadResult validateFileEntries(ModuleFile &M); 891b68ffb107a86f5e3851e8108c712b64dd16ba258Argyrios Kyrtzidis 8925e35693721364673f8196e4f5a370f56b92e6053Douglas Gregor /// \brief Make the entities in the given module and any of its (non-explicit) 8935e35693721364673f8196e4f5a370f56b92e6053Douglas Gregor /// submodules visible to name lookup. 8945e35693721364673f8196e4f5a370f56b92e6053Douglas Gregor /// 8955e35693721364673f8196e4f5a370f56b92e6053Douglas Gregor /// \param Mod The module whose names should be made visible. 8965e35693721364673f8196e4f5a370f56b92e6053Douglas Gregor /// 8975e35693721364673f8196e4f5a370f56b92e6053Douglas Gregor /// \param Visibility The level of visibility to give the names in the module. 8985e35693721364673f8196e4f5a370f56b92e6053Douglas Gregor /// Visibility can only be increased over time. 8995e35693721364673f8196e4f5a370f56b92e6053Douglas Gregor void makeModuleVisible(Module *Mod, 9005e35693721364673f8196e4f5a370f56b92e6053Douglas Gregor Module::NameVisibilityKind NameVisibility); 9015e35693721364673f8196e4f5a370f56b92e6053Douglas Gregor 902ecc2c090e7146c029dd9ee9a5a2fd66b275c01c0Douglas Gregor /// \brief Make the names within this set of hidden names visible. 903ecc2c090e7146c029dd9ee9a5a2fd66b275c01c0Douglas Gregor void makeNamesVisible(const HiddenNames &Names); 904ecc2c090e7146c029dd9ee9a5a2fd66b275c01c0Douglas Gregor 9053c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// \brief Set the AST callbacks listener. 906571db7f0cb31789737be92fce1c1b738e6dbe795Sebastian Redl void setListener(ASTReaderListener *listener) { 90711e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis Listener.reset(listener); 90811e51106329c550d008fad2c657c053d81611ea8Argyrios Kyrtzidis } 9091eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 9103c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// \brief Set the AST deserialization listener. 911571db7f0cb31789737be92fce1c1b738e6dbe795Sebastian Redl void setDeserializationListener(ASTDeserializationListener *Listener); 91230c514c225342844700ed4640ec6d90ddf0e12b2Sebastian Redl 913359427794704666ff7a5a933ace11c5256fa3af7Douglas Gregor /// \brief Initializes the ASTContext 914359427794704666ff7a5a933ace11c5256fa3af7Douglas Gregor void InitializeContext(); 9152cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor 916c24a1eef40207457692a1ad597cefdd0dc8fa149Jonathan D. Turner /// \brief Add in-memory (virtual file) buffer. 917c24a1eef40207457692a1ad597cefdd0dc8fa149Jonathan D. Turner void addInMemoryBuffer(StringRef &FileName, llvm::MemoryBuffer *Buffer) { 918c24a1eef40207457692a1ad597cefdd0dc8fa149Jonathan D. Turner ModuleMgr.addInMemoryBuffer(FileName, Buffer); 919b0f4b9a558933b307073f7cd7753602f94354ae9Argyrios Kyrtzidis } 920b0f4b9a558933b307073f7cd7753602f94354ae9Argyrios Kyrtzidis 921ecc2c090e7146c029dd9ee9a5a2fd66b275c01c0Douglas Gregor /// \brief Finalizes the AST reader's state before writing an AST file to 922ecc2c090e7146c029dd9ee9a5a2fd66b275c01c0Douglas Gregor /// disk. 923ecc2c090e7146c029dd9ee9a5a2fd66b275c01c0Douglas Gregor /// 924ecc2c090e7146c029dd9ee9a5a2fd66b275c01c0Douglas Gregor /// This operation may undo temporary state in the AST that should not be 925ecc2c090e7146c029dd9ee9a5a2fd66b275c01c0Douglas Gregor /// emitted. 926ecc2c090e7146c029dd9ee9a5a2fd66b275c01c0Douglas Gregor void finalizeForWriting(); 927ecc2c090e7146c029dd9ee9a5a2fd66b275c01c0Douglas Gregor 928e95b9198b8b70ce0219cfb89483b41102e02dbf5Douglas Gregor /// \brief Retrieve the module manager. 929e95b9198b8b70ce0219cfb89483b41102e02dbf5Douglas Gregor ModuleManager &getModuleManager() { return ModuleMgr; } 930e19944c93961b7618f4f3f3185f698f46369ea54Steve Naroff 931d10a381d92a60d4f4c126c4e81045c8ad4636a0bDouglas Gregor /// \brief Retrieve the preprocessor. 932712f2fcb70ae2eb0cb684d565e7d2cb76881006bDouglas Gregor Preprocessor &getPreprocessor() const { return PP; } 933ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 9341eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// \brief Retrieve the name of the original source file name 935b64c19365deab788753d29c9bc881253c3f16f37Douglas Gregor const std::string &getOriginalSourceFile() { return OriginalFileName; } 936b64c19365deab788753d29c9bc881253c3f16f37Douglas Gregor 9373c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// \brief Retrieve the name of the original source file name directly from 9383c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// the AST file, without actually loading the AST file. 9393c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl static std::string getOriginalSourceFile(const std::string &ASTFileName, 940389db16c63eec6ecfa9b235155252d8da766e94eArgyrios Kyrtzidis FileManager &FileMgr, 941d6471f7c1921c7802804ce3ff6fe9768310f72b9David Blaikie DiagnosticsEngine &Diags); 942b64c19365deab788753d29c9bc881253c3f16f37Douglas Gregor 943e721f95069d42b899c20c1caabdc6184dd42b820Douglas Gregor /// \brief Returns the suggested contents of the predefines buffer, 944e721f95069d42b899c20c1caabdc6184dd42b820Douglas Gregor /// which contains a (typically-empty) subset of the predefines 945e721f95069d42b899c20c1caabdc6184dd42b820Douglas Gregor /// build prior to including the precompiled header. 946e721f95069d42b899c20c1caabdc6184dd42b820Douglas Gregor const std::string &getSuggestedPredefines() { return SuggestedPredefines; } 947e24692b30adbe8144597678a0e3354912e99c747Argyrios Kyrtzidis 948e24692b30adbe8144597678a0e3354912e99c747Argyrios Kyrtzidis /// \brief Read a preallocated preprocessed entity from the external source. 949e24692b30adbe8144597678a0e3354912e99c747Argyrios Kyrtzidis /// 950e24692b30adbe8144597678a0e3354912e99c747Argyrios Kyrtzidis /// \returns null if an error occurred that prevented the preprocessed 951e24692b30adbe8144597678a0e3354912e99c747Argyrios Kyrtzidis /// entity from being loaded. 952e24692b30adbe8144597678a0e3354912e99c747Argyrios Kyrtzidis virtual PreprocessedEntity *ReadPreprocessedEntity(unsigned Index); 953e721f95069d42b899c20c1caabdc6184dd42b820Douglas Gregor 9542dbaca748bc3eb6539f417bd8354c930bdf88fa4Argyrios Kyrtzidis /// \brief Returns a pair of [Begin, End) indices of preallocated 9552dbaca748bc3eb6539f417bd8354c930bdf88fa4Argyrios Kyrtzidis /// preprocessed entities that \arg Range encompasses. 9562dbaca748bc3eb6539f417bd8354c930bdf88fa4Argyrios Kyrtzidis virtual std::pair<unsigned, unsigned> 9572dbaca748bc3eb6539f417bd8354c930bdf88fa4Argyrios Kyrtzidis findPreprocessedEntitiesInRange(SourceRange Range); 958ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 959f226ff9fe8c8db6c5b74a61ce649eda1491c3502Argyrios Kyrtzidis /// \brief Optionally returns true or false if the preallocated preprocessed 960f226ff9fe8c8db6c5b74a61ce649eda1491c3502Argyrios Kyrtzidis /// entity with index \arg Index came from file \arg FID. 961f226ff9fe8c8db6c5b74a61ce649eda1491c3502Argyrios Kyrtzidis virtual llvm::Optional<bool> isPreprocessedEntityInFileID(unsigned Index, 962f226ff9fe8c8db6c5b74a61ce649eda1491c3502Argyrios Kyrtzidis FileID FID); 9632dbaca748bc3eb6539f417bd8354c930bdf88fa4Argyrios Kyrtzidis 964cfbf1c7536e016dc275139dd842d4a5f059a749fDouglas Gregor /// \brief Read the header file information for the given file entry. 965cfbf1c7536e016dc275139dd842d4a5f059a749fDouglas Gregor virtual HeaderFileInfo GetHeaderFileInfo(const FileEntry *FE); 966cfbf1c7536e016dc275139dd842d4a5f059a749fDouglas Gregor 967d6471f7c1921c7802804ce3ff6fe9768310f72b9David Blaikie void ReadPragmaDiagnosticMappings(DiagnosticsEngine &Diag); 968f41d3be39980d40849850d3fb90403623cc8459eArgyrios Kyrtzidis 969f2f0f03d08c6143137a79a8edffc7d41823bc3c7Sebastian Redl /// \brief Returns the number of source locations found in the chain. 9700fa7d0b15ea2a224bfe43ac745d411f915da87ddSebastian Redl unsigned getTotalNumSLocs() const { 9710fa7d0b15ea2a224bfe43ac745d411f915da87ddSebastian Redl return TotalNumSLocEntries; 9720fa7d0b15ea2a224bfe43ac745d411f915da87ddSebastian Redl } 9730fa7d0b15ea2a224bfe43ac745d411f915da87ddSebastian Redl 974f2f0f03d08c6143137a79a8edffc7d41823bc3c7Sebastian Redl /// \brief Returns the number of identifiers found in the chain. 975f2f0f03d08c6143137a79a8edffc7d41823bc3c7Sebastian Redl unsigned getTotalNumIdentifiers() const { 976f2f0f03d08c6143137a79a8edffc7d41823bc3c7Sebastian Redl return static_cast<unsigned>(IdentifiersLoaded.size()); 977f2f0f03d08c6143137a79a8edffc7d41823bc3c7Sebastian Redl } 978f2f0f03d08c6143137a79a8edffc7d41823bc3c7Sebastian Redl 979e58aa890e8de55bb3146e6ea9fbbba3a58ce30c6Sebastian Redl /// \brief Returns the number of types found in the chain. 98077a3c9ede5cdb26b5eb3001e82bb0a36ca997e1fSebastian Redl unsigned getTotalNumTypes() const { 98177a3c9ede5cdb26b5eb3001e82bb0a36ca997e1fSebastian Redl return static_cast<unsigned>(TypesLoaded.size()); 98277a3c9ede5cdb26b5eb3001e82bb0a36ca997e1fSebastian Redl } 98377a3c9ede5cdb26b5eb3001e82bb0a36ca997e1fSebastian Redl 984e58aa890e8de55bb3146e6ea9fbbba3a58ce30c6Sebastian Redl /// \brief Returns the number of declarations found in the chain. 98577a3c9ede5cdb26b5eb3001e82bb0a36ca997e1fSebastian Redl unsigned getTotalNumDecls() const { 98677a3c9ede5cdb26b5eb3001e82bb0a36ca997e1fSebastian Redl return static_cast<unsigned>(DeclsLoaded.size()); 98777a3c9ede5cdb26b5eb3001e82bb0a36ca997e1fSebastian Redl } 98877a3c9ede5cdb26b5eb3001e82bb0a36ca997e1fSebastian Redl 98926ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor /// \brief Returns the number of submodules known. 99026ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor unsigned getTotalNumSubmodules() const { 99126ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor return static_cast<unsigned>(SubmodulesLoaded.size()); 99226ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor } 99326ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor 994e58aa890e8de55bb3146e6ea9fbbba3a58ce30c6Sebastian Redl /// \brief Returns the number of selectors found in the chain. 995e58aa890e8de55bb3146e6ea9fbbba3a58ce30c6Sebastian Redl unsigned getTotalNumSelectors() const { 996e58aa890e8de55bb3146e6ea9fbbba3a58ce30c6Sebastian Redl return static_cast<unsigned>(SelectorsLoaded.size()); 997e58aa890e8de55bb3146e6ea9fbbba3a58ce30c6Sebastian Redl } 998e58aa890e8de55bb3146e6ea9fbbba3a58ce30c6Sebastian Redl 9994c30bb148b53c8063e940ca3e049ba4d270dc9d5Douglas Gregor /// \brief Returns the number of preprocessed entities known to the AST 10004c30bb148b53c8063e940ca3e049ba4d270dc9d5Douglas Gregor /// reader. 10014c30bb148b53c8063e940ca3e049ba4d270dc9d5Douglas Gregor unsigned getTotalNumPreprocessedEntities() const { 10024c30bb148b53c8063e940ca3e049ba4d270dc9d5Douglas Gregor unsigned Result = 0; 10035d6d89fef8c7fff8b1a67c943fb5557a2a803468Jonathan D. Turner for (ModuleConstIterator I = ModuleMgr.begin(), 10045d6d89fef8c7fff8b1a67c943fb5557a2a803468Jonathan D. Turner E = ModuleMgr.end(); I != E; ++I) { 1005e24692b30adbe8144597678a0e3354912e99c747Argyrios Kyrtzidis Result += (*I)->NumPreprocessedEntities; 10065d6d89fef8c7fff8b1a67c943fb5557a2a803468Jonathan D. Turner } 1007ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 10084c30bb148b53c8063e940ca3e049ba4d270dc9d5Douglas Gregor return Result; 10094c30bb148b53c8063e940ca3e049ba4d270dc9d5Douglas Gregor } 1010ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 10117c789c1a3f77f24032aa0bed2afacdb9e094e952Douglas Gregor /// \brief Returns the number of C++ base specifiers found in the chain. 10121da901467f72d1733704b068e22089813a1962fdJonathan D. Turner unsigned getTotalNumCXXBaseSpecifiers() const { 10131da901467f72d1733704b068e22089813a1962fdJonathan D. Turner return NumCXXBaseSpecifiersLoaded; 10141da901467f72d1733704b068e22089813a1962fdJonathan D. Turner } 1015ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1016833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall /// \brief Reads a TemplateArgumentLocInfo appropriate for the 1017833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall /// given TemplateArgument kind. 1018833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall TemplateArgumentLocInfo 10191a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor GetTemplateArgumentLocInfo(ModuleFile &F, TemplateArgument::ArgKind Kind, 1020833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall const RecordData &Record, unsigned &Idx); 1021833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 102244f8c37e378f716e8cbb600e3800f437cf58f9e5Argyrios Kyrtzidis /// \brief Reads a TemplateArgumentLoc. 1023577d4796d358c0e72ebaa023113505226ab51b4fSebastian Redl TemplateArgumentLoc 10241a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor ReadTemplateArgumentLoc(ModuleFile &F, 1025577d4796d358c0e72ebaa023113505226ab51b4fSebastian Redl const RecordData &Record, unsigned &Idx); 102644f8c37e378f716e8cbb600e3800f437cf58f9e5Argyrios Kyrtzidis 1027a1ee0c548b8aa4aaf93d1917e304e3da13171a08John McCall /// \brief Reads a declarator info from the given record. 10281a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor TypeSourceInfo *GetTypeSourceInfo(ModuleFile &F, 1029577d4796d358c0e72ebaa023113505226ab51b4fSebastian Redl const RecordData &Record, unsigned &Idx); 1030a1ee0c548b8aa4aaf93d1917e304e3da13171a08John McCall 10312cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor /// \brief Resolve a type ID into a type, potentially building a new 10322cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor /// type. 10338538e8d43a3a9bd439c987c0de37bcbf035dd391Sebastian Redl QualType GetType(serialization::TypeID ID); 10342cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor 1035393f249399fe30e9580e1529a7479489e90f3a57Douglas Gregor /// \brief Resolve a local type ID within a given AST file into a type. 10361a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor QualType getLocalType(ModuleFile &F, unsigned LocalID); 1037ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1038393f249399fe30e9580e1529a7479489e90f3a57Douglas Gregor /// \brief Map a local type ID within a given AST file into a global type ID. 10391a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor serialization::TypeID getGlobalTypeID(ModuleFile &F, unsigned LocalID) const; 1040ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1041ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie /// \brief Read a type from the current position in the given record, which 1042393f249399fe30e9580e1529a7479489e90f3a57Douglas Gregor /// was read from the given AST file. 10431a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor QualType readType(ModuleFile &F, const RecordData &Record, unsigned &Idx) { 1044393f249399fe30e9580e1529a7479489e90f3a57Douglas Gregor if (Idx >= Record.size()) 1045393f249399fe30e9580e1529a7479489e90f3a57Douglas Gregor return QualType(); 1046ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1047393f249399fe30e9580e1529a7479489e90f3a57Douglas Gregor return getLocalType(F, Record[Idx++]); 1048393f249399fe30e9580e1529a7479489e90f3a57Douglas Gregor } 1049ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1050ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie /// \brief Map from a local declaration ID within a given module to a 1051409448c832d27703146b70a1137d86b020f29863Douglas Gregor /// global declaration ID. 10521a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor serialization::DeclID getGlobalDeclID(ModuleFile &F, unsigned LocalID) const; 1053e6b8d68a927368b06ac06cc9ac9e7f60aa966d5fArgyrios Kyrtzidis 1054e6b8d68a927368b06ac06cc9ac9e7f60aa966d5fArgyrios Kyrtzidis /// \brief Returns true if global DeclID \arg ID originated from module 1055e6b8d68a927368b06ac06cc9ac9e7f60aa966d5fArgyrios Kyrtzidis /// \arg M. 10561a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor bool isDeclIDFromModule(serialization::GlobalDeclID ID, ModuleFile &M) const; 1057dfb332d0081c6641d1dbae6a2aeff757c99cc740Argyrios Kyrtzidis 1058cff9f26ce0ed76d555cd33b3dca84dd5cdf376afDouglas Gregor /// \brief Retrieve the module file that owns the given declaration, or NULL 1059cff9f26ce0ed76d555cd33b3dca84dd5cdf376afDouglas Gregor /// if the declaration is not from a module file. 1060cff9f26ce0ed76d555cd33b3dca84dd5cdf376afDouglas Gregor ModuleFile *getOwningModuleFile(Decl *D); 1061cff9f26ce0ed76d555cd33b3dca84dd5cdf376afDouglas Gregor 1062dfb332d0081c6641d1dbae6a2aeff757c99cc740Argyrios Kyrtzidis /// \brief Returns the source location for the decl \arg ID. 1063dfb332d0081c6641d1dbae6a2aeff757c99cc740Argyrios Kyrtzidis SourceLocation getSourceLocationForDeclID(serialization::GlobalDeclID ID); 1064ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 10652cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor /// \brief Resolve a declaration ID into a declaration, potentially 10662cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor /// building a new declaration. 10678538e8d43a3a9bd439c987c0de37bcbf035dd391Sebastian Redl Decl *GetDecl(serialization::DeclID ID); 106876bd1f387e6a7b7abfe53f63b3bd429b97bb80f0John McCall virtual Decl *GetExternalDecl(uint32_t ID); 10692cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor 107043fd9388d374f29e908e611a686c6137553efa79Jonathan D. Turner /// \brief Reads a declaration with the given local ID in the given module. 10711a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor Decl *GetLocalDecl(ModuleFile &F, uint32_t LocalID) { 1072409448c832d27703146b70a1137d86b020f29863Douglas Gregor return GetDecl(getGlobalDeclID(F, LocalID)); 1073409448c832d27703146b70a1137d86b020f29863Douglas Gregor } 1074409448c832d27703146b70a1137d86b020f29863Douglas Gregor 107543fd9388d374f29e908e611a686c6137553efa79Jonathan D. Turner /// \brief Reads a declaration with the given local ID in the given module. 1076409448c832d27703146b70a1137d86b020f29863Douglas Gregor /// 1077409448c832d27703146b70a1137d86b020f29863Douglas Gregor /// \returns The requested declaration, casted to the given return type. 1078409448c832d27703146b70a1137d86b020f29863Douglas Gregor template<typename T> 10791a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor T *GetLocalDeclAs(ModuleFile &F, uint32_t LocalID) { 1080409448c832d27703146b70a1137d86b020f29863Douglas Gregor return cast_or_null<T>(GetLocalDecl(F, LocalID)); 1081409448c832d27703146b70a1137d86b020f29863Douglas Gregor } 1082409448c832d27703146b70a1137d86b020f29863Douglas Gregor 1083a1be278c4f3a234ff61f04018d26c6beecde1654Douglas Gregor /// \brief Map a global declaration ID into the declaration ID used to 1084a1be278c4f3a234ff61f04018d26c6beecde1654Douglas Gregor /// refer to this declaration within the given module fule. 1085a1be278c4f3a234ff61f04018d26c6beecde1654Douglas Gregor /// 1086a1be278c4f3a234ff61f04018d26c6beecde1654Douglas Gregor /// \returns the global ID of the given declaration as known in the given 1087a1be278c4f3a234ff61f04018d26c6beecde1654Douglas Gregor /// module file. 1088a1be278c4f3a234ff61f04018d26c6beecde1654Douglas Gregor serialization::DeclID 1089a1be278c4f3a234ff61f04018d26c6beecde1654Douglas Gregor mapGlobalIDToModuleFileGlobalID(ModuleFile &M, 1090a1be278c4f3a234ff61f04018d26c6beecde1654Douglas Gregor serialization::DeclID GlobalID); 1091a1be278c4f3a234ff61f04018d26c6beecde1654Douglas Gregor 1092ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie /// \brief Reads a declaration ID from the given position in a record in the 1093409448c832d27703146b70a1137d86b020f29863Douglas Gregor /// given module. 1094409448c832d27703146b70a1137d86b020f29863Douglas Gregor /// 1095409448c832d27703146b70a1137d86b020f29863Douglas Gregor /// \returns The declaration ID read from the record, adjusted to a global ID. 10961a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor serialization::DeclID ReadDeclID(ModuleFile &F, const RecordData &Record, 1097409448c832d27703146b70a1137d86b020f29863Douglas Gregor unsigned &Idx); 1098ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1099409448c832d27703146b70a1137d86b020f29863Douglas Gregor /// \brief Reads a declaration from the given position in a record in the 1100409448c832d27703146b70a1137d86b020f29863Douglas Gregor /// given module. 11011a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor Decl *ReadDecl(ModuleFile &F, const RecordData &R, unsigned &I) { 1102409448c832d27703146b70a1137d86b020f29863Douglas Gregor return GetDecl(ReadDeclID(F, R, I)); 1103409448c832d27703146b70a1137d86b020f29863Douglas Gregor } 1104ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1105409448c832d27703146b70a1137d86b020f29863Douglas Gregor /// \brief Reads a declaration from the given position in a record in the 1106409448c832d27703146b70a1137d86b020f29863Douglas Gregor /// given module. 1107409448c832d27703146b70a1137d86b020f29863Douglas Gregor /// 1108409448c832d27703146b70a1137d86b020f29863Douglas Gregor /// \returns The declaration read from this location, casted to the given 1109409448c832d27703146b70a1137d86b020f29863Douglas Gregor /// result type. 1110409448c832d27703146b70a1137d86b020f29863Douglas Gregor template<typename T> 11111a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor T *ReadDeclAs(ModuleFile &F, const RecordData &R, unsigned &I) { 1112409448c832d27703146b70a1137d86b020f29863Douglas Gregor return cast_or_null<T>(GetDecl(ReadDeclID(F, R, I))); 1113409448c832d27703146b70a1137d86b020f29863Douglas Gregor } 1114409448c832d27703146b70a1137d86b020f29863Douglas Gregor 1115e92b8a1dbba150e213c4980710fcb59ec5c5c570Douglas Gregor /// \brief Read a CXXBaseSpecifiers ID form the given record and 1116e92b8a1dbba150e213c4980710fcb59ec5c5c570Douglas Gregor /// return its global bit offset. 11171a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor uint64_t readCXXBaseSpecifiers(ModuleFile &M, const RecordData &Record, 1118e92b8a1dbba150e213c4980710fcb59ec5c5c570Douglas Gregor unsigned &Idx); 1119ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 11207c789c1a3f77f24032aa0bed2afacdb9e094e952Douglas Gregor virtual CXXBaseSpecifier *GetExternalCXXBaseSpecifiers(uint64_t Offset); 1121ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1122250fc9c859fdeed3f200ae911a7e7ea338f38436Douglas Gregor /// \brief Resolve the offset of a statement into a statement. 1123250fc9c859fdeed3f200ae911a7e7ea338f38436Douglas Gregor /// 1124250fc9c859fdeed3f200ae911a7e7ea338f38436Douglas Gregor /// This operation will read a new statement from the external 1125250fc9c859fdeed3f200ae911a7e7ea338f38436Douglas Gregor /// source each time it is called, and is meant to be used via a 1126887e2b375fc5e00084ec7bf3dd050c2ca399a6d2Chris Lattner /// LazyOffsetPtr (which is used by Decls for the body of functions, etc). 112776bd1f387e6a7b7abfe53f63b3bd429b97bb80f0John McCall virtual Stmt *GetExternalDeclStmt(uint64_t Offset); 1128250fc9c859fdeed3f200ae911a7e7ea338f38436Douglas Gregor 11296367f6d06308ef29c28d2c1604ded45625caeec9Chris Lattner /// ReadBlockAbbrevs - Enter a subblock of the specified BlockID with the 11306367f6d06308ef29c28d2c1604ded45625caeec9Chris Lattner /// specified cursor. Read the abbreviations that are at the top of the block 11316367f6d06308ef29c28d2c1604ded45625caeec9Chris Lattner /// and then leave the cursor pointing into the block. 11326367f6d06308ef29c28d2c1604ded45625caeec9Chris Lattner bool ReadBlockAbbrevs(llvm::BitstreamCursor &Cursor, unsigned BlockID); 11336367f6d06308ef29c28d2c1604ded45625caeec9Chris Lattner 113476bd1f387e6a7b7abfe53f63b3bd429b97bb80f0John McCall /// \brief Finds all the visible declarations with a given name. 113576bd1f387e6a7b7abfe53f63b3bd429b97bb80f0John McCall /// The current implementation of this method just loads the entire 113676bd1f387e6a7b7abfe53f63b3bd429b97bb80f0John McCall /// lookup table as unmaterialized references. 113776bd1f387e6a7b7abfe53f63b3bd429b97bb80f0John McCall virtual DeclContext::lookup_result 113876bd1f387e6a7b7abfe53f63b3bd429b97bb80f0John McCall FindExternalVisibleDeclsByName(const DeclContext *DC, 113976bd1f387e6a7b7abfe53f63b3bd429b97bb80f0John McCall DeclarationName Name); 114076bd1f387e6a7b7abfe53f63b3bd429b97bb80f0John McCall 11412cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor /// \brief Read all of the declarations lexically stored in a 11422cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor /// declaration context. 11432cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor /// 11442cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor /// \param DC The declaration context whose declarations will be 11452cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor /// read. 11462cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor /// 11472cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor /// \param Decls Vector that will contain the declarations loaded 11482cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor /// from the external source. The caller is responsible for merging 11492cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor /// these declarations with any declarations already stored in the 11502cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor /// declaration context. 11512cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor /// 11522cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor /// \returns true if there was an error while reading the 11532cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor /// declarations for this declaration context. 1154ba6ffaf21e465c0926d7fc5fa294ea52f8d45fafDouglas Gregor virtual ExternalLoadResult FindExternalLexicalDecls(const DeclContext *DC, 1155eb5e9986e577b1e2bff3cca5973a2494fb593fbbArgyrios Kyrtzidis bool (*isKindWeWant)(Decl::Kind), 1156686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVectorImpl<Decl*> &Decls); 11572cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor 1158dfb332d0081c6641d1dbae6a2aeff757c99cc740Argyrios Kyrtzidis /// \brief Get the decls that are contained in a file in the Offset/Length 1159dfb332d0081c6641d1dbae6a2aeff757c99cc740Argyrios Kyrtzidis /// range. \arg Length can be 0 to indicate a point at \arg Offset instead of 1160ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie /// a range. 1161dfb332d0081c6641d1dbae6a2aeff757c99cc740Argyrios Kyrtzidis virtual void FindFileRegionDecls(FileID File, unsigned Offset,unsigned Length, 1162dfb332d0081c6641d1dbae6a2aeff757c99cc740Argyrios Kyrtzidis SmallVectorImpl<Decl *> &Decls); 1163dfb332d0081c6641d1dbae6a2aeff757c99cc740Argyrios Kyrtzidis 1164c43b54cbc10654ed59de797898042e1a05265246Sebastian Redl /// \brief Notify ASTReader that we started deserialization of 116529ee3a273f58e16df7f2c524ab62a869e44fc9b1Argyrios Kyrtzidis /// a decl or type so until FinishedDeserializing is called there may be 116629ee3a273f58e16df7f2c524ab62a869e44fc9b1Argyrios Kyrtzidis /// decls that are initializing. Must be paired with FinishedDeserializing. 116729ee3a273f58e16df7f2c524ab62a869e44fc9b1Argyrios Kyrtzidis virtual void StartedDeserializing() { ++NumCurrentElementsDeserializing; } 116829ee3a273f58e16df7f2c524ab62a869e44fc9b1Argyrios Kyrtzidis 1169c43b54cbc10654ed59de797898042e1a05265246Sebastian Redl /// \brief Notify ASTReader that we finished the deserialization of 117029ee3a273f58e16df7f2c524ab62a869e44fc9b1Argyrios Kyrtzidis /// a decl or type. Must be paired with StartedDeserializing. 117129ee3a273f58e16df7f2c524ab62a869e44fc9b1Argyrios Kyrtzidis virtual void FinishedDeserializing(); 117229ee3a273f58e16df7f2c524ab62a869e44fc9b1Argyrios Kyrtzidis 1173fdd0172ca1b3c837f8c2b37d69cc2085234e09faDouglas Gregor /// \brief Function that will be invoked when we begin parsing a new 1174fdd0172ca1b3c837f8c2b37d69cc2085234e09faDouglas Gregor /// translation unit involving this external AST source. 1175fdd0172ca1b3c837f8c2b37d69cc2085234e09faDouglas Gregor /// 1176fdd0172ca1b3c837f8c2b37d69cc2085234e09faDouglas Gregor /// This function will provide all of the external definitions to 1177fdd0172ca1b3c837f8c2b37d69cc2085234e09faDouglas Gregor /// the ASTConsumer. 1178fdd0172ca1b3c837f8c2b37d69cc2085234e09faDouglas Gregor virtual void StartTranslationUnit(ASTConsumer *Consumer); 1179fdd0172ca1b3c837f8c2b37d69cc2085234e09faDouglas Gregor 11803c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// \brief Print some statistics about AST usage. 11812cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor virtual void PrintStats(); 11822cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor 118323d7df5ce30f4a068e13ad6cb81d473365d260dbDouglas Gregor /// \brief Dump information about the AST reader to standard error. 118423d7df5ce30f4a068e13ad6cb81d473365d260dbDouglas Gregor void dump(); 1185ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1186e9b5f3d4acfc2ad6e8b65a4072464e997dea9ed3Ted Kremenek /// Return the amount of memory used by memory buffers, breaking down 1187e9b5f3d4acfc2ad6e8b65a4072464e997dea9ed3Ted Kremenek /// by heap-backed versus mmap'ed memory. 1188e9b5f3d4acfc2ad6e8b65a4072464e997dea9ed3Ted Kremenek virtual void getMemoryBufferSizes(MemoryBufferSizes &sizes) const; 1189e9b5f3d4acfc2ad6e8b65a4072464e997dea9ed3Ted Kremenek 1190668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor /// \brief Initialize the semantic source with the Sema instance 1191668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor /// being used to perform semantic analysis on the abstract syntax 1192668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor /// tree. 1193668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor virtual void InitializeSema(Sema &S); 1194668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor 1195ec2a4ed278a1112ebf84fdcb80ed66f53d8ec8baDaniel Dunbar /// \brief Inform the semantic consumer that Sema is no longer available. 1196ec2a4ed278a1112ebf84fdcb80ed66f53d8ec8baDaniel Dunbar virtual void ForgetSema() { SemaObj = 0; } 1197ec2a4ed278a1112ebf84fdcb80ed66f53d8ec8baDaniel Dunbar 1198668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor /// \brief Retrieve the IdentifierInfo for the named identifier. 1199668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor /// 12004d5936aaa4e4e2d41fe79101ac9c09444951448fDaniel Dunbar /// This routine builds a new IdentifierInfo for the given identifier. If any 12014d5936aaa4e4e2d41fe79101ac9c09444951448fDaniel Dunbar /// declarations with this name are visible from translation unit scope, their 12024d5936aaa4e4e2d41fe79101ac9c09444951448fDaniel Dunbar /// declarations will be deserialized and introduced into the declaration 120388a35862fbe473f2a4f0c19f24dbe536937e1dc6Douglas Gregor /// chain of the identifier. 1204d2598368876cfe40bc8465540033bc5b5e58d8afChris Lattner virtual IdentifierInfo *get(const char *NameStart, const char *NameEnd); 1205686775deca8b8685eb90801495880e3abdd844c2Chris Lattner IdentifierInfo *get(StringRef Name) { 12064d5936aaa4e4e2d41fe79101ac9c09444951448fDaniel Dunbar return get(Name.begin(), Name.end()); 12074d5936aaa4e4e2d41fe79101ac9c09444951448fDaniel Dunbar } 1208668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor 120995f4292cc526c629fead321c7fcfd4fe0f3bc66eDouglas Gregor /// \brief Retrieve an iterator into the set of all identifiers 121095f4292cc526c629fead321c7fcfd4fe0f3bc66eDouglas Gregor /// in all loaded AST files. 121195f4292cc526c629fead321c7fcfd4fe0f3bc66eDouglas Gregor virtual IdentifierIterator *getIdentifiers() const; 121295f4292cc526c629fead321c7fcfd4fe0f3bc66eDouglas Gregor 1213f0aaf7a59729a4ae0146e3464ee987745be95829Douglas Gregor /// \brief Load the contents of the global method pool for a given 1214f0aaf7a59729a4ae0146e3464ee987745be95829Douglas Gregor /// selector. 12155ac4b6917aa34fae6da64036539023a6155a3d48Douglas Gregor virtual void ReadMethodPool(Selector Sel); 1216f0aaf7a59729a4ae0146e3464ee987745be95829Douglas Gregor 1217d8bba9c15230d2b1b3893e272106aa79efc50251Douglas Gregor /// \brief Load the set of namespaces that are known to the external source, 1218d8bba9c15230d2b1b3893e272106aa79efc50251Douglas Gregor /// which will be used during typo correction. 1219d8bba9c15230d2b1b3893e272106aa79efc50251Douglas Gregor virtual void ReadKnownNamespaces( 1220686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVectorImpl<NamespaceDecl *> &Namespaces); 1221d8bba9c15230d2b1b3893e272106aa79efc50251Douglas Gregor 1222a862320972e63349524dc9aa744dec1b95f54ba1Douglas Gregor virtual void ReadTentativeDefinitions( 1223a862320972e63349524dc9aa744dec1b95f54ba1Douglas Gregor SmallVectorImpl<VarDecl *> &TentativeDefs); 1224a862320972e63349524dc9aa744dec1b95f54ba1Douglas Gregor 1225a2ee20aa9660851080135219cac5b31fbac08b78Douglas Gregor virtual void ReadUnusedFileScopedDecls( 1226a2ee20aa9660851080135219cac5b31fbac08b78Douglas Gregor SmallVectorImpl<const DeclaratorDecl *> &Decls); 1227a2ee20aa9660851080135219cac5b31fbac08b78Douglas Gregor 12280129b561a1452bf057f6b18b6a1de815d487ab81Douglas Gregor virtual void ReadDelegatingConstructors( 12290129b561a1452bf057f6b18b6a1de815d487ab81Douglas Gregor SmallVectorImpl<CXXConstructorDecl *> &Decls); 12300129b561a1452bf057f6b18b6a1de815d487ab81Douglas Gregor 1231d58a0a55e64a7c410a80e9d6dcd899e61e99cc4dDouglas Gregor virtual void ReadExtVectorDecls(SmallVectorImpl<TypedefNameDecl *> &Decls); 1232d58a0a55e64a7c410a80e9d6dcd899e61e99cc4dDouglas Gregor 1233a126f17ca83b985300c1f65cee647bea108db657Douglas Gregor virtual void ReadDynamicClasses(SmallVectorImpl<CXXRecordDecl *> &Decls); 1234a126f17ca83b985300c1f65cee647bea108db657Douglas Gregor 1235ec12ce2f6da44bfc9048772327a3924498099d60Douglas Gregor virtual void ReadLocallyScopedExternalDecls( 1236ec12ce2f6da44bfc9048772327a3924498099d60Douglas Gregor SmallVectorImpl<NamedDecl *> &Decls); 1237ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 12385b9dc7caaef0469babc45dd8e713727a136ce517Douglas Gregor virtual void ReadReferencedSelectors( 12395b9dc7caaef0469babc45dd8e713727a136ce517Douglas Gregor SmallVectorImpl<std::pair<Selector, SourceLocation> > &Sels); 12405b9dc7caaef0469babc45dd8e713727a136ce517Douglas Gregor 124131e37b2d7b4815fdea6a35d49f33005562f0d494Douglas Gregor virtual void ReadWeakUndeclaredIdentifiers( 124231e37b2d7b4815fdea6a35d49f33005562f0d494Douglas Gregor SmallVectorImpl<std::pair<IdentifierInfo *, WeakInfo> > &WI); 124331e37b2d7b4815fdea6a35d49f33005562f0d494Douglas Gregor 1244dfe6543e12eca5c79421378b7fa6b3e8fc403e63Douglas Gregor virtual void ReadUsedVTables(SmallVectorImpl<ExternalVTableUse> &VTables); 1245dfe6543e12eca5c79421378b7fa6b3e8fc403e63Douglas Gregor 12466e4a3f5c59664af13e02e9bb58c2810b830e3b96Douglas Gregor virtual void ReadPendingInstantiations( 1247ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie SmallVectorImpl<std::pair<ValueDecl *, 12486e4a3f5c59664af13e02e9bb58c2810b830e3b96Douglas Gregor SourceLocation> > &Pending); 12496e4a3f5c59664af13e02e9bb58c2810b830e3b96Douglas Gregor 1250e58aa890e8de55bb3146e6ea9fbbba3a58ce30c6Sebastian Redl /// \brief Load a selector from disk, registering its ID if it exists. 1251e58aa890e8de55bb3146e6ea9fbbba3a58ce30c6Sebastian Redl void LoadSelector(Selector Sel); 1252e58aa890e8de55bb3146e6ea9fbbba3a58ce30c6Sebastian Redl 12532b3a5a83ea30bde7fa8f9d8e9a0cb12623759bfbDouglas Gregor void SetIdentifierInfo(unsigned ID, IdentifierInfo *II); 12541eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump void SetGloballyVisibleDecls(IdentifierInfo *II, 1255686775deca8b8685eb90801495880e3abdd844c2Chris Lattner const SmallVectorImpl<uint32_t> &DeclIDs, 1256d89275bc865e2b552836c7b33e636d4f86b8de6dDouglas Gregor bool Nonrecursive = false); 12571eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 12580a0428e96c6f1e8bef7a481a9eb69a6f6df38951Douglas Gregor /// \brief Report a diagnostic. 12590a0428e96c6f1e8bef7a481a9eb69a6f6df38951Douglas Gregor DiagnosticBuilder Diag(unsigned DiagID); 12600a0428e96c6f1e8bef7a481a9eb69a6f6df38951Douglas Gregor 1261e1d918e9fe55e3b34401fd5d420c47ea0f9572c9Douglas Gregor /// \brief Report a diagnostic. 1262e1d918e9fe55e3b34401fd5d420c47ea0f9572c9Douglas Gregor DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID); 1263e1d918e9fe55e3b34401fd5d420c47ea0f9572c9Douglas Gregor 126495eab176f51beed44a9bc14c0dcdd37844b23740Douglas Gregor IdentifierInfo *DecodeIdentifierInfo(serialization::IdentifierID ID); 12651eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 12661a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor IdentifierInfo *GetIdentifierInfo(ModuleFile &M, const RecordData &Record, 126795eab176f51beed44a9bc14c0dcdd37844b23740Douglas Gregor unsigned &Idx) { 126895eab176f51beed44a9bc14c0dcdd37844b23740Douglas Gregor return DecodeIdentifierInfo(getGlobalIdentifierID(M, Record[Idx++])); 12697356a31327be9b3c3434a0c88746028980da5684Chris Lattner } 12701eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 127195eab176f51beed44a9bc14c0dcdd37844b23740Douglas Gregor virtual IdentifierInfo *GetIdentifier(serialization::IdentifierID ID) { 12728c5a760b82e73ed90b560090772db97e2ae27b09Douglas Gregor return DecodeIdentifierInfo(ID); 12738c5a760b82e73ed90b560090772db97e2ae27b09Douglas Gregor } 12748c5a760b82e73ed90b560090772db97e2ae27b09Douglas Gregor 12751a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor IdentifierInfo *getLocalIdentifier(ModuleFile &M, unsigned LocalID); 1276ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 12771a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor serialization::IdentifierID getGlobalIdentifierID(ModuleFile &M, 127895eab176f51beed44a9bc14c0dcdd37844b23740Douglas Gregor unsigned LocalID); 1279ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 12807f94b0b0c6791013d2f72ced9b4bedd3b23673a6Douglas Gregor /// \brief Read the source location entry with index ID. 1281f62d43d2afe1960755a1b5813cae1e5983bcac1bDouglas Gregor virtual bool ReadSLocEntry(int ID); 12827f94b0b0c6791013d2f72ced9b4bedd3b23673a6Douglas Gregor 128326ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor /// \brief Retrieve the global submodule ID given a module and its local ID 128426ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor /// number. 128526ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor serialization::SubmoduleID 128626ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor getGlobalSubmoduleID(ModuleFile &M, unsigned LocalID); 128726ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor 128826ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor /// \brief Retrieve the submodule that corresponds to a global submodule ID. 128926ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor /// 129026ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor Module *getSubmodule(serialization::SubmoduleID GlobalID); 129126ced127b7d443fcf3472463c9f39c2376bd9d70Douglas Gregor 12922d2689ab787c6d54cb985c28ff3f16370bc01b0fDouglas Gregor /// \brief Retrieve a selector from the given module with its local ID 12932d2689ab787c6d54cb985c28ff3f16370bc01b0fDouglas Gregor /// number. 12941a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor Selector getLocalSelector(ModuleFile &M, unsigned LocalID); 12952d2689ab787c6d54cb985c28ff3f16370bc01b0fDouglas Gregor 12962d2689ab787c6d54cb985c28ff3f16370bc01b0fDouglas Gregor Selector DecodeSelector(serialization::SelectorID Idx); 12971eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 12988451ec7e709baf777bec07dc70653e0c523dd120Douglas Gregor virtual Selector GetExternalSelector(serialization::SelectorID ID); 129976bd1f387e6a7b7abfe53f63b3bd429b97bb80f0John McCall uint32_t GetNumExternalSelectors(); 1300719770dcfcb3987e8a2377dcca97955301445eb5Douglas Gregor 13011a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor Selector ReadSelector(ModuleFile &M, const RecordData &Record, unsigned &Idx) { 13022d2689ab787c6d54cb985c28ff3f16370bc01b0fDouglas Gregor return getLocalSelector(M, Record[Idx++]); 130390cd1bb1baac2a0221f3642de0cbea3244b116e5Steve Naroff } 1304ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 13058451ec7e709baf777bec07dc70653e0c523dd120Douglas Gregor /// \brief Retrieve the global selector ID that corresponds to this 13068451ec7e709baf777bec07dc70653e0c523dd120Douglas Gregor /// the local selector ID in a given module. 13071a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor serialization::SelectorID getGlobalSelectorID(ModuleFile &F, 13088451ec7e709baf777bec07dc70653e0c523dd120Douglas Gregor unsigned LocalID) const; 13096ad9ac097918fbdeb443ea7b99d4db9e49b28534Chris Lattner 13106ad9ac097918fbdeb443ea7b99d4db9e49b28534Chris Lattner /// \brief Read a declaration name. 13111a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor DeclarationName ReadDeclarationName(ModuleFile &F, 1312393f249399fe30e9580e1529a7479489e90f3a57Douglas Gregor const RecordData &Record, unsigned &Idx); 13131a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor void ReadDeclarationNameLoc(ModuleFile &F, 13144045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis DeclarationNameLoc &DNLoc, DeclarationName Name, 13154045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis const RecordData &Record, unsigned &Idx); 13161a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor void ReadDeclarationNameInfo(ModuleFile &F, DeclarationNameInfo &NameInfo, 13174045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis const RecordData &Record, unsigned &Idx); 13184045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis 13191a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor void ReadQualifierInfo(ModuleFile &F, QualifierInfo &Info, 13204045107b7384fd68eed5e3e2f06fc2a47e7be0a6Argyrios Kyrtzidis const RecordData &Record, unsigned &Idx); 13210a2b45e5885b6b8477b167042c0f6cd1d99a1f13Douglas Gregor 13221a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor NestedNameSpecifier *ReadNestedNameSpecifier(ModuleFile &F, 1323409448c832d27703146b70a1137d86b020f29863Douglas Gregor const RecordData &Record, 13246ad9ac097918fbdeb443ea7b99d4db9e49b28534Chris Lattner unsigned &Idx); 13256ad9ac097918fbdeb443ea7b99d4db9e49b28534Chris Lattner 13261a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor NestedNameSpecifierLoc ReadNestedNameSpecifierLoc(ModuleFile &F, 1327dc355713be51fcb4ee52d9fd6b4548ceff47fadfDouglas Gregor const RecordData &Record, 1328dc355713be51fcb4ee52d9fd6b4548ceff47fadfDouglas Gregor unsigned &Idx); 1329dc355713be51fcb4ee52d9fd6b4548ceff47fadfDouglas Gregor 13308731ca76acf81826df7048bffd0c44c7c0f96c7fArgyrios Kyrtzidis /// \brief Read a template name. 13311a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor TemplateName ReadTemplateName(ModuleFile &F, const RecordData &Record, 13321aee05d08b2184acadeb36de300e216390780d6cDouglas Gregor unsigned &Idx); 13338731ca76acf81826df7048bffd0c44c7c0f96c7fArgyrios Kyrtzidis 13348731ca76acf81826df7048bffd0c44c7c0f96c7fArgyrios Kyrtzidis /// \brief Read a template argument. 13351a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor TemplateArgument ReadTemplateArgument(ModuleFile &F, 1336577d4796d358c0e72ebaa023113505226ab51b4fSebastian Redl const RecordData &Record,unsigned &Idx); 1337ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1338dd41c14bfd7686b556de2acf6952e21a4f80b7aaArgyrios Kyrtzidis /// \brief Read a template parameter list. 13391a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor TemplateParameterList *ReadTemplateParameterList(ModuleFile &F, 1340c3632730cc83ed7b51f0ab5c38997ae5a9439b0cSebastian Redl const RecordData &Record, 1341dd41c14bfd7686b556de2acf6952e21a4f80b7aaArgyrios Kyrtzidis unsigned &Idx); 1342ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1343dd41c14bfd7686b556de2acf6952e21a4f80b7aaArgyrios Kyrtzidis /// \brief Read a template argument array. 1344dd41c14bfd7686b556de2acf6952e21a4f80b7aaArgyrios Kyrtzidis void 1345686775deca8b8685eb90801495880e3abdd844c2Chris Lattner ReadTemplateArgumentList(SmallVector<TemplateArgument, 8> &TemplArgs, 13461a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor ModuleFile &F, const RecordData &Record, 1347c3632730cc83ed7b51f0ab5c38997ae5a9439b0cSebastian Redl unsigned &Idx); 13488731ca76acf81826df7048bffd0c44c7c0f96c7fArgyrios Kyrtzidis 134937ffed3b7f229844cae2463ff82b527506c86c74Argyrios Kyrtzidis /// \brief Read a UnresolvedSet structure. 13501a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor void ReadUnresolvedSet(ModuleFile &F, UnresolvedSetImpl &Set, 135137ffed3b7f229844cae2463ff82b527506c86c74Argyrios Kyrtzidis const RecordData &Record, unsigned &Idx); 135237ffed3b7f229844cae2463ff82b527506c86c74Argyrios Kyrtzidis 13530745d0a648b75bd304045309276c70a755adaafbArgyrios Kyrtzidis /// \brief Read a C++ base specifier. 13541a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor CXXBaseSpecifier ReadCXXBaseSpecifier(ModuleFile &F, 13555606220447c7901ba8d80147ddab893bb7949dd5Nick Lewycky const RecordData &Record,unsigned &Idx); 13560745d0a648b75bd304045309276c70a755adaafbArgyrios Kyrtzidis 1357cbb67480094b3bcb5b715acd827cbad55e2a204cSean Hunt /// \brief Read a CXXCtorInitializer array. 1358cbb67480094b3bcb5b715acd827cbad55e2a204cSean Hunt std::pair<CXXCtorInitializer **, unsigned> 13591a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor ReadCXXCtorInitializers(ModuleFile &F, const RecordData &Record, 1360cbb67480094b3bcb5b715acd827cbad55e2a204cSean Hunt unsigned &Idx); 13618e706f4b8da141612861e127610141b8d17a9667Argyrios Kyrtzidis 1362c3632730cc83ed7b51f0ab5c38997ae5a9439b0cSebastian Redl /// \brief Read a source location from raw form. 13631a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor SourceLocation ReadSourceLocation(ModuleFile &ModuleFile, unsigned Raw) const { 13645a4374812c56aa60672e291b07e14d3696bbb5a6Argyrios Kyrtzidis SourceLocation Loc = SourceLocation::getFromRawEncoding(Raw); 13651a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor assert(ModuleFile.SLocRemap.find(Loc.getOffset()) != ModuleFile.SLocRemap.end() && 1366f62d43d2afe1960755a1b5813cae1e5983bcac1bDouglas Gregor "Cannot find offset to remap."); 13671a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor int Remap = ModuleFile.SLocRemap.find(Loc.getOffset())->second; 1368a64ccefdf0ea4e03ec88805d71b0af74950c7472Argyrios Kyrtzidis return Loc.getLocWithOffset(Remap); 1369c3632730cc83ed7b51f0ab5c38997ae5a9439b0cSebastian Redl } 1370c3632730cc83ed7b51f0ab5c38997ae5a9439b0cSebastian Redl 13716ad9ac097918fbdeb443ea7b99d4db9e49b28534Chris Lattner /// \brief Read a source location. 13721a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor SourceLocation ReadSourceLocation(ModuleFile &ModuleFile, 1373c3632730cc83ed7b51f0ab5c38997ae5a9439b0cSebastian Redl const RecordData &Record, unsigned& Idx) { 13741a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor return ReadSourceLocation(ModuleFile, Record[Idx++]); 13756ad9ac097918fbdeb443ea7b99d4db9e49b28534Chris Lattner } 13766ad9ac097918fbdeb443ea7b99d4db9e49b28534Chris Lattner 13776ad9ac097918fbdeb443ea7b99d4db9e49b28534Chris Lattner /// \brief Read a source range. 13781a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor SourceRange ReadSourceRange(ModuleFile &F, 1379c3632730cc83ed7b51f0ab5c38997ae5a9439b0cSebastian Redl const RecordData &Record, unsigned& Idx); 13806ad9ac097918fbdeb443ea7b99d4db9e49b28534Chris Lattner 13810a2b45e5885b6b8477b167042c0f6cd1d99a1f13Douglas Gregor /// \brief Read an integral value 13820a2b45e5885b6b8477b167042c0f6cd1d99a1f13Douglas Gregor llvm::APInt ReadAPInt(const RecordData &Record, unsigned &Idx); 13830a2b45e5885b6b8477b167042c0f6cd1d99a1f13Douglas Gregor 13840a2b45e5885b6b8477b167042c0f6cd1d99a1f13Douglas Gregor /// \brief Read a signed integral value 13850a2b45e5885b6b8477b167042c0f6cd1d99a1f13Douglas Gregor llvm::APSInt ReadAPSInt(const RecordData &Record, unsigned &Idx); 13863a2f7e42514ddbec983c61826ce85d3071e23e8eDouglas Gregor 138717fc223395d51be582fc666bb6ea21bd1dff26dcDouglas Gregor /// \brief Read a floating-point value 138817fc223395d51be582fc666bb6ea21bd1dff26dcDouglas Gregor llvm::APFloat ReadAPFloat(const RecordData &Record, unsigned &Idx); 138917fc223395d51be582fc666bb6ea21bd1dff26dcDouglas Gregor 139068a2eb0cc76267ba0615992fb5e0977853c397b2Douglas Gregor // \brief Read a string 139168a2eb0cc76267ba0615992fb5e0977853c397b2Douglas Gregor std::string ReadString(const RecordData &Record, unsigned &Idx); 139268a2eb0cc76267ba0615992fb5e0977853c397b2Douglas Gregor 13930a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor /// \brief Read a version tuple. 13940a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor VersionTuple ReadVersionTuple(const RecordData &Record, unsigned &Idx); 13950a0d2b179085a52c10402feebeb6db8b4d96a140Douglas Gregor 13961a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor CXXTemporary *ReadCXXTemporary(ModuleFile &F, const RecordData &Record, 1397409448c832d27703146b70a1137d86b020f29863Douglas Gregor unsigned &Idx); 1398ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 139968a2eb0cc76267ba0615992fb5e0977853c397b2Douglas Gregor /// \brief Reads attributes from the current stream position. 14001a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor void ReadAttributes(ModuleFile &F, AttrVec &Attrs, 14014eb9fc0449ddbd5239ddc3ae6b6e52880f47dcf7Argyrios Kyrtzidis const RecordData &Record, unsigned &Idx); 140268a2eb0cc76267ba0615992fb5e0977853c397b2Douglas Gregor 1403919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis /// \brief Reads a statement. 14041a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor Stmt *ReadStmt(ModuleFile &F); 14050b7489194f9f89fac39d57211c1e7953ae50251fDouglas Gregor 1406919e693e80632d214c1f3110f6ee5d1c0b61f06bArgyrios Kyrtzidis /// \brief Reads an expression. 14071a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor Expr *ReadExpr(ModuleFile &F); 1408c9490c000f515c29f200a1215328d8ab9a0f3818Douglas Gregor 1409d98a2ab9275f896df49e42ea4e4b8871610e0f45Argyrios Kyrtzidis /// \brief Reads a sub-statement operand during statement reading. 1410d98a2ab9275f896df49e42ea4e4b8871610e0f45Argyrios Kyrtzidis Stmt *ReadSubStmt() { 1411d98a2ab9275f896df49e42ea4e4b8871610e0f45Argyrios Kyrtzidis assert(ReadingKind == Read_Stmt && 1412d98a2ab9275f896df49e42ea4e4b8871610e0f45Argyrios Kyrtzidis "Should be called only during statement reading!"); 1413d98a2ab9275f896df49e42ea4e4b8871610e0f45Argyrios Kyrtzidis // Subexpressions are stored from last to first, so the next Stmt we need 1414d98a2ab9275f896df49e42ea4e4b8871610e0f45Argyrios Kyrtzidis // is at the back of the stack. 1415d98a2ab9275f896df49e42ea4e4b8871610e0f45Argyrios Kyrtzidis assert(!StmtStack.empty() && "Read too many sub statements!"); 1416d98a2ab9275f896df49e42ea4e4b8871610e0f45Argyrios Kyrtzidis return StmtStack.pop_back_val(); 1417d98a2ab9275f896df49e42ea4e4b8871610e0f45Argyrios Kyrtzidis } 1418d98a2ab9275f896df49e42ea4e4b8871610e0f45Argyrios Kyrtzidis 1419d98a2ab9275f896df49e42ea4e4b8871610e0f45Argyrios Kyrtzidis /// \brief Reads a sub-expression operand during statement reading. 1420d98a2ab9275f896df49e42ea4e4b8871610e0f45Argyrios Kyrtzidis Expr *ReadSubExpr(); 1421d98a2ab9275f896df49e42ea4e4b8871610e0f45Argyrios Kyrtzidis 142237e2684abfe38207fdb90620da062bb18c23f29aDouglas Gregor /// \brief Reads the macro record located at the given offset. 14231a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor void ReadMacroRecord(ModuleFile &F, uint64_t Offset); 1424ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 142586c67d8802a9e0887c31c850188991465ac3c1bdDouglas Gregor /// \brief Determine the global preprocessed entity ID that corresponds to 142686c67d8802a9e0887c31c850188991465ac3c1bdDouglas Gregor /// the given local ID within the given module. 1427ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie serialization::PreprocessedEntityID 14281a4761edca58c6b559de825b9abfb66f7f1ba94aDouglas Gregor getGlobalPreprocessedEntityID(ModuleFile &M, unsigned LocalID) const; 1429ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 1430295a2a617ac335f590e430ab7fcd98f8ce109251Douglas Gregor /// \brief Note that the identifier is a macro whose record will be loaded 1431295a2a617ac335f590e430ab7fcd98f8ce109251Douglas Gregor /// from the given AST file at the given (file-local) offset. 14321329264ce0922b3cec8c8c599108f082105fa0e1Douglas Gregor /// 14331329264ce0922b3cec8c8c599108f082105fa0e1Douglas Gregor /// \param II The name of the macro. 14341329264ce0922b3cec8c8c599108f082105fa0e1Douglas Gregor /// 14351329264ce0922b3cec8c8c599108f082105fa0e1Douglas Gregor /// \param F The module file from which the macro definition was deserialized. 14361329264ce0922b3cec8c8c599108f082105fa0e1Douglas Gregor /// 14371329264ce0922b3cec8c8c599108f082105fa0e1Douglas Gregor /// \param Offset The offset into the module file at which the macro 14381329264ce0922b3cec8c8c599108f082105fa0e1Douglas Gregor /// definition is located. 14391329264ce0922b3cec8c8c599108f082105fa0e1Douglas Gregor /// 14401329264ce0922b3cec8c8c599108f082105fa0e1Douglas Gregor /// \param Visible Whether the macro should be made visible. 14411329264ce0922b3cec8c8c599108f082105fa0e1Douglas Gregor void setIdentifierIsMacro(IdentifierInfo *II, ModuleFile &F, 14421329264ce0922b3cec8c8c599108f082105fa0e1Douglas Gregor uint64_t Offset, bool Visible); 1443ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 144488a35862fbe473f2a4f0c19f24dbe536937e1dc6Douglas Gregor /// \brief Read the set of macros defined by this external macro source. 144588a35862fbe473f2a4f0c19f24dbe536937e1dc6Douglas Gregor virtual void ReadDefinedMacros(); 144688a35862fbe473f2a4f0c19f24dbe536937e1dc6Douglas Gregor 1447295a2a617ac335f590e430ab7fcd98f8ce109251Douglas Gregor /// \brief Read the macro definition for this identifier. 1448295a2a617ac335f590e430ab7fcd98f8ce109251Douglas Gregor virtual void LoadMacroDefinition(IdentifierInfo *II); 1449295a2a617ac335f590e430ab7fcd98f8ce109251Douglas Gregor 1450eee242ff426bf79149f221798966e58688383c1eDouglas Gregor /// \brief Update an out-of-date identifier. 1451eee242ff426bf79149f221798966e58688383c1eDouglas Gregor virtual void updateOutOfDateIdentifier(IdentifierInfo &II); 1452eee242ff426bf79149f221798966e58688383c1eDouglas Gregor 1453057df20b3107cef764052d271c89b8591b98b3ceDouglas Gregor /// \brief Note that this identifier is up-to-date. 1454057df20b3107cef764052d271c89b8591b98b3ceDouglas Gregor void markIdentifierUpToDate(IdentifierInfo *II); 1455057df20b3107cef764052d271c89b8591b98b3ceDouglas Gregor 1456295a2a617ac335f590e430ab7fcd98f8ce109251Douglas Gregor /// \brief Read the macro definition corresponding to this iterator 1457295a2a617ac335f590e430ab7fcd98f8ce109251Douglas Gregor /// into the unread macro record offsets table. 1458295a2a617ac335f590e430ab7fcd98f8ce109251Douglas Gregor void LoadMacroDefinition( 1459295a2a617ac335f590e430ab7fcd98f8ce109251Douglas Gregor llvm::DenseMap<IdentifierInfo *, uint64_t>::iterator Pos); 1460ba243b59a1074e0962f6abfa3bb9aa984eac1245David Blaikie 14613c7f4134603d04b44f997b43c0a9def270f25386Sebastian Redl /// \brief Retrieve the AST context that this AST reader supplements. 1462359427794704666ff7a5a933ace11c5256fa3af7Douglas Gregor ASTContext &getContext() { return Context; } 1463025452fa0eda63e150cfaeebe64f0a19c96b3a06Douglas Gregor 14646cfc1a8b7582b8433b61222502effb018c534393Douglas Gregor // \brief Contains declarations that were loaded before we have 14656cfc1a8b7582b8433b61222502effb018c534393Douglas Gregor // access to a Sema object. 1466686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVector<NamedDecl *, 16> PreloadedDecls; 1467668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor 1468668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor /// \brief Retrieve the semantic analysis object used to analyze the 1469668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor /// translation unit in which the precompiled header is being 1470668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor /// imported. 1471668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor Sema *getSema() { return SemaObj; } 1472668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor 1473668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor /// \brief Retrieve the identifier table associated with the 1474668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor /// preprocessor. 1475668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor IdentifierTable &getIdentifierTable(); 1476668c1a4fdcc56bdd050256b1688e116fe84b72dbDouglas Gregor 1477025452fa0eda63e150cfaeebe64f0a19c96b3a06Douglas Gregor /// \brief Record that the given ID maps to the given switch-case 1478025452fa0eda63e150cfaeebe64f0a19c96b3a06Douglas Gregor /// statement. 1479025452fa0eda63e150cfaeebe64f0a19c96b3a06Douglas Gregor void RecordSwitchCaseID(SwitchCase *SC, unsigned ID); 1480025452fa0eda63e150cfaeebe64f0a19c96b3a06Douglas Gregor 1481025452fa0eda63e150cfaeebe64f0a19c96b3a06Douglas Gregor /// \brief Retrieve the switch-case statement with the given ID. 1482025452fa0eda63e150cfaeebe64f0a19c96b3a06Douglas Gregor SwitchCase *getSwitchCaseWithID(unsigned ID); 14831de05feeeafe5b215fe7617594a7076a5192a6e2Douglas Gregor 1484e09a275444576deb2c8d9e2255554242f65d7c00Argyrios Kyrtzidis void ClearSwitchCaseIDs(); 14852cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor}; 14862cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor 148702602be3ccc3b29da5b91d2502c3419404992409Chris Lattner/// \brief Helper class that saves the current stream position and 148802602be3ccc3b29da5b91d2502c3419404992409Chris Lattner/// then restores it when destroyed. 148902602be3ccc3b29da5b91d2502c3419404992409Chris Lattnerstruct SavedStreamPosition { 149002602be3ccc3b29da5b91d2502c3419404992409Chris Lattner explicit SavedStreamPosition(llvm::BitstreamCursor &Cursor) 149102602be3ccc3b29da5b91d2502c3419404992409Chris Lattner : Cursor(Cursor), Offset(Cursor.GetCurrentBitNo()) { } 14921eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 149302602be3ccc3b29da5b91d2502c3419404992409Chris Lattner ~SavedStreamPosition() { 149402602be3ccc3b29da5b91d2502c3419404992409Chris Lattner Cursor.JumpToBit(Offset); 149502602be3ccc3b29da5b91d2502c3419404992409Chris Lattner } 14961eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 149702602be3ccc3b29da5b91d2502c3419404992409Chris Lattnerprivate: 149802602be3ccc3b29da5b91d2502c3419404992409Chris Lattner llvm::BitstreamCursor &Cursor; 149902602be3ccc3b29da5b91d2502c3419404992409Chris Lattner uint64_t Offset; 150002602be3ccc3b29da5b91d2502c3419404992409Chris Lattner}; 15011eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1502d5d7b3f61f82b0fed9d6f02839bc72e528332911Ted Kremenekinline void PCHValidator::Error(const char *Msg) { 1503d5d7b3f61f82b0fed9d6f02839bc72e528332911Ted Kremenek Reader.Error(Msg); 1504d5d7b3f61f82b0fed9d6f02839bc72e528332911Ted Kremenek} 1505d5d7b3f61f82b0fed9d6f02839bc72e528332911Ted Kremenek 15062cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor} // end namespace clang 15072cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor 15082cf2634ffdb4f7c8d46cef3f8e60a55993f1c57aDouglas Gregor#endif 1509