diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2012-04-14 14:01:31 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2012-04-14 14:01:31 +0000 |
commit | dbe13110f59f48b4dbb7552b3ac2935acdeece7f (patch) | |
tree | be1815eb79b42ff482a8562b13c2dcbf0c5dcbee /include/clang/Serialization | |
parent | 9da628931ebf2609493570f87824ca22402cc65f (diff) |
Notes
Diffstat (limited to 'include/clang/Serialization')
-rw-r--r-- | include/clang/Serialization/ASTBitCodes.h | 215 | ||||
-rw-r--r-- | include/clang/Serialization/ASTDeserializationListener.h | 6 | ||||
-rw-r--r-- | include/clang/Serialization/ASTReader.h | 544 | ||||
-rw-r--r-- | include/clang/Serialization/ASTWriter.h | 235 | ||||
-rw-r--r-- | include/clang/Serialization/ChainedIncludesSource.h | 75 | ||||
-rw-r--r-- | include/clang/Serialization/ContinuousRangeMap.h | 10 | ||||
-rw-r--r-- | include/clang/Serialization/Module.h | 229 | ||||
-rw-r--r-- | include/clang/Serialization/ModuleManager.h | 30 | ||||
-rw-r--r-- | include/clang/Serialization/SerializationDiagnostic.h | 28 |
9 files changed, 912 insertions, 460 deletions
diff --git a/include/clang/Serialization/ASTBitCodes.h b/include/clang/Serialization/ASTBitCodes.h index dc4d05c6f346f..4591630357dd1 100644 --- a/include/clang/Serialization/ASTBitCodes.h +++ b/include/clang/Serialization/ASTBitCodes.h @@ -127,7 +127,7 @@ namespace clang { /// \brief The number of predefined identifier IDs. const unsigned int NUM_PREDEF_IDENT_IDS = 1; - /// \brief An ID number that refers to an ObjC selctor in an AST file. + /// \brief An ID number that refers to an ObjC selector in an AST file. typedef uint32_t SelectorID; /// \brief The number of predefined selector IDs. @@ -141,6 +141,12 @@ namespace clang { /// preprocessing record. typedef uint32_t PreprocessedEntityID; + /// \brief An ID number that refers to a submodule in a module file. + typedef uint32_t SubmoduleID; + + /// \brief The number of predefined submodule IDs. + const unsigned int NUM_PREDEF_SUBMODULE_IDS = 1; + /// \brief Source range/offset of a preprocessed entity. struct PPEntityOffset { /// \brief Raw source location of beginning of range. @@ -156,6 +162,22 @@ namespace clang { BitOffset(BitOffset) { } }; + /// \brief Source range/offset of a preprocessed entity. + struct DeclOffset { + /// \brief Raw source location. + unsigned Loc; + /// \brief Offset in the AST file. + uint32_t BitOffset; + + DeclOffset() : Loc(0), BitOffset(0) { } + DeclOffset(SourceLocation Loc, uint32_t BitOffset) + : Loc(Loc.getRawEncoding()), + BitOffset(BitOffset) { } + void setLocation(SourceLocation L) { + Loc = L.getRawEncoding(); + } + }; + /// \brief The number of predefined preprocessed entity IDs. const unsigned int NUM_PREDEF_PP_ENTITY_IDS = 1; @@ -182,7 +204,10 @@ namespace clang { DECL_UPDATES_BLOCK_ID, /// \brief The block containing the detailed preprocessing record. - PREPROCESSOR_DETAIL_BLOCK_ID + PREPROCESSOR_DETAIL_BLOCK_ID, + + /// \brief The block containing the submodule structure. + SUBMODULE_BLOCK_ID }; /// \brief Record types that occur within the AST block itself. @@ -341,10 +366,11 @@ namespace clang { /// \brief Record code for an update to the TU's lexically contained /// declarations. TU_UPDATE_LEXICAL = 28, - - /// \brief Record code for an update to first decls pointing to the - /// latest redeclarations. - REDECLS_UPDATE_LATEST = 29, + + /// \brief Record code for the array describing the locations (in the + /// LOCAL_REDECLARATIONS record) of the redeclaration chains, indexed by + /// the first known ID. + LOCAL_REDECLARATIONS_MAP = 29, /// \brief Record code for declarations that Sema keeps references of. SEMA_DECL_REFS = 30, @@ -418,9 +444,32 @@ namespace clang { /// which stores information about #line directives. SOURCE_MANAGER_LINE_TABLE = 48, - /// \brief Record code for ObjC categories in a module that are chained to - /// an interface. - OBJC_CHAINED_CATEGORIES + /// \brief Record code for map of Objective-C class definition IDs to the + /// ObjC categories in a module that are attached to that class. + OBJC_CATEGORIES_MAP = 49, + + /// \brief Record code for a file sorted array of DeclIDs in a module. + FILE_SORTED_DECLS = 50, + + /// \brief Record code for an array of all of the (sub)modules that were + /// imported by the AST file. + IMPORTED_MODULES = 51, + + /// \brief Record code for the set of merged declarations in an AST file. + MERGED_DECLARATIONS = 52, + + /// \brief Record code for the array of redeclaration chains. + /// + /// This array can only be interpreted properly using the local + /// redeclarations map. + LOCAL_REDECLARATIONS = 53, + + /// \brief Record code for the array of Objective-C categories (including + /// extensions). + /// + /// This array can only be interpreted properly using the Objective-C + /// categories map. + OBJC_CATEGORIES }; /// \brief Record types used within a source manager block. @@ -433,7 +482,8 @@ namespace clang { SM_SLOC_BUFFER_ENTRY = 2, /// \brief Describes a blob that contains the data for a buffer /// entry. This kind of record always directly follows a - /// SM_SLOC_BUFFER_ENTRY record. + /// SM_SLOC_BUFFER_ENTRY record or a SM_SLOC_FILE_ENTRY with an + /// overridden buffer. SM_SLOC_BUFFER_BLOB = 3, /// \brief Describes a source location entry (SLocEntry) for a /// macro expansion. @@ -472,6 +522,30 @@ namespace clang { PPD_INCLUSION_DIRECTIVE = 2 }; + /// \brief Record types used within a submodule description block. + enum SubmoduleRecordTypes { + /// \brief Metadata for submodules as a whole. + SUBMODULE_METADATA = 0, + /// \brief Defines the major attributes of a submodule, including its + /// name and parent. + SUBMODULE_DEFINITION = 1, + /// \brief Specifies the umbrella header used to create this module, + /// if any. + SUBMODULE_UMBRELLA_HEADER = 2, + /// \brief Specifies a header that falls into this (sub)module. + SUBMODULE_HEADER = 3, + /// \brief Specifies an umbrella directory. + SUBMODULE_UMBRELLA_DIR = 4, + /// \brief Specifies the submodules that are imported by this + /// submodule. + SUBMODULE_IMPORTS = 5, + /// \brief Specifies the submodules that are re-exported from this + /// submodule. + SUBMODULE_EXPORTS = 6, + /// \brief Specifies a required feature. + SUBMODULE_REQUIRES = 7 + }; + /// \defgroup ASTAST AST file AST constants /// /// The constants in this group describe various components of the @@ -554,7 +628,11 @@ namespace clang { /// \brief The "auto &&" deduction type. PREDEF_TYPE_AUTO_RREF_DEDUCT = 32, /// \brief The OpenCL 'half' / ARM NEON __fp16 type. - PREDEF_TYPE_HALF_ID = 33 + PREDEF_TYPE_HALF_ID = 33, + /// \brief ARC's unbridged-cast placeholder type. + PREDEF_TYPE_ARC_UNBRIDGED_CAST = 34, + /// \brief The pseudo-object placeholder type. + PREDEF_TYPE_PSEUDO_OBJECT = 35 }; /// \brief The number of predefined type IDs that are reserved for @@ -662,26 +740,26 @@ namespace clang { enum SpecialTypeIDs { /// \brief __builtin_va_list SPECIAL_TYPE_BUILTIN_VA_LIST = 0, - /// \brief Objective-C Protocol type - SPECIAL_TYPE_OBJC_PROTOCOL = 1, /// \brief CFConstantString type - SPECIAL_TYPE_CF_CONSTANT_STRING = 2, + SPECIAL_TYPE_CF_CONSTANT_STRING = 1, /// \brief C FILE typedef type - SPECIAL_TYPE_FILE = 3, + SPECIAL_TYPE_FILE = 2, /// \brief C jmp_buf typedef type - SPECIAL_TYPE_jmp_buf = 4, + SPECIAL_TYPE_JMP_BUF = 3, /// \brief C sigjmp_buf typedef type - SPECIAL_TYPE_sigjmp_buf = 5, + SPECIAL_TYPE_SIGJMP_BUF = 4, /// \brief Objective-C "id" redefinition type - SPECIAL_TYPE_OBJC_ID_REDEFINITION = 6, + SPECIAL_TYPE_OBJC_ID_REDEFINITION = 5, /// \brief Objective-C "Class" redefinition type - SPECIAL_TYPE_OBJC_CLASS_REDEFINITION = 7, + SPECIAL_TYPE_OBJC_CLASS_REDEFINITION = 6, /// \brief Objective-C "SEL" redefinition type - SPECIAL_TYPE_OBJC_SEL_REDEFINITION = 8 + SPECIAL_TYPE_OBJC_SEL_REDEFINITION = 7, + /// \brief C ucontext_t typedef type + SPECIAL_TYPE_UCONTEXT_T = 8 }; /// \brief The number of special type IDs. - const unsigned NumSpecialTypeIDs = 0; + const unsigned NumSpecialTypeIDs = 9; /// \brief Predefined declaration IDs. /// @@ -704,22 +782,25 @@ namespace clang { /// \brief The Objective-C 'Class' type. PREDEF_DECL_OBJC_CLASS_ID = 4, + + /// \brief The Objective-C 'Protocol' type. + PREDEF_DECL_OBJC_PROTOCOL_ID = 5, /// \brief The signed 128-bit integer type. - PREDEF_DECL_INT_128_ID = 5, + PREDEF_DECL_INT_128_ID = 6, /// \brief The unsigned 128-bit integer type. - PREDEF_DECL_UNSIGNED_INT_128_ID = 6, + PREDEF_DECL_UNSIGNED_INT_128_ID = 7, /// \brief The internal 'instancetype' typedef. - PREDEF_DECL_OBJC_INSTANCETYPE_ID = 7 + PREDEF_DECL_OBJC_INSTANCETYPE_ID = 8 }; /// \brief The number of declaration IDs that are predefined. /// /// For more information about predefined declarations, see the /// \c PredefinedDeclIDs type and the PREDEF_DECL_*_ID constants. - const unsigned int NUM_PREDEF_DECL_IDS = 8; + const unsigned int NUM_PREDEF_DECL_IDS = 9; /// \brief Record codes for each kind of declaration. /// @@ -750,10 +831,6 @@ namespace clang { DECL_OBJC_IVAR, /// \brief A ObjCAtDefsFieldDecl record. DECL_OBJC_AT_DEFS_FIELD, - /// \brief A ObjCClassDecl record. - DECL_OBJC_CLASS, - /// \brief A ObjCForwardProtocolDecl record. - DECL_OBJC_FORWARD_PROTOCOL, /// \brief A ObjCCategoryDecl record. DECL_OBJC_CATEGORY, /// \brief A ObjCCategoryImplDecl record. @@ -857,7 +934,9 @@ namespace clang { DECL_EXPANDED_NON_TYPE_TEMPLATE_PARM_PACK, /// \brief A ClassScopeFunctionSpecializationDecl record a class scope /// function specialization. (Microsoft extension). - DECL_CLASS_SCOPE_FUNCTION_SPECIALIZATION + DECL_CLASS_SCOPE_FUNCTION_SPECIALIZATION, + /// \brief An ImportDecl recording a module import. + DECL_IMPORT }; /// \brief Record codes for each kind of statement or expression. @@ -873,6 +952,8 @@ namespace clang { STMT_STOP = 100, /// \brief A NULL expression. STMT_NULL_PTR, + /// \brief A reference to a previously [de]serialized Stmt record. + STMT_REF_PTR, /// \brief A NullStmt record. STMT_NULL, /// \brief A CompoundStmt record. @@ -971,10 +1052,10 @@ namespace clang { EXPR_SHUFFLE_VECTOR, /// \brief BlockExpr EXPR_BLOCK, - /// \brief A BlockDeclRef record. - EXPR_BLOCK_DECL_REF, /// \brief A GenericSelectionExpr record. EXPR_GENERIC_SELECTION, + /// \brief A PseudoObjectExpr record. + EXPR_PSEUDO_OBJECT, /// \brief An AtomicExpr record. EXPR_ATOMIC, @@ -982,6 +1063,12 @@ namespace clang { /// \brief An ObjCStringLiteral record. EXPR_OBJC_STRING_LITERAL, + + EXPR_OBJC_NUMERIC_LITERAL, + EXPR_OBJC_ARRAY_LITERAL, + EXPR_OBJC_DICTIONARY_LITERAL, + + /// \brief An ObjCEncodeExpr record. EXPR_OBJC_ENCODE, /// \brief An ObjCSelectorExpr record. @@ -992,6 +1079,8 @@ namespace clang { EXPR_OBJC_IVAR_REF_EXPR, /// \brief An ObjCPropertyRefExpr record. EXPR_OBJC_PROPERTY_REF_EXPR, + /// \brief An ObjCSubscriptRefExpr record. + EXPR_OBJC_SUBSCRIPT_REF_EXPR, /// \brief UNUSED EXPR_OBJC_KVC_REF_EXPR, /// \brief An ObjCMessageExpr record. @@ -1015,6 +1104,8 @@ namespace clang { STMT_OBJC_AT_THROW, /// \brief An ObjCAutoreleasePoolStmt record. STMT_OBJC_AUTORELEASE_POOL, + /// \brief A ObjCBoolLiteralExpr record. + EXPR_OBJC_BOOL_LITERAL, // C++ @@ -1043,6 +1134,8 @@ namespace clang { EXPR_CXX_CONST_CAST, /// \brief A CXXFunctionalCastExpr record. EXPR_CXX_FUNCTIONAL_CAST, + /// \brief A UserDefinedLiteral record. + EXPR_USER_DEFINED_LITERAL, /// \brief A CXXBoolLiteralExpr record. EXPR_CXX_BOOL_LITERAL, EXPR_CXX_NULL_PTR_LITERAL, // CXXNullPtrLiteralExpr @@ -1073,6 +1166,7 @@ namespace clang { EXPR_OPAQUE_VALUE, // OpaqueValueExpr EXPR_BINARY_CONDITIONAL_OPERATOR, // BinaryConditionalOperator EXPR_BINARY_TYPE_TRAIT, // BinaryTypeTraitExpr + EXPR_TYPE_TRAIT, // TypeTraitExpr EXPR_ARRAY_TYPE_TRAIT, // ArrayTypeTraitIntExpr EXPR_PACK_EXPANSION, // PackExpansionExpr @@ -1095,7 +1189,10 @@ namespace clang { STMT_SEH_TRY, // SEHTryStmt // ARC - EXPR_OBJC_BRIDGED_CAST // ObjCBridgedCastExpr + EXPR_OBJC_BRIDGED_CAST, // ObjCBridgedCastExpr + + STMT_MS_DEPENDENT_EXISTS, // MSDependentExistsStmt + EXPR_LAMBDA // LambdaExpr }; /// \brief The kinds of designators that can occur in a @@ -1121,6 +1218,58 @@ namespace clang { CTOR_INITIALIZER_INDIRECT_MEMBER }; + /// \brief Describes the redeclarations of a declaration. + struct LocalRedeclarationsInfo { + DeclID FirstID; // The ID of the first declaration + unsigned Offset; // Offset into the array of redeclaration chains. + + friend bool operator<(const LocalRedeclarationsInfo &X, + const LocalRedeclarationsInfo &Y) { + return X.FirstID < Y.FirstID; + } + + friend bool operator>(const LocalRedeclarationsInfo &X, + const LocalRedeclarationsInfo &Y) { + return X.FirstID > Y.FirstID; + } + + friend bool operator<=(const LocalRedeclarationsInfo &X, + const LocalRedeclarationsInfo &Y) { + return X.FirstID <= Y.FirstID; + } + + friend bool operator>=(const LocalRedeclarationsInfo &X, + const LocalRedeclarationsInfo &Y) { + return X.FirstID >= Y.FirstID; + } + }; + + /// \brief Describes the categories of an Objective-C class. + struct ObjCCategoriesInfo { + DeclID DefinitionID; // The ID of the definition + unsigned Offset; // Offset into the array of category lists. + + friend bool operator<(const ObjCCategoriesInfo &X, + const ObjCCategoriesInfo &Y) { + return X.DefinitionID < Y.DefinitionID; + } + + friend bool operator>(const ObjCCategoriesInfo &X, + const ObjCCategoriesInfo &Y) { + return X.DefinitionID > Y.DefinitionID; + } + + friend bool operator<=(const ObjCCategoriesInfo &X, + const ObjCCategoriesInfo &Y) { + return X.DefinitionID <= Y.DefinitionID; + } + + friend bool operator>=(const ObjCCategoriesInfo &X, + const ObjCCategoriesInfo &Y) { + return X.DefinitionID >= Y.DefinitionID; + } + }; + /// @} } } // end namespace clang diff --git a/include/clang/Serialization/ASTDeserializationListener.h b/include/clang/Serialization/ASTDeserializationListener.h index 588fe0e63c046..ab0d313a5c84d 100644 --- a/include/clang/Serialization/ASTDeserializationListener.h +++ b/include/clang/Serialization/ASTDeserializationListener.h @@ -23,6 +23,7 @@ class Decl; class ASTReader; class QualType; class MacroDefinition; +class Module; class ASTDeserializationListener { protected: @@ -47,6 +48,11 @@ public: /// \brief A macro definition was read from the AST file. virtual void MacroDefinitionRead(serialization::PreprocessedEntityID, MacroDefinition *MD) { } + /// \brief A macro definition that had previously been deserialized + /// (and removed via IdentifierRead) has now been made visible. + virtual void MacroVisible(IdentifierInfo *II) { } + /// \brief A module definition was read from the AST file. + virtual void ModuleRead(serialization::SubmoduleID ID, Module *Mod) { } }; } diff --git a/include/clang/Serialization/ASTReader.h b/include/clang/Serialization/ASTReader.h index 996a13465944a..9baaf4bcb5275 100644 --- a/include/clang/Serialization/ASTReader.h +++ b/include/clang/Serialization/ASTReader.h @@ -34,6 +34,8 @@ #include "llvm/ADT/APInt.h" #include "llvm/ADT/APSInt.h" #include "llvm/ADT/OwningPtr.h" +#include "llvm/ADT/SmallPtrSet.h" +#include "llvm/ADT/SmallSet.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/DenseSet.h" @@ -162,16 +164,16 @@ private: void Error(const char *Msg); }; -namespace serialization { +namespace serialization { class ReadMethodPoolVisitor; - + namespace reader { class ASTIdentifierLookupTrait; } - + } // end namespace serialization - + /// \brief Reads an AST files chain containing the contents of a translation /// unit. /// @@ -191,7 +193,7 @@ class ASTReader public ExternalSemaSource, public IdentifierInfoLookup, public ExternalIdentifierLookup, - public ExternalSLocEntrySource + public ExternalSLocEntrySource { public: enum ASTReadResult { Success, Failure, IgnorePCH }; @@ -205,18 +207,18 @@ public: friend class ASTWriter; friend class ASTUnit; // ASTUnit needs to remap source locations. friend class serialization::ReadMethodPoolVisitor; - - typedef serialization::Module Module; + + typedef serialization::ModuleFile ModuleFile; typedef serialization::ModuleKind ModuleKind; typedef serialization::ModuleManager ModuleManager; - + typedef ModuleManager::ModuleIterator ModuleIterator; typedef ModuleManager::ModuleConstIterator ModuleConstIterator; typedef ModuleManager::ModuleReverseIterator ModuleReverseIterator; private: /// \brief The receiver of some callbacks invoked by ASTReader. - llvm::OwningPtr<ASTReaderListener> Listener; + OwningPtr<ASTReaderListener> Listener; /// \brief The receiver of deserialization events. ASTDeserializationListener *DeserializationListener; @@ -224,7 +226,7 @@ private: SourceManager &SourceMgr; FileManager &FileMgr; DiagnosticsEngine &Diags; - + /// \brief The semantic analysis object that will be processing the /// AST files and the translation unit that uses it. Sema *SemaObj; @@ -234,7 +236,7 @@ private: /// \brief The AST context into which we'll read the AST files. ASTContext &Context; - + /// \brief The AST consumer. ASTConsumer *Consumer; @@ -243,24 +245,24 @@ private: /// \brief A map of global bit offsets to the module that stores entities /// at those bit offsets. - ContinuousRangeMap<uint64_t, Module*, 4> GlobalBitOffsetsMap; + ContinuousRangeMap<uint64_t, ModuleFile*, 4> GlobalBitOffsetsMap; /// \brief A map of negated SLocEntryIDs to the modules containing them. - ContinuousRangeMap<unsigned, Module*, 64> GlobalSLocEntryMap; + ContinuousRangeMap<unsigned, ModuleFile*, 64> GlobalSLocEntryMap; + + typedef ContinuousRangeMap<unsigned, ModuleFile*, 64> GlobalSLocOffsetMapType; - typedef ContinuousRangeMap<unsigned, Module*, 64> GlobalSLocOffsetMapType; - /// \brief A map of reversed (SourceManager::MaxLoadedOffset - SLocOffset) /// SourceLocation offsets to the modules containing them. GlobalSLocOffsetMapType GlobalSLocOffsetMap; - + /// \brief Types that have already been loaded from the chain. /// /// When the pointer at index I is non-NULL, the type with /// ID = (I + 1) << FastQual::Width has already been loaded std::vector<QualType> TypesLoaded; - typedef ContinuousRangeMap<serialization::TypeID, Module *, 4> + typedef ContinuousRangeMap<serialization::TypeID, ModuleFile *, 4> GlobalTypeMapType; /// \brief Mapping from global type IDs to the module in which the @@ -274,60 +276,67 @@ private: /// = I + 1 has already been loaded. std::vector<Decl *> DeclsLoaded; - typedef ContinuousRangeMap<serialization::DeclID, Module *, 4> + typedef ContinuousRangeMap<serialization::DeclID, ModuleFile *, 4> GlobalDeclMapType; - + /// \brief Mapping from global declaration IDs to the module in which the /// declaration resides. GlobalDeclMapType GlobalDeclMap; - - typedef std::pair<Module *, uint64_t> FileOffset; + + typedef std::pair<ModuleFile *, uint64_t> FileOffset; typedef SmallVector<FileOffset, 2> FileOffsetsTy; typedef llvm::DenseMap<serialization::DeclID, FileOffsetsTy> DeclUpdateOffsetsMap; - + /// \brief Declarations that have modifications residing in a later file /// in the chain. DeclUpdateOffsetsMap DeclUpdateOffsets; - typedef llvm::DenseMap<serialization::DeclID, - std::pair<Module *, uint64_t> > + struct ReplacedDeclInfo { + ModuleFile *Mod; + uint64_t Offset; + unsigned RawLoc; + + ReplacedDeclInfo() : Mod(0), Offset(0), RawLoc(0) {} + ReplacedDeclInfo(ModuleFile *Mod, uint64_t Offset, unsigned RawLoc) + : Mod(Mod), Offset(Offset), RawLoc(RawLoc) {} + }; + + typedef llvm::DenseMap<serialization::DeclID, ReplacedDeclInfo> DeclReplacementMap; /// \brief Declarations that have been replaced in a later file in the chain. DeclReplacementMap ReplacedDecls; + struct FileDeclsInfo { + ModuleFile *Mod; + ArrayRef<serialization::LocalDeclID> Decls; + + FileDeclsInfo() : Mod(0) {} + FileDeclsInfo(ModuleFile *Mod, ArrayRef<serialization::LocalDeclID> Decls) + : Mod(Mod), Decls(Decls) {} + }; + + /// \brief Map from a FileID to the file-level declarations that it contains. + llvm::DenseMap<FileID, FileDeclsInfo> FileDeclIDs; + // Updates for visible decls can occur for other contexts than just the // TU, and when we read those update records, the actual context will not // be available yet (unless it's the TU), so have this pending map using the // ID as a key. It will be realized when the context is actually loaded. - typedef SmallVector<std::pair<void *, Module*>, 1> DeclContextVisibleUpdates; + typedef SmallVector<std::pair<void *, ModuleFile*>, 1> DeclContextVisibleUpdates; typedef llvm::DenseMap<serialization::DeclID, DeclContextVisibleUpdates> DeclContextVisibleUpdatesPending; /// \brief Updates to the visible declarations of declaration contexts that /// haven't been loaded yet. DeclContextVisibleUpdatesPending PendingVisibleUpdates; - - typedef SmallVector<CXXRecordDecl *, 4> ForwardRefs; - typedef llvm::DenseMap<const CXXRecordDecl *, ForwardRefs> - PendingForwardRefsMap; - /// \brief Forward references that have a definition but the definition decl - /// is still initializing. When the definition gets read it will update - /// the DefinitionData pointer of all pending references. - PendingForwardRefsMap PendingForwardRefs; - - typedef llvm::DenseMap<serialization::DeclID, serialization::DeclID> - FirstLatestDeclIDMap; - /// \brief Map of first declarations from a chained PCH that point to the - /// most recent declarations in another AST file. - FirstLatestDeclIDMap FirstLatestDeclIDs; - - /// \brief Set of ObjC interfaces that have categories chained to them in - /// other modules. - llvm::DenseSet<serialization::GlobalDeclID> ObjCChainedCategoriesInterfaces; - + + /// \brief The set of C++ or Objective-C classes that have forward + /// declarations that have not yet been linked to their definitions. + llvm::SmallPtrSet<Decl *, 4> PendingDefinitions; + /// \brief Read the records that describe the contents of declcontexts. - bool ReadDeclContextStorage(Module &M, + bool ReadDeclContextStorage(ModuleFile &M, llvm::BitstreamCursor &Cursor, const std::pair<uint64_t, uint64_t> &Offsets, serialization::DeclContextInfo &Info); @@ -340,14 +349,62 @@ private: /// been loaded. std::vector<IdentifierInfo *> IdentifiersLoaded; - typedef ContinuousRangeMap<serialization::IdentID, Module *, 4> + typedef ContinuousRangeMap<serialization::IdentID, ModuleFile *, 4> GlobalIdentifierMapType; - + /// \brief Mapping from global identifer IDs to the module in which the /// identifier resides along with the offset that should be added to the /// global identifier ID to produce a local ID. GlobalIdentifierMapType GlobalIdentifierMap; + /// \brief A vector containing submodules that have already been loaded. + /// + /// This vector is indexed by the Submodule ID (-1). NULL submodule entries + /// indicate that the particular submodule ID has not yet been loaded. + SmallVector<Module *, 2> SubmodulesLoaded; + + typedef ContinuousRangeMap<serialization::SubmoduleID, ModuleFile *, 4> + GlobalSubmoduleMapType; + + /// \brief Mapping from global submodule IDs to the module file in which the + /// submodule resides along with the offset that should be added to the + /// global submodule ID to produce a local ID. + GlobalSubmoduleMapType GlobalSubmoduleMap; + + /// \brief A set of hidden declarations. + typedef llvm::SmallVector<llvm::PointerUnion<Decl *, IdentifierInfo *>, 2> + HiddenNames; + + typedef llvm::DenseMap<Module *, HiddenNames> HiddenNamesMapType; + + /// \brief A mapping from each of the hidden submodules to the deserialized + /// declarations in that submodule that could be made visible. + HiddenNamesMapType HiddenNamesMap; + + + /// \brief A module import or export that hasn't yet been resolved. + struct UnresolvedModuleImportExport { + /// \brief The file in which this module resides. + ModuleFile *File; + + /// \brief The module that is importing or exporting. + Module *Mod; + + /// \brief The local ID of the module that is being exported. + unsigned ID; + + /// \brief Whether this is an import (vs. an export). + unsigned IsImport : 1; + + /// \brief Whether this is a wildcard export. + unsigned IsWildcard : 1; + }; + + /// \brief The set of module imports and exports that still need to be + /// resolved. + llvm::SmallVector<UnresolvedModuleImportExport, 2> + UnresolvedModuleImportExports; + /// \brief A vector containing selectors that have already been loaded. /// /// This vector is indexed by the Selector ID (-1). NULL selector @@ -355,27 +412,31 @@ private: /// been loaded. SmallVector<Selector, 16> SelectorsLoaded; - typedef ContinuousRangeMap<serialization::SelectorID, Module *, 4> + typedef ContinuousRangeMap<serialization::SelectorID, ModuleFile *, 4> GlobalSelectorMapType; - + /// \brief Mapping from global selector IDs to the module in which the /// selector resides along with the offset that should be added to the /// global selector ID to produce a local ID. GlobalSelectorMapType GlobalSelectorMap; + /// \brief The generation number of the last time we loaded data from the + /// global method pool for this selector. + llvm::DenseMap<Selector, unsigned> SelectorGeneration; + /// \brief Mapping from identifiers that represent macros whose definitions /// have not yet been deserialized to the global offset where the macro /// record resides. llvm::DenseMap<IdentifierInfo *, uint64_t> UnreadMacroRecordOffsets; - typedef ContinuousRangeMap<unsigned, Module *, 4> + typedef ContinuousRangeMap<unsigned, ModuleFile *, 4> GlobalPreprocessedEntityMapType; - + /// \brief Mapping from global preprocessing entity IDs to the module in /// which the preprocessed entity resides along with the offset that should be /// added to the global preprocessing entitiy ID to produce a local ID. GlobalPreprocessedEntityMapType GlobalPreprocessedEntityMap; - + /// \name CodeGen-relevant special data /// \brief Fields containing data that is relevant to CodeGen. //@{ @@ -423,7 +484,7 @@ private: /// \brief A list of all the delegating constructors we've seen, to diagnose /// cycles. SmallVector<uint64_t, 4> DelegatingCtorDecls; - + /// \brief Method selectors used in a @selector expression. Used for /// implementation of -Wselector. SmallVector<uint64_t, 64> ReferencedSelectorsData; @@ -480,6 +541,9 @@ private: /// \brief A list of the namespaces we've seen. SmallVector<uint64_t, 4> KnownNamespaces; + /// \brief A list of modules that were imported by precompiled headers or + /// any other non-module AST file. + SmallVector<serialization::SubmoduleID, 2> ImportedModules; //@} /// \brief The original file name that was used to build the primary AST file, @@ -493,7 +557,7 @@ private: /// \brief The file ID for the original file that was used to build the /// primary AST file. FileID OriginalFileID; - + /// \brief The directory that the PCH was originally created in. Used to /// allow resolving headers even after headers+PCH was moved to a new path. std::string OriginalDir; @@ -511,19 +575,23 @@ private: /// \brief Whether to disable the normal validation performed on precompiled /// headers when they are loaded. bool DisableValidation; - + /// \brief Whether to disable the use of stat caches in AST files. bool DisableStatCache; + /// \brief Whether to accept an AST file with compiler errors. + bool AllowASTWithCompilerErrors; + + /// \brief The current "generation" of the module file import stack, which + /// indicates how many separate module file load operations have occurred. + unsigned CurrentGeneration; + /// \brief Mapping from switch-case IDs in the chain to switch-case statements /// /// Statements usually don't have IDs, but switch cases need them, so that the /// switch statement can refer to them. std::map<unsigned, SwitchCase *> SwitchCaseStmts; - /// \brief Mapping from opaque value IDs to OpaqueValueExprs. - std::map<unsigned, OpaqueValueExpr*> OpaqueValueExprs; - /// \brief The number of stat() calls that hit/missed the stat /// cache. unsigned NumStatHits, NumStatMisses; @@ -567,13 +635,19 @@ private: /// Number of visible decl contexts read/total. unsigned NumVisibleDeclContextsRead, TotalVisibleDeclContexts; - + /// Total size of modules, in bits, currently loaded uint64_t TotalModulesSizeInBits; /// \brief Number of Decl/types that are currently deserializing. unsigned NumCurrentElementsDeserializing; + /// \brief Set true while we are in the process of passing deserialized + /// "interesting" decls to consumer inside FinishedDeserializing(). + /// This is used as a guard to avoid recursively repeating the process of + /// passing decls to consumer. + bool PassingDeclsToConsumer; + /// Number of CXX base specifiers currently loaded unsigned NumCXXBaseSpecifiersLoaded; @@ -591,6 +665,10 @@ private: /// loaded once the recursive loading has completed. std::deque<PendingIdentifierInfo> PendingIdentifierInfos; + /// \brief The generation number of each identifier, which keeps track of + /// the last time we loaded information about this identifier. + llvm::DenseMap<IdentifierInfo *, unsigned> IdentifierGeneration; + /// \brief Contains declarations and definitions that will be /// "interesting" to the ASTConsumer, when we get that AST consumer. /// @@ -599,10 +677,58 @@ private: /// Objective-C protocols. std::deque<Decl *> InterestingDecls; - /// \brief We delay loading of the previous declaration chain to avoid - /// deeply nested calls when there are many redeclarations. - std::deque<std::pair<Decl *, serialization::DeclID> > PendingPreviousDecls; - + /// \brief The set of redeclarable declaraations that have been deserialized + /// since the last time the declaration chains were linked. + llvm::SmallPtrSet<Decl *, 16> RedeclsDeserialized; + + /// \brief The list of redeclaration chains that still need to be + /// reconstructed. + /// + /// Each element is the global declaration ID of the first declaration in + /// the chain. Elements in this vector should be unique; use + /// PendingDeclChainsKnown to ensure uniqueness. + llvm::SmallVector<serialization::DeclID, 16> PendingDeclChains; + + /// \brief Keeps track of the elements added to PendingDeclChains. + llvm::SmallSet<serialization::DeclID, 16> PendingDeclChainsKnown; + + /// \brief The set of Objective-C categories that have been deserialized + /// since the last time the declaration chains were linked. + llvm::SmallPtrSet<ObjCCategoryDecl *, 16> CategoriesDeserialized; + + /// \brief The set of Objective-C class definitions that have already been + /// loaded, for which we will need to check for categories whenever a new + /// module is loaded. + llvm::SmallVector<ObjCInterfaceDecl *, 16> ObjCClassesLoaded; + + typedef llvm::DenseMap<Decl *, llvm::SmallVector<serialization::DeclID, 2> > + MergedDeclsMap; + + /// \brief A mapping from canonical declarations to the set of additional + /// (global, previously-canonical) declaration IDs that have been merged with + /// that canonical declaration. + MergedDeclsMap MergedDecls; + + typedef llvm::DenseMap<serialization::GlobalDeclID, + llvm::SmallVector<serialization::DeclID, 2> > + StoredMergedDeclsMap; + + /// \brief A mapping from canonical declaration IDs to the set of additional + /// declaration IDs that have been merged with that canonical declaration. + /// + /// This is the deserialized representation of the entries in MergedDecls. + /// When we query entries in MergedDecls, they will be augmented with entries + /// from StoredMergedDecls. + StoredMergedDeclsMap StoredMergedDecls; + + /// \brief Combine the stored merged declarations for the given canonical + /// declaration into the set of merged declarations. + /// + /// \returns An iterator into MergedDecls that corresponds to the position of + /// the given canonical declaration. + MergedDeclsMap::iterator + combineStoredMergedDecls(Decl *Canon, serialization::GlobalDeclID CanonID); + /// \brief Ready to load the previous declaration of the given Decl. void loadAndAttachPreviousDecl(Decl *D, serialization::DeclID ID); @@ -614,7 +740,7 @@ private: Read_Decl, Read_Type, Read_Stmt }; - /// \brief What kind of records we are reading. + /// \brief What kind of records we are reading. ReadingKind ReadingKind; /// \brief RAII object to change the reading kind. @@ -649,7 +775,7 @@ private: std::string SuggestedPredefines; /// \brief Reads a statement from the specified cursor. - Stmt *ReadStmtFromStream(Module &F); + Stmt *ReadStmtFromStream(ModuleFile &F); /// \brief Get a FileEntry out of stored-in-PCH filename, making sure we take /// into account all the necessary relocations. @@ -658,20 +784,21 @@ private: void MaybeAddSystemRootToFilename(std::string &Filename); ASTReadResult ReadASTCore(StringRef FileName, ModuleKind Type, - Module *ImportedBy); - ASTReadResult ReadASTBlock(Module &F); + ModuleFile *ImportedBy); + ASTReadResult ReadASTBlock(ModuleFile &F); bool CheckPredefinesBuffers(); - bool ParseLineTable(Module &F, SmallVectorImpl<uint64_t> &Record); - ASTReadResult ReadSourceManagerBlock(Module &F); + bool ParseLineTable(ModuleFile &F, SmallVectorImpl<uint64_t> &Record); + ASTReadResult ReadSourceManagerBlock(ModuleFile &F); ASTReadResult ReadSLocEntryRecord(int ID); llvm::BitstreamCursor &SLocCursorForID(int ID); - SourceLocation getImportLocation(Module *F); + SourceLocation getImportLocation(ModuleFile *F); + ASTReadResult ReadSubmoduleBlock(ModuleFile &F); bool ParseLanguageOptions(const SmallVectorImpl<uint64_t> &Record); - + struct RecordLocation { - RecordLocation(Module *M, uint64_t O) + RecordLocation(ModuleFile *M, uint64_t O) : F(M), Offset(O) {} - Module *F; + ModuleFile *F; uint64_t Offset; }; @@ -679,19 +806,22 @@ private: RecordLocation TypeCursorForIndex(unsigned Index); void LoadedDecl(unsigned Index, Decl *D); Decl *ReadDeclRecord(serialization::DeclID ID); - RecordLocation DeclCursorForID(serialization::DeclID ID); + RecordLocation DeclCursorForID(serialization::DeclID ID, + unsigned &RawLocation); void loadDeclUpdateRecords(serialization::DeclID ID, Decl *D); - void loadObjCChainedCategories(serialization::GlobalDeclID ID, - ObjCInterfaceDecl *D); - + void loadPendingDeclChain(serialization::GlobalDeclID ID); + void loadObjCCategories(serialization::GlobalDeclID ID, ObjCInterfaceDecl *D, + unsigned PreviousGeneration = 0); + RecordLocation getLocalBitOffset(uint64_t GlobalOffset); - uint64_t getGlobalBitOffset(Module &M, uint32_t LocalOffset); + uint64_t getGlobalBitOffset(ModuleFile &M, uint32_t LocalOffset); /// \brief Returns the first preprocessed entity ID that ends after \arg BLoc. serialization::PreprocessedEntityID findBeginPreprocessedEntity(SourceLocation BLoc) const; - /// \brief Returns the first preprocessed entity ID that begins after \arg ELoc. + /// \brief Returns the first preprocessed entity ID that begins after \arg + /// ELoc. serialization::PreprocessedEntityID findEndPreprocessedEntity(SourceLocation ELoc) const; @@ -703,7 +833,15 @@ private: findNextPreprocessedEntity( GlobalSLocOffsetMapType::const_iterator SLocMapI) const; + /// \brief Returns (ModuleFile, Local index) pair for \arg GlobalIndex of a + /// preprocessed entity. + std::pair<ModuleFile *, unsigned> + getModulePreprocessedEntity(unsigned GlobalIndex); + void PassInterestingDeclsToConsumer(); + void PassInterestingDeclToConsumer(Decl *D); + + void finishPendingActions(); /// \brief Produce an error diagnostic and return true. /// @@ -740,20 +878,38 @@ public: /// help when an AST file is being used in cases where the /// underlying files in the file system may have changed, but /// parsing should still continue. + /// + /// \param AllowASTWithCompilerErrors If true, the AST reader will accept an + /// AST file the was created out of an AST with compiler errors, + /// otherwise it will reject it. ASTReader(Preprocessor &PP, ASTContext &Context, StringRef isysroot = "", - bool DisableValidation = false, bool DisableStatCache = false); + bool DisableValidation = false, bool DisableStatCache = false, + bool AllowASTWithCompilerErrors = false); ~ASTReader(); SourceManager &getSourceManager() const { return SourceMgr; } - + /// \brief Load the AST file designated by the given file name. ASTReadResult ReadAST(const std::string &FileName, ModuleKind Type); /// \brief Checks that no file that is stored in PCH is out-of-sync with /// the actual file in the file system. - ASTReadResult validateFileEntries(Module &M); + ASTReadResult validateFileEntries(ModuleFile &M); + /// \brief Make the entities in the given module and any of its (non-explicit) + /// submodules visible to name lookup. + /// + /// \param Mod The module whose names should be made visible. + /// + /// \param Visibility The level of visibility to give the names in the module. + /// Visibility can only be increased over time. + void makeModuleVisible(Module *Mod, + Module::NameVisibilityKind NameVisibility); + + /// \brief Make the names within this set of hidden names visible. + void makeNamesVisible(const HiddenNames &Names); + /// \brief Set the AST callbacks listener. void setListener(ASTReaderListener *listener) { Listener.reset(listener); @@ -770,12 +926,19 @@ public: ModuleMgr.addInMemoryBuffer(FileName, Buffer); } + /// \brief Finalizes the AST reader's state before writing an AST file to + /// disk. + /// + /// This operation may undo temporary state in the AST that should not be + /// emitted. + void finalizeForWriting(); + /// \brief Retrieve the module manager. ModuleManager &getModuleManager() { return ModuleMgr; } /// \brief Retrieve the preprocessor. Preprocessor &getPreprocessor() const { return PP; } - + /// \brief Retrieve the name of the original source file name const std::string &getOriginalSourceFile() { return OriginalFileName; } @@ -801,6 +964,11 @@ public: virtual std::pair<unsigned, unsigned> findPreprocessedEntitiesInRange(SourceRange Range); + /// \brief Optionally returns true or false if the preallocated preprocessed + /// entity with index \arg Index came from file \arg FID. + virtual llvm::Optional<bool> isPreprocessedEntityInFileID(unsigned Index, + FileID FID); + /// \brief Read the header file information for the given file entry. virtual HeaderFileInfo GetHeaderFileInfo(const FileEntry *FE); @@ -826,6 +994,11 @@ public: return static_cast<unsigned>(DeclsLoaded.size()); } + /// \brief Returns the number of submodules known. + unsigned getTotalNumSubmodules() const { + return static_cast<unsigned>(SubmodulesLoaded.size()); + } + /// \brief Returns the number of selectors found in the chain. unsigned getTotalNumSelectors() const { return static_cast<unsigned>(SelectorsLoaded.size()); @@ -839,28 +1012,28 @@ public: E = ModuleMgr.end(); I != E; ++I) { Result += (*I)->NumPreprocessedEntities; } - + return Result; } - + /// \brief Returns the number of C++ base specifiers found in the chain. unsigned getTotalNumCXXBaseSpecifiers() const { return NumCXXBaseSpecifiersLoaded; } - + /// \brief Reads a TemplateArgumentLocInfo appropriate for the /// given TemplateArgument kind. TemplateArgumentLocInfo - GetTemplateArgumentLocInfo(Module &F, TemplateArgument::ArgKind Kind, + GetTemplateArgumentLocInfo(ModuleFile &F, TemplateArgument::ArgKind Kind, const RecordData &Record, unsigned &Idx); /// \brief Reads a TemplateArgumentLoc. TemplateArgumentLoc - ReadTemplateArgumentLoc(Module &F, + ReadTemplateArgumentLoc(ModuleFile &F, const RecordData &Record, unsigned &Idx); /// \brief Reads a declarator info from the given record. - TypeSourceInfo *GetTypeSourceInfo(Module &F, + TypeSourceInfo *GetTypeSourceInfo(ModuleFile &F, const RecordData &Record, unsigned &Idx); /// \brief Resolve a type ID into a type, potentially building a new @@ -868,35 +1041,42 @@ public: QualType GetType(serialization::TypeID ID); /// \brief Resolve a local type ID within a given AST file into a type. - QualType getLocalType(Module &F, unsigned LocalID); - + QualType getLocalType(ModuleFile &F, unsigned LocalID); + /// \brief Map a local type ID within a given AST file into a global type ID. - serialization::TypeID getGlobalTypeID(Module &F, unsigned LocalID) const; - - /// \brief Read a type from the current position in the given record, which + serialization::TypeID getGlobalTypeID(ModuleFile &F, unsigned LocalID) const; + + /// \brief Read a type from the current position in the given record, which /// was read from the given AST file. - QualType readType(Module &F, const RecordData &Record, unsigned &Idx) { + QualType readType(ModuleFile &F, const RecordData &Record, unsigned &Idx) { if (Idx >= Record.size()) return QualType(); - + return getLocalType(F, Record[Idx++]); } - - /// \brief Map from a local declaration ID within a given module to a + + /// \brief Map from a local declaration ID within a given module to a /// global declaration ID. - serialization::DeclID getGlobalDeclID(Module &F, unsigned LocalID) const; + serialization::DeclID getGlobalDeclID(ModuleFile &F, unsigned LocalID) const; /// \brief Returns true if global DeclID \arg ID originated from module /// \arg M. - bool isDeclIDFromModule(serialization::GlobalDeclID ID, Module &M) const; + bool isDeclIDFromModule(serialization::GlobalDeclID ID, ModuleFile &M) const; + + /// \brief Retrieve the module file that owns the given declaration, or NULL + /// if the declaration is not from a module file. + ModuleFile *getOwningModuleFile(Decl *D); + /// \brief Returns the source location for the decl \arg ID. + SourceLocation getSourceLocationForDeclID(serialization::GlobalDeclID ID); + /// \brief Resolve a declaration ID into a declaration, potentially /// building a new declaration. Decl *GetDecl(serialization::DeclID ID); virtual Decl *GetExternalDecl(uint32_t ID); /// \brief Reads a declaration with the given local ID in the given module. - Decl *GetLocalDecl(Module &F, uint32_t LocalID) { + Decl *GetLocalDecl(ModuleFile &F, uint32_t LocalID) { return GetDecl(getGlobalDeclID(F, LocalID)); } @@ -904,40 +1084,49 @@ public: /// /// \returns The requested declaration, casted to the given return type. template<typename T> - T *GetLocalDeclAs(Module &F, uint32_t LocalID) { + T *GetLocalDeclAs(ModuleFile &F, uint32_t LocalID) { return cast_or_null<T>(GetLocalDecl(F, LocalID)); } - /// \brief Reads a declaration ID from the given position in a record in the + /// \brief Map a global declaration ID into the declaration ID used to + /// refer to this declaration within the given module fule. + /// + /// \returns the global ID of the given declaration as known in the given + /// module file. + serialization::DeclID + mapGlobalIDToModuleFileGlobalID(ModuleFile &M, + serialization::DeclID GlobalID); + + /// \brief Reads a declaration ID from the given position in a record in the /// given module. /// /// \returns The declaration ID read from the record, adjusted to a global ID. - serialization::DeclID ReadDeclID(Module &F, const RecordData &Record, + serialization::DeclID ReadDeclID(ModuleFile &F, const RecordData &Record, unsigned &Idx); - + /// \brief Reads a declaration from the given position in a record in the /// given module. - Decl *ReadDecl(Module &F, const RecordData &R, unsigned &I) { + Decl *ReadDecl(ModuleFile &F, const RecordData &R, unsigned &I) { return GetDecl(ReadDeclID(F, R, I)); } - + /// \brief Reads a declaration from the given position in a record in the /// given module. /// /// \returns The declaration read from this location, casted to the given /// result type. template<typename T> - T *ReadDeclAs(Module &F, const RecordData &R, unsigned &I) { + T *ReadDeclAs(ModuleFile &F, const RecordData &R, unsigned &I) { return cast_or_null<T>(GetDecl(ReadDeclID(F, R, I))); } /// \brief Read a CXXBaseSpecifiers ID form the given record and /// return its global bit offset. - uint64_t readCXXBaseSpecifiers(Module &M, const RecordData &Record, + uint64_t readCXXBaseSpecifiers(ModuleFile &M, const RecordData &Record, unsigned &Idx); - + virtual CXXBaseSpecifier *GetExternalCXXBaseSpecifiers(uint64_t Offset); - + /// \brief Resolve the offset of a statement into a statement. /// /// This operation will read a new statement from the external @@ -974,6 +1163,12 @@ public: bool (*isKindWeWant)(Decl::Kind), SmallVectorImpl<Decl*> &Decls); + /// \brief Get the decls that are contained in a file in the Offset/Length + /// range. \arg Length can be 0 to indicate a point at \arg Offset instead of + /// a range. + virtual void FindFileRegionDecls(FileID File, unsigned Offset,unsigned Length, + SmallVectorImpl<Decl *> &Decls); + /// \brief Notify ASTReader that we started deserialization of /// a decl or type so until FinishedDeserializing is called there may be /// decls that are initializing. Must be paired with FinishedDeserializing. @@ -995,7 +1190,7 @@ public: /// \brief Dump information about the AST reader to standard error. void dump(); - + /// Return the amount of memory used by memory buffers, breaking down /// by heap-backed versus mmap'ed memory. virtual void getMemoryBufferSizes(MemoryBufferSizes &sizes) const; @@ -1025,11 +1220,7 @@ public: /// \brief Load the contents of the global method pool for a given /// selector. - /// - /// \returns a pair of Objective-C methods lists containing the - /// instance and factory methods, respectively, with this selector. - virtual std::pair<ObjCMethodList, ObjCMethodList> - ReadMethodPool(Selector Sel); + virtual void ReadMethodPool(Selector Sel); /// \brief Load the set of namespaces that are known to the external source, /// which will be used during typo correction. @@ -1051,7 +1242,7 @@ public: virtual void ReadLocallyScopedExternalDecls( SmallVectorImpl<NamedDecl *> &Decls); - + virtual void ReadReferencedSelectors( SmallVectorImpl<std::pair<Selector, SourceLocation> > &Sels); @@ -1061,7 +1252,7 @@ public: virtual void ReadUsedVTables(SmallVectorImpl<ExternalVTableUse> &VTables); virtual void ReadPendingInstantiations( - SmallVectorImpl<std::pair<ValueDecl *, + SmallVectorImpl<std::pair<ValueDecl *, SourceLocation> > &Pending); /// \brief Load a selector from disk, registering its ID if it exists. @@ -1080,7 +1271,7 @@ public: IdentifierInfo *DecodeIdentifierInfo(serialization::IdentifierID ID); - IdentifierInfo *GetIdentifierInfo(Module &M, const RecordData &Record, + IdentifierInfo *GetIdentifierInfo(ModuleFile &M, const RecordData &Record, unsigned &Idx) { return DecodeIdentifierInfo(getGlobalIdentifierID(M, Record[Idx++])); } @@ -1089,101 +1280,110 @@ public: return DecodeIdentifierInfo(ID); } - IdentifierInfo *getLocalIdentifier(Module &M, unsigned LocalID); - - serialization::IdentifierID getGlobalIdentifierID(Module &M, + IdentifierInfo *getLocalIdentifier(ModuleFile &M, unsigned LocalID); + + serialization::IdentifierID getGlobalIdentifierID(ModuleFile &M, unsigned LocalID); - + /// \brief Read the source location entry with index ID. virtual bool ReadSLocEntry(int ID); + /// \brief Retrieve the global submodule ID given a module and its local ID + /// number. + serialization::SubmoduleID + getGlobalSubmoduleID(ModuleFile &M, unsigned LocalID); + + /// \brief Retrieve the submodule that corresponds to a global submodule ID. + /// + Module *getSubmodule(serialization::SubmoduleID GlobalID); + /// \brief Retrieve a selector from the given module with its local ID /// number. - Selector getLocalSelector(Module &M, unsigned LocalID); + Selector getLocalSelector(ModuleFile &M, unsigned LocalID); Selector DecodeSelector(serialization::SelectorID Idx); virtual Selector GetExternalSelector(serialization::SelectorID ID); uint32_t GetNumExternalSelectors(); - Selector ReadSelector(Module &M, const RecordData &Record, unsigned &Idx) { + Selector ReadSelector(ModuleFile &M, const RecordData &Record, unsigned &Idx) { return getLocalSelector(M, Record[Idx++]); } - + /// \brief Retrieve the global selector ID that corresponds to this /// the local selector ID in a given module. - serialization::SelectorID getGlobalSelectorID(Module &F, + serialization::SelectorID getGlobalSelectorID(ModuleFile &F, unsigned LocalID) const; /// \brief Read a declaration name. - DeclarationName ReadDeclarationName(Module &F, + DeclarationName ReadDeclarationName(ModuleFile &F, const RecordData &Record, unsigned &Idx); - void ReadDeclarationNameLoc(Module &F, + void ReadDeclarationNameLoc(ModuleFile &F, DeclarationNameLoc &DNLoc, DeclarationName Name, const RecordData &Record, unsigned &Idx); - void ReadDeclarationNameInfo(Module &F, DeclarationNameInfo &NameInfo, + void ReadDeclarationNameInfo(ModuleFile &F, DeclarationNameInfo &NameInfo, const RecordData &Record, unsigned &Idx); - void ReadQualifierInfo(Module &F, QualifierInfo &Info, + void ReadQualifierInfo(ModuleFile &F, QualifierInfo &Info, const RecordData &Record, unsigned &Idx); - NestedNameSpecifier *ReadNestedNameSpecifier(Module &F, + NestedNameSpecifier *ReadNestedNameSpecifier(ModuleFile &F, const RecordData &Record, unsigned &Idx); - NestedNameSpecifierLoc ReadNestedNameSpecifierLoc(Module &F, + NestedNameSpecifierLoc ReadNestedNameSpecifierLoc(ModuleFile &F, const RecordData &Record, unsigned &Idx); /// \brief Read a template name. - TemplateName ReadTemplateName(Module &F, const RecordData &Record, + TemplateName ReadTemplateName(ModuleFile &F, const RecordData &Record, unsigned &Idx); /// \brief Read a template argument. - TemplateArgument ReadTemplateArgument(Module &F, + TemplateArgument ReadTemplateArgument(ModuleFile &F, const RecordData &Record,unsigned &Idx); - + /// \brief Read a template parameter list. - TemplateParameterList *ReadTemplateParameterList(Module &F, + TemplateParameterList *ReadTemplateParameterList(ModuleFile &F, const RecordData &Record, unsigned &Idx); - + /// \brief Read a template argument array. void ReadTemplateArgumentList(SmallVector<TemplateArgument, 8> &TemplArgs, - Module &F, const RecordData &Record, + ModuleFile &F, const RecordData &Record, unsigned &Idx); /// \brief Read a UnresolvedSet structure. - void ReadUnresolvedSet(Module &F, UnresolvedSetImpl &Set, + void ReadUnresolvedSet(ModuleFile &F, UnresolvedSetImpl &Set, const RecordData &Record, unsigned &Idx); /// \brief Read a C++ base specifier. - CXXBaseSpecifier ReadCXXBaseSpecifier(Module &F, + CXXBaseSpecifier ReadCXXBaseSpecifier(ModuleFile &F, const RecordData &Record,unsigned &Idx); /// \brief Read a CXXCtorInitializer array. std::pair<CXXCtorInitializer **, unsigned> - ReadCXXCtorInitializers(Module &F, const RecordData &Record, + ReadCXXCtorInitializers(ModuleFile &F, const RecordData &Record, unsigned &Idx); /// \brief Read a source location from raw form. - SourceLocation ReadSourceLocation(Module &Module, unsigned Raw) const { + SourceLocation ReadSourceLocation(ModuleFile &ModuleFile, unsigned Raw) const { SourceLocation Loc = SourceLocation::getFromRawEncoding(Raw); - assert(Module.SLocRemap.find(Loc.getOffset()) != Module.SLocRemap.end() && + assert(ModuleFile.SLocRemap.find(Loc.getOffset()) != ModuleFile.SLocRemap.end() && "Cannot find offset to remap."); - int Remap = Module.SLocRemap.find(Loc.getOffset())->second; + int Remap = ModuleFile.SLocRemap.find(Loc.getOffset())->second; return Loc.getLocWithOffset(Remap); } /// \brief Read a source location. - SourceLocation ReadSourceLocation(Module &Module, + SourceLocation ReadSourceLocation(ModuleFile &ModuleFile, const RecordData &Record, unsigned& Idx) { - return ReadSourceLocation(Module, Record[Idx++]); + return ReadSourceLocation(ModuleFile, Record[Idx++]); } /// \brief Read a source range. - SourceRange ReadSourceRange(Module &F, + SourceRange ReadSourceRange(ModuleFile &F, const RecordData &Record, unsigned& Idx); /// \brief Read an integral value @@ -1201,18 +1401,18 @@ public: /// \brief Read a version tuple. VersionTuple ReadVersionTuple(const RecordData &Record, unsigned &Idx); - CXXTemporary *ReadCXXTemporary(Module &F, const RecordData &Record, + CXXTemporary *ReadCXXTemporary(ModuleFile &F, const RecordData &Record, unsigned &Idx); - + /// \brief Reads attributes from the current stream position. - void ReadAttributes(Module &F, AttrVec &Attrs, + void ReadAttributes(ModuleFile &F, AttrVec &Attrs, const RecordData &Record, unsigned &Idx); /// \brief Reads a statement. - Stmt *ReadStmt(Module &F); + Stmt *ReadStmt(ModuleFile &F); /// \brief Reads an expression. - Expr *ReadExpr(Module &F); + Expr *ReadExpr(ModuleFile &F); /// \brief Reads a sub-statement operand during statement reading. Stmt *ReadSubStmt() { @@ -1228,29 +1428,47 @@ public: Expr *ReadSubExpr(); /// \brief Reads the macro record located at the given offset. - void ReadMacroRecord(Module &F, uint64_t Offset); - + void ReadMacroRecord(ModuleFile &F, uint64_t Offset); + /// \brief Determine the global preprocessed entity ID that corresponds to /// the given local ID within the given module. - serialization::PreprocessedEntityID - getGlobalPreprocessedEntityID(Module &M, unsigned LocalID) const; - + serialization::PreprocessedEntityID + getGlobalPreprocessedEntityID(ModuleFile &M, unsigned LocalID) const; + /// \brief Note that the identifier is a macro whose record will be loaded /// from the given AST file at the given (file-local) offset. - void SetIdentifierIsMacro(IdentifierInfo *II, Module &F, - uint64_t Offset); - + /// + /// \param II The name of the macro. + /// + /// \param F The module file from which the macro definition was deserialized. + /// + /// \param Offset The offset into the module file at which the macro + /// definition is located. + /// + /// \param Visible Whether the macro should be made visible. + void setIdentifierIsMacro(IdentifierInfo *II, ModuleFile &F, + uint64_t Offset, bool Visible); + /// \brief Read the set of macros defined by this external macro source. virtual void ReadDefinedMacros(); /// \brief Read the macro definition for this identifier. virtual void LoadMacroDefinition(IdentifierInfo *II); + /// \brief Update an out-of-date identifier. + virtual void updateOutOfDateIdentifier(IdentifierInfo &II); + + /// \brief Note that this identifier is up-to-date. + void markIdentifierUpToDate(IdentifierInfo *II); + /// \brief Read the macro definition corresponding to this iterator /// into the unread macro record offsets table. void LoadMacroDefinition( llvm::DenseMap<IdentifierInfo *, uint64_t>::iterator Pos); - + + /// \brief Load all external visible decls in the given DeclContext. + void completeVisibleDeclsMap(DeclContext *DC); + /// \brief Retrieve the AST context that this AST reader supplements. ASTContext &getContext() { return Context; } diff --git a/include/clang/Serialization/ASTWriter.h b/include/clang/Serialization/ASTWriter.h index 7a49e485f2a63..4c62385cf2c2e 100644 --- a/include/clang/Serialization/ASTWriter.h +++ b/include/clang/Serialization/ASTWriter.h @@ -24,6 +24,8 @@ #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/DenseSet.h" +#include "llvm/ADT/SetVector.h" #include "llvm/Bitcode/BitstreamWriter.h" #include <map> #include <queue> @@ -43,11 +45,13 @@ class CXXBaseSpecifier; class CXXCtorInitializer; class FPOptions; class HeaderSearch; +class IdentifierResolver; class MacroDefinition; class MemorizeStatCalls; class OpaqueValueExpr; class OpenCLOptions; class ASTReader; +class Module; class PreprocessedEntity; class PreprocessingRecord; class Preprocessor; @@ -57,6 +61,8 @@ class SwitchCase; class TargetInfo; class VersionTuple; +namespace SrcMgr { class SLocEntry; } + /// \brief Writes an AST file containing the contents of a translation unit. /// /// The ASTWriter class produces a bitstream containing the serialized @@ -80,7 +86,7 @@ private: /// allow for the const/volatile qualifiers. /// /// Keys in the map never have const/volatile qualifiers. - typedef llvm::DenseMap<QualType, serialization::TypeIdx, + typedef llvm::DenseMap<QualType, serialization::TypeIdx, serialization::UnsafeQualTypeDenseMapInfo> TypeIdxMap; @@ -89,33 +95,42 @@ private: /// \brief The ASTContext we're writing. ASTContext *Context; - + + /// \brief The preprocessor we're writing. + Preprocessor *PP; + /// \brief The reader of existing AST files, if we're chaining. ASTReader *Chain; - - /// \brief Indicates when the AST writing is actively performing + + /// \brief The module we're currently writing, if any. + Module *WritingModule; + + /// \brief Indicates when the AST writing is actively performing /// serialization, rather than just queueing updates. bool WritingAST; - + + /// \brief Indicates that the AST contained compiler errors. + bool ASTHasCompilerErrors; + /// \brief Stores a declaration or a type to be written to the AST file. class DeclOrType { public: DeclOrType(Decl *D) : Stored(D), IsType(false) { } DeclOrType(QualType T) : Stored(T.getAsOpaquePtr()), IsType(true) { } - + bool isType() const { return IsType; } bool isDecl() const { return !IsType; } - + QualType getType() const { assert(isType() && "Not a type!"); return QualType::getFromOpaquePtr(Stored); } - + Decl *getDecl() const { assert(isDecl() && "Not a decl!"); return static_cast<Decl *>(Stored); } - + private: void *Stored; bool IsType; @@ -140,7 +155,25 @@ private: /// \brief Offset of each declaration in the bitstream, indexed by /// the declaration's ID. - std::vector<uint32_t> DeclOffsets; + std::vector<serialization::DeclOffset> DeclOffsets; + + /// \brief Sorted (by file offset) vector of pairs of file offset/DeclID. + typedef SmallVector<std::pair<unsigned, serialization::DeclID>, 64> + LocDeclIDsTy; + struct DeclIDInFileInfo { + LocDeclIDsTy DeclIDs; + /// \brief Set when the DeclIDs vectors from all files are joined, this + /// indicates the index that this particular vector has in the global one. + unsigned FirstDeclIndex; + }; + typedef llvm::DenseMap<const SrcMgr::SLocEntry *, + DeclIDInFileInfo *> FileDeclIDsTy; + + /// \brief Map from file SLocEntries to info about the file-level declarations + /// that it contains. + FileDeclIDsTy FileDeclIDs; + + void associateDeclWithFile(const Decl *D, serialization::DeclID); /// \brief The first ID number we can use for our own types. serialization::TypeID FirstTypeID; @@ -177,14 +210,32 @@ private: /// IdentifierInfo. llvm::DenseMap<const IdentifierInfo *, serialization::IdentID> IdentifierIDs; + /// @name FlushStmt Caches + /// @{ + + /// \brief Set of parent Stmts for the currently serializing sub stmt. + llvm::DenseSet<Stmt *> ParentStmts; + + /// \brief Offsets of sub stmts already serialized. The offset points + /// just after the stmt record. + llvm::DenseMap<Stmt *, uint64_t> SubStmtEntries; + + /// @} + /// \brief Offsets of each of the identifier IDs into the identifier /// table. std::vector<uint32_t> IdentifierOffsets; + /// \brief The first ID number we can use for our own submodules. + serialization::SubmoduleID FirstSubmoduleID; + + /// \brief The submodule ID that will be assigned to the next new submodule. + serialization::SubmoduleID NextSubmoduleID; + /// \brief The first ID number we can use for our own selectors. serialization::SelectorID FirstSelectorID; - /// \brief The selector ID that will be assigned to the next new identifier. + /// \brief The selector ID that will be assigned to the next new selector. serialization::SelectorID NextSelectorID; /// \brief Map that provides the ID numbers of each Selector. @@ -193,7 +244,7 @@ private: /// \brief Offset of each selector within the method pool/selector /// table, indexed by the Selector ID (-1). std::vector<uint32_t> SelectorOffsets; - + /// \brief Offsets of each of the macro identifiers into the /// bitstream. /// @@ -204,7 +255,7 @@ private: /// \brief The set of identifiers that had macro definitions at some point. std::vector<const IdentifierInfo *> DeserializedMacroNames; - + /// \brief Mapping from macro definitions (as they occur in the preprocessing /// record) to the macro IDs. llvm::DenseMap<const MacroDefinition *, serialization::PreprocessedEntityID> @@ -220,7 +271,7 @@ private: /// \brief Map of first declarations from a chained PCH that point to the /// most recent declarations in another PCH. FirstLatestDeclMap FirstLatestDecls; - + /// \brief Declarations encountered that might be external /// definitions. /// @@ -238,31 +289,30 @@ private: /// \brief DeclContexts that have received extensions since their serialized /// form. /// - /// For namespaces, when we're chaining and encountering a namespace, we check if - /// its primary namespace comes from the chain. If it does, we add the primary - /// to this set, so that we can write out lexical content updates for it. + /// For namespaces, when we're chaining and encountering a namespace, we check + /// if its primary namespace comes from the chain. If it does, we add the + /// primary to this set, so that we can write out lexical content updates for + /// it. llvm::SmallPtrSet<const DeclContext *, 16> UpdatedDeclContexts; typedef llvm::SmallPtrSet<const Decl *, 16> DeclsToRewriteTy; /// \brief Decls that will be replaced in the current dependent AST file. DeclsToRewriteTy DeclsToRewrite; - struct ChainedObjCCategoriesData { - /// \brief The interface in the imported module. - const ObjCInterfaceDecl *Interface; - /// \brief The local tail category ID that got chained to the imported - /// interface. - const ObjCCategoryDecl *TailCategory; - - /// \brief ID corresponding to \c Interface. - serialization::DeclID InterfaceID; - - /// \brief ID corresponding to TailCategoryID. - serialization::DeclID TailCategoryID; + /// \brief The set of Objective-C class that have categories we + /// should serialize. + llvm::SetVector<ObjCInterfaceDecl *> ObjCClassesWithCategories; + + struct ReplacedDeclInfo { + serialization::DeclID ID; + uint64_t Offset; + unsigned Loc; + + ReplacedDeclInfo() : ID(0), Offset(0), Loc(0) {} + ReplacedDeclInfo(serialization::DeclID ID, uint64_t Offset, + SourceLocation Loc) + : ID(ID), Offset(Offset), Loc(Loc.getRawEncoding()) {} }; - /// \brief ObjC categories that got chained to an interface imported from - /// another module. - SmallVector<ChainedObjCCategoriesData, 16> LocalChainedObjCCategories; /// \brief Decls that have been replaced in the current dependent AST file. /// @@ -270,23 +320,24 @@ private: /// happen, but the ObjC AST nodes are designed this way), it will be /// serialized again. In this case, it is registered here, so that the reader /// knows to read the updated version. - SmallVector<std::pair<serialization::DeclID, uint64_t>, 16> - ReplacedDecls; - + SmallVector<ReplacedDeclInfo, 16> ReplacedDecls; + + /// \brief The set of declarations that may have redeclaration chains that + /// need to be serialized. + llvm::SetVector<Decl *, llvm::SmallVector<Decl *, 4>, + llvm::SmallPtrSet<Decl *, 4> > Redeclarations; + /// \brief Statements that we've encountered while serializing a /// declaration or type. SmallVector<Stmt *, 16> StmtsToEmit; /// \brief Statements collection to use for ASTWriter::AddStmt(). - /// It will point to StmtsToEmit unless it is overriden. + /// It will point to StmtsToEmit unless it is overriden. SmallVector<Stmt *, 16> *CollectedStmts; /// \brief Mapping from SwitchCase statements to IDs. std::map<SwitchCase *, unsigned> SwitchCaseIDs; - /// \brief Mapping from OpaqueValueExpr expressions to IDs. - llvm::DenseMap<OpaqueValueExpr *, unsigned> OpaqueValues; - /// \brief The number of statements written to the AST file. unsigned NumStatements; @@ -303,35 +354,44 @@ private: /// \brief The offset of each CXXBaseSpecifier set within the AST. SmallVector<uint32_t, 4> CXXBaseSpecifiersOffsets; - + /// \brief The first ID number we can use for our own base specifiers. serialization::CXXBaseSpecifiersID FirstCXXBaseSpecifiersID; - - /// \brief The base specifiers ID that will be assigned to the next new + + /// \brief The base specifiers ID that will be assigned to the next new /// set of C++ base specifiers. serialization::CXXBaseSpecifiersID NextCXXBaseSpecifiersID; - /// \brief A set of C++ base specifiers that is queued to be written into the - /// AST file. + /// \brief A set of C++ base specifiers that is queued to be written into the + /// AST file. struct QueuedCXXBaseSpecifiers { QueuedCXXBaseSpecifiers() : ID(), Bases(), BasesEnd() { } - + QueuedCXXBaseSpecifiers(serialization::CXXBaseSpecifiersID ID, CXXBaseSpecifier const *Bases, CXXBaseSpecifier const *BasesEnd) : ID(ID), Bases(Bases), BasesEnd(BasesEnd) { } - + serialization::CXXBaseSpecifiersID ID; CXXBaseSpecifier const * Bases; CXXBaseSpecifier const * BasesEnd; }; - + /// \brief Queue of C++ base specifiers to be written to the AST file, /// in the order they should be written. SmallVector<QueuedCXXBaseSpecifiers, 2> CXXBaseSpecifiersToWrite; + + /// \brief A mapping from each known submodule to its ID number, which will + /// be a positive integer. + llvm::DenseMap<Module *, unsigned> SubmoduleIDs; + + /// \brief Retrieve or create a submodule ID for this module. + unsigned getSubmoduleID(Module *Mod); /// \brief Write the given subexpression to the bitstream. - void WriteSubStmt(Stmt *S); + void WriteSubStmt(Stmt *S, + llvm::DenseMap<Stmt *, uint64_t> &SubStmtEntries, + llvm::DenseSet<Stmt *> &ParentStmts); void WriteBlockInfoBlock(); void WriteMetadata(ASTContext &Context, StringRef isysroot, @@ -342,27 +402,32 @@ private: const Preprocessor &PP, StringRef isysroot); void WritePreprocessor(const Preprocessor &PP, bool IsModule); - void WriteHeaderSearch(HeaderSearch &HS, StringRef isysroot); + void WriteHeaderSearch(const HeaderSearch &HS, StringRef isysroot); void WritePreprocessorDetail(PreprocessingRecord &PPRec); + void WriteSubmodules(Module *WritingModule); + void WritePragmaDiagnosticMappings(const DiagnosticsEngine &Diag); void WriteCXXBaseSpecifiersOffsets(); void WriteType(QualType T); uint64_t WriteDeclContextLexicalBlock(ASTContext &Context, DeclContext *DC); uint64_t WriteDeclContextVisibleBlock(ASTContext &Context, DeclContext *DC); void WriteTypeDeclOffsets(); + void WriteFileDeclIDsMap(); void WriteSelectors(Sema &SemaRef); void WriteReferencedSelectorsPool(Sema &SemaRef); - void WriteIdentifierTable(Preprocessor &PP, bool IsModule); + void WriteIdentifierTable(Preprocessor &PP, IdentifierResolver &IdResolver, + bool IsModule); void WriteAttributes(const AttrVec &Attrs, RecordDataImpl &Record); void ResolveDeclUpdatesBlocks(); void WriteDeclUpdatesBlocks(); void WriteDeclReplacementsBlock(); - void ResolveChainedObjCCategories(); - void WriteChainedObjCCategories(); void WriteDeclContextVisibleUpdate(const DeclContext *DC); void WriteFPPragmaOptions(const FPOptions &Opts); void WriteOpenCLExtensions(Sema &SemaRef); - + void WriteObjCCategories(); + void WriteRedeclarations(); + void WriteMergedDecls(); + unsigned DeclParmVarAbbrev; unsigned DeclContextLexicalAbbrev; unsigned DeclContextVisibleLookupAbbrev; @@ -382,13 +447,14 @@ private: void WriteASTCore(Sema &SemaRef, MemorizeStatCalls *StatCalls, StringRef isysroot, const std::string &OutputFile, - bool IsModule); - + Module *WritingModule); + public: /// \brief Create a new precompiled header writer that outputs to /// the given bitstream. ASTWriter(llvm::BitstreamWriter &Stream); - + ~ASTWriter(); + /// \brief Write a precompiled header for the given semantic analysis. /// /// \param SemaRef a reference to the semantic analysis object that processed @@ -397,21 +463,22 @@ public: /// \param StatCalls the object that cached all of the stat() calls made while /// searching for source files and headers. /// - /// \param IsModule Whether we're writing a module (otherwise, we're writing a - /// precompiled header). + /// \param WritingModule The module that we are writing. If null, we are + /// writing a precompiled header. /// /// \param isysroot if non-empty, write a relocatable file whose headers /// are relative to the given system root. void WriteAST(Sema &SemaRef, MemorizeStatCalls *StatCalls, const std::string &OutputFile, - bool IsModule, StringRef isysroot); + Module *WritingModule, StringRef isysroot, + bool hasErrors = false); /// \brief Emit a source location. void AddSourceLocation(SourceLocation Loc, RecordDataImpl &Record); /// \brief Emit a source range. void AddSourceRange(SourceRange Range, RecordDataImpl &Record); - + /// \brief Emit an integral value. void AddAPInt(const llvm::APInt &Value, RecordDataImpl &Record); @@ -434,10 +501,10 @@ public: void AddCXXBaseSpecifiersRef(CXXBaseSpecifier const *Bases, CXXBaseSpecifier const *BasesEnd, RecordDataImpl &Record); - + /// \brief Get the unique number used to refer to the given selector. serialization::SelectorID getSelectorRef(Selector Sel); - + /// \brief Get the unique number used to refer to the given identifier. serialization::IdentID getIdentifierRef(const IdentifierInfo *II); @@ -450,7 +517,7 @@ public: "Identifier does not name a macro"); return MacroOffsets[II]; } - + /// \brief Emit a reference to a type. void AddTypeRef(QualType T, RecordDataImpl &Record); @@ -484,7 +551,7 @@ public: /// \brief Emit a reference to a declaration. void AddDeclRef(const Decl *D, RecordDataImpl &Record); - + /// \brief Force a declaration to be emitted and get its ID. serialization::DeclID GetDeclRef(const Decl *D); @@ -505,9 +572,9 @@ public: void AddNestedNameSpecifier(NestedNameSpecifier *NNS, RecordDataImpl &Record); /// \brief Emit a nested name specifier with source-location information. - void AddNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS, + void AddNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS, RecordDataImpl &Record); - + /// \brief Emit a template name. void AddTemplateName(TemplateName Name, RecordDataImpl &Record); @@ -526,7 +593,8 @@ public: void AddUnresolvedSet(const UnresolvedSetImpl &Set, RecordDataImpl &Record); /// \brief Emit a C++ base specifier. - void AddCXXBaseSpecifier(const CXXBaseSpecifier &Base, RecordDataImpl &Record); + void AddCXXBaseSpecifier(const CXXBaseSpecifier &Base, + RecordDataImpl &Record); /// \brief Emit a CXXCtorInitializer array. void AddCXXCtorInitializers( @@ -549,10 +617,16 @@ public: void RewriteDecl(const Decl *D) { DeclsToRewrite.insert(D); - // Reset the flag, so that we don't add this decl multiple times. - const_cast<Decl *>(D)->setChangedSinceDeserialization(false); } + bool isRewritten(const Decl *D) const { + return DeclsToRewrite.count(D); + } + + /// \brief Infer the submodule ID that contains an entity at the given + /// source location. + serialization::SubmoduleID inferSubmoduleIDFromLocation(SourceLocation Loc); + /// \brief Note that the identifier II occurs at the given offset /// within the identifier table. void SetIdentifierOffset(const IdentifierInfo *II, uint32_t Offset); @@ -577,10 +651,10 @@ public: /// been added to the queue via AddStmt(). void FlushStmts(); - /// \brief Flush all of the C++ base specifier sets that have been added + /// \brief Flush all of the C++ base specifier sets that have been added /// via \c AddCXXBaseSpecifiersRef(). void FlushCXXBaseSpecifiers(); - + /// \brief Record an ID for the given switch-case statement. unsigned RecordSwitchCaseID(SwitchCase *S); @@ -589,9 +663,6 @@ public: void ClearSwitchCaseIDs(); - /// \brief Retrieve the ID for the given opaque value expression. - unsigned getOpaqueValueID(OpaqueValueExpr *e); - unsigned getDeclParmVarAbbrev() const { return DeclParmVarAbbrev; } unsigned getDeclRefExprAbbrev() const { return DeclRefExprAbbrev; } unsigned getCharacterLiteralAbbrev() const { return CharacterLiteralAbbrev; } @@ -609,11 +680,12 @@ public: void ReaderInitialized(ASTReader *Reader); void IdentifierRead(serialization::IdentID ID, IdentifierInfo *II); void TypeRead(serialization::TypeIdx Idx, QualType T); - void DeclRead(serialization::DeclID ID, const Decl *D); void SelectorRead(serialization::SelectorID ID, Selector Sel); void MacroDefinitionRead(serialization::PreprocessedEntityID ID, MacroDefinition *MD); - + void MacroVisible(IdentifierInfo *II); + void ModuleRead(serialization::SubmoduleID ID, Module *Mod); + // ASTMutationListener implementation. virtual void CompletedTagDefinition(const TagDecl *D); virtual void AddedVisibleDecl(const DeclContext *DC, const Decl *D); @@ -626,6 +698,9 @@ public: virtual void StaticDataMemberInstantiated(const VarDecl *D); virtual void AddedObjCCategoryToInterface(const ObjCCategoryDecl *CatD, const ObjCInterfaceDecl *IFD); + virtual void AddedObjCPropertyInClassExtension(const ObjCPropertyDecl *Prop, + const ObjCPropertyDecl *OrigProp, + const ObjCCategoryDecl *ClassExt); }; /// \brief AST and semantic-analysis consumer that generates a @@ -633,12 +708,12 @@ public: class PCHGenerator : public SemaConsumer { const Preprocessor &PP; std::string OutputFile; - bool IsModule; + clang::Module *Module; std::string isysroot; raw_ostream *Out; Sema *SemaPtr; MemorizeStatCalls *StatCalls; // owned by the FileManager - std::vector<unsigned char> Buffer; + llvm::SmallVector<char, 128> Buffer; llvm::BitstreamWriter Stream; ASTWriter Writer; @@ -647,8 +722,8 @@ protected: const ASTWriter &getWriter() const { return Writer; } public: - PCHGenerator(const Preprocessor &PP, StringRef OutputFile, - bool IsModule, + PCHGenerator(const Preprocessor &PP, StringRef OutputFile, + clang::Module *Module, StringRef isysroot, raw_ostream *Out); ~PCHGenerator(); virtual void InitializeSema(Sema &S) { SemaPtr = &S; } diff --git a/include/clang/Serialization/ChainedIncludesSource.h b/include/clang/Serialization/ChainedIncludesSource.h deleted file mode 100644 index 620dbdf40c484..0000000000000 --- a/include/clang/Serialization/ChainedIncludesSource.h +++ /dev/null @@ -1,75 +0,0 @@ -//===- ChainedIncludesSource.h - Chained PCHs in Memory ---------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file defines the ChainedIncludesSource class, which converts headers -// to chained PCHs in memory, mainly used for testing. -// -//===----------------------------------------------------------------------===// -#ifndef LLVM_CLANG_SERIALIZATION_CHAINEDINCLUDESSOURCE_H -#define LLVM_CLANG_SERIALIZATION_CHAINEDINCLUDESSOURCE_H - -#include "clang/Sema/ExternalSemaSource.h" -#include <vector> - -namespace clang { - class CompilerInstance; - -class ChainedIncludesSource : public ExternalSemaSource { -public: - virtual ~ChainedIncludesSource(); - - static ChainedIncludesSource *create(CompilerInstance &CI); - -private: - ExternalSemaSource &getFinalReader() const { return *FinalReader; } - - std::vector<CompilerInstance *> CIs; - llvm::OwningPtr<ExternalSemaSource> FinalReader; - - -protected: - -//===----------------------------------------------------------------------===// -// ExternalASTSource interface. -//===----------------------------------------------------------------------===// - - virtual Decl *GetExternalDecl(uint32_t ID); - virtual Selector GetExternalSelector(uint32_t ID); - virtual uint32_t GetNumExternalSelectors(); - virtual Stmt *GetExternalDeclStmt(uint64_t Offset); - virtual CXXBaseSpecifier *GetExternalCXXBaseSpecifiers(uint64_t Offset); - virtual DeclContextLookupResult - FindExternalVisibleDeclsByName(const DeclContext *DC, DeclarationName Name); - virtual ExternalLoadResult FindExternalLexicalDecls(const DeclContext *DC, - bool (*isKindWeWant)(Decl::Kind), - SmallVectorImpl<Decl*> &Result); - virtual void CompleteType(TagDecl *Tag); - virtual void CompleteType(ObjCInterfaceDecl *Class); - virtual void StartedDeserializing(); - virtual void FinishedDeserializing(); - virtual void StartTranslationUnit(ASTConsumer *Consumer); - virtual void PrintStats(); - - /// Return the amount of memory used by memory buffers, breaking down - /// by heap-backed versus mmap'ed memory. - virtual void getMemoryBufferSizes(MemoryBufferSizes &sizes) const; - -//===----------------------------------------------------------------------===// -// ExternalSemaSource interface. -//===----------------------------------------------------------------------===// - - virtual void InitializeSema(Sema &S); - virtual void ForgetSema(); - virtual std::pair<ObjCMethodList,ObjCMethodList> ReadMethodPool(Selector Sel); - virtual bool LookupUnqualified(LookupResult &R, Scope *S); -}; - -} - -#endif diff --git a/include/clang/Serialization/ContinuousRangeMap.h b/include/clang/Serialization/ContinuousRangeMap.h index 7f7832041072e..f368a80a97d82 100644 --- a/include/clang/Serialization/ContinuousRangeMap.h +++ b/include/clang/Serialization/ContinuousRangeMap.h @@ -68,6 +68,16 @@ public: "Must insert keys in order."); Rep.push_back(Val); } + + void insertOrReplace(const value_type &Val) { + iterator I = std::lower_bound(Rep.begin(), Rep.end(), Val, Compare()); + if (I != Rep.end() && I->first == Val.first) { + I->second = Val.second; + return; + } + + Rep.insert(I, Val); + } typedef typename Representation::iterator iterator; typedef typename Representation::const_iterator const_iterator; diff --git a/include/clang/Serialization/Module.h b/include/clang/Serialization/Module.h index 42b5a58e085f6..4c93c33842cf9 100644 --- a/include/clang/Serialization/Module.h +++ b/include/clang/Serialization/Module.h @@ -23,12 +23,13 @@ #include "llvm/Bitcode/BitstreamReader.h" #include <string> -namespace clang { +namespace clang { class DeclContext; +class Module; namespace serialization { - + /// \brief Specifies the kind of module that has been loaded. enum ModuleKind { MK_Module, ///< File is a module proper. @@ -39,9 +40,9 @@ enum ModuleKind { /// \brief Information about the contents of a DeclContext. struct DeclContextInfo { - DeclContextInfo() + DeclContextInfo() : NameLookupTableData(), LexicalDecls(), NumLexicalDecls() {} - + void *NameLookupTableData; // an ASTDeclContextNameLookupTable. const KindDeclIDPair *LexicalDecls; unsigned NumLexicalDecls; @@ -49,265 +50,303 @@ struct DeclContextInfo { /// \brief Information about a module that has been loaded by the ASTReader. /// -/// Each instance of the Module class corresponds to a single AST file, which -/// may be a precompiled header, precompiled preamble, a module, or an AST file -/// of some sort loaded as the main file, all of which are specific formulations of -/// the general notion of a "module". A module may depend on any number of +/// Each instance of the Module class corresponds to a single AST file, which +/// may be a precompiled header, precompiled preamble, a module, or an AST file +/// of some sort loaded as the main file, all of which are specific formulations +/// of the general notion of a "module". A module may depend on any number of /// other modules. -class Module { -public: - Module(ModuleKind Kind); - ~Module(); - +class ModuleFile { +public: + ModuleFile(ModuleKind Kind, unsigned Generation); + ~ModuleFile(); + // === General information === - + /// \brief The type of this module. ModuleKind Kind; - + /// \brief The file name of the module file. std::string FileName; - + /// \brief Whether this module has been directly imported by the /// user. bool DirectlyImported; + + /// \brief The generation of which this module file is a part. + unsigned Generation; /// \brief The memory buffer that stores the data associated with /// this AST file. - llvm::OwningPtr<llvm::MemoryBuffer> Buffer; - + OwningPtr<llvm::MemoryBuffer> Buffer; + /// \brief The size of this file, in bits. uint64_t SizeInBits; - + /// \brief The global bit offset (or base) of this module uint64_t GlobalBitOffset; - + /// \brief The bitstream reader from which we'll read the AST file. llvm::BitstreamReader StreamFile; - + /// \brief The main bitstream cursor for the main block. llvm::BitstreamCursor Stream; - + /// \brief The source location where this module was first imported. SourceLocation ImportLoc; - + /// \brief The first source location in this module. SourceLocation FirstLoc; - + // === Source Locations === - + /// \brief Cursor used to read source location entries. llvm::BitstreamCursor SLocEntryCursor; - + /// \brief The number of source location entries in this AST file. unsigned LocalNumSLocEntries; - + /// \brief The base ID in the source manager's view of this module. int SLocEntryBaseID; - + /// \brief The base offset in the source manager's view of this module. unsigned SLocEntryBaseOffset; - + /// \brief Offsets for all of the source location entries in the /// AST file. const uint32_t *SLocEntryOffsets; - + /// \brief SLocEntries that we're going to preload. SmallVector<uint64_t, 4> PreloadSLocEntries; /// \brief The number of source location file entries in this AST file. unsigned LocalNumSLocFileEntries; - + /// \brief Offsets for all of the source location file entries in the /// AST file. const uint32_t *SLocFileOffsets; - + /// \brief Remapping table for source locations in this module. ContinuousRangeMap<uint32_t, int, 2> SLocRemap; - + // === Identifiers === - + /// \brief The number of identifiers in this AST file. unsigned LocalNumIdentifiers; - + /// \brief Offsets into the identifier table data. /// /// This array is indexed by the identifier ID (-1), and provides /// the offset into IdentifierTableData where the string data is /// stored. const uint32_t *IdentifierOffsets; - + /// \brief Base identifier ID for identifiers local to this module. serialization::IdentID BaseIdentifierID; - + /// \brief Remapping table for identifier IDs in this module. ContinuousRangeMap<uint32_t, int, 2> IdentifierRemap; - + /// \brief Actual data for the on-disk hash table of identifiers. /// /// This pointer points into a memory buffer, where the on-disk hash /// table for identifiers actually lives. const char *IdentifierTableData; - + /// \brief A pointer to an on-disk hash table of opaque type /// IdentifierHashTable. void *IdentifierLookupTable; - + // === Macros === - + /// \brief The cursor to the start of the preprocessor block, which stores /// all of the macro definitions. llvm::BitstreamCursor MacroCursor; - + /// \brief The offset of the start of the set of defined macros. uint64_t MacroStartOffset; - + // === Detailed PreprocessingRecord === - - /// \brief The cursor to the start of the (optional) detailed preprocessing + + /// \brief The cursor to the start of the (optional) detailed preprocessing /// record block. llvm::BitstreamCursor PreprocessorDetailCursor; - + /// \brief The offset of the start of the preprocessor detail cursor. uint64_t PreprocessorDetailStartOffset; - - /// \brief Base preprocessed entity ID for preprocessed entities local to + + /// \brief Base preprocessed entity ID for preprocessed entities local to /// this module. serialization::PreprocessedEntityID BasePreprocessedEntityID; - + /// \brief Remapping table for preprocessed entity IDs in this module. ContinuousRangeMap<uint32_t, int, 2> PreprocessedEntityRemap; - + const PPEntityOffset *PreprocessedEntityOffsets; unsigned NumPreprocessedEntities; - + // === Header search information === - + /// \brief The number of local HeaderFileInfo structures. unsigned LocalNumHeaderFileInfos; - - /// \brief Actual data for the on-disk hash table of header file + + /// \brief Actual data for the on-disk hash table of header file /// information. /// /// This pointer points into a memory buffer, where the on-disk hash /// table for header file information actually lives. const char *HeaderFileInfoTableData; - + /// \brief The on-disk hash table that contains information about each of /// the header files. void *HeaderFileInfoTable; - + /// \brief Actual data for the list of framework names used in the header /// search information. const char *HeaderFileFrameworkStrings; + + // === Submodule information === + /// \brief The number of submodules in this module. + unsigned LocalNumSubmodules; - // === Selectors === + /// \brief Base submodule ID for submodules local to this module. + serialization::SubmoduleID BaseSubmoduleID; + /// \brief Remapping table for submodule IDs in this module. + ContinuousRangeMap<uint32_t, int, 2> SubmoduleRemap; + + // === Selectors === + /// \brief The number of selectors new to this file. /// /// This is the number of entries in SelectorOffsets. unsigned LocalNumSelectors; - + /// \brief Offsets into the selector lookup table's data array /// where each selector resides. const uint32_t *SelectorOffsets; - + /// \brief Base selector ID for selectors local to this module. serialization::SelectorID BaseSelectorID; - + /// \brief Remapping table for selector IDs in this module. ContinuousRangeMap<uint32_t, int, 2> SelectorRemap; - + /// \brief A pointer to the character data that comprises the selector table /// /// The SelectorOffsets table refers into this memory. const unsigned char *SelectorLookupTableData; - + /// \brief A pointer to an on-disk hash table of opaque type /// ASTSelectorLookupTable. /// /// This hash table provides the IDs of all selectors, and the associated /// instance and factory methods. void *SelectorLookupTable; - + // === Declarations === - + /// DeclsCursor - This is a cursor to the start of the DECLS_BLOCK block. It /// has read all the abbreviations at the start of the block and is ready to /// jump around with these in context. llvm::BitstreamCursor DeclsCursor; - + /// \brief The number of declarations in this AST file. unsigned LocalNumDecls; - + /// \brief Offset of each declaration within the bitstream, indexed /// by the declaration ID (-1). - const uint32_t *DeclOffsets; - + const DeclOffset *DeclOffsets; + /// \brief Base declaration ID for declarations local to this module. serialization::DeclID BaseDeclID; - + /// \brief Remapping table for declaration IDs in this module. ContinuousRangeMap<uint32_t, int, 2> DeclRemap; - + + /// \brief Mapping from the module files that this module file depends on + /// to the base declaration ID for that module as it is understood within this + /// module. + /// + /// This is effectively a reverse global-to-local mapping for declaration + /// IDs, so that we can interpret a true global ID (for this translation unit) + /// as a local ID (for this module file). + llvm::DenseMap<ModuleFile *, serialization::DeclID> GlobalToLocalDeclIDs; + /// \brief The number of C++ base specifier sets in this AST file. unsigned LocalNumCXXBaseSpecifiers; - + /// \brief Offset of each C++ base specifier set within the bitstream, /// indexed by the C++ base specifier set ID (-1). const uint32_t *CXXBaseSpecifiersOffsets; - + typedef llvm::DenseMap<const DeclContext *, DeclContextInfo> DeclContextInfosMap; - + /// \brief Information about the lexical and visible declarations /// for each DeclContext. DeclContextInfosMap DeclContextInfos; - typedef llvm::DenseMap<serialization::GlobalDeclID, - std::pair<serialization::LocalDeclID, serialization::LocalDeclID> > - ChainedObjCCategoriesMap; - /// \brief ObjC categories that got chained to an interface from another - /// module. - /// Key is the ID of the interface. - /// Value is a pair of linked category DeclIDs (head category, tail category). - ChainedObjCCategoriesMap ChainedObjCCategories; + /// \brief Array of file-level DeclIDs sorted by file. + const serialization::DeclID *FileSortedDecls; + + /// \brief Array of redeclaration chain location information within this + /// module file, sorted by the first declaration ID. + const serialization::LocalRedeclarationsInfo *RedeclarationsMap; + + /// \brief The number of redeclaration info entries in RedeclarationsMap. + unsigned LocalNumRedeclarationsInMap; - // === Types === + /// \brief The redeclaration chains for declarations local to this + /// module file. + SmallVector<uint64_t, 1> RedeclarationChains; + + /// \brief Array of category list location information within this + /// module file, sorted by the definition ID. + const serialization::ObjCCategoriesInfo *ObjCCategoriesMap; + /// \brief The number of redeclaration info entries in ObjCCategoriesMap. + unsigned LocalNumObjCCategoriesInMap; + + /// \brief The Objective-C category lists for categories known to this + /// module. + SmallVector<uint64_t, 1> ObjCCategories; + + // === Types === + /// \brief The number of types in this AST file. unsigned LocalNumTypes; - + /// \brief Offset of each type within the bitstream, indexed by the /// type ID, or the representation of a Type*. const uint32_t *TypeOffsets; - - /// \brief Base type ID for types local to this module as represented in + + /// \brief Base type ID for types local to this module as represented in /// the global type ID space. serialization::TypeID BaseTypeIndex; - + /// \brief Remapping table for type IDs in this module. ContinuousRangeMap<uint32_t, int, 2> TypeRemap; - + // === Miscellaneous === - + /// \brief Diagnostic IDs and their mappings that the user changed. SmallVector<uint64_t, 8> PragmaDiagMappings; - + /// \brief The AST stat cache installed for this file, if any. /// /// The dynamic type of this stat cache is always ASTStatCache void *StatCache; - + /// \brief List of modules which depend on this module - llvm::SetVector<Module *> ImportedBy; - + llvm::SetVector<ModuleFile *> ImportedBy; + /// \brief List of modules which this module depends on - llvm::SetVector<Module *> Imports; - + llvm::SetVector<ModuleFile *> Imports; + /// \brief Determine whether this module was directly imported at /// any point during translation. bool isDirectlyImported() const { return DirectlyImported; } - + /// \brief Dump debugging output for this module. void dump(); }; diff --git a/include/clang/Serialization/ModuleManager.h b/include/clang/Serialization/ModuleManager.h index f86915a79cd00..6ff0640b64d11 100644 --- a/include/clang/Serialization/ModuleManager.h +++ b/include/clang/Serialization/ModuleManager.h @@ -27,10 +27,10 @@ namespace serialization { class ModuleManager { /// \brief The chain of AST files. The first entry is the one named by the /// user, the last one is the one that doesn't depend on anything further. - llvm::SmallVector<Module*, 2> Chain; + llvm::SmallVector<ModuleFile*, 2> Chain; /// \brief All loaded modules, indexed by name. - llvm::DenseMap<const FileEntry *, Module *> Modules; + llvm::DenseMap<const FileEntry *, ModuleFile *> Modules; /// \brief FileManager that handles translating between filenames and /// FileEntry *. @@ -40,9 +40,9 @@ class ModuleManager { llvm::DenseMap<const FileEntry *, llvm::MemoryBuffer *> InMemoryBuffers; public: - typedef SmallVector<Module*, 2>::iterator ModuleIterator; - typedef SmallVector<Module*, 2>::const_iterator ModuleConstIterator; - typedef SmallVector<Module*, 2>::reverse_iterator ModuleReverseIterator; + typedef SmallVector<ModuleFile*, 2>::iterator ModuleIterator; + typedef SmallVector<ModuleFile*, 2>::const_iterator ModuleConstIterator; + typedef SmallVector<ModuleFile*, 2>::reverse_iterator ModuleReverseIterator; typedef std::pair<uint32_t, StringRef> ModuleOffset; ModuleManager(const FileSystemOptions &FSO); @@ -68,17 +68,17 @@ public: /// \brief Returns the primary module associated with the manager, that is, /// the first module loaded - Module &getPrimaryModule() { return *Chain[0]; } + ModuleFile &getPrimaryModule() { return *Chain[0]; } /// \brief Returns the primary module associated with the manager, that is, /// the first module loaded. - Module &getPrimaryModule() const { return *Chain[0]; } + ModuleFile &getPrimaryModule() const { return *Chain[0]; } /// \brief Returns the module associated with the given index - Module &operator[](unsigned Index) const { return *Chain[Index]; } + ModuleFile &operator[](unsigned Index) const { return *Chain[Index]; } /// \brief Returns the module associated with the given name - Module *lookup(StringRef Name); + ModuleFile *lookup(StringRef Name); /// \brief Returns the in-memory (virtual file) buffer with the given name llvm::MemoryBuffer *lookupBuffer(StringRef Name); @@ -95,14 +95,16 @@ public: /// \param ImportedBy The module that is importing this module, or NULL if /// this module is imported directly by the user. /// + /// \param Generation The generation in which this module was loaded. + /// /// \param ErrorStr Will be set to a non-empty string if any errors occurred /// while trying to load the module. /// /// \return A pointer to the module that corresponds to this file name, /// and a boolean indicating whether the module was newly added. - std::pair<Module *, bool> - addModule(StringRef FileName, ModuleKind Type, Module *ImportedBy, - std::string &ErrorStr); + std::pair<ModuleFile *, bool> + addModule(StringRef FileName, ModuleKind Type, ModuleFile *ImportedBy, + unsigned Generation, std::string &ErrorStr); /// \brief Add an in-memory buffer the list of known buffers void addInMemoryBuffer(StringRef FileName, llvm::MemoryBuffer *Buffer); @@ -125,7 +127,7 @@ public: /// /// \param UserData User data associated with the visitor object, which /// will be passed along to the visitor. - void visit(bool (*Visitor)(Module &M, void *UserData), void *UserData); + void visit(bool (*Visitor)(ModuleFile &M, void *UserData), void *UserData); /// \brief Visit each of the modules with a depth-first traversal. /// @@ -143,7 +145,7 @@ public: /// /// \param UserData User data ssociated with the visitor object, /// which will be passed along to the user. - void visitDepthFirst(bool (*Visitor)(Module &M, bool Preorder, + void visitDepthFirst(bool (*Visitor)(ModuleFile &M, bool Preorder, void *UserData), void *UserData); diff --git a/include/clang/Serialization/SerializationDiagnostic.h b/include/clang/Serialization/SerializationDiagnostic.h new file mode 100644 index 0000000000000..e63f814ee6a05 --- /dev/null +++ b/include/clang/Serialization/SerializationDiagnostic.h @@ -0,0 +1,28 @@ +//===--- SerializationDiagnostic.h - Serialization Diagnostics -*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_SERIALIZATIONDIAGNOSTIC_H +#define LLVM_CLANG_SERIALIZATIONDIAGNOSTIC_H + +#include "clang/Basic/Diagnostic.h" + +namespace clang { + namespace diag { + enum { +#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,\ + SFINAE,ACCESS,NOWERROR,SHOWINSYSHEADER,CATEGORY) ENUM, +#define SERIALIZATIONSTART +#include "clang/Basic/DiagnosticSerializationKinds.inc" +#undef DIAG + NUM_BUILTIN_SERIALIZATION_DIAGNOSTICS + }; + } // end namespace diag +} // end namespace clang + +#endif |