diff options
Diffstat (limited to 'include/clang/Serialization')
-rw-r--r-- | include/clang/Serialization/ASTBitCodes.h | 1605 | ||||
-rw-r--r-- | include/clang/Serialization/ASTDeserializationListener.h | 58 | ||||
-rw-r--r-- | include/clang/Serialization/ASTReader.h | 2141 | ||||
-rw-r--r-- | include/clang/Serialization/ASTWriter.h | 920 | ||||
-rw-r--r-- | include/clang/Serialization/CMakeLists.txt | 9 | ||||
-rw-r--r-- | include/clang/Serialization/ContinuousRangeMap.h | 139 | ||||
-rw-r--r-- | include/clang/Serialization/GlobalModuleIndex.h | 207 | ||||
-rw-r--r-- | include/clang/Serialization/Makefile | 19 | ||||
-rw-r--r-- | include/clang/Serialization/Module.h | 475 | ||||
-rw-r--r-- | include/clang/Serialization/ModuleFileExtension.h | 149 | ||||
-rw-r--r-- | include/clang/Serialization/ModuleManager.h | 289 | ||||
-rw-r--r-- | include/clang/Serialization/SerializationDiagnostic.h | 28 |
12 files changed, 0 insertions, 6039 deletions
diff --git a/include/clang/Serialization/ASTBitCodes.h b/include/clang/Serialization/ASTBitCodes.h deleted file mode 100644 index 16bda6e..0000000 --- a/include/clang/Serialization/ASTBitCodes.h +++ /dev/null @@ -1,1605 +0,0 @@ -//===- ASTBitCodes.h - Enum values for the PCH bitcode format ---*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This header defines Bitcode enum values for Clang serialized AST files. -// -// The enum values defined in this file should be considered permanent. If -// new features are added, they should have values added at the end of the -// respective lists. -// -//===----------------------------------------------------------------------===// -#ifndef LLVM_CLANG_SERIALIZATION_ASTBITCODES_H -#define LLVM_CLANG_SERIALIZATION_ASTBITCODES_H - -#include "clang/AST/DeclarationName.h" -#include "clang/AST/Type.h" -#include "llvm/ADT/DenseMap.h" -#include "llvm/Bitcode/BitCodes.h" -#include "llvm/Support/DataTypes.h" - -namespace clang { - namespace serialization { - /// \brief AST file major version number supported by this version of - /// Clang. - /// - /// Whenever the AST file format changes in a way that makes it - /// incompatible with previous versions (such that a reader - /// designed for the previous version could not support reading - /// the new version), this number should be increased. - /// - /// Version 4 of AST files also requires that the version control branch and - /// revision match exactly, since there is no backward compatibility of - /// AST files at this time. - const unsigned VERSION_MAJOR = 6; - - /// \brief AST file minor version number supported by this version of - /// Clang. - /// - /// Whenever the AST format changes in a way that is still - /// compatible with previous versions (such that a reader designed - /// for the previous version could still support reading the new - /// version by ignoring new kinds of subblocks), this number - /// should be increased. - const unsigned VERSION_MINOR = 0; - - /// \brief An ID number that refers to an identifier in an AST file. - /// - /// The ID numbers of identifiers are consecutive (in order of discovery) - /// and start at 1. 0 is reserved for NULL. - typedef uint32_t IdentifierID; - - /// \brief An ID number that refers to a declaration in an AST file. - /// - /// The ID numbers of declarations are consecutive (in order of - /// discovery), with values below NUM_PREDEF_DECL_IDS being reserved. - /// At the start of a chain of precompiled headers, declaration ID 1 is - /// used for the translation unit declaration. - typedef uint32_t DeclID; - - // FIXME: Turn these into classes so we can have some type safety when - // we go from local ID to global and vice-versa. - typedef DeclID LocalDeclID; - typedef DeclID GlobalDeclID; - - /// \brief An ID number that refers to a type in an AST file. - /// - /// The ID of a type is partitioned into two parts: the lower - /// three bits are used to store the const/volatile/restrict - /// qualifiers (as with QualType) and the upper bits provide a - /// type index. The type index values are partitioned into two - /// sets. The values below NUM_PREDEF_TYPE_IDs are predefined type - /// IDs (based on the PREDEF_TYPE_*_ID constants), with 0 as a - /// placeholder for "no type". Values from NUM_PREDEF_TYPE_IDs are - /// other types that have serialized representations. - typedef uint32_t TypeID; - - /// \brief A type index; the type ID with the qualifier bits removed. - class TypeIdx { - uint32_t Idx; - public: - TypeIdx() : Idx(0) { } - explicit TypeIdx(uint32_t index) : Idx(index) { } - - uint32_t getIndex() const { return Idx; } - TypeID asTypeID(unsigned FastQuals) const { - if (Idx == uint32_t(-1)) - return TypeID(-1); - - return (Idx << Qualifiers::FastWidth) | FastQuals; - } - static TypeIdx fromTypeID(TypeID ID) { - if (ID == TypeID(-1)) - return TypeIdx(-1); - - return TypeIdx(ID >> Qualifiers::FastWidth); - } - }; - - /// A structure for putting "fast"-unqualified QualTypes into a - /// DenseMap. This uses the standard pointer hash function. - struct UnsafeQualTypeDenseMapInfo { - static inline bool isEqual(QualType A, QualType B) { return A == B; } - static inline QualType getEmptyKey() { - return QualType::getFromOpaquePtr((void*) 1); - } - static inline QualType getTombstoneKey() { - return QualType::getFromOpaquePtr((void*) 2); - } - static inline unsigned getHashValue(QualType T) { - assert(!T.getLocalFastQualifiers() && - "hash invalid for types with fast quals"); - uintptr_t v = reinterpret_cast<uintptr_t>(T.getAsOpaquePtr()); - return (unsigned(v) >> 4) ^ (unsigned(v) >> 9); - } - }; - - /// \brief An ID number that refers to an identifier in an AST file. - typedef uint32_t IdentID; - - /// \brief The number of predefined identifier IDs. - const unsigned int NUM_PREDEF_IDENT_IDS = 1; - - /// \brief An ID number that refers to a macro in an AST file. - typedef uint32_t MacroID; - - /// \brief A global ID number that refers to a macro in an AST file. - typedef uint32_t GlobalMacroID; - - /// \brief A local to a module ID number that refers to a macro in an - /// AST file. - typedef uint32_t LocalMacroID; - - /// \brief The number of predefined macro IDs. - const unsigned int NUM_PREDEF_MACRO_IDS = 1; - - /// \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. - const unsigned int NUM_PREDEF_SELECTOR_IDS = 1; - - /// \brief An ID number that refers to a set of CXXBaseSpecifiers in an - /// AST file. - typedef uint32_t CXXBaseSpecifiersID; - - /// \brief An ID number that refers to a list of CXXCtorInitializers in an - /// AST file. - typedef uint32_t CXXCtorInitializersID; - - /// \brief An ID number that refers to an entity in the detailed - /// 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. - unsigned Begin; - /// \brief Raw source location of end of range. - unsigned End; - /// \brief Offset in the AST file. - uint32_t BitOffset; - - PPEntityOffset(SourceRange R, uint32_t BitOffset) - : Begin(R.getBegin().getRawEncoding()), - End(R.getEnd().getRawEncoding()), - 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; - - /// \brief Describes the various kinds of blocks that occur within - /// an AST file. - enum BlockIDs { - /// \brief The AST block, which acts as a container around the - /// full AST block. - AST_BLOCK_ID = llvm::bitc::FIRST_APPLICATION_BLOCKID, - - /// \brief The block containing information about the source - /// manager. - SOURCE_MANAGER_BLOCK_ID, - - /// \brief The block containing information about the - /// preprocessor. - PREPROCESSOR_BLOCK_ID, - - /// \brief The block containing the definitions of all of the - /// types and decls used within the AST file. - DECLTYPES_BLOCK_ID, - - /// \brief The block containing the detailed preprocessing record. - PREPROCESSOR_DETAIL_BLOCK_ID, - - /// \brief The block containing the submodule structure. - SUBMODULE_BLOCK_ID, - - /// \brief The block containing comments. - COMMENTS_BLOCK_ID, - - /// \brief The control block, which contains all of the - /// information that needs to be validated prior to committing - /// to loading the AST file. - CONTROL_BLOCK_ID, - - /// \brief The block of input files, which were used as inputs - /// to create this AST file. - /// - /// This block is part of the control block. - INPUT_FILES_BLOCK_ID, - - /// \brief The block of configuration options, used to check that - /// a module is being used in a configuration compatible with the - /// configuration in which it was built. - /// - /// This block is part of the control block. - OPTIONS_BLOCK_ID, - - /// \brief A block containing a module file extension. - EXTENSION_BLOCK_ID, - }; - - /// \brief Record types that occur within the control block. - enum ControlRecordTypes { - /// \brief AST file metadata, including the AST file version number - /// and information about the compiler used to build this AST file. - METADATA = 1, - - /// \brief Record code for the list of other AST files imported by - /// this AST file. - IMPORTS, - - /// \brief Record code for the original file that was used to - /// generate the AST file, including both its file ID and its - /// name. - ORIGINAL_FILE, - - /// \brief The directory that the PCH was originally created in. - ORIGINAL_PCH_DIR, - - /// \brief Record code for file ID of the file or buffer that was used to - /// generate the AST file. - ORIGINAL_FILE_ID, - - /// \brief Offsets into the input-files block where input files - /// reside. - INPUT_FILE_OFFSETS, - - /// \brief Record code for the module name. - MODULE_NAME, - - /// \brief Record code for the module map file that was used to build this - /// AST file. - MODULE_MAP_FILE, - - /// \brief Record code for the signature that identifiers this AST file. - SIGNATURE, - - /// \brief Record code for the module build directory. - MODULE_DIRECTORY, - }; - - /// \brief Record types that occur within the options block inside - /// the control block. - enum OptionsRecordTypes { - /// \brief Record code for the language options table. - /// - /// The record with this code contains the contents of the - /// LangOptions structure. We serialize the entire contents of - /// the structure, and let the reader decide which options are - /// actually important to check. - LANGUAGE_OPTIONS = 1, - - /// \brief Record code for the target options table. - TARGET_OPTIONS, - - /// \brief Record code for the diagnostic options table. - DIAGNOSTIC_OPTIONS, - - /// \brief Record code for the filesystem options table. - FILE_SYSTEM_OPTIONS, - - /// \brief Record code for the headers search options table. - HEADER_SEARCH_OPTIONS, - - /// \brief Record code for the preprocessor options table. - PREPROCESSOR_OPTIONS, - }; - - /// \brief Record code for extension blocks. - enum ExtensionBlockRecordTypes { - /// Metadata describing this particular extension. - EXTENSION_METADATA = 1, - - /// The first record ID allocated to the extensions themselves. - FIRST_EXTENSION_RECORD_ID = 4 - }; - - /// \brief Record types that occur within the input-files block - /// inside the control block. - enum InputFileRecordTypes { - /// \brief An input file. - INPUT_FILE = 1 - }; - - /// \brief Record types that occur within the AST block itself. - enum ASTRecordTypes { - /// \brief Record code for the offsets of each type. - /// - /// The TYPE_OFFSET constant describes the record that occurs - /// within the AST block. The record itself is an array of offsets that - /// point into the declarations and types block (identified by - /// DECLTYPES_BLOCK_ID). The index into the array is based on the ID - /// of a type. For a given type ID @c T, the lower three bits of - /// @c T are its qualifiers (const, volatile, restrict), as in - /// the QualType class. The upper bits, after being shifted and - /// subtracting NUM_PREDEF_TYPE_IDS, are used to index into the - /// TYPE_OFFSET block to determine the offset of that type's - /// corresponding record within the DECLTYPES_BLOCK_ID block. - TYPE_OFFSET = 1, - - /// \brief Record code for the offsets of each decl. - /// - /// The DECL_OFFSET constant describes the record that occurs - /// within the block identified by DECL_OFFSETS_BLOCK_ID within - /// the AST block. The record itself is an array of offsets that - /// point into the declarations and types block (identified by - /// DECLTYPES_BLOCK_ID). The declaration ID is an index into this - /// record, after subtracting one to account for the use of - /// declaration ID 0 for a NULL declaration pointer. Index 0 is - /// reserved for the translation unit declaration. - DECL_OFFSET = 2, - - /// \brief Record code for the table of offsets of each - /// identifier ID. - /// - /// The offset table contains offsets into the blob stored in - /// the IDENTIFIER_TABLE record. Each offset points to the - /// NULL-terminated string that corresponds to that identifier. - IDENTIFIER_OFFSET = 3, - - /// \brief This is so that older clang versions, before the introduction - /// of the control block, can read and reject the newer PCH format. - /// *DON'T CHANGE THIS NUMBER*. - METADATA_OLD_FORMAT = 4, - - /// \brief Record code for the identifier table. - /// - /// The identifier table is a simple blob that contains - /// NULL-terminated strings for all of the identifiers - /// referenced by the AST file. The IDENTIFIER_OFFSET table - /// contains the mapping from identifier IDs to the characters - /// in this blob. Note that the starting offsets of all of the - /// identifiers are odd, so that, when the identifier offset - /// table is loaded in, we can use the low bit to distinguish - /// between offsets (for unresolved identifier IDs) and - /// IdentifierInfo pointers (for already-resolved identifier - /// IDs). - IDENTIFIER_TABLE = 5, - - /// \brief Record code for the array of eagerly deserialized decls. - /// - /// The AST file contains a list of all of the declarations that should be - /// eagerly deserialized present within the parsed headers, stored as an - /// array of declaration IDs. These declarations will be - /// reported to the AST consumer after the AST file has been - /// read, since their presence can affect the semantics of the - /// program (e.g., for code generation). - EAGERLY_DESERIALIZED_DECLS = 6, - - /// \brief Record code for the set of non-builtin, special - /// types. - /// - /// This record contains the type IDs for the various type nodes - /// that are constructed during semantic analysis (e.g., - /// __builtin_va_list). The SPECIAL_TYPE_* constants provide - /// offsets into this record. - SPECIAL_TYPES = 7, - - /// \brief Record code for the extra statistics we gather while - /// generating an AST file. - STATISTICS = 8, - - /// \brief Record code for the array of tentative definitions. - TENTATIVE_DEFINITIONS = 9, - - // ID 10 used to be for a list of extern "C" declarations. - - /// \brief Record code for the table of offsets into the - /// Objective-C method pool. - SELECTOR_OFFSETS = 11, - - /// \brief Record code for the Objective-C method pool, - METHOD_POOL = 12, - - /// \brief The value of the next __COUNTER__ to dispense. - /// [PP_COUNTER_VALUE, Val] - PP_COUNTER_VALUE = 13, - - /// \brief Record code for the table of offsets into the block - /// of source-location information. - SOURCE_LOCATION_OFFSETS = 14, - - /// \brief Record code for the set of source location entries - /// that need to be preloaded by the AST reader. - /// - /// This set contains the source location entry for the - /// predefines buffer and for any file entries that need to be - /// preloaded. - SOURCE_LOCATION_PRELOADS = 15, - - /// \brief Record code for the set of ext_vector type names. - EXT_VECTOR_DECLS = 16, - - /// \brief Record code for the array of unused file scoped decls. - UNUSED_FILESCOPED_DECLS = 17, - - /// \brief Record code for the table of offsets to entries in the - /// preprocessing record. - PPD_ENTITIES_OFFSETS = 18, - - /// \brief Record code for the array of VTable uses. - VTABLE_USES = 19, - - // ID 20 used to be for a list of dynamic classes. - - /// \brief Record code for referenced selector pool. - REFERENCED_SELECTOR_POOL = 21, - - /// \brief Record code for an update to the TU's lexically contained - /// declarations. - TU_UPDATE_LEXICAL = 22, - - // ID 23 used to be for a list of local redeclarations. - - /// \brief Record code for declarations that Sema keeps references of. - SEMA_DECL_REFS = 24, - - /// \brief Record code for weak undeclared identifiers. - WEAK_UNDECLARED_IDENTIFIERS = 25, - - /// \brief Record code for pending implicit instantiations. - PENDING_IMPLICIT_INSTANTIATIONS = 26, - - /// \brief Record code for a decl replacement block. - /// - /// If a declaration is modified after having been deserialized, and then - /// written to a dependent AST file, its ID and offset must be added to - /// the replacement block. - DECL_REPLACEMENTS = 27, - - /// \brief Record code for an update to a decl context's lookup table. - /// - /// In practice, this should only be used for the TU and namespaces. - UPDATE_VISIBLE = 28, - - /// \brief Record for offsets of DECL_UPDATES records for declarations - /// that were modified after being deserialized and need updates. - DECL_UPDATE_OFFSETS = 29, - - /// \brief Record of updates for a declaration that was modified after - /// being deserialized. - DECL_UPDATES = 30, - - /// \brief Record code for the table of offsets to CXXBaseSpecifier - /// sets. - CXX_BASE_SPECIFIER_OFFSETS = 31, - - /// \brief Record code for \#pragma diagnostic mappings. - DIAG_PRAGMA_MAPPINGS = 32, - - /// \brief Record code for special CUDA declarations. - CUDA_SPECIAL_DECL_REFS = 33, - - /// \brief Record code for header search information. - HEADER_SEARCH_TABLE = 34, - - /// \brief Record code for floating point \#pragma options. - FP_PRAGMA_OPTIONS = 35, - - /// \brief Record code for enabled OpenCL extensions. - OPENCL_EXTENSIONS = 36, - - /// \brief The list of delegating constructor declarations. - DELEGATING_CTORS = 37, - - /// \brief Record code for the set of known namespaces, which are used - /// for typo correction. - KNOWN_NAMESPACES = 38, - - /// \brief Record code for the remapping information used to relate - /// loaded modules to the various offsets and IDs(e.g., source location - /// offests, declaration and type IDs) that are used in that module to - /// refer to other modules. - MODULE_OFFSET_MAP = 39, - - /// \brief Record code for the source manager line table information, - /// which stores information about \#line directives. - SOURCE_MANAGER_LINE_TABLE = 40, - - /// \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 = 41, - - /// \brief Record code for a file sorted array of DeclIDs in a module. - FILE_SORTED_DECLS = 42, - - /// \brief Record code for an array of all of the (sub)modules that were - /// imported by the AST file. - IMPORTED_MODULES = 43, - - // ID 44 used to be a table of merged canonical declarations. - // ID 45 used to be a list of declaration IDs of local redeclarations. - - /// \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 = 46, - - /// \brief Record code for the table of offsets of each macro ID. - /// - /// The offset table contains offsets into the blob stored in - /// the preprocessor block. Each offset points to the corresponding - /// macro definition. - MACRO_OFFSET = 47, - - /// \brief A list of "interesting" identifiers. Only used in C++ (where we - /// don't normally do lookups into the serialized identifier table). These - /// are eagerly deserialized. - INTERESTING_IDENTIFIERS = 48, - - /// \brief Record code for undefined but used functions and variables that - /// need a definition in this TU. - UNDEFINED_BUT_USED = 49, - - /// \brief Record code for late parsed template functions. - LATE_PARSED_TEMPLATE = 50, - - /// \brief Record code for \#pragma optimize options. - OPTIMIZE_PRAGMA_OPTIONS = 51, - - /// \brief Record code for potentially unused local typedef names. - UNUSED_LOCAL_TYPEDEF_NAME_CANDIDATES = 52, - - /// \brief Record code for the table of offsets to CXXCtorInitializers - /// lists. - CXX_CTOR_INITIALIZERS_OFFSETS = 53, - - /// \brief Delete expressions that will be analyzed later. - DELETE_EXPRS_TO_ANALYZE = 54 - }; - - /// \brief Record types used within a source manager block. - enum SourceManagerRecordTypes { - /// \brief Describes a source location entry (SLocEntry) for a - /// file. - SM_SLOC_FILE_ENTRY = 1, - /// \brief Describes a source location entry (SLocEntry) for a - /// buffer. - 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 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. - SM_SLOC_EXPANSION_ENTRY = 4 - }; - - /// \brief Record types used within a preprocessor block. - enum PreprocessorRecordTypes { - // The macros in the PP section are a PP_MACRO_* instance followed by a - // list of PP_TOKEN instances for each token in the definition. - - /// \brief An object-like macro definition. - /// [PP_MACRO_OBJECT_LIKE, IdentInfoID, SLoc, IsUsed] - PP_MACRO_OBJECT_LIKE = 1, - - /// \brief A function-like macro definition. - /// [PP_MACRO_FUNCTION_LIKE, \<ObjectLikeStuff>, IsC99Varargs, - /// IsGNUVarars, NumArgs, ArgIdentInfoID* ] - PP_MACRO_FUNCTION_LIKE = 2, - - /// \brief Describes one token. - /// [PP_TOKEN, SLoc, Length, IdentInfoID, Kind, Flags] - PP_TOKEN = 3, - - /// \brief The macro directives history for a particular identifier. - PP_MACRO_DIRECTIVE_HISTORY = 4, - - /// \brief A macro directive exported by a module. - /// [PP_MODULE_MACRO, SubmoduleID, MacroID, (Overridden SubmoduleID)*] - PP_MODULE_MACRO = 5, - }; - - /// \brief Record types used within a preprocessor detail block. - enum PreprocessorDetailRecordTypes { - /// \brief Describes a macro expansion within the preprocessing record. - PPD_MACRO_EXPANSION = 0, - - /// \brief Describes a macro definition within the preprocessing record. - PPD_MACRO_DEFINITION = 1, - - /// \brief Describes an inclusion directive within the preprocessing - /// record. - 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 a top-level header that falls into this (sub)module. - SUBMODULE_TOPHEADER = 4, - /// \brief Specifies an umbrella directory. - SUBMODULE_UMBRELLA_DIR = 5, - /// \brief Specifies the submodules that are imported by this - /// submodule. - SUBMODULE_IMPORTS = 6, - /// \brief Specifies the submodules that are re-exported from this - /// submodule. - SUBMODULE_EXPORTS = 7, - /// \brief Specifies a required feature. - SUBMODULE_REQUIRES = 8, - /// \brief Specifies a header that has been explicitly excluded - /// from this submodule. - SUBMODULE_EXCLUDED_HEADER = 9, - /// \brief Specifies a library or framework to link against. - SUBMODULE_LINK_LIBRARY = 10, - /// \brief Specifies a configuration macro for this module. - SUBMODULE_CONFIG_MACRO = 11, - /// \brief Specifies a conflict with another module. - SUBMODULE_CONFLICT = 12, - /// \brief Specifies a header that is private to this submodule. - SUBMODULE_PRIVATE_HEADER = 13, - /// \brief Specifies a header that is part of the module but must be - /// textually included. - SUBMODULE_TEXTUAL_HEADER = 14, - /// \brief Specifies a header that is private to this submodule but - /// must be textually included. - SUBMODULE_PRIVATE_TEXTUAL_HEADER = 15, - }; - - /// \brief Record types used within a comments block. - enum CommentRecordTypes { - COMMENTS_RAW_COMMENT = 0 - }; - - /// \defgroup ASTAST AST file AST constants - /// - /// The constants in this group describe various components of the - /// abstract syntax tree within an AST file. - /// - /// @{ - - /// \brief Predefined type IDs. - /// - /// These type IDs correspond to predefined types in the AST - /// context, such as built-in types (int) and special place-holder - /// types (the \<overload> and \<dependent> type markers). Such - /// types are never actually serialized, since they will be built - /// by the AST context when it is created. - enum PredefinedTypeIDs { - /// \brief The NULL type. - PREDEF_TYPE_NULL_ID = 0, - /// \brief The void type. - PREDEF_TYPE_VOID_ID = 1, - /// \brief The 'bool' or '_Bool' type. - PREDEF_TYPE_BOOL_ID = 2, - /// \brief The 'char' type, when it is unsigned. - PREDEF_TYPE_CHAR_U_ID = 3, - /// \brief The 'unsigned char' type. - PREDEF_TYPE_UCHAR_ID = 4, - /// \brief The 'unsigned short' type. - PREDEF_TYPE_USHORT_ID = 5, - /// \brief The 'unsigned int' type. - PREDEF_TYPE_UINT_ID = 6, - /// \brief The 'unsigned long' type. - PREDEF_TYPE_ULONG_ID = 7, - /// \brief The 'unsigned long long' type. - PREDEF_TYPE_ULONGLONG_ID = 8, - /// \brief The 'char' type, when it is signed. - PREDEF_TYPE_CHAR_S_ID = 9, - /// \brief The 'signed char' type. - PREDEF_TYPE_SCHAR_ID = 10, - /// \brief The C++ 'wchar_t' type. - PREDEF_TYPE_WCHAR_ID = 11, - /// \brief The (signed) 'short' type. - PREDEF_TYPE_SHORT_ID = 12, - /// \brief The (signed) 'int' type. - PREDEF_TYPE_INT_ID = 13, - /// \brief The (signed) 'long' type. - PREDEF_TYPE_LONG_ID = 14, - /// \brief The (signed) 'long long' type. - PREDEF_TYPE_LONGLONG_ID = 15, - /// \brief The 'float' type. - PREDEF_TYPE_FLOAT_ID = 16, - /// \brief The 'double' type. - PREDEF_TYPE_DOUBLE_ID = 17, - /// \brief The 'long double' type. - PREDEF_TYPE_LONGDOUBLE_ID = 18, - /// \brief The placeholder type for overloaded function sets. - PREDEF_TYPE_OVERLOAD_ID = 19, - /// \brief The placeholder type for dependent types. - PREDEF_TYPE_DEPENDENT_ID = 20, - /// \brief The '__uint128_t' type. - PREDEF_TYPE_UINT128_ID = 21, - /// \brief The '__int128_t' type. - PREDEF_TYPE_INT128_ID = 22, - /// \brief The type of 'nullptr'. - PREDEF_TYPE_NULLPTR_ID = 23, - /// \brief The C++ 'char16_t' type. - PREDEF_TYPE_CHAR16_ID = 24, - /// \brief The C++ 'char32_t' type. - PREDEF_TYPE_CHAR32_ID = 25, - /// \brief The ObjC 'id' type. - PREDEF_TYPE_OBJC_ID = 26, - /// \brief The ObjC 'Class' type. - PREDEF_TYPE_OBJC_CLASS = 27, - /// \brief The ObjC 'SEL' type. - PREDEF_TYPE_OBJC_SEL = 28, - /// \brief The 'unknown any' placeholder type. - PREDEF_TYPE_UNKNOWN_ANY = 29, - /// \brief The placeholder type for bound member functions. - PREDEF_TYPE_BOUND_MEMBER = 30, - /// \brief The "auto" deduction type. - PREDEF_TYPE_AUTO_DEDUCT = 31, - /// \brief The "auto &&" deduction type. - PREDEF_TYPE_AUTO_RREF_DEDUCT = 32, - /// \brief The OpenCL 'half' / ARM NEON __fp16 type. - 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 placeholder type for builtin functions. - PREDEF_TYPE_BUILTIN_FN = 36, - /// \brief OpenCL 1d image type. - PREDEF_TYPE_IMAGE1D_ID = 37, - /// \brief OpenCL 1d image array type. - PREDEF_TYPE_IMAGE1D_ARR_ID = 38, - /// \brief OpenCL 1d image buffer type. - PREDEF_TYPE_IMAGE1D_BUFF_ID = 39, - /// \brief OpenCL 2d image type. - PREDEF_TYPE_IMAGE2D_ID = 40, - /// \brief OpenCL 2d image array type. - PREDEF_TYPE_IMAGE2D_ARR_ID = 41, - /// \brief OpenCL 2d image depth type. - PREDEF_TYPE_IMAGE2D_DEP_ID = 42, - /// \brief OpenCL 2d image array depth type. - PREDEF_TYPE_IMAGE2D_ARR_DEP_ID = 43, - /// \brief OpenCL 2d image MSAA type. - PREDEF_TYPE_IMAGE2D_MSAA_ID = 44, - /// \brief OpenCL 2d image array MSAA type. - PREDEF_TYPE_IMAGE2D_ARR_MSAA_ID = 45, - /// \brief OpenCL 2d image MSAA depth type. - PREDEF_TYPE_IMAGE2D_MSAA_DEP_ID = 46, - /// \brief OpenCL 2d image array MSAA depth type. - PREDEF_TYPE_IMAGE2D_ARR_MSAA_DEPTH_ID = 47, - /// \brief OpenCL 3d image type. - PREDEF_TYPE_IMAGE3D_ID = 48, - /// \brief OpenCL event type. - PREDEF_TYPE_EVENT_ID = 49, - /// \brief OpenCL clk event type. - PREDEF_TYPE_CLK_EVENT_ID = 50, - /// \brief OpenCL sampler type. - PREDEF_TYPE_SAMPLER_ID = 51, - /// \brief OpenCL queue type. - PREDEF_TYPE_QUEUE_ID = 52, - /// \brief OpenCL ndrange type. - PREDEF_TYPE_NDRANGE_ID = 53, - /// \brief OpenCL reserve_id type. - PREDEF_TYPE_RESERVE_ID_ID = 54, - /// \brief The placeholder type for OpenMP array section. - PREDEF_TYPE_OMP_ARRAY_SECTION = 55 - }; - - /// \brief The number of predefined type IDs that are reserved for - /// the PREDEF_TYPE_* constants. - /// - /// Type IDs for non-predefined types will start at - /// NUM_PREDEF_TYPE_IDs. - const unsigned NUM_PREDEF_TYPE_IDS = 100; - - /// \brief Record codes for each kind of type. - /// - /// These constants describe the type records that can occur within a - /// block identified by DECLTYPES_BLOCK_ID in the AST file. Each - /// constant describes a record for a specific type class in the - /// AST. - enum TypeCode { - /// \brief An ExtQualType record. - TYPE_EXT_QUAL = 1, - /// \brief A ComplexType record. - TYPE_COMPLEX = 3, - /// \brief A PointerType record. - TYPE_POINTER = 4, - /// \brief A BlockPointerType record. - TYPE_BLOCK_POINTER = 5, - /// \brief An LValueReferenceType record. - TYPE_LVALUE_REFERENCE = 6, - /// \brief An RValueReferenceType record. - TYPE_RVALUE_REFERENCE = 7, - /// \brief A MemberPointerType record. - TYPE_MEMBER_POINTER = 8, - /// \brief A ConstantArrayType record. - TYPE_CONSTANT_ARRAY = 9, - /// \brief An IncompleteArrayType record. - TYPE_INCOMPLETE_ARRAY = 10, - /// \brief A VariableArrayType record. - TYPE_VARIABLE_ARRAY = 11, - /// \brief A VectorType record. - TYPE_VECTOR = 12, - /// \brief An ExtVectorType record. - TYPE_EXT_VECTOR = 13, - /// \brief A FunctionNoProtoType record. - TYPE_FUNCTION_NO_PROTO = 14, - /// \brief A FunctionProtoType record. - TYPE_FUNCTION_PROTO = 15, - /// \brief A TypedefType record. - TYPE_TYPEDEF = 16, - /// \brief A TypeOfExprType record. - TYPE_TYPEOF_EXPR = 17, - /// \brief A TypeOfType record. - TYPE_TYPEOF = 18, - /// \brief A RecordType record. - TYPE_RECORD = 19, - /// \brief An EnumType record. - TYPE_ENUM = 20, - /// \brief An ObjCInterfaceType record. - TYPE_OBJC_INTERFACE = 21, - /// \brief An ObjCObjectPointerType record. - TYPE_OBJC_OBJECT_POINTER = 22, - /// \brief a DecltypeType record. - TYPE_DECLTYPE = 23, - /// \brief An ElaboratedType record. - TYPE_ELABORATED = 24, - /// \brief A SubstTemplateTypeParmType record. - TYPE_SUBST_TEMPLATE_TYPE_PARM = 25, - /// \brief An UnresolvedUsingType record. - TYPE_UNRESOLVED_USING = 26, - /// \brief An InjectedClassNameType record. - TYPE_INJECTED_CLASS_NAME = 27, - /// \brief An ObjCObjectType record. - TYPE_OBJC_OBJECT = 28, - /// \brief An TemplateTypeParmType record. - TYPE_TEMPLATE_TYPE_PARM = 29, - /// \brief An TemplateSpecializationType record. - TYPE_TEMPLATE_SPECIALIZATION = 30, - /// \brief A DependentNameType record. - TYPE_DEPENDENT_NAME = 31, - /// \brief A DependentTemplateSpecializationType record. - TYPE_DEPENDENT_TEMPLATE_SPECIALIZATION = 32, - /// \brief A DependentSizedArrayType record. - TYPE_DEPENDENT_SIZED_ARRAY = 33, - /// \brief A ParenType record. - TYPE_PAREN = 34, - /// \brief A PackExpansionType record. - TYPE_PACK_EXPANSION = 35, - /// \brief An AttributedType record. - TYPE_ATTRIBUTED = 36, - /// \brief A SubstTemplateTypeParmPackType record. - TYPE_SUBST_TEMPLATE_TYPE_PARM_PACK = 37, - /// \brief A AutoType record. - TYPE_AUTO = 38, - /// \brief A UnaryTransformType record. - TYPE_UNARY_TRANSFORM = 39, - /// \brief An AtomicType record. - TYPE_ATOMIC = 40, - /// \brief A DecayedType record. - TYPE_DECAYED = 41, - /// \brief An AdjustedType record. - TYPE_ADJUSTED = 42 - }; - - /// \brief The type IDs for special types constructed by semantic - /// analysis. - /// - /// The constants in this enumeration are indices into the - /// SPECIAL_TYPES record. - enum SpecialTypeIDs { - /// \brief CFConstantString type - SPECIAL_TYPE_CF_CONSTANT_STRING = 0, - /// \brief C FILE typedef type - SPECIAL_TYPE_FILE = 1, - /// \brief C jmp_buf typedef type - SPECIAL_TYPE_JMP_BUF = 2, - /// \brief C sigjmp_buf typedef type - SPECIAL_TYPE_SIGJMP_BUF = 3, - /// \brief Objective-C "id" redefinition type - SPECIAL_TYPE_OBJC_ID_REDEFINITION = 4, - /// \brief Objective-C "Class" redefinition type - SPECIAL_TYPE_OBJC_CLASS_REDEFINITION = 5, - /// \brief Objective-C "SEL" redefinition type - SPECIAL_TYPE_OBJC_SEL_REDEFINITION = 6, - /// \brief C ucontext_t typedef type - SPECIAL_TYPE_UCONTEXT_T = 7 - }; - - /// \brief The number of special type IDs. - const unsigned NumSpecialTypeIDs = 8; - - /// \brief Predefined declaration IDs. - /// - /// These declaration IDs correspond to predefined declarations in the AST - /// context, such as the NULL declaration ID. Such declarations are never - /// actually serialized, since they will be built by the AST context when - /// it is created. - enum PredefinedDeclIDs { - /// \brief The NULL declaration. - PREDEF_DECL_NULL_ID = 0, - - /// \brief The translation unit. - PREDEF_DECL_TRANSLATION_UNIT_ID = 1, - - /// \brief The Objective-C 'id' type. - PREDEF_DECL_OBJC_ID_ID = 2, - - /// \brief The Objective-C 'SEL' type. - PREDEF_DECL_OBJC_SEL_ID = 3, - - /// \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 = 6, - - /// \brief The unsigned 128-bit integer type. - PREDEF_DECL_UNSIGNED_INT_128_ID = 7, - - /// \brief The internal 'instancetype' typedef. - PREDEF_DECL_OBJC_INSTANCETYPE_ID = 8, - - /// \brief The internal '__builtin_va_list' typedef. - PREDEF_DECL_BUILTIN_VA_LIST_ID = 9, - - /// \brief The internal '__va_list_tag' struct, if any. - PREDEF_DECL_VA_LIST_TAG = 10, - - /// \brief The internal '__builtin_ms_va_list' typedef. - PREDEF_DECL_BUILTIN_MS_VA_LIST_ID = 11, - - /// \brief The extern "C" context. - PREDEF_DECL_EXTERN_C_CONTEXT_ID = 12, - - /// \brief The internal '__make_integer_seq' template. - PREDEF_DECL_MAKE_INTEGER_SEQ_ID = 13, - }; - - /// \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 = 14; - - /// \brief Record code for a list of local redeclarations of a declaration. - const unsigned int LOCAL_REDECLARATIONS = 50; - - /// \brief Record codes for each kind of declaration. - /// - /// These constants describe the declaration records that can occur within - /// a declarations block (identified by DECLS_BLOCK_ID). Each - /// constant describes a record for a specific declaration class - /// in the AST. - enum DeclCode { - /// \brief A TypedefDecl record. - DECL_TYPEDEF = 51, - /// \brief A TypeAliasDecl record. - DECL_TYPEALIAS, - /// \brief An EnumDecl record. - DECL_ENUM, - /// \brief A RecordDecl record. - DECL_RECORD, - /// \brief An EnumConstantDecl record. - DECL_ENUM_CONSTANT, - /// \brief A FunctionDecl record. - DECL_FUNCTION, - /// \brief A ObjCMethodDecl record. - DECL_OBJC_METHOD, - /// \brief A ObjCInterfaceDecl record. - DECL_OBJC_INTERFACE, - /// \brief A ObjCProtocolDecl record. - DECL_OBJC_PROTOCOL, - /// \brief A ObjCIvarDecl record. - DECL_OBJC_IVAR, - /// \brief A ObjCAtDefsFieldDecl record. - DECL_OBJC_AT_DEFS_FIELD, - /// \brief A ObjCCategoryDecl record. - DECL_OBJC_CATEGORY, - /// \brief A ObjCCategoryImplDecl record. - DECL_OBJC_CATEGORY_IMPL, - /// \brief A ObjCImplementationDecl record. - DECL_OBJC_IMPLEMENTATION, - /// \brief A ObjCCompatibleAliasDecl record. - DECL_OBJC_COMPATIBLE_ALIAS, - /// \brief A ObjCPropertyDecl record. - DECL_OBJC_PROPERTY, - /// \brief A ObjCPropertyImplDecl record. - DECL_OBJC_PROPERTY_IMPL, - /// \brief A FieldDecl record. - DECL_FIELD, - /// \brief A MSPropertyDecl record. - DECL_MS_PROPERTY, - /// \brief A VarDecl record. - DECL_VAR, - /// \brief An ImplicitParamDecl record. - DECL_IMPLICIT_PARAM, - /// \brief A ParmVarDecl record. - DECL_PARM_VAR, - /// \brief A FileScopeAsmDecl record. - DECL_FILE_SCOPE_ASM, - /// \brief A BlockDecl record. - DECL_BLOCK, - /// \brief A CapturedDecl record. - DECL_CAPTURED, - /// \brief A record that stores the set of declarations that are - /// lexically stored within a given DeclContext. - /// - /// The record itself is a blob that is an array of declaration IDs, - /// in the order in which those declarations were added to the - /// declaration context. This data is used when iterating over - /// the contents of a DeclContext, e.g., via - /// DeclContext::decls_begin() and DeclContext::decls_end(). - DECL_CONTEXT_LEXICAL, - /// \brief A record that stores the set of declarations that are - /// visible from a given DeclContext. - /// - /// The record itself stores a set of mappings, each of which - /// associates a declaration name with one or more declaration - /// IDs. This data is used when performing qualified name lookup - /// into a DeclContext via DeclContext::lookup. - DECL_CONTEXT_VISIBLE, - /// \brief A LabelDecl record. - DECL_LABEL, - /// \brief A NamespaceDecl record. - DECL_NAMESPACE, - /// \brief A NamespaceAliasDecl record. - DECL_NAMESPACE_ALIAS, - /// \brief A UsingDecl record. - DECL_USING, - /// \brief A UsingShadowDecl record. - DECL_USING_SHADOW, - /// \brief A UsingDirecitveDecl record. - DECL_USING_DIRECTIVE, - /// \brief An UnresolvedUsingValueDecl record. - DECL_UNRESOLVED_USING_VALUE, - /// \brief An UnresolvedUsingTypenameDecl record. - DECL_UNRESOLVED_USING_TYPENAME, - /// \brief A LinkageSpecDecl record. - DECL_LINKAGE_SPEC, - /// \brief A CXXRecordDecl record. - DECL_CXX_RECORD, - /// \brief A CXXMethodDecl record. - DECL_CXX_METHOD, - /// \brief A CXXConstructorDecl record. - DECL_CXX_CONSTRUCTOR, - /// \brief A CXXDestructorDecl record. - DECL_CXX_DESTRUCTOR, - /// \brief A CXXConversionDecl record. - DECL_CXX_CONVERSION, - /// \brief An AccessSpecDecl record. - DECL_ACCESS_SPEC, - - /// \brief A FriendDecl record. - DECL_FRIEND, - /// \brief A FriendTemplateDecl record. - DECL_FRIEND_TEMPLATE, - /// \brief A ClassTemplateDecl record. - DECL_CLASS_TEMPLATE, - /// \brief A ClassTemplateSpecializationDecl record. - DECL_CLASS_TEMPLATE_SPECIALIZATION, - /// \brief A ClassTemplatePartialSpecializationDecl record. - DECL_CLASS_TEMPLATE_PARTIAL_SPECIALIZATION, - /// \brief A VarTemplateDecl record. - DECL_VAR_TEMPLATE, - /// \brief A VarTemplateSpecializationDecl record. - DECL_VAR_TEMPLATE_SPECIALIZATION, - /// \brief A VarTemplatePartialSpecializationDecl record. - DECL_VAR_TEMPLATE_PARTIAL_SPECIALIZATION, - /// \brief A FunctionTemplateDecl record. - DECL_FUNCTION_TEMPLATE, - /// \brief A TemplateTypeParmDecl record. - DECL_TEMPLATE_TYPE_PARM, - /// \brief A NonTypeTemplateParmDecl record. - DECL_NON_TYPE_TEMPLATE_PARM, - /// \brief A TemplateTemplateParmDecl record. - DECL_TEMPLATE_TEMPLATE_PARM, - /// \brief A TypeAliasTemplateDecl record. - DECL_TYPE_ALIAS_TEMPLATE, - /// \brief A StaticAssertDecl record. - DECL_STATIC_ASSERT, - /// \brief A record containing CXXBaseSpecifiers. - DECL_CXX_BASE_SPECIFIERS, - /// \brief A record containing CXXCtorInitializers. - DECL_CXX_CTOR_INITIALIZERS, - /// \brief A IndirectFieldDecl record. - DECL_INDIRECTFIELD, - /// \brief A NonTypeTemplateParmDecl record that stores an expanded - /// non-type template parameter pack. - DECL_EXPANDED_NON_TYPE_TEMPLATE_PARM_PACK, - /// \brief A TemplateTemplateParmDecl record that stores an expanded - /// template template parameter pack. - DECL_EXPANDED_TEMPLATE_TEMPLATE_PARM_PACK, - /// \brief A ClassScopeFunctionSpecializationDecl record a class scope - /// function specialization. (Microsoft extension). - DECL_CLASS_SCOPE_FUNCTION_SPECIALIZATION, - /// \brief An ImportDecl recording a module import. - DECL_IMPORT, - /// \brief An OMPThreadPrivateDecl record. - DECL_OMP_THREADPRIVATE, - /// \brief An EmptyDecl record. - DECL_EMPTY, - /// \brief An ObjCTypeParamDecl record. - DECL_OBJC_TYPE_PARAM, - }; - - /// \brief Record codes for each kind of statement or expression. - /// - /// These constants describe the records that describe statements - /// or expressions. These records occur within type and declarations - /// block, so they begin with record values of 128. Each constant - /// describes a record for a specific statement or expression class in the - /// AST. - enum StmtCode { - /// \brief A marker record that indicates that we are at the end - /// of an expression. - STMT_STOP = 128, - /// \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. - STMT_COMPOUND, - /// \brief A CaseStmt record. - STMT_CASE, - /// \brief A DefaultStmt record. - STMT_DEFAULT, - /// \brief A LabelStmt record. - STMT_LABEL, - /// \brief An AttributedStmt record. - STMT_ATTRIBUTED, - /// \brief An IfStmt record. - STMT_IF, - /// \brief A SwitchStmt record. - STMT_SWITCH, - /// \brief A WhileStmt record. - STMT_WHILE, - /// \brief A DoStmt record. - STMT_DO, - /// \brief A ForStmt record. - STMT_FOR, - /// \brief A GotoStmt record. - STMT_GOTO, - /// \brief An IndirectGotoStmt record. - STMT_INDIRECT_GOTO, - /// \brief A ContinueStmt record. - STMT_CONTINUE, - /// \brief A BreakStmt record. - STMT_BREAK, - /// \brief A ReturnStmt record. - STMT_RETURN, - /// \brief A DeclStmt record. - STMT_DECL, - /// \brief A CapturedStmt record. - STMT_CAPTURED, - /// \brief A GCC-style AsmStmt record. - STMT_GCCASM, - /// \brief A MS-style AsmStmt record. - STMT_MSASM, - /// \brief A PredefinedExpr record. - EXPR_PREDEFINED, - /// \brief A DeclRefExpr record. - EXPR_DECL_REF, - /// \brief An IntegerLiteral record. - EXPR_INTEGER_LITERAL, - /// \brief A FloatingLiteral record. - EXPR_FLOATING_LITERAL, - /// \brief An ImaginaryLiteral record. - EXPR_IMAGINARY_LITERAL, - /// \brief A StringLiteral record. - EXPR_STRING_LITERAL, - /// \brief A CharacterLiteral record. - EXPR_CHARACTER_LITERAL, - /// \brief A ParenExpr record. - EXPR_PAREN, - /// \brief A ParenListExpr record. - EXPR_PAREN_LIST, - /// \brief A UnaryOperator record. - EXPR_UNARY_OPERATOR, - /// \brief An OffsetOfExpr record. - EXPR_OFFSETOF, - /// \brief A SizefAlignOfExpr record. - EXPR_SIZEOF_ALIGN_OF, - /// \brief An ArraySubscriptExpr record. - EXPR_ARRAY_SUBSCRIPT, - /// \brief A CallExpr record. - EXPR_CALL, - /// \brief A MemberExpr record. - EXPR_MEMBER, - /// \brief A BinaryOperator record. - EXPR_BINARY_OPERATOR, - /// \brief A CompoundAssignOperator record. - EXPR_COMPOUND_ASSIGN_OPERATOR, - /// \brief A ConditionOperator record. - EXPR_CONDITIONAL_OPERATOR, - /// \brief An ImplicitCastExpr record. - EXPR_IMPLICIT_CAST, - /// \brief A CStyleCastExpr record. - EXPR_CSTYLE_CAST, - /// \brief A CompoundLiteralExpr record. - EXPR_COMPOUND_LITERAL, - /// \brief An ExtVectorElementExpr record. - EXPR_EXT_VECTOR_ELEMENT, - /// \brief An InitListExpr record. - EXPR_INIT_LIST, - /// \brief A DesignatedInitExpr record. - EXPR_DESIGNATED_INIT, - /// \brief A DesignatedInitUpdateExpr record. - EXPR_DESIGNATED_INIT_UPDATE, - /// \brief An ImplicitValueInitExpr record. - EXPR_IMPLICIT_VALUE_INIT, - /// \brief An NoInitExpr record. - EXPR_NO_INIT, - /// \brief A VAArgExpr record. - EXPR_VA_ARG, - /// \brief An AddrLabelExpr record. - EXPR_ADDR_LABEL, - /// \brief A StmtExpr record. - EXPR_STMT, - /// \brief A ChooseExpr record. - EXPR_CHOOSE, - /// \brief A GNUNullExpr record. - EXPR_GNU_NULL, - /// \brief A ShuffleVectorExpr record. - EXPR_SHUFFLE_VECTOR, - /// \brief A ConvertVectorExpr record. - EXPR_CONVERT_VECTOR, - /// \brief BlockExpr - EXPR_BLOCK, - /// \brief A GenericSelectionExpr record. - EXPR_GENERIC_SELECTION, - /// \brief A PseudoObjectExpr record. - EXPR_PSEUDO_OBJECT, - /// \brief An AtomicExpr record. - EXPR_ATOMIC, - - // Objective-C - - /// \brief An ObjCStringLiteral record. - EXPR_OBJC_STRING_LITERAL, - - EXPR_OBJC_BOXED_EXPRESSION, - EXPR_OBJC_ARRAY_LITERAL, - EXPR_OBJC_DICTIONARY_LITERAL, - - - /// \brief An ObjCEncodeExpr record. - EXPR_OBJC_ENCODE, - /// \brief An ObjCSelectorExpr record. - EXPR_OBJC_SELECTOR_EXPR, - /// \brief An ObjCProtocolExpr record. - EXPR_OBJC_PROTOCOL_EXPR, - /// \brief An ObjCIvarRefExpr record. - 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. - EXPR_OBJC_MESSAGE_EXPR, - /// \brief An ObjCIsa Expr record. - EXPR_OBJC_ISA, - /// \brief An ObjCIndirectCopyRestoreExpr record. - EXPR_OBJC_INDIRECT_COPY_RESTORE, - - /// \brief An ObjCForCollectionStmt record. - STMT_OBJC_FOR_COLLECTION, - /// \brief An ObjCAtCatchStmt record. - STMT_OBJC_CATCH, - /// \brief An ObjCAtFinallyStmt record. - STMT_OBJC_FINALLY, - /// \brief An ObjCAtTryStmt record. - STMT_OBJC_AT_TRY, - /// \brief An ObjCAtSynchronizedStmt record. - STMT_OBJC_AT_SYNCHRONIZED, - /// \brief An ObjCAtThrowStmt record. - STMT_OBJC_AT_THROW, - /// \brief An ObjCAutoreleasePoolStmt record. - STMT_OBJC_AUTORELEASE_POOL, - /// \brief A ObjCBoolLiteralExpr record. - EXPR_OBJC_BOOL_LITERAL, - - // C++ - - /// \brief A CXXCatchStmt record. - STMT_CXX_CATCH, - /// \brief A CXXTryStmt record. - STMT_CXX_TRY, - /// \brief A CXXForRangeStmt record. - STMT_CXX_FOR_RANGE, - - /// \brief A CXXOperatorCallExpr record. - EXPR_CXX_OPERATOR_CALL, - /// \brief A CXXMemberCallExpr record. - EXPR_CXX_MEMBER_CALL, - /// \brief A CXXConstructExpr record. - EXPR_CXX_CONSTRUCT, - /// \brief A CXXTemporaryObjectExpr record. - EXPR_CXX_TEMPORARY_OBJECT, - /// \brief A CXXStaticCastExpr record. - EXPR_CXX_STATIC_CAST, - /// \brief A CXXDynamicCastExpr record. - EXPR_CXX_DYNAMIC_CAST, - /// \brief A CXXReinterpretCastExpr record. - EXPR_CXX_REINTERPRET_CAST, - /// \brief A CXXConstCastExpr record. - EXPR_CXX_CONST_CAST, - /// \brief A CXXFunctionalCastExpr record. - EXPR_CXX_FUNCTIONAL_CAST, - /// \brief A UserDefinedLiteral record. - EXPR_USER_DEFINED_LITERAL, - /// \brief A CXXStdInitializerListExpr record. - EXPR_CXX_STD_INITIALIZER_LIST, - /// \brief A CXXBoolLiteralExpr record. - EXPR_CXX_BOOL_LITERAL, - EXPR_CXX_NULL_PTR_LITERAL, // CXXNullPtrLiteralExpr - EXPR_CXX_TYPEID_EXPR, // CXXTypeidExpr (of expr). - EXPR_CXX_TYPEID_TYPE, // CXXTypeidExpr (of type). - EXPR_CXX_THIS, // CXXThisExpr - EXPR_CXX_THROW, // CXXThrowExpr - EXPR_CXX_DEFAULT_ARG, // CXXDefaultArgExpr - EXPR_CXX_DEFAULT_INIT, // CXXDefaultInitExpr - EXPR_CXX_BIND_TEMPORARY, // CXXBindTemporaryExpr - - EXPR_CXX_SCALAR_VALUE_INIT, // CXXScalarValueInitExpr - EXPR_CXX_NEW, // CXXNewExpr - EXPR_CXX_DELETE, // CXXDeleteExpr - EXPR_CXX_PSEUDO_DESTRUCTOR, // CXXPseudoDestructorExpr - - EXPR_EXPR_WITH_CLEANUPS, // ExprWithCleanups - - EXPR_CXX_DEPENDENT_SCOPE_MEMBER, // CXXDependentScopeMemberExpr - EXPR_CXX_DEPENDENT_SCOPE_DECL_REF, // DependentScopeDeclRefExpr - EXPR_CXX_UNRESOLVED_CONSTRUCT, // CXXUnresolvedConstructExpr - EXPR_CXX_UNRESOLVED_MEMBER, // UnresolvedMemberExpr - EXPR_CXX_UNRESOLVED_LOOKUP, // UnresolvedLookupExpr - - EXPR_CXX_EXPRESSION_TRAIT, // ExpressionTraitExpr - EXPR_CXX_NOEXCEPT, // CXXNoexceptExpr - - EXPR_OPAQUE_VALUE, // OpaqueValueExpr - EXPR_BINARY_CONDITIONAL_OPERATOR, // BinaryConditionalOperator - EXPR_TYPE_TRAIT, // TypeTraitExpr - EXPR_ARRAY_TYPE_TRAIT, // ArrayTypeTraitIntExpr - - EXPR_PACK_EXPANSION, // PackExpansionExpr - EXPR_SIZEOF_PACK, // SizeOfPackExpr - EXPR_SUBST_NON_TYPE_TEMPLATE_PARM, // SubstNonTypeTemplateParmExpr - EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK,// SubstNonTypeTemplateParmPackExpr - EXPR_FUNCTION_PARM_PACK, // FunctionParmPackExpr - EXPR_MATERIALIZE_TEMPORARY, // MaterializeTemporaryExpr - EXPR_CXX_FOLD, // CXXFoldExpr - - // CUDA - EXPR_CUDA_KERNEL_CALL, // CUDAKernelCallExpr - - // OpenCL - EXPR_ASTYPE, // AsTypeExpr - - // Microsoft - EXPR_CXX_PROPERTY_REF_EXPR, // MSPropertyRefExpr - EXPR_CXX_PROPERTY_SUBSCRIPT_EXPR, // MSPropertySubscriptExpr - EXPR_CXX_UUIDOF_EXPR, // CXXUuidofExpr (of expr). - EXPR_CXX_UUIDOF_TYPE, // CXXUuidofExpr (of type). - STMT_SEH_LEAVE, // SEHLeaveStmt - STMT_SEH_EXCEPT, // SEHExceptStmt - STMT_SEH_FINALLY, // SEHFinallyStmt - STMT_SEH_TRY, // SEHTryStmt - - // OpenMP directives - STMT_OMP_PARALLEL_DIRECTIVE, - STMT_OMP_SIMD_DIRECTIVE, - STMT_OMP_FOR_DIRECTIVE, - STMT_OMP_FOR_SIMD_DIRECTIVE, - STMT_OMP_SECTIONS_DIRECTIVE, - STMT_OMP_SECTION_DIRECTIVE, - STMT_OMP_SINGLE_DIRECTIVE, - STMT_OMP_MASTER_DIRECTIVE, - STMT_OMP_CRITICAL_DIRECTIVE, - STMT_OMP_PARALLEL_FOR_DIRECTIVE, - STMT_OMP_PARALLEL_FOR_SIMD_DIRECTIVE, - STMT_OMP_PARALLEL_SECTIONS_DIRECTIVE, - STMT_OMP_TASK_DIRECTIVE, - STMT_OMP_TASKYIELD_DIRECTIVE, - STMT_OMP_BARRIER_DIRECTIVE, - STMT_OMP_TASKWAIT_DIRECTIVE, - STMT_OMP_FLUSH_DIRECTIVE, - STMT_OMP_ORDERED_DIRECTIVE, - STMT_OMP_ATOMIC_DIRECTIVE, - STMT_OMP_TARGET_DIRECTIVE, - STMT_OMP_TARGET_DATA_DIRECTIVE, - STMT_OMP_TEAMS_DIRECTIVE, - STMT_OMP_TASKGROUP_DIRECTIVE, - STMT_OMP_CANCELLATION_POINT_DIRECTIVE, - STMT_OMP_CANCEL_DIRECTIVE, - STMT_OMP_TASKLOOP_DIRECTIVE, - STMT_OMP_TASKLOOP_SIMD_DIRECTIVE, - STMT_OMP_DISTRIBUTE_DIRECTIVE, - EXPR_OMP_ARRAY_SECTION, - - // ARC - EXPR_OBJC_BRIDGED_CAST, // ObjCBridgedCastExpr - - STMT_MS_DEPENDENT_EXISTS, // MSDependentExistsStmt - EXPR_LAMBDA // LambdaExpr - }; - - /// \brief The kinds of designators that can occur in a - /// DesignatedInitExpr. - enum DesignatorTypes { - /// \brief Field designator where only the field name is known. - DESIG_FIELD_NAME = 0, - /// \brief Field designator where the field has been resolved to - /// a declaration. - DESIG_FIELD_DECL = 1, - /// \brief Array designator. - DESIG_ARRAY = 2, - /// \brief GNU array range designator. - DESIG_ARRAY_RANGE = 3 - }; - - /// \brief The different kinds of data that can occur in a - /// CtorInitializer. - enum CtorInitializerType { - CTOR_INITIALIZER_BASE, - CTOR_INITIALIZER_DELEGATING, - CTOR_INITIALIZER_MEMBER, - 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; - } - }; - - /// \brief A key used when looking up entities by \ref DeclarationName. - /// - /// Different \ref DeclarationNames are mapped to different keys, but the - /// same key can occasionally represent multiple names (for names that - /// contain types, in particular). - class DeclarationNameKey { - typedef unsigned NameKind; - - NameKind Kind; - uint64_t Data; - - public: - DeclarationNameKey() : Kind(), Data() {} - DeclarationNameKey(DeclarationName Name); - - DeclarationNameKey(NameKind Kind, uint64_t Data) - : Kind(Kind), Data(Data) {} - - NameKind getKind() const { return Kind; } - - IdentifierInfo *getIdentifier() const { - assert(Kind == DeclarationName::Identifier || - Kind == DeclarationName::CXXLiteralOperatorName); - return (IdentifierInfo *)Data; - } - Selector getSelector() const { - assert(Kind == DeclarationName::ObjCZeroArgSelector || - Kind == DeclarationName::ObjCOneArgSelector || - Kind == DeclarationName::ObjCMultiArgSelector); - return Selector(Data); - } - OverloadedOperatorKind getOperatorKind() const { - assert(Kind == DeclarationName::CXXOperatorName); - return (OverloadedOperatorKind)Data; - } - - /// Compute a fingerprint of this key for use in on-disk hash table. - unsigned getHash() const; - - friend bool operator==(const DeclarationNameKey &A, - const DeclarationNameKey &B) { - return A.Kind == B.Kind && A.Data == B.Data; - } - }; - - /// @} - } -} // end namespace clang - -namespace llvm { - template <> struct DenseMapInfo<clang::serialization::DeclarationNameKey> { - static clang::serialization::DeclarationNameKey getEmptyKey() { - return clang::serialization::DeclarationNameKey(-1, 1); - } - static clang::serialization::DeclarationNameKey getTombstoneKey() { - return clang::serialization::DeclarationNameKey(-1, 2); - } - static unsigned - getHashValue(const clang::serialization::DeclarationNameKey &Key) { - return Key.getHash(); - } - static bool isEqual(const clang::serialization::DeclarationNameKey &L, - const clang::serialization::DeclarationNameKey &R) { - return L == R; - } - }; -} - -#endif diff --git a/include/clang/Serialization/ASTDeserializationListener.h b/include/clang/Serialization/ASTDeserializationListener.h deleted file mode 100644 index 4b10c39..0000000 --- a/include/clang/Serialization/ASTDeserializationListener.h +++ /dev/null @@ -1,58 +0,0 @@ -//===- ASTDeserializationListener.h - Decl/Type PCH Read Events -*- 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 ASTDeserializationListener class, which is notified -// by the ASTReader whenever a type or declaration is deserialized. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_CLANG_SERIALIZATION_ASTDESERIALIZATIONLISTENER_H -#define LLVM_CLANG_SERIALIZATION_ASTDESERIALIZATIONLISTENER_H - -#include "clang/Basic/IdentifierTable.h" -#include "clang/Serialization/ASTBitCodes.h" - -namespace clang { - -class Decl; -class ASTReader; -class QualType; -class MacroDefinitionRecord; -class MacroInfo; -class Module; - -class ASTDeserializationListener { -public: - virtual ~ASTDeserializationListener(); - - /// \brief The ASTReader was initialized. - virtual void ReaderInitialized(ASTReader *Reader) { } - - /// \brief An identifier was deserialized from the AST file. - virtual void IdentifierRead(serialization::IdentID ID, - IdentifierInfo *II) { } - /// \brief A macro was read from the AST file. - virtual void MacroRead(serialization::MacroID ID, MacroInfo *MI) { } - /// \brief A type was deserialized from the AST file. The ID here has the - /// qualifier bits already removed, and T is guaranteed to be locally - /// unqualified. - virtual void TypeRead(serialization::TypeIdx Idx, QualType T) { } - /// \brief A decl was deserialized from the AST file. - virtual void DeclRead(serialization::DeclID ID, const Decl *D) { } - /// \brief A selector was read from the AST file. - virtual void SelectorRead(serialization::SelectorID iD, Selector Sel) {} - /// \brief A macro definition was read from the AST file. - virtual void MacroDefinitionRead(serialization::PreprocessedEntityID, - MacroDefinitionRecord *MD) {} - /// \brief A module definition was read from the AST file. - virtual void ModuleRead(serialization::SubmoduleID ID, Module *Mod) {} -}; -} - -#endif diff --git a/include/clang/Serialization/ASTReader.h b/include/clang/Serialization/ASTReader.h deleted file mode 100644 index 588a6a9..0000000 --- a/include/clang/Serialization/ASTReader.h +++ /dev/null @@ -1,2141 +0,0 @@ -//===--- ASTReader.h - AST File Reader --------------------------*- 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 ASTReader class, which reads AST files. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_CLANG_SERIALIZATION_ASTREADER_H -#define LLVM_CLANG_SERIALIZATION_ASTREADER_H - -#include "clang/AST/DeclObjC.h" -#include "clang/AST/DeclarationName.h" -#include "clang/AST/TemplateBase.h" -#include "clang/Basic/Diagnostic.h" -#include "clang/Basic/FileManager.h" -#include "clang/Basic/FileSystemOptions.h" -#include "clang/Basic/IdentifierTable.h" -#include "clang/Basic/SourceManager.h" -#include "clang/Basic/Version.h" -#include "clang/Lex/ExternalPreprocessorSource.h" -#include "clang/Lex/HeaderSearch.h" -#include "clang/Lex/PreprocessingRecord.h" -#include "clang/Sema/ExternalSemaSource.h" -#include "clang/Serialization/ASTBitCodes.h" -#include "clang/Serialization/ContinuousRangeMap.h" -#include "clang/Serialization/Module.h" -#include "clang/Serialization/ModuleFileExtension.h" -#include "clang/Serialization/ModuleManager.h" -#include "llvm/ADT/APFloat.h" -#include "llvm/ADT/APInt.h" -#include "llvm/ADT/APSInt.h" -#include "llvm/ADT/MapVector.h" -#include "llvm/ADT/SmallPtrSet.h" -#include "llvm/ADT/SmallSet.h" -#include "llvm/ADT/SmallVector.h" -#include "llvm/ADT/StringMap.h" -#include "llvm/ADT/StringRef.h" -#include "llvm/ADT/TinyPtrVector.h" -#include "llvm/Bitcode/BitstreamReader.h" -#include "llvm/Support/DataTypes.h" -#include "llvm/Support/Timer.h" -#include <deque> -#include <map> -#include <memory> -#include <string> -#include <utility> -#include <vector> - -namespace llvm { - class MemoryBuffer; -} - -namespace clang { - -class AddrLabelExpr; -class ASTConsumer; -class ASTContext; -class ASTIdentifierIterator; -class ASTUnit; // FIXME: Layering violation and egregious hack. -class Attr; -class Decl; -class DeclContext; -class DefMacroDirective; -class DiagnosticOptions; -class NestedNameSpecifier; -class CXXBaseSpecifier; -class CXXConstructorDecl; -class CXXCtorInitializer; -class GlobalModuleIndex; -class GotoStmt; -class MacroDefinition; -class MacroDirective; -class ModuleMacro; -class NamedDecl; -class OpaqueValueExpr; -class Preprocessor; -class PreprocessorOptions; -class Sema; -class SwitchCase; -class ASTDeserializationListener; -class ASTWriter; -class ASTReader; -class ASTDeclReader; -class ASTStmtReader; -class TypeLocReader; -struct HeaderFileInfo; -class VersionTuple; -class TargetOptions; -class LazyASTUnresolvedSet; - -/// \brief Abstract interface for callback invocations by the ASTReader. -/// -/// While reading an AST file, the ASTReader will call the methods of the -/// listener to pass on specific information. Some of the listener methods can -/// return true to indicate to the ASTReader that the information (and -/// consequently the AST file) is invalid. -class ASTReaderListener { -public: - virtual ~ASTReaderListener(); - - /// \brief Receives the full Clang version information. - /// - /// \returns true to indicate that the version is invalid. Subclasses should - /// generally defer to this implementation. - virtual bool ReadFullVersionInformation(StringRef FullVersion) { - return FullVersion != getClangFullRepositoryVersion(); - } - - virtual void ReadModuleName(StringRef ModuleName) {} - virtual void ReadModuleMapFile(StringRef ModuleMapPath) {} - - /// \brief Receives the language options. - /// - /// \returns true to indicate the options are invalid or false otherwise. - virtual bool ReadLanguageOptions(const LangOptions &LangOpts, - bool Complain, - bool AllowCompatibleDifferences) { - return false; - } - - /// \brief Receives the target options. - /// - /// \returns true to indicate the target options are invalid, or false - /// otherwise. - virtual bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain, - bool AllowCompatibleDifferences) { - return false; - } - - /// \brief Receives the diagnostic options. - /// - /// \returns true to indicate the diagnostic options are invalid, or false - /// otherwise. - virtual bool - ReadDiagnosticOptions(IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts, - bool Complain) { - return false; - } - - /// \brief Receives the file system options. - /// - /// \returns true to indicate the file system options are invalid, or false - /// otherwise. - virtual bool ReadFileSystemOptions(const FileSystemOptions &FSOpts, - bool Complain) { - return false; - } - - /// \brief Receives the header search options. - /// - /// \returns true to indicate the header search options are invalid, or false - /// otherwise. - virtual bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts, - StringRef SpecificModuleCachePath, - bool Complain) { - return false; - } - - /// \brief Receives the preprocessor options. - /// - /// \param SuggestedPredefines Can be filled in with the set of predefines - /// that are suggested by the preprocessor options. Typically only used when - /// loading a precompiled header. - /// - /// \returns true to indicate the preprocessor options are invalid, or false - /// otherwise. - virtual bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, - bool Complain, - std::string &SuggestedPredefines) { - return false; - } - - /// \brief Receives __COUNTER__ value. - virtual void ReadCounter(const serialization::ModuleFile &M, - unsigned Value) {} - - /// This is called for each AST file loaded. - virtual void visitModuleFile(StringRef Filename, - serialization::ModuleKind Kind) {} - - /// \brief Returns true if this \c ASTReaderListener wants to receive the - /// input files of the AST file via \c visitInputFile, false otherwise. - virtual bool needsInputFileVisitation() { return false; } - /// \brief Returns true if this \c ASTReaderListener wants to receive the - /// system input files of the AST file via \c visitInputFile, false otherwise. - virtual bool needsSystemInputFileVisitation() { return false; } - /// \brief if \c needsInputFileVisitation returns true, this is called for - /// each non-system input file of the AST File. If - /// \c needsSystemInputFileVisitation is true, then it is called for all - /// system input files as well. - /// - /// \returns true to continue receiving the next input file, false to stop. - virtual bool visitInputFile(StringRef Filename, bool isSystem, - bool isOverridden, bool isExplicitModule) { - return true; - } - - /// \brief Returns true if this \c ASTReaderListener wants to receive the - /// imports of the AST file via \c visitImport, false otherwise. - virtual bool needsImportVisitation() const { return false; } - /// \brief If needsImportVisitation returns \c true, this is called for each - /// AST file imported by this AST file. - virtual void visitImport(StringRef Filename) {} - - /// Indicates that a particular module file extension has been read. - virtual void readModuleFileExtension( - const ModuleFileExtensionMetadata &Metadata) {} -}; - -/// \brief Simple wrapper class for chaining listeners. -class ChainedASTReaderListener : public ASTReaderListener { - std::unique_ptr<ASTReaderListener> First; - std::unique_ptr<ASTReaderListener> Second; - -public: - /// Takes ownership of \p First and \p Second. - ChainedASTReaderListener(std::unique_ptr<ASTReaderListener> First, - std::unique_ptr<ASTReaderListener> Second) - : First(std::move(First)), Second(std::move(Second)) {} - - std::unique_ptr<ASTReaderListener> takeFirst() { return std::move(First); } - std::unique_ptr<ASTReaderListener> takeSecond() { return std::move(Second); } - - bool ReadFullVersionInformation(StringRef FullVersion) override; - void ReadModuleName(StringRef ModuleName) override; - void ReadModuleMapFile(StringRef ModuleMapPath) override; - bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain, - bool AllowCompatibleDifferences) override; - bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain, - bool AllowCompatibleDifferences) override; - bool ReadDiagnosticOptions(IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts, - bool Complain) override; - bool ReadFileSystemOptions(const FileSystemOptions &FSOpts, - bool Complain) override; - - bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts, - StringRef SpecificModuleCachePath, - bool Complain) override; - bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, - bool Complain, - std::string &SuggestedPredefines) override; - - void ReadCounter(const serialization::ModuleFile &M, unsigned Value) override; - bool needsInputFileVisitation() override; - bool needsSystemInputFileVisitation() override; - void visitModuleFile(StringRef Filename, - serialization::ModuleKind Kind) override; - bool visitInputFile(StringRef Filename, bool isSystem, - bool isOverridden, bool isExplicitModule) override; - void readModuleFileExtension( - const ModuleFileExtensionMetadata &Metadata) override; -}; - -/// \brief ASTReaderListener implementation to validate the information of -/// the PCH file against an initialized Preprocessor. -class PCHValidator : public ASTReaderListener { - Preprocessor &PP; - ASTReader &Reader; - -public: - PCHValidator(Preprocessor &PP, ASTReader &Reader) - : PP(PP), Reader(Reader) {} - - bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain, - bool AllowCompatibleDifferences) override; - bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain, - bool AllowCompatibleDifferences) override; - bool ReadDiagnosticOptions(IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts, - bool Complain) override; - bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, bool Complain, - std::string &SuggestedPredefines) override; - bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts, - StringRef SpecificModuleCachePath, - bool Complain) override; - void ReadCounter(const serialization::ModuleFile &M, unsigned Value) override; - -private: - void Error(const char *Msg); -}; - -namespace serialization { - -class ReadMethodPoolVisitor; - -namespace reader { - class ASTIdentifierLookupTrait; - /// \brief The on-disk hash table(s) used for DeclContext name lookup. - struct DeclContextLookupTable; -} - -} // end namespace serialization - -/// \brief Reads an AST files chain containing the contents of a translation -/// unit. -/// -/// The ASTReader class reads bitstreams (produced by the ASTWriter -/// class) containing the serialized representation of a given -/// abstract syntax tree and its supporting data structures. An -/// instance of the ASTReader can be attached to an ASTContext object, -/// which will provide access to the contents of the AST files. -/// -/// The AST reader provides lazy de-serialization of declarations, as -/// required when traversing the AST. Only those AST nodes that are -/// actually required will be de-serialized. -class ASTReader - : public ExternalPreprocessorSource, - public ExternalPreprocessingRecordSource, - public ExternalHeaderFileInfoSource, - public ExternalSemaSource, - public IdentifierInfoLookup, - public ExternalSLocEntrySource -{ -public: - typedef SmallVector<uint64_t, 64> RecordData; - typedef SmallVectorImpl<uint64_t> RecordDataImpl; - - /// \brief The result of reading the control block of an AST file, which - /// can fail for various reasons. - enum ASTReadResult { - /// \brief The control block was read successfully. Aside from failures, - /// the AST file is safe to read into the current context. - Success, - /// \brief The AST file itself appears corrupted. - Failure, - /// \brief The AST file was missing. - Missing, - /// \brief The AST file is out-of-date relative to its input files, - /// and needs to be regenerated. - OutOfDate, - /// \brief The AST file was written by a different version of Clang. - VersionMismatch, - /// \brief The AST file was writtten with a different language/target - /// configuration. - ConfigurationMismatch, - /// \brief The AST file has errors. - HadErrors - }; - - /// \brief Types of AST files. - friend class PCHValidator; - friend class ASTDeclReader; - friend class ASTStmtReader; - friend class ASTIdentifierIterator; - friend class serialization::reader::ASTIdentifierLookupTrait; - friend class TypeLocReader; - friend class ASTWriter; - friend class ASTUnit; // ASTUnit needs to remap source locations. - friend class serialization::ReadMethodPoolVisitor; - - 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. - std::unique_ptr<ASTReaderListener> Listener; - - /// \brief The receiver of deserialization events. - ASTDeserializationListener *DeserializationListener; - bool OwnsDeserializationListener; - - SourceManager &SourceMgr; - FileManager &FileMgr; - const PCHContainerReader &PCHContainerRdr; - DiagnosticsEngine &Diags; - - /// \brief The semantic analysis object that will be processing the - /// AST files and the translation unit that uses it. - Sema *SemaObj; - - /// \brief The preprocessor that will be loading the source file. - Preprocessor &PP; - - /// \brief The AST context into which we'll read the AST files. - ASTContext &Context; - - /// \brief The AST consumer. - ASTConsumer *Consumer; - - /// \brief The module manager which manages modules and their dependencies - ModuleManager ModuleMgr; - - /// A mapping from extension block names to module file extensions. - llvm::StringMap<IntrusiveRefCntPtr<ModuleFileExtension>> ModuleFileExtensions; - - /// \brief A timer used to track the time spent deserializing. - std::unique_ptr<llvm::Timer> ReadTimer; - - /// \brief The location where the module file will be considered as - /// imported from. For non-module AST types it should be invalid. - SourceLocation CurrentImportLoc; - - /// \brief The global module index, if loaded. - std::unique_ptr<GlobalModuleIndex> GlobalIndex; - - /// \brief A map of global bit offsets to the module that stores entities - /// at those bit offsets. - ContinuousRangeMap<uint64_t, ModuleFile*, 4> GlobalBitOffsetsMap; - - /// \brief A map of negated SLocEntryIDs to the modules containing them. - ContinuousRangeMap<unsigned, ModuleFile*, 64> GlobalSLocEntryMap; - - typedef ContinuousRangeMap<unsigned, ModuleFile*, 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, ModuleFile *, 4> - GlobalTypeMapType; - - /// \brief Mapping from global type IDs to the module in which the - /// type resides along with the offset that should be added to the - /// global type ID to produce a local ID. - GlobalTypeMapType GlobalTypeMap; - - /// \brief Declarations that have already been loaded from the chain. - /// - /// When the pointer at index I is non-NULL, the declaration with ID - /// = I + 1 has already been loaded. - std::vector<Decl *> DeclsLoaded; - - 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<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; - - /// \brief Declaration updates for already-loaded declarations that we need - /// to apply once we finish processing an import. - llvm::SmallVector<std::pair<serialization::GlobalDeclID, Decl*>, 16> - PendingUpdateRecords; - - enum class PendingFakeDefinitionKind { NotFake, Fake, FakeLoaded }; - - /// \brief The DefinitionData pointers that we faked up for class definitions - /// that we needed but hadn't loaded yet. - llvm::DenseMap<void *, PendingFakeDefinitionKind> PendingFakeDefinitionData; - - /// \brief Exception specification updates that have been loaded but not yet - /// propagated across the relevant redeclaration chain. The map key is the - /// canonical declaration (used only for deduplication) and the value is a - /// declaration that has an exception specification. - llvm::SmallMapVector<Decl *, FunctionDecl *, 4> PendingExceptionSpecUpdates; - - struct ReplacedDeclInfo { - ModuleFile *Mod; - uint64_t Offset; - unsigned RawLoc; - - ReplacedDeclInfo() : Mod(nullptr), 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; - - /// \brief Declarations that have been imported and have typedef names for - /// linkage purposes. - llvm::DenseMap<std::pair<DeclContext*, IdentifierInfo*>, NamedDecl*> - ImportedTypedefNamesForLinkage; - - /// \brief Mergeable declaration contexts that have anonymous declarations - /// within them, and those anonymous declarations. - llvm::DenseMap<DeclContext*, llvm::SmallVector<NamedDecl*, 2>> - AnonymousDeclarationsForMerging; - - struct FileDeclsInfo { - ModuleFile *Mod; - ArrayRef<serialization::LocalDeclID> Decls; - - FileDeclsInfo() : Mod(nullptr) {} - 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; - - /// \brief An array of lexical contents of a declaration context, as a sequence of - /// Decl::Kind, DeclID pairs. - typedef ArrayRef<llvm::support::unaligned_uint32_t> LexicalContents; - - /// \brief Map from a DeclContext to its lexical contents. - llvm::DenseMap<const DeclContext*, std::pair<ModuleFile*, LexicalContents>> - LexicalDecls; - - /// \brief Map from the TU to its lexical contents from each module file. - std::vector<std::pair<ModuleFile*, LexicalContents>> TULexicalDecls; - - /// \brief Map from a DeclContext to its lookup tables. - llvm::DenseMap<const DeclContext *, - serialization::reader::DeclContextLookupTable> Lookups; - - // Updates for visible decls can occur for other contexts than just the - // TU, and when we read those update records, the actual context may not - // be available yet, so have this pending map using the ID as a key. It - // will be realized when the context is actually loaded. - struct PendingVisibleUpdate { - ModuleFile *Mod; - const unsigned char *Data; - }; - typedef SmallVector<PendingVisibleUpdate, 1> DeclContextVisibleUpdates; - - /// \brief Updates to the visible declarations of declaration contexts that - /// haven't been loaded yet. - llvm::DenseMap<serialization::DeclID, DeclContextVisibleUpdates> - PendingVisibleUpdates; - - /// \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; - - typedef llvm::MapVector<Decl *, uint64_t, - llvm::SmallDenseMap<Decl *, unsigned, 4>, - SmallVector<std::pair<Decl *, uint64_t>, 4> > - PendingBodiesMap; - - /// \brief Functions or methods that have bodies that will be attached. - PendingBodiesMap PendingBodies; - - /// \brief Definitions for which we have added merged definitions but not yet - /// performed deduplication. - llvm::SetVector<NamedDecl*> PendingMergedDefinitionsToDeduplicate; - - /// \brief Read the record that describes the lexical contents of a DC. - bool ReadLexicalDeclContextStorage(ModuleFile &M, - llvm::BitstreamCursor &Cursor, - uint64_t Offset, DeclContext *DC); - /// \brief Read the record that describes the visible contents of a DC. - bool ReadVisibleDeclContextStorage(ModuleFile &M, - llvm::BitstreamCursor &Cursor, - uint64_t Offset, serialization::DeclID ID); - - /// \brief A vector containing identifiers that have already been - /// loaded. - /// - /// If the pointer at index I is non-NULL, then it refers to the - /// IdentifierInfo for the identifier with ID=I+1 that has already - /// been loaded. - std::vector<IdentifierInfo *> IdentifiersLoaded; - - typedef ContinuousRangeMap<serialization::IdentID, ModuleFile *, 4> - GlobalIdentifierMapType; - - /// \brief Mapping from global identifier 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 macros that have already been - /// loaded. - /// - /// If the pointer at index I is non-NULL, then it refers to the - /// MacroInfo for the identifier with ID=I+1 that has already - /// been loaded. - std::vector<MacroInfo *> MacrosLoaded; - - typedef std::pair<IdentifierInfo *, serialization::SubmoduleID> - LoadedMacroInfo; - - /// \brief A set of #undef directives that we have loaded; used to - /// deduplicate the same #undef information coming from multiple module - /// files. - llvm::DenseSet<LoadedMacroInfo> LoadedUndefs; - - typedef ContinuousRangeMap<serialization::MacroID, ModuleFile *, 4> - GlobalMacroMapType; - - /// \brief Mapping from global macro IDs to the module in which the - /// macro resides along with the offset that should be added to the - /// global macro ID to produce a local ID. - GlobalMacroMapType GlobalMacroMap; - - /// \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 SmallVector<Decl*, 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, export, or conflict that hasn't yet been resolved. - struct UnresolvedModuleRef { - /// \brief The file in which this module resides. - ModuleFile *File; - - /// \brief The module that is importing or exporting. - Module *Mod; - - /// \brief The kind of module reference. - enum { Import, Export, Conflict } Kind; - - /// \brief The local ID of the module that is being exported. - unsigned ID; - - /// \brief Whether this is a wildcard export. - unsigned IsWildcard : 1; - - /// \brief String data. - StringRef String; - }; - - /// \brief The set of module imports and exports that still need to be - /// resolved. - SmallVector<UnresolvedModuleRef, 2> UnresolvedModuleRefs; - - /// \brief A vector containing selectors that have already been loaded. - /// - /// This vector is indexed by the Selector ID (-1). NULL selector - /// entries indicate that the particular selector ID has not yet - /// been loaded. - SmallVector<Selector, 16> SelectorsLoaded; - - typedef ContinuousRangeMap<serialization::SelectorID, ModuleFile *, 4> - GlobalSelectorMapType; - - /// \brief Mapping from global selector IDs to the module in which 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; - - struct PendingMacroInfo { - ModuleFile *M; - uint64_t MacroDirectivesOffset; - - PendingMacroInfo(ModuleFile *M, uint64_t MacroDirectivesOffset) - : M(M), MacroDirectivesOffset(MacroDirectivesOffset) {} - }; - - typedef llvm::MapVector<IdentifierInfo *, SmallVector<PendingMacroInfo, 2> > - PendingMacroIDsMap; - - /// \brief Mapping from identifiers that have a macro history to the global - /// IDs have not yet been deserialized to the global IDs of those macros. - PendingMacroIDsMap PendingMacroIDs; - - 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. - //@{ - - /// \brief The IDs of all declarations that fulfill the criteria of - /// "interesting" decls. - /// - /// This contains the data loaded from all EAGERLY_DESERIALIZED_DECLS blocks - /// in the chain. The referenced declarations are deserialized and passed to - /// the consumer eagerly. - SmallVector<uint64_t, 16> EagerlyDeserializedDecls; - - /// \brief The IDs of all tentative definitions stored in the chain. - /// - /// Sema keeps track of all tentative definitions in a TU because it has to - /// complete them and pass them on to CodeGen. Thus, tentative definitions in - /// the PCH chain must be eagerly deserialized. - SmallVector<uint64_t, 16> TentativeDefinitions; - - /// \brief The IDs of all CXXRecordDecls stored in the chain whose VTables are - /// used. - /// - /// CodeGen has to emit VTables for these records, so they have to be eagerly - /// deserialized. - SmallVector<uint64_t, 64> VTableUses; - - /// \brief A snapshot of the pending instantiations in the chain. - /// - /// This record tracks the instantiations that Sema has to perform at the - /// end of the TU. It consists of a pair of values for every pending - /// instantiation where the first value is the ID of the decl and the second - /// is the instantiation location. - SmallVector<uint64_t, 64> PendingInstantiations; - - //@} - - /// \name DiagnosticsEngine-relevant special data - /// \brief Fields containing data that is used for generating diagnostics - //@{ - - /// \brief A snapshot of Sema's unused file-scoped variable tracking, for - /// generating warnings. - SmallVector<uint64_t, 16> UnusedFileScopedDecls; - - /// \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; - - /// \brief A snapshot of Sema's weak undeclared identifier tracking, for - /// generating warnings. - SmallVector<uint64_t, 64> WeakUndeclaredIdentifiers; - - /// \brief The IDs of type aliases for ext_vectors that exist in the chain. - /// - /// Used by Sema for finding sugared names for ext_vectors in diagnostics. - SmallVector<uint64_t, 4> ExtVectorDecls; - - //@} - - /// \name Sema-relevant special data - /// \brief Fields containing data that is used for semantic analysis - //@{ - - /// \brief The IDs of all potentially unused typedef names in the chain. - /// - /// Sema tracks these to emit warnings. - SmallVector<uint64_t, 16> UnusedLocalTypedefNameCandidates; - - /// \brief The IDs of the declarations Sema stores directly. - /// - /// Sema tracks a few important decls, such as namespace std, directly. - SmallVector<uint64_t, 4> SemaDeclRefs; - - /// \brief The IDs of the types ASTContext stores directly. - /// - /// The AST context tracks a few important types, such as va_list, directly. - SmallVector<uint64_t, 16> SpecialTypes; - - /// \brief The IDs of CUDA-specific declarations ASTContext stores directly. - /// - /// The AST context tracks a few important decls, currently cudaConfigureCall, - /// directly. - SmallVector<uint64_t, 2> CUDASpecialDeclRefs; - - /// \brief The floating point pragma option settings. - SmallVector<uint64_t, 1> FPPragmaOptions; - - /// \brief The pragma clang optimize location (if the pragma state is "off"). - SourceLocation OptimizeOffPragmaLocation; - - /// \brief The OpenCL extension settings. - SmallVector<uint64_t, 1> OpenCLExtensions; - - /// \brief A list of the namespaces we've seen. - SmallVector<uint64_t, 4> KnownNamespaces; - - /// \brief A list of undefined decls with internal linkage followed by the - /// SourceLocation of a matching ODR-use. - SmallVector<uint64_t, 8> UndefinedButUsed; - - /// \brief Delete expressions to analyze at the end of translation unit. - SmallVector<uint64_t, 8> DelayedDeleteExprs; - - // \brief A list of late parsed template function data. - SmallVector<uint64_t, 1> LateParsedTemplates; - - struct ImportedSubmodule { - serialization::SubmoduleID ID; - SourceLocation ImportLoc; - - ImportedSubmodule(serialization::SubmoduleID ID, SourceLocation ImportLoc) - : ID(ID), ImportLoc(ImportLoc) {} - }; - - /// \brief A list of modules that were imported by precompiled headers or - /// any other non-module AST file. - SmallVector<ImportedSubmodule, 2> ImportedModules; - //@} - - /// \brief The directory that the PCH we are reading is stored in. - std::string CurrentDir; - - /// \brief The system include root to be used when loading the - /// precompiled header. - std::string isysroot; - - /// \brief Whether to disable the normal validation performed on precompiled - /// headers when they are loaded. - bool DisableValidation; - - /// \brief Whether to accept an AST file with compiler errors. - bool AllowASTWithCompilerErrors; - - /// \brief Whether to accept an AST file that has a different configuration - /// from the current compiler instance. - bool AllowConfigurationMismatch; - - /// \brief Whether validate system input files. - bool ValidateSystemInputs; - - /// \brief Whether we are allowed to use the global module index. - bool UseGlobalIndex; - - /// \brief Whether we have tried loading the global module index yet. - bool TriedLoadingGlobalIndex; - - typedef llvm::DenseMap<unsigned, SwitchCase *> SwitchCaseMapTy; - /// \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. - SwitchCaseMapTy SwitchCaseStmts; - - SwitchCaseMapTy *CurrSwitchCaseStmts; - - /// \brief The number of source location entries de-serialized from - /// the PCH file. - unsigned NumSLocEntriesRead; - - /// \brief The number of source location entries in the chain. - unsigned TotalNumSLocEntries; - - /// \brief The number of statements (and expressions) de-serialized - /// from the chain. - unsigned NumStatementsRead; - - /// \brief The total number of statements (and expressions) stored - /// in the chain. - unsigned TotalNumStatements; - - /// \brief The number of macros de-serialized from the chain. - unsigned NumMacrosRead; - - /// \brief The total number of macros stored in the chain. - unsigned TotalNumMacros; - - /// \brief The number of lookups into identifier tables. - unsigned NumIdentifierLookups; - - /// \brief The number of lookups into identifier tables that succeed. - unsigned NumIdentifierLookupHits; - - /// \brief The number of selectors that have been read. - unsigned NumSelectorsRead; - - /// \brief The number of method pool entries that have been read. - unsigned NumMethodPoolEntriesRead; - - /// \brief The number of times we have looked up a selector in the method - /// pool. - unsigned NumMethodPoolLookups; - - /// \brief The number of times we have looked up a selector in the method - /// pool and found something. - unsigned NumMethodPoolHits; - - /// \brief The number of times we have looked up a selector in the method - /// pool within a specific module. - unsigned NumMethodPoolTableLookups; - - /// \brief The number of times we have looked up a selector in the method - /// pool within a specific module and found something. - unsigned NumMethodPoolTableHits; - - /// \brief The total number of method pool entries in the selector table. - unsigned TotalNumMethodPoolEntries; - - /// Number of lexical decl contexts read/total. - unsigned NumLexicalDeclContextsRead, TotalLexicalDeclContexts; - - /// 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; - - /// \brief The set of identifiers that were read while the AST reader was - /// (recursively) loading declarations. - /// - /// The declarations on the identifier chain for these identifiers will be - /// loaded once the recursive loading has completed. - llvm::MapVector<IdentifierInfo *, SmallVector<uint32_t, 4> > - PendingIdentifierInfos; - - /// \brief The set of lookup results that we have faked in order to support - /// merging of partially deserialized decls but that we have not yet removed. - llvm::SmallMapVector<IdentifierInfo *, SmallVector<NamedDecl*, 2>, 16> - PendingFakeLookupResults; - - /// \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. - /// - /// "Interesting" declarations are those that have data that may - /// need to be emitted, such as inline function definitions or - /// Objective-C protocols. - std::deque<Decl *> InterestingDecls; - - /// \brief The list of redeclaration chains that still need to be - /// reconstructed, and the local offset to the corresponding list - /// of redeclarations. - SmallVector<std::pair<Decl *, uint64_t>, 16> PendingDeclChains; - - /// \brief The list of canonical declarations whose redeclaration chains - /// need to be marked as incomplete once we're done deserializing things. - SmallVector<Decl *, 16> PendingIncompleteDeclChains; - - /// \brief The Decl IDs for the Sema/Lexical DeclContext of a Decl that has - /// been loaded but its DeclContext was not set yet. - struct PendingDeclContextInfo { - Decl *D; - serialization::GlobalDeclID SemaDC; - serialization::GlobalDeclID LexicalDC; - }; - - /// \brief The set of Decls that have been loaded but their DeclContexts are - /// not set yet. - /// - /// The DeclContexts for these Decls will be set once recursive loading has - /// been completed. - std::deque<PendingDeclContextInfo> PendingDeclContextInfos; - - /// \brief The set of NamedDecls that have been loaded, but are members of a - /// context that has been merged into another context where the corresponding - /// declaration is either missing or has not yet been loaded. - /// - /// We will check whether the corresponding declaration is in fact missing - /// once recursing loading has been completed. - llvm::SmallVector<NamedDecl *, 16> PendingOdrMergeChecks; - - /// \brief Record definitions in which we found an ODR violation. - llvm::SmallDenseMap<CXXRecordDecl *, llvm::TinyPtrVector<CXXRecordDecl *>, 2> - PendingOdrMergeFailures; - - /// \brief DeclContexts in which we have diagnosed an ODR violation. - llvm::SmallPtrSet<DeclContext*, 2> DiagnosedOdrMergeFailures; - - /// \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. - SmallVector<ObjCInterfaceDecl *, 16> ObjCClassesLoaded; - - typedef llvm::DenseMap<Decl *, SmallVector<serialization::DeclID, 2> > - KeyDeclsMap; - - /// \brief A mapping from canonical declarations to the set of global - /// declaration IDs for key declaration that have been merged with that - /// canonical declaration. A key declaration is a formerly-canonical - /// declaration whose module did not import any other key declaration for that - /// entity. These are the IDs that we use as keys when finding redecl chains. - KeyDeclsMap KeyDecls; - - /// \brief A mapping from DeclContexts to the semantic DeclContext that we - /// are treating as the definition of the entity. This is used, for instance, - /// when merging implicit instantiations of class templates across modules. - llvm::DenseMap<DeclContext *, DeclContext *> MergedDeclContexts; - - /// \brief A mapping from canonical declarations of enums to their canonical - /// definitions. Only populated when using modules in C++. - llvm::DenseMap<EnumDecl *, EnumDecl *> EnumDefinitions; - - /// \brief When reading a Stmt tree, Stmt operands are placed in this stack. - SmallVector<Stmt *, 16> StmtStack; - - /// \brief What kind of records we are reading. - enum ReadingKind { - Read_None, Read_Decl, Read_Type, Read_Stmt - }; - - /// \brief What kind of records we are reading. - ReadingKind ReadingKind; - - /// \brief RAII object to change the reading kind. - class ReadingKindTracker { - ASTReader &Reader; - enum ReadingKind PrevKind; - - ReadingKindTracker(const ReadingKindTracker &) = delete; - void operator=(const ReadingKindTracker &) = delete; - - public: - ReadingKindTracker(enum ReadingKind newKind, ASTReader &reader) - : Reader(reader), PrevKind(Reader.ReadingKind) { - Reader.ReadingKind = newKind; - } - - ~ReadingKindTracker() { Reader.ReadingKind = PrevKind; } - }; - - /// \brief Suggested contents of the predefines buffer, after this - /// PCH file has been processed. - /// - /// In most cases, this string will be empty, because the predefines - /// buffer computed to build the PCH file will be identical to the - /// predefines buffer computed from the command line. However, when - /// there are differences that the PCH reader can work around, this - /// predefines buffer may contain additional definitions. - std::string SuggestedPredefines; - - /// \brief Reads a statement from the specified cursor. - Stmt *ReadStmtFromStream(ModuleFile &F); - - struct InputFileInfo { - std::string Filename; - off_t StoredSize; - time_t StoredTime; - bool Overridden; - bool Transient; - }; - - /// \brief Reads the stored information about an input file. - InputFileInfo readInputFileInfo(ModuleFile &F, unsigned ID); - - /// \brief Retrieve the file entry and 'overridden' bit for an input - /// file in the given module file. - serialization::InputFile getInputFile(ModuleFile &F, unsigned ID, - bool Complain = true); - -public: - void ResolveImportedPath(ModuleFile &M, std::string &Filename); - static void ResolveImportedPath(std::string &Filename, StringRef Prefix); - - /// \brief Returns the first key declaration for the given declaration. This - /// is one that is formerly-canonical (or still canonical) and whose module - /// did not import any other key declaration of the entity. - Decl *getKeyDeclaration(Decl *D) { - D = D->getCanonicalDecl(); - if (D->isFromASTFile()) - return D; - - auto I = KeyDecls.find(D); - if (I == KeyDecls.end() || I->second.empty()) - return D; - return GetExistingDecl(I->second[0]); - } - const Decl *getKeyDeclaration(const Decl *D) { - return getKeyDeclaration(const_cast<Decl*>(D)); - } - - /// \brief Run a callback on each imported key declaration of \p D. - template <typename Fn> - void forEachImportedKeyDecl(const Decl *D, Fn Visit) { - D = D->getCanonicalDecl(); - if (D->isFromASTFile()) - Visit(D); - - auto It = KeyDecls.find(const_cast<Decl*>(D)); - if (It != KeyDecls.end()) - for (auto ID : It->second) - Visit(GetExistingDecl(ID)); - } - - /// \brief Get the loaded lookup tables for \p Primary, if any. - const serialization::reader::DeclContextLookupTable * - getLoadedLookupTables(DeclContext *Primary) const; - -private: - struct ImportedModule { - ModuleFile *Mod; - ModuleFile *ImportedBy; - SourceLocation ImportLoc; - - ImportedModule(ModuleFile *Mod, - ModuleFile *ImportedBy, - SourceLocation ImportLoc) - : Mod(Mod), ImportedBy(ImportedBy), ImportLoc(ImportLoc) { } - }; - - ASTReadResult ReadASTCore(StringRef FileName, ModuleKind Type, - SourceLocation ImportLoc, ModuleFile *ImportedBy, - SmallVectorImpl<ImportedModule> &Loaded, - off_t ExpectedSize, time_t ExpectedModTime, - serialization::ASTFileSignature ExpectedSignature, - unsigned ClientLoadCapabilities); - ASTReadResult ReadControlBlock(ModuleFile &F, - SmallVectorImpl<ImportedModule> &Loaded, - const ModuleFile *ImportedBy, - unsigned ClientLoadCapabilities); - static ASTReadResult ReadOptionsBlock( - llvm::BitstreamCursor &Stream, unsigned ClientLoadCapabilities, - bool AllowCompatibleConfigurationMismatch, ASTReaderListener &Listener, - std::string &SuggestedPredefines); - ASTReadResult ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities); - ASTReadResult ReadExtensionBlock(ModuleFile &F); - bool ParseLineTable(ModuleFile &F, const RecordData &Record); - bool ReadSourceManagerBlock(ModuleFile &F); - llvm::BitstreamCursor &SLocCursorForID(int ID); - SourceLocation getImportLocation(ModuleFile *F); - ASTReadResult ReadModuleMapFileBlock(RecordData &Record, ModuleFile &F, - const ModuleFile *ImportedBy, - unsigned ClientLoadCapabilities); - ASTReadResult ReadSubmoduleBlock(ModuleFile &F, - unsigned ClientLoadCapabilities); - static bool ParseLanguageOptions(const RecordData &Record, bool Complain, - ASTReaderListener &Listener, - bool AllowCompatibleDifferences); - static bool ParseTargetOptions(const RecordData &Record, bool Complain, - ASTReaderListener &Listener, - bool AllowCompatibleDifferences); - static bool ParseDiagnosticOptions(const RecordData &Record, bool Complain, - ASTReaderListener &Listener); - static bool ParseFileSystemOptions(const RecordData &Record, bool Complain, - ASTReaderListener &Listener); - static bool ParseHeaderSearchOptions(const RecordData &Record, bool Complain, - ASTReaderListener &Listener); - static bool ParsePreprocessorOptions(const RecordData &Record, bool Complain, - ASTReaderListener &Listener, - std::string &SuggestedPredefines); - - struct RecordLocation { - RecordLocation(ModuleFile *M, uint64_t O) - : F(M), Offset(O) {} - ModuleFile *F; - uint64_t Offset; - }; - - QualType readTypeRecord(unsigned Index); - void readExceptionSpec(ModuleFile &ModuleFile, - SmallVectorImpl<QualType> &ExceptionStorage, - FunctionProtoType::ExceptionSpecInfo &ESI, - const RecordData &Record, unsigned &Index); - RecordLocation TypeCursorForIndex(unsigned Index); - void LoadedDecl(unsigned Index, Decl *D); - Decl *ReadDeclRecord(serialization::DeclID ID); - void markIncompleteDeclChain(Decl *Canon); - - /// \brief Returns the most recent declaration of a declaration (which must be - /// of a redeclarable kind) that is either local or has already been loaded - /// merged into its redecl chain. - Decl *getMostRecentExistingDecl(Decl *D); - - RecordLocation DeclCursorForID(serialization::DeclID ID, - unsigned &RawLocation); - void loadDeclUpdateRecords(serialization::DeclID ID, Decl *D); - void loadPendingDeclChain(Decl *D, uint64_t LocalOffset); - void loadObjCCategories(serialization::GlobalDeclID ID, ObjCInterfaceDecl *D, - unsigned PreviousGeneration = 0); - - RecordLocation getLocalBitOffset(uint64_t GlobalOffset); - uint64_t getGlobalBitOffset(ModuleFile &M, uint32_t LocalOffset); - - /// \brief Returns the first preprocessed entity ID that begins or ends after - /// \arg Loc. - serialization::PreprocessedEntityID - findPreprocessedEntity(SourceLocation Loc, bool EndsAfter) const; - - /// \brief Find the next module that contains entities and return the ID - /// of the first entry. - /// - /// \param SLocMapI points at a chunk of a module that contains no - /// preprocessed entities or the entities it contains are not the - /// ones we are looking for. - serialization::PreprocessedEntityID - findNextPreprocessedEntity( - GlobalSLocOffsetMapType::const_iterator SLocMapI) const; - - /// \brief Returns (ModuleFile, Local index) pair for \p GlobalIndex of a - /// preprocessed entity. - std::pair<ModuleFile *, unsigned> - getModulePreprocessedEntity(unsigned GlobalIndex); - - /// \brief Returns (begin, end) pair for the preprocessed entities of a - /// particular module. - llvm::iterator_range<PreprocessingRecord::iterator> - getModulePreprocessedEntities(ModuleFile &Mod) const; - - class ModuleDeclIterator - : public llvm::iterator_adaptor_base< - ModuleDeclIterator, const serialization::LocalDeclID *, - std::random_access_iterator_tag, const Decl *, ptrdiff_t, - const Decl *, const Decl *> { - ASTReader *Reader; - ModuleFile *Mod; - - public: - ModuleDeclIterator() - : iterator_adaptor_base(nullptr), Reader(nullptr), Mod(nullptr) {} - - ModuleDeclIterator(ASTReader *Reader, ModuleFile *Mod, - const serialization::LocalDeclID *Pos) - : iterator_adaptor_base(Pos), Reader(Reader), Mod(Mod) {} - - value_type operator*() const { - return Reader->GetDecl(Reader->getGlobalDeclID(*Mod, *I)); - } - value_type operator->() const { return **this; } - - bool operator==(const ModuleDeclIterator &RHS) const { - assert(Reader == RHS.Reader && Mod == RHS.Mod); - return I == RHS.I; - } - }; - - llvm::iterator_range<ModuleDeclIterator> - getModuleFileLevelDecls(ModuleFile &Mod); - - void PassInterestingDeclsToConsumer(); - void PassInterestingDeclToConsumer(Decl *D); - - void finishPendingActions(); - void diagnoseOdrViolations(); - - void pushExternalDeclIntoScope(NamedDecl *D, DeclarationName Name); - - void addPendingDeclContextInfo(Decl *D, - serialization::GlobalDeclID SemaDC, - serialization::GlobalDeclID LexicalDC) { - assert(D); - PendingDeclContextInfo Info = { D, SemaDC, LexicalDC }; - PendingDeclContextInfos.push_back(Info); - } - - /// \brief Produce an error diagnostic and return true. - /// - /// This routine should only be used for fatal errors that have to - /// do with non-routine failures (e.g., corrupted AST file). - void Error(StringRef Msg); - void Error(unsigned DiagID, StringRef Arg1 = StringRef(), - StringRef Arg2 = StringRef()); - - ASTReader(const ASTReader &) = delete; - void operator=(const ASTReader &) = delete; -public: - /// \brief Load the AST file and validate its contents against the given - /// Preprocessor. - /// - /// \param PP the preprocessor associated with the context in which this - /// precompiled header will be loaded. - /// - /// \param Context the AST context that this precompiled header will be - /// loaded into. - /// - /// \param PCHContainerRdr the PCHContainerOperations to use for loading and - /// creating modules. - /// - /// \param Extensions the list of module file extensions that can be loaded - /// from the AST files. - /// - /// \param isysroot If non-NULL, the system include path specified by the - /// user. This is only used with relocatable PCH files. If non-NULL, - /// a relocatable PCH file will use the default path "/". - /// - /// \param DisableValidation If true, the AST reader will suppress most - /// of its regular consistency checking, allowing the use of precompiled - /// headers that cannot be determined to be compatible. - /// - /// \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. - /// - /// \param AllowConfigurationMismatch If true, the AST reader will not check - /// for configuration differences between the AST file and the invocation. - /// - /// \param ValidateSystemInputs If true, the AST reader will validate - /// system input files in addition to user input files. This is only - /// meaningful if \p DisableValidation is false. - /// - /// \param UseGlobalIndex If true, the AST reader will try to load and use - /// the global module index. - /// - /// \param ReadTimer If non-null, a timer used to track the time spent - /// deserializing. - ASTReader(Preprocessor &PP, ASTContext &Context, - const PCHContainerReader &PCHContainerRdr, - ArrayRef<IntrusiveRefCntPtr<ModuleFileExtension>> Extensions, - StringRef isysroot = "", bool DisableValidation = false, - bool AllowASTWithCompilerErrors = false, - bool AllowConfigurationMismatch = false, - bool ValidateSystemInputs = false, bool UseGlobalIndex = true, - std::unique_ptr<llvm::Timer> ReadTimer = {}); - - ~ASTReader() override; - - SourceManager &getSourceManager() const { return SourceMgr; } - FileManager &getFileManager() const { return FileMgr; } - DiagnosticsEngine &getDiags() const { return Diags; } - - /// \brief Flags that indicate what kind of AST loading failures the client - /// of the AST reader can directly handle. - /// - /// When a client states that it can handle a particular kind of failure, - /// the AST reader will not emit errors when producing that kind of failure. - enum LoadFailureCapabilities { - /// \brief The client can't handle any AST loading failures. - ARR_None = 0, - /// \brief The client can handle an AST file that cannot load because it - /// is missing. - ARR_Missing = 0x1, - /// \brief The client can handle an AST file that cannot load because it - /// is out-of-date relative to its input files. - ARR_OutOfDate = 0x2, - /// \brief The client can handle an AST file that cannot load because it - /// was built with a different version of Clang. - ARR_VersionMismatch = 0x4, - /// \brief The client can handle an AST file that cannot load because it's - /// compiled configuration doesn't match that of the context it was - /// loaded into. - ARR_ConfigurationMismatch = 0x8 - }; - - /// \brief Load the AST file designated by the given file name. - /// - /// \param FileName The name of the AST file to load. - /// - /// \param Type The kind of AST being loaded, e.g., PCH, module, main file, - /// or preamble. - /// - /// \param ImportLoc the location where the module file will be considered as - /// imported from. For non-module AST types it should be invalid. - /// - /// \param ClientLoadCapabilities The set of client load-failure - /// capabilities, represented as a bitset of the enumerators of - /// LoadFailureCapabilities. - ASTReadResult ReadAST(const std::string &FileName, ModuleKind Type, - SourceLocation ImportLoc, - unsigned ClientLoadCapabilities); - - /// \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 NameVisibility The level of visibility to give the names in the - /// module. Visibility can only be increased over time. - /// - /// \param ImportLoc The location at which the import occurs. - void makeModuleVisible(Module *Mod, - Module::NameVisibilityKind NameVisibility, - SourceLocation ImportLoc); - - /// \brief Make the names within this set of hidden names visible. - void makeNamesVisible(const HiddenNames &Names, Module *Owner); - - /// \brief Take the AST callbacks listener. - std::unique_ptr<ASTReaderListener> takeListener() { - return std::move(Listener); - } - - /// \brief Set the AST callbacks listener. - void setListener(std::unique_ptr<ASTReaderListener> Listener) { - this->Listener = std::move(Listener); - } - - /// \brief Add an AST callback listener. - /// - /// Takes ownership of \p L. - void addListener(std::unique_ptr<ASTReaderListener> L) { - if (Listener) - L = llvm::make_unique<ChainedASTReaderListener>(std::move(L), - std::move(Listener)); - Listener = std::move(L); - } - - /// RAII object to temporarily add an AST callback listener. - class ListenerScope { - ASTReader &Reader; - bool Chained; - - public: - ListenerScope(ASTReader &Reader, std::unique_ptr<ASTReaderListener> L) - : Reader(Reader), Chained(false) { - auto Old = Reader.takeListener(); - if (Old) { - Chained = true; - L = llvm::make_unique<ChainedASTReaderListener>(std::move(L), - std::move(Old)); - } - Reader.setListener(std::move(L)); - } - ~ListenerScope() { - auto New = Reader.takeListener(); - if (Chained) - Reader.setListener(static_cast<ChainedASTReaderListener *>(New.get()) - ->takeSecond()); - } - }; - - /// \brief Set the AST deserialization listener. - void setDeserializationListener(ASTDeserializationListener *Listener, - bool TakeOwnership = false); - - /// \brief Determine whether this AST reader has a global index. - bool hasGlobalIndex() const { return (bool)GlobalIndex; } - - /// \brief Return global module index. - GlobalModuleIndex *getGlobalIndex() { return GlobalIndex.get(); } - - /// \brief Reset reader for a reload try. - void resetForReload() { TriedLoadingGlobalIndex = false; } - - /// \brief Attempts to load the global index. - /// - /// \returns true if loading the global index has failed for any reason. - bool loadGlobalIndex(); - - /// \brief Determine whether we tried to load the global index, but failed, - /// e.g., because it is out-of-date or does not exist. - bool isGlobalIndexUnavailable() const; - - /// \brief Initializes the ASTContext - void InitializeContext(); - - /// \brief Update the state of Sema after loading some additional modules. - void UpdateSema(); - - /// \brief Add in-memory (virtual file) buffer. - void addInMemoryBuffer(StringRef &FileName, - std::unique_ptr<llvm::MemoryBuffer> Buffer) { - ModuleMgr.addInMemoryBuffer(FileName, std::move(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 for the primary - /// module file. - StringRef getOriginalSourceFile() { - return ModuleMgr.getPrimaryModule().OriginalSourceFileName; - } - - /// \brief Retrieve the name of the original source file name directly from - /// the AST file, without actually loading the AST file. - static std::string - getOriginalSourceFile(const std::string &ASTFileName, FileManager &FileMgr, - const PCHContainerReader &PCHContainerRdr, - DiagnosticsEngine &Diags); - - /// \brief Read the control block for the named AST file. - /// - /// \returns true if an error occurred, false otherwise. - static bool - readASTFileControlBlock(StringRef Filename, FileManager &FileMgr, - const PCHContainerReader &PCHContainerRdr, - bool FindModuleFileExtensions, - ASTReaderListener &Listener); - - /// \brief Determine whether the given AST file is acceptable to load into a - /// translation unit with the given language and target options. - static bool isAcceptableASTFile(StringRef Filename, FileManager &FileMgr, - const PCHContainerReader &PCHContainerRdr, - const LangOptions &LangOpts, - const TargetOptions &TargetOpts, - const PreprocessorOptions &PPOpts, - std::string ExistingModuleCachePath); - - /// \brief Returns the suggested contents of the predefines buffer, - /// which contains a (typically-empty) subset of the predefines - /// build prior to including the precompiled header. - const std::string &getSuggestedPredefines() { return SuggestedPredefines; } - - /// \brief Read a preallocated preprocessed entity from the external source. - /// - /// \returns null if an error occurred that prevented the preprocessed - /// entity from being loaded. - PreprocessedEntity *ReadPreprocessedEntity(unsigned Index) override; - - /// \brief Returns a pair of [Begin, End) indices of preallocated - /// preprocessed entities that \p Range encompasses. - std::pair<unsigned, unsigned> - findPreprocessedEntitiesInRange(SourceRange Range) override; - - /// \brief Optionally returns true or false if the preallocated preprocessed - /// entity with index \p Index came from file \p FID. - Optional<bool> isPreprocessedEntityInFileID(unsigned Index, - FileID FID) override; - - /// \brief Read the header file information for the given file entry. - HeaderFileInfo GetHeaderFileInfo(const FileEntry *FE) override; - - void ReadPragmaDiagnosticMappings(DiagnosticsEngine &Diag); - - /// \brief Returns the number of source locations found in the chain. - unsigned getTotalNumSLocs() const { - return TotalNumSLocEntries; - } - - /// \brief Returns the number of identifiers found in the chain. - unsigned getTotalNumIdentifiers() const { - return static_cast<unsigned>(IdentifiersLoaded.size()); - } - - /// \brief Returns the number of macros found in the chain. - unsigned getTotalNumMacros() const { - return static_cast<unsigned>(MacrosLoaded.size()); - } - - /// \brief Returns the number of types found in the chain. - unsigned getTotalNumTypes() const { - return static_cast<unsigned>(TypesLoaded.size()); - } - - /// \brief Returns the number of declarations found in the chain. - unsigned getTotalNumDecls() const { - 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()); - } - - /// \brief Returns the number of preprocessed entities known to the AST - /// reader. - unsigned getTotalNumPreprocessedEntities() const { - unsigned Result = 0; - for (ModuleConstIterator I = ModuleMgr.begin(), - E = ModuleMgr.end(); I != E; ++I) { - Result += (*I)->NumPreprocessedEntities; - } - - return Result; - } - - /// \brief Reads a TemplateArgumentLocInfo appropriate for the - /// given TemplateArgument kind. - TemplateArgumentLocInfo - GetTemplateArgumentLocInfo(ModuleFile &F, TemplateArgument::ArgKind Kind, - const RecordData &Record, unsigned &Idx); - - /// \brief Reads a TemplateArgumentLoc. - TemplateArgumentLoc - ReadTemplateArgumentLoc(ModuleFile &F, - const RecordData &Record, unsigned &Idx); - - const ASTTemplateArgumentListInfo* - ReadASTTemplateArgumentListInfo(ModuleFile &F, - const RecordData &Record, unsigned &Index); - - /// \brief Reads a declarator info from the given record. - TypeSourceInfo *GetTypeSourceInfo(ModuleFile &F, - const RecordData &Record, unsigned &Idx); - - /// \brief Resolve a type ID into a type, potentially building a new - /// type. - QualType GetType(serialization::TypeID ID); - - /// \brief Resolve a local type ID within a given AST file into a type. - 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(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(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 - /// global declaration ID. - serialization::DeclID getGlobalDeclID(ModuleFile &F, - serialization::LocalDeclID LocalID) const; - - /// \brief Returns true if global DeclID \p ID originated from module \p M. - 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(const Decl *D); - - /// \brief Get the best name we know for the module that owns the given - /// declaration, or an empty string if the declaration is not from a module. - std::string getOwningModuleNameForDiagnostic(const Decl *D); - - /// \brief Returns the source location for the decl \p ID. - SourceLocation getSourceLocationForDeclID(serialization::GlobalDeclID ID); - - /// \brief Resolve a declaration ID into a declaration, potentially - /// building a new declaration. - Decl *GetDecl(serialization::DeclID ID); - Decl *GetExternalDecl(uint32_t ID) override; - - /// \brief Resolve a declaration ID into a declaration. Return 0 if it's not - /// been loaded yet. - Decl *GetExistingDecl(serialization::DeclID ID); - - /// \brief Reads a declaration with the given local ID in the given module. - Decl *GetLocalDecl(ModuleFile &F, uint32_t LocalID) { - return GetDecl(getGlobalDeclID(F, LocalID)); - } - - /// \brief Reads a declaration with the given local ID in the given module. - /// - /// \returns The requested declaration, casted to the given return type. - template<typename T> - T *GetLocalDeclAs(ModuleFile &F, uint32_t LocalID) { - return cast_or_null<T>(GetLocalDecl(F, LocalID)); - } - - /// \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(ModuleFile &F, const RecordData &Record, - unsigned &Idx); - - /// \brief Reads a declaration from the given position in a record in the - /// given module. - 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(ModuleFile &F, const RecordData &R, unsigned &I) { - return cast_or_null<T>(GetDecl(ReadDeclID(F, R, I))); - } - - /// \brief If any redeclarations of \p D have been imported since it was - /// last checked, this digs out those redeclarations and adds them to the - /// redeclaration chain for \p D. - void CompleteRedeclChain(const Decl *D) override; - - /// \brief Read a CXXBaseSpecifiers ID form the given record and - /// return its global bit offset. - uint64_t readCXXBaseSpecifiers(ModuleFile &M, const RecordData &Record, - unsigned &Idx); - - CXXBaseSpecifier *GetExternalCXXBaseSpecifiers(uint64_t Offset) override; - - /// \brief Resolve the offset of a statement into a statement. - /// - /// This operation will read a new statement from the external - /// source each time it is called, and is meant to be used via a - /// LazyOffsetPtr (which is used by Decls for the body of functions, etc). - Stmt *GetExternalDeclStmt(uint64_t Offset) override; - - /// ReadBlockAbbrevs - Enter a subblock of the specified BlockID with the - /// specified cursor. Read the abbreviations that are at the top of the block - /// and then leave the cursor pointing into the block. - static bool ReadBlockAbbrevs(llvm::BitstreamCursor &Cursor, unsigned BlockID); - - /// \brief Finds all the visible declarations with a given name. - /// The current implementation of this method just loads the entire - /// lookup table as unmaterialized references. - bool FindExternalVisibleDeclsByName(const DeclContext *DC, - DeclarationName Name) override; - - /// \brief Read all of the declarations lexically stored in a - /// declaration context. - /// - /// \param DC The declaration context whose declarations will be - /// read. - /// - /// \param IsKindWeWant A predicate indicating which declaration kinds - /// we are interested in. - /// - /// \param Decls Vector that will contain the declarations loaded - /// from the external source. The caller is responsible for merging - /// these declarations with any declarations already stored in the - /// declaration context. - void - FindExternalLexicalDecls(const DeclContext *DC, - llvm::function_ref<bool(Decl::Kind)> IsKindWeWant, - SmallVectorImpl<Decl *> &Decls) override; - - /// \brief Get the decls that are contained in a file in the Offset/Length - /// range. \p Length can be 0 to indicate a point at \p Offset instead of - /// a range. - void FindFileRegionDecls(FileID File, unsigned Offset, unsigned Length, - SmallVectorImpl<Decl *> &Decls) override; - - /// \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. - void StartedDeserializing() override; - - /// \brief Notify ASTReader that we finished the deserialization of - /// a decl or type. Must be paired with StartedDeserializing. - void FinishedDeserializing() override; - - /// \brief Function that will be invoked when we begin parsing a new - /// translation unit involving this external AST source. - /// - /// This function will provide all of the external definitions to - /// the ASTConsumer. - void StartTranslationUnit(ASTConsumer *Consumer) override; - - /// \brief Print some statistics about AST usage. - void PrintStats() override; - - /// \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. - void getMemoryBufferSizes(MemoryBufferSizes &sizes) const override; - - /// \brief Initialize the semantic source with the Sema instance - /// being used to perform semantic analysis on the abstract syntax - /// tree. - void InitializeSema(Sema &S) override; - - /// \brief Inform the semantic consumer that Sema is no longer available. - void ForgetSema() override { SemaObj = nullptr; } - - /// \brief Retrieve the IdentifierInfo for the named identifier. - /// - /// This routine builds a new IdentifierInfo for the given identifier. If any - /// declarations with this name are visible from translation unit scope, their - /// declarations will be deserialized and introduced into the declaration - /// chain of the identifier. - IdentifierInfo *get(StringRef Name) override; - - /// \brief Retrieve an iterator into the set of all identifiers - /// in all loaded AST files. - IdentifierIterator *getIdentifiers() override; - - /// \brief Load the contents of the global method pool for a given - /// selector. - void ReadMethodPool(Selector Sel) override; - - /// \brief Load the set of namespaces that are known to the external source, - /// which will be used during typo correction. - void ReadKnownNamespaces( - SmallVectorImpl<NamespaceDecl *> &Namespaces) override; - - void ReadUndefinedButUsed( - llvm::DenseMap<NamedDecl *, SourceLocation> &Undefined) override; - - void ReadMismatchingDeleteExpressions(llvm::MapVector< - FieldDecl *, llvm::SmallVector<std::pair<SourceLocation, bool>, 4>> & - Exprs) override; - - void ReadTentativeDefinitions( - SmallVectorImpl<VarDecl *> &TentativeDefs) override; - - void ReadUnusedFileScopedDecls( - SmallVectorImpl<const DeclaratorDecl *> &Decls) override; - - void ReadDelegatingConstructors( - SmallVectorImpl<CXXConstructorDecl *> &Decls) override; - - void ReadExtVectorDecls(SmallVectorImpl<TypedefNameDecl *> &Decls) override; - - void ReadUnusedLocalTypedefNameCandidates( - llvm::SmallSetVector<const TypedefNameDecl *, 4> &Decls) override; - - void ReadReferencedSelectors( - SmallVectorImpl<std::pair<Selector, SourceLocation> > &Sels) override; - - void ReadWeakUndeclaredIdentifiers( - SmallVectorImpl<std::pair<IdentifierInfo *, WeakInfo> > &WI) override; - - void ReadUsedVTables(SmallVectorImpl<ExternalVTableUse> &VTables) override; - - void ReadPendingInstantiations( - SmallVectorImpl<std::pair<ValueDecl *, - SourceLocation> > &Pending) override; - - void ReadLateParsedTemplates( - llvm::MapVector<const FunctionDecl *, LateParsedTemplate *> &LPTMap) - override; - - /// \brief Load a selector from disk, registering its ID if it exists. - void LoadSelector(Selector Sel); - - void SetIdentifierInfo(unsigned ID, IdentifierInfo *II); - void SetGloballyVisibleDecls(IdentifierInfo *II, - const SmallVectorImpl<uint32_t> &DeclIDs, - SmallVectorImpl<Decl *> *Decls = nullptr); - - /// \brief Report a diagnostic. - DiagnosticBuilder Diag(unsigned DiagID); - - /// \brief Report a diagnostic. - DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID); - - IdentifierInfo *DecodeIdentifierInfo(serialization::IdentifierID ID); - - IdentifierInfo *GetIdentifierInfo(ModuleFile &M, const RecordData &Record, - unsigned &Idx) { - return DecodeIdentifierInfo(getGlobalIdentifierID(M, Record[Idx++])); - } - - IdentifierInfo *GetIdentifier(serialization::IdentifierID ID) override { - // Note that we are loading an identifier. - Deserializing AnIdentifier(this); - - return DecodeIdentifierInfo(ID); - } - - IdentifierInfo *getLocalIdentifier(ModuleFile &M, unsigned LocalID); - - serialization::IdentifierID getGlobalIdentifierID(ModuleFile &M, - unsigned LocalID); - - void resolvePendingMacro(IdentifierInfo *II, const PendingMacroInfo &PMInfo); - - /// \brief Retrieve the macro with the given ID. - MacroInfo *getMacro(serialization::MacroID ID); - - /// \brief Retrieve the global macro ID corresponding to the given local - /// ID within the given module file. - serialization::MacroID getGlobalMacroID(ModuleFile &M, unsigned LocalID); - - /// \brief Read the source location entry with index ID. - bool ReadSLocEntry(int ID) override; - - /// \brief Retrieve the module import location and module name for the - /// given source manager entry ID. - std::pair<SourceLocation, StringRef> getModuleImportLoc(int ID) override; - - /// \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 the module that corresponds to the given module ID. - /// - /// Note: overrides method in ExternalASTSource - Module *getModule(unsigned ID) override; - - /// \brief Retrieve the module file with a given local ID within the specified - /// ModuleFile. - ModuleFile *getLocalModuleFile(ModuleFile &M, unsigned ID); - - /// \brief Get an ID for the given module file. - unsigned getModuleFileID(ModuleFile *M); - - /// \brief Return a descriptor for the corresponding module. - llvm::Optional<ASTSourceDescriptor> getSourceDescriptor(unsigned ID) override; - - /// \brief Retrieve a selector from the given module with its local ID - /// number. - Selector getLocalSelector(ModuleFile &M, unsigned LocalID); - - Selector DecodeSelector(serialization::SelectorID Idx); - - Selector GetExternalSelector(serialization::SelectorID ID) override; - uint32_t GetNumExternalSelectors() override; - - 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(ModuleFile &F, - unsigned LocalID) const; - - /// \brief Read a declaration name. - DeclarationName ReadDeclarationName(ModuleFile &F, - const RecordData &Record, unsigned &Idx); - void ReadDeclarationNameLoc(ModuleFile &F, - DeclarationNameLoc &DNLoc, DeclarationName Name, - const RecordData &Record, unsigned &Idx); - void ReadDeclarationNameInfo(ModuleFile &F, DeclarationNameInfo &NameInfo, - const RecordData &Record, unsigned &Idx); - - void ReadQualifierInfo(ModuleFile &F, QualifierInfo &Info, - const RecordData &Record, unsigned &Idx); - - NestedNameSpecifier *ReadNestedNameSpecifier(ModuleFile &F, - const RecordData &Record, - unsigned &Idx); - - NestedNameSpecifierLoc ReadNestedNameSpecifierLoc(ModuleFile &F, - const RecordData &Record, - unsigned &Idx); - - /// \brief Read a template name. - TemplateName ReadTemplateName(ModuleFile &F, const RecordData &Record, - unsigned &Idx); - - /// \brief Read a template argument. - TemplateArgument ReadTemplateArgument(ModuleFile &F, const RecordData &Record, - unsigned &Idx, - bool Canonicalize = false); - - /// \brief Read a template parameter list. - TemplateParameterList *ReadTemplateParameterList(ModuleFile &F, - const RecordData &Record, - unsigned &Idx); - - /// \brief Read a template argument array. - void ReadTemplateArgumentList(SmallVectorImpl<TemplateArgument> &TemplArgs, - ModuleFile &F, const RecordData &Record, - unsigned &Idx, bool Canonicalize = false); - - /// \brief Read a UnresolvedSet structure. - void ReadUnresolvedSet(ModuleFile &F, LazyASTUnresolvedSet &Set, - const RecordData &Record, unsigned &Idx); - - /// \brief Read a C++ base specifier. - CXXBaseSpecifier ReadCXXBaseSpecifier(ModuleFile &F, - const RecordData &Record,unsigned &Idx); - - /// \brief Read a CXXCtorInitializer array. - CXXCtorInitializer ** - ReadCXXCtorInitializers(ModuleFile &F, const RecordData &Record, - unsigned &Idx); - - /// \brief Read a CXXCtorInitializers ID from the given record and - /// return its global bit offset. - uint64_t ReadCXXCtorInitializersRef(ModuleFile &M, const RecordData &Record, - unsigned &Idx); - - /// \brief Read the contents of a CXXCtorInitializer array. - CXXCtorInitializer **GetExternalCXXCtorInitializers(uint64_t Offset) override; - - /// \brief Read a source location from raw form. - SourceLocation ReadSourceLocation(ModuleFile &ModuleFile, unsigned Raw) const { - SourceLocation Loc = SourceLocation::getFromRawEncoding(Raw); - assert(ModuleFile.SLocRemap.find(Loc.getOffset()) != ModuleFile.SLocRemap.end() && - "Cannot find offset to remap."); - int Remap = ModuleFile.SLocRemap.find(Loc.getOffset())->second; - return Loc.getLocWithOffset(Remap); - } - - /// \brief Read a source location. - SourceLocation ReadSourceLocation(ModuleFile &ModuleFile, - const RecordDataImpl &Record, - unsigned &Idx) { - return ReadSourceLocation(ModuleFile, Record[Idx++]); - } - - /// \brief Read a source range. - SourceRange ReadSourceRange(ModuleFile &F, - const RecordData &Record, unsigned &Idx); - - /// \brief Read an integral value - llvm::APInt ReadAPInt(const RecordData &Record, unsigned &Idx); - - /// \brief Read a signed integral value - llvm::APSInt ReadAPSInt(const RecordData &Record, unsigned &Idx); - - /// \brief Read a floating-point value - llvm::APFloat ReadAPFloat(const RecordData &Record, - const llvm::fltSemantics &Sem, unsigned &Idx); - - // \brief Read a string - static std::string ReadString(const RecordData &Record, unsigned &Idx); - - // \brief Read a path - std::string ReadPath(ModuleFile &F, const RecordData &Record, unsigned &Idx); - - /// \brief Read a version tuple. - static VersionTuple ReadVersionTuple(const RecordData &Record, unsigned &Idx); - - CXXTemporary *ReadCXXTemporary(ModuleFile &F, const RecordData &Record, - unsigned &Idx); - - /// \brief Reads attributes from the current stream position. - void ReadAttributes(ModuleFile &F, AttrVec &Attrs, - const RecordData &Record, unsigned &Idx); - - /// \brief Reads a statement. - Stmt *ReadStmt(ModuleFile &F); - - /// \brief Reads an expression. - Expr *ReadExpr(ModuleFile &F); - - /// \brief Reads a sub-statement operand during statement reading. - Stmt *ReadSubStmt() { - assert(ReadingKind == Read_Stmt && - "Should be called only during statement reading!"); - // Subexpressions are stored from last to first, so the next Stmt we need - // is at the back of the stack. - assert(!StmtStack.empty() && "Read too many sub-statements!"); - return StmtStack.pop_back_val(); - } - - /// \brief Reads a sub-expression operand during statement reading. - Expr *ReadSubExpr(); - - /// \brief Reads a token out of a record. - Token ReadToken(ModuleFile &M, const RecordDataImpl &Record, unsigned &Idx); - - /// \brief Reads the macro record located at the given offset. - MacroInfo *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(ModuleFile &M, unsigned LocalID) const; - - /// \brief Add a macro to deserialize its macro directive history. - /// - /// \param II The name of the macro. - /// \param M The module file. - /// \param MacroDirectivesOffset Offset of the serialized macro directive - /// history. - void addPendingMacro(IdentifierInfo *II, ModuleFile *M, - uint64_t MacroDirectivesOffset); - - /// \brief Read the set of macros defined by this external macro source. - void ReadDefinedMacros() override; - - /// \brief Update an out-of-date identifier. - void updateOutOfDateIdentifier(IdentifierInfo &II) override; - - /// \brief Note that this identifier is up-to-date. - void markIdentifierUpToDate(IdentifierInfo *II); - - /// \brief Load all external visible decls in the given DeclContext. - void completeVisibleDeclsMap(const DeclContext *DC) override; - - /// \brief Retrieve the AST context that this AST reader supplements. - ASTContext &getContext() { return Context; } - - // \brief Contains the IDs for declarations that were requested before we have - // access to a Sema object. - SmallVector<uint64_t, 16> PreloadedDeclIDs; - - /// \brief Retrieve the semantic analysis object used to analyze the - /// translation unit in which the precompiled header is being - /// imported. - Sema *getSema() { return SemaObj; } - - /// \brief Retrieve the identifier table associated with the - /// preprocessor. - IdentifierTable &getIdentifierTable(); - - /// \brief Record that the given ID maps to the given switch-case - /// statement. - void RecordSwitchCaseID(SwitchCase *SC, unsigned ID); - - /// \brief Retrieve the switch-case statement with the given ID. - SwitchCase *getSwitchCaseWithID(unsigned ID); - - void ClearSwitchCaseIDs(); - - /// \brief Cursors for comments blocks. - SmallVector<std::pair<llvm::BitstreamCursor, - serialization::ModuleFile *>, 8> CommentsCursors; - - /// \brief Loads comments ranges. - void ReadComments() override; -}; - -/// \brief Helper class that saves the current stream position and -/// then restores it when destroyed. -struct SavedStreamPosition { - explicit SavedStreamPosition(llvm::BitstreamCursor &Cursor) - : Cursor(Cursor), Offset(Cursor.GetCurrentBitNo()) { } - - ~SavedStreamPosition() { - Cursor.JumpToBit(Offset); - } - -private: - llvm::BitstreamCursor &Cursor; - uint64_t Offset; -}; - -inline void PCHValidator::Error(const char *Msg) { - Reader.Error(Msg); -} - -} // end namespace clang - -#endif diff --git a/include/clang/Serialization/ASTWriter.h b/include/clang/Serialization/ASTWriter.h deleted file mode 100644 index ed34547..0000000 --- a/include/clang/Serialization/ASTWriter.h +++ /dev/null @@ -1,920 +0,0 @@ -//===--- ASTWriter.h - AST File Writer --------------------------*- 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 ASTWriter class, which writes an AST file -// containing a serialized representation of a translation unit. -// -//===----------------------------------------------------------------------===// -#ifndef LLVM_CLANG_SERIALIZATION_ASTWRITER_H -#define LLVM_CLANG_SERIALIZATION_ASTWRITER_H - -#include "clang/AST/ASTMutationListener.h" -#include "clang/AST/Decl.h" -#include "clang/AST/DeclarationName.h" -#include "clang/Frontend/PCHContainerOperations.h" -#include "clang/AST/TemplateBase.h" -#include "clang/Sema/SemaConsumer.h" -#include "clang/Serialization/ASTBitCodes.h" -#include "clang/Serialization/ASTDeserializationListener.h" -#include "llvm/ADT/DenseMap.h" -#include "llvm/ADT/DenseSet.h" -#include "llvm/ADT/MapVector.h" -#include "llvm/ADT/SetVector.h" -#include "llvm/ADT/SmallPtrSet.h" -#include "llvm/ADT/SmallVector.h" -#include "llvm/Bitcode/BitstreamWriter.h" -#include <map> -#include <queue> -#include <vector> - -namespace llvm { - class APFloat; - class APInt; - class BitstreamWriter; -} - -namespace clang { - -class ASTContext; -class Attr; -class NestedNameSpecifier; -class CXXBaseSpecifier; -class CXXCtorInitializer; -class FileEntry; -class FPOptions; -class HeaderSearch; -class HeaderSearchOptions; -class IdentifierResolver; -class MacroDefinitionRecord; -class MacroDirective; -class MacroInfo; -class OpaqueValueExpr; -class OpenCLOptions; -class ASTReader; -class Module; -class ModuleFileExtension; -class ModuleFileExtensionWriter; -class PreprocessedEntity; -class PreprocessingRecord; -class Preprocessor; -class RecordDecl; -class Sema; -class SourceManager; -struct StoredDeclsList; -class SwitchCase; -class TargetInfo; -class Token; -class VersionTuple; -class ASTUnresolvedSet; - -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 -/// representation of a given abstract syntax tree and its supporting -/// data structures. This bitstream can be de-serialized via an -/// instance of the ASTReader class. -class ASTWriter : public ASTDeserializationListener, - public ASTMutationListener { -public: - typedef SmallVector<uint64_t, 64> RecordData; - typedef SmallVectorImpl<uint64_t> RecordDataImpl; - typedef ArrayRef<uint64_t> RecordDataRef; - - friend class ASTDeclWriter; - friend class ASTStmtWriter; -private: - /// \brief Map that provides the ID numbers of each type within the - /// output stream, plus those deserialized from a chained PCH. - /// - /// The ID numbers of types are consecutive (in order of discovery) - /// and start at 1. 0 is reserved for NULL. When types are actually - /// stored in the stream, the ID number is shifted by 2 bits to - /// allow for the const/volatile qualifiers. - /// - /// Keys in the map never have const/volatile qualifiers. - typedef llvm::DenseMap<QualType, serialization::TypeIdx, - serialization::UnsafeQualTypeDenseMapInfo> - TypeIdxMap; - - /// \brief The bitstream writer used to emit this precompiled header. - llvm::BitstreamWriter &Stream; - - /// \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 The module we're currently writing, if any. - Module *WritingModule; - - /// \brief The base directory for any relative paths we emit. - std::string BaseDirectory; - - /// \brief Indicates whether timestamps should be written to the produced - /// module file. This is the case for files implicitly written to the - /// module cache, where we need the timestamps to determine if the module - /// file is up to date, but not otherwise. - bool IncludeTimestamps; - - /// \brief Indicates when the AST writing is actively performing - /// serialization, rather than just queueing updates. - bool WritingAST; - - /// \brief Indicates that we are done serializing the collection of decls - /// and types to emit. - bool DoneWritingDeclsAndTypes; - - /// \brief Indicates that the AST contained compiler errors. - bool ASTHasCompilerErrors; - - /// \brief Mapping from input file entries to the index into the - /// offset table where information about that input file is stored. - llvm::DenseMap<const FileEntry *, uint32_t> InputFileIDs; - - /// \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; - }; - - /// \brief The declarations and types to emit. - std::queue<DeclOrType> DeclTypesToEmit; - - /// \brief The first ID number we can use for our own declarations. - serialization::DeclID FirstDeclID; - - /// \brief The decl ID that will be assigned to the next new decl. - serialization::DeclID NextDeclID; - - /// \brief Map that provides the ID numbers of each declaration within - /// the output stream, as well as those deserialized from a chained PCH. - /// - /// The ID numbers of declarations are consecutive (in order of - /// discovery) and start at 2. 1 is reserved for the translation - /// unit, while 0 is reserved for NULL. - llvm::DenseMap<const Decl *, serialization::DeclID> DeclIDs; - - /// \brief Offset of each declaration in the bitstream, indexed by - /// the declaration's ID. - 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<FileID, 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; - - /// \brief The type ID that will be assigned to the next new type. - serialization::TypeID NextTypeID; - - /// \brief Map that provides the ID numbers of each type within the - /// output stream, plus those deserialized from a chained PCH. - /// - /// The ID numbers of types are consecutive (in order of discovery) - /// and start at 1. 0 is reserved for NULL. When types are actually - /// stored in the stream, the ID number is shifted by 2 bits to - /// allow for the const/volatile qualifiers. - /// - /// Keys in the map never have const/volatile qualifiers. - TypeIdxMap TypeIdxs; - - /// \brief Offset of each type in the bitstream, indexed by - /// the type's ID. - std::vector<uint32_t> TypeOffsets; - - /// \brief The first ID number we can use for our own identifiers. - serialization::IdentID FirstIdentID; - - /// \brief The identifier ID that will be assigned to the next new identifier. - serialization::IdentID NextIdentID; - - /// \brief Map that provides the ID numbers of each identifier in - /// the output stream. - /// - /// The ID numbers for identifiers are consecutive (in order of - /// discovery), starting at 1. An ID of zero refers to a NULL - /// IdentifierInfo. - llvm::MapVector<const IdentifierInfo *, serialization::IdentID> IdentifierIDs; - - /// \brief The first ID number we can use for our own macros. - serialization::MacroID FirstMacroID; - - /// \brief The identifier ID that will be assigned to the next new identifier. - serialization::MacroID NextMacroID; - - /// \brief Map that provides the ID numbers of each macro. - llvm::DenseMap<MacroInfo *, serialization::MacroID> MacroIDs; - - struct MacroInfoToEmitData { - const IdentifierInfo *Name; - MacroInfo *MI; - serialization::MacroID ID; - }; - /// \brief The macro infos to emit. - std::vector<MacroInfoToEmitData> MacroInfosToEmit; - - llvm::DenseMap<const IdentifierInfo *, uint64_t> IdentMacroDirectivesOffsetMap; - - /// @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 selector. - serialization::SelectorID NextSelectorID; - - /// \brief Map that provides the ID numbers of each Selector. - llvm::MapVector<Selector, serialization::SelectorID> SelectorIDs; - - /// \brief Offset of each selector within the method pool/selector - /// table, indexed by the Selector ID (-1). - std::vector<uint32_t> SelectorOffsets; - - /// \brief Mapping from macro definitions (as they occur in the preprocessing - /// record) to the macro IDs. - llvm::DenseMap<const MacroDefinitionRecord *, - serialization::PreprocessedEntityID> MacroDefinitions; - - /// \brief Cache of indices of anonymous declarations within their lexical - /// contexts. - llvm::DenseMap<const Decl *, unsigned> AnonymousDeclarationNumbers; - - /// An update to a Decl. - class DeclUpdate { - /// A DeclUpdateKind. - unsigned Kind; - union { - const Decl *Dcl; - void *Type; - unsigned Loc; - unsigned Val; - Module *Mod; - const Attr *Attribute; - }; - - public: - DeclUpdate(unsigned Kind) : Kind(Kind), Dcl(nullptr) {} - DeclUpdate(unsigned Kind, const Decl *Dcl) : Kind(Kind), Dcl(Dcl) {} - DeclUpdate(unsigned Kind, QualType Type) - : Kind(Kind), Type(Type.getAsOpaquePtr()) {} - DeclUpdate(unsigned Kind, SourceLocation Loc) - : Kind(Kind), Loc(Loc.getRawEncoding()) {} - DeclUpdate(unsigned Kind, unsigned Val) - : Kind(Kind), Val(Val) {} - DeclUpdate(unsigned Kind, Module *M) - : Kind(Kind), Mod(M) {} - DeclUpdate(unsigned Kind, const Attr *Attribute) - : Kind(Kind), Attribute(Attribute) {} - - unsigned getKind() const { return Kind; } - const Decl *getDecl() const { return Dcl; } - QualType getType() const { return QualType::getFromOpaquePtr(Type); } - SourceLocation getLoc() const { - return SourceLocation::getFromRawEncoding(Loc); - } - unsigned getNumber() const { return Val; } - Module *getModule() const { return Mod; } - const Attr *getAttr() const { return Attribute; } - }; - - typedef SmallVector<DeclUpdate, 1> UpdateRecord; - typedef llvm::MapVector<const Decl *, UpdateRecord> DeclUpdateMap; - /// \brief Mapping from declarations that came from a chained PCH to the - /// record containing modifications to them. - DeclUpdateMap DeclUpdates; - - typedef llvm::DenseMap<Decl *, Decl *> FirstLatestDeclMap; - /// \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. - /// - /// We keep track of external definitions and other 'interesting' declarations - /// as we are emitting declarations to the AST file. The AST file contains a - /// separate record for these declarations, which are provided to the AST - /// consumer by the AST reader. This is behavior is required to properly cope with, - /// e.g., tentative variable definitions that occur within - /// headers. The declarations themselves are stored as declaration - /// IDs, since they will be written out to an EAGERLY_DESERIALIZED_DECLS - /// record. - SmallVector<uint64_t, 16> EagerlyDeserializedDecls; - - /// \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. - llvm::SmallSetVector<const DeclContext *, 16> UpdatedDeclContexts; - - /// \brief Keeps track of visible decls that were added in DeclContexts - /// coming from another AST file. - SmallVector<const Decl *, 16> UpdatingVisibleDecls; - - /// \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 Decls that have been replaced in the current dependent AST file. - /// - /// When a decl changes fundamentally after being deserialized (this shouldn't - /// 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<ReplacedDeclInfo, 16> ReplacedDecls; - - /// \brief The set of declarations that may have redeclaration chains that - /// need to be serialized. - llvm::SmallVector<const Decl *, 16> Redeclarations; - - /// \brief A cache of the first local declaration for "interesting" - /// redeclaration chains. - llvm::DenseMap<const Decl *, const Decl *> FirstLocalDeclCache; - - /// \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. - SmallVector<Stmt *, 16> *CollectedStmts; - - /// \brief Mapping from SwitchCase statements to IDs. - llvm::DenseMap<SwitchCase *, unsigned> SwitchCaseIDs; - - /// \brief The number of statements written to the AST file. - unsigned NumStatements; - - /// \brief The number of macros written to the AST file. - unsigned NumMacros; - - /// \brief The number of lexical declcontexts written to the AST - /// file. - unsigned NumLexicalDeclContexts; - - /// \brief The number of visible declcontexts written to the AST - /// file. - unsigned NumVisibleDeclContexts; - - /// \brief The offset of each CXXBaseSpecifier set within the AST. - SmallVector<uint32_t, 16> 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 - /// 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. - 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 The offset of each CXXCtorInitializer list within the AST. - SmallVector<uint32_t, 16> CXXCtorInitializersOffsets; - - /// \brief The first ID number we can use for our own ctor initializers. - serialization::CXXCtorInitializersID FirstCXXCtorInitializersID; - - /// \brief The ctor initializers ID that will be assigned to the next new - /// list of C++ ctor initializers. - serialization::CXXCtorInitializersID NextCXXCtorInitializersID; - - /// \brief A set of C++ ctor initializers that is queued to be written - /// into the AST file. - struct QueuedCXXCtorInitializers { - QueuedCXXCtorInitializers() : ID() {} - - QueuedCXXCtorInitializers(serialization::CXXCtorInitializersID ID, - ArrayRef<CXXCtorInitializer*> Inits) - : ID(ID), Inits(Inits) {} - - serialization::CXXCtorInitializersID ID; - ArrayRef<CXXCtorInitializer*> Inits; - }; - - /// \brief Queue of C++ ctor initializers to be written to the AST file, - /// in the order they should be written. - SmallVector<QueuedCXXCtorInitializers, 2> CXXCtorInitializersToWrite; - - /// \brief A mapping from each known submodule to its ID number, which will - /// be a positive integer. - llvm::DenseMap<Module *, unsigned> SubmoduleIDs; - - /// \brief A list of the module file extension writers. - std::vector<std::unique_ptr<ModuleFileExtensionWriter>> - ModuleFileExtensionWriters; - - /// \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, - llvm::DenseMap<Stmt *, uint64_t> &SubStmtEntries, - llvm::DenseSet<Stmt *> &ParentStmts); - - void WriteBlockInfoBlock(); - uint64_t WriteControlBlock(Preprocessor &PP, ASTContext &Context, - StringRef isysroot, const std::string &OutputFile); - void WriteInputFiles(SourceManager &SourceMgr, HeaderSearchOptions &HSOpts, - bool Modules); - void WriteSourceManagerBlock(SourceManager &SourceMgr, - const Preprocessor &PP); - void WritePreprocessor(const Preprocessor &PP, bool IsModule); - void WriteHeaderSearch(const HeaderSearch &HS); - void WritePreprocessorDetail(PreprocessingRecord &PPRec); - void WriteSubmodules(Module *WritingModule); - - void WritePragmaDiagnosticMappings(const DiagnosticsEngine &Diag, - bool isModule); - void WriteCXXBaseSpecifiersOffsets(); - void WriteCXXCtorInitializersOffsets(); - - unsigned TypeExtQualAbbrev; - unsigned TypeFunctionProtoAbbrev; - void WriteTypeAbbrevs(); - void WriteType(QualType T); - - bool isLookupResultExternal(StoredDeclsList &Result, DeclContext *DC); - bool isLookupResultEntirelyExternal(StoredDeclsList &Result, DeclContext *DC); - - void GenerateNameLookupTable(const DeclContext *DC, - llvm::SmallVectorImpl<char> &LookupTable); - uint64_t WriteDeclContextLexicalBlock(ASTContext &Context, DeclContext *DC); - uint64_t WriteDeclContextVisibleBlock(ASTContext &Context, DeclContext *DC); - void WriteTypeDeclOffsets(); - void WriteFileDeclIDsMap(); - void WriteComments(); - void WriteSelectors(Sema &SemaRef); - void WriteReferencedSelectorsPool(Sema &SemaRef); - void WriteIdentifierTable(Preprocessor &PP, IdentifierResolver &IdResolver, - bool IsModule); - void WriteAttributes(ArrayRef<const Attr*> Attrs, RecordDataImpl &Record); - void WriteDeclUpdatesBlocks(RecordDataImpl &OffsetsRecord); - void WriteDeclReplacementsBlock(); - void WriteDeclContextVisibleUpdate(const DeclContext *DC); - void WriteFPPragmaOptions(const FPOptions &Opts); - void WriteOpenCLExtensions(Sema &SemaRef); - void WriteObjCCategories(); - void WriteLateParsedTemplates(Sema &SemaRef); - void WriteOptimizePragmaOptions(Sema &SemaRef); - void WriteModuleFileExtension(Sema &SemaRef, - ModuleFileExtensionWriter &Writer); - - unsigned DeclParmVarAbbrev; - unsigned DeclContextLexicalAbbrev; - unsigned DeclContextVisibleLookupAbbrev; - unsigned UpdateVisibleAbbrev; - unsigned DeclRecordAbbrev; - unsigned DeclTypedefAbbrev; - unsigned DeclVarAbbrev; - unsigned DeclFieldAbbrev; - unsigned DeclEnumAbbrev; - unsigned DeclObjCIvarAbbrev; - unsigned DeclCXXMethodAbbrev; - - unsigned DeclRefExprAbbrev; - unsigned CharacterLiteralAbbrev; - unsigned IntegerLiteralAbbrev; - unsigned ExprImplicitCastAbbrev; - - void WriteDeclAbbrevs(); - void WriteDecl(ASTContext &Context, Decl *D); - void AddFunctionDefinition(const FunctionDecl *FD, RecordData &Record); - - uint64_t WriteASTCore(Sema &SemaRef, - StringRef isysroot, const std::string &OutputFile, - Module *WritingModule); - -public: - /// \brief Create a new precompiled header writer that outputs to - /// the given bitstream. - ASTWriter(llvm::BitstreamWriter &Stream, - ArrayRef<llvm::IntrusiveRefCntPtr<ModuleFileExtension>> Extensions, - bool IncludeTimestamps = true); - ~ASTWriter() override; - - const LangOptions &getLangOpts() const; - - /// \brief Get a timestamp for output into the AST file. The actual timestamp - /// of the specified file may be ignored if we have been instructed to not - /// include timestamps in the output file. - time_t getTimestampForOutput(const FileEntry *E) const; - - /// \brief Write a precompiled header for the given semantic analysis. - /// - /// \param SemaRef a reference to the semantic analysis object that processed - /// the AST to be written into the 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. If we're writing a module, its - /// build directory will be used in preference to this if both are available. - /// - /// \return the module signature, which eventually will be a hash of - /// the module but currently is merely a random 32-bit number. - uint64_t WriteAST(Sema &SemaRef, const std::string &OutputFile, - Module *WritingModule, StringRef isysroot, - bool hasErrors = false); - - /// \brief Emit a token. - void AddToken(const Token &Tok, RecordDataImpl &Record); - - /// \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); - - /// \brief Emit a signed integral value. - void AddAPSInt(const llvm::APSInt &Value, RecordDataImpl &Record); - - /// \brief Emit a floating-point value. - void AddAPFloat(const llvm::APFloat &Value, RecordDataImpl &Record); - - /// \brief Emit a reference to an identifier. - void AddIdentifierRef(const IdentifierInfo *II, RecordDataImpl &Record); - - /// \brief Emit a Selector (which is a smart pointer reference). - void AddSelectorRef(Selector, RecordDataImpl &Record); - - /// \brief Emit a CXXTemporary. - void AddCXXTemporary(const CXXTemporary *Temp, RecordDataImpl &Record); - - /// \brief Emit a set of C++ base specifiers to the record. - 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); - - /// \brief Get the unique number used to refer to the given macro. - serialization::MacroID getMacroRef(MacroInfo *MI, const IdentifierInfo *Name); - - /// \brief Determine the ID of an already-emitted macro. - serialization::MacroID getMacroID(MacroInfo *MI); - - uint64_t getMacroDirectivesOffset(const IdentifierInfo *Name); - - /// \brief Emit a reference to a type. - void AddTypeRef(QualType T, RecordDataImpl &Record); - - /// \brief Force a type to be emitted and get its ID. - serialization::TypeID GetOrCreateTypeID(QualType T); - - /// \brief Determine the type ID of an already-emitted type. - serialization::TypeID getTypeID(QualType T) const; - - /// \brief Emits a reference to a declarator info. - void AddTypeSourceInfo(TypeSourceInfo *TInfo, RecordDataImpl &Record); - - /// \brief Emits a type with source-location information. - void AddTypeLoc(TypeLoc TL, RecordDataImpl &Record); - - /// \brief Emits a template argument location info. - void AddTemplateArgumentLocInfo(TemplateArgument::ArgKind Kind, - const TemplateArgumentLocInfo &Arg, - RecordDataImpl &Record); - - /// \brief Emits a template argument location. - void AddTemplateArgumentLoc(const TemplateArgumentLoc &Arg, - RecordDataImpl &Record); - - /// \brief Emits an AST template argument list info. - void AddASTTemplateArgumentListInfo( - const ASTTemplateArgumentListInfo *ASTTemplArgList, - RecordDataImpl &Record); - - /// \brief Find the first local declaration of a given local redeclarable - /// decl. - const Decl *getFirstLocalDecl(const Decl *D); - - /// \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); - - /// \brief Determine the declaration ID of an already-emitted - /// declaration. - serialization::DeclID getDeclID(const Decl *D); - - /// \brief Emit a declaration name. - void AddDeclarationName(DeclarationName Name, RecordDataImpl &Record); - void AddDeclarationNameLoc(const DeclarationNameLoc &DNLoc, - DeclarationName Name, RecordDataImpl &Record); - void AddDeclarationNameInfo(const DeclarationNameInfo &NameInfo, - RecordDataImpl &Record); - unsigned getAnonymousDeclarationNumber(const NamedDecl *D); - - void AddQualifierInfo(const QualifierInfo &Info, RecordDataImpl &Record); - - /// \brief Emit a nested name specifier. - void AddNestedNameSpecifier(NestedNameSpecifier *NNS, RecordDataImpl &Record); - - /// \brief Emit a nested name specifier with source-location information. - void AddNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS, - RecordDataImpl &Record); - - /// \brief Emit a template name. - void AddTemplateName(TemplateName Name, RecordDataImpl &Record); - - /// \brief Emit a template argument. - void AddTemplateArgument(const TemplateArgument &Arg, RecordDataImpl &Record); - - /// \brief Emit a template parameter list. - void AddTemplateParameterList(const TemplateParameterList *TemplateParams, - RecordDataImpl &Record); - - /// \brief Emit a template argument list. - void AddTemplateArgumentList(const TemplateArgumentList *TemplateArgs, - RecordDataImpl &Record); - - /// \brief Emit a UnresolvedSet structure. - void AddUnresolvedSet(const ASTUnresolvedSet &Set, RecordDataImpl &Record); - - /// \brief Emit a C++ base specifier. - void AddCXXBaseSpecifier(const CXXBaseSpecifier &Base, - RecordDataImpl &Record); - - /// \brief Emit the ID for a CXXCtorInitializer array and register the array - /// for later serialization. - void AddCXXCtorInitializersRef(ArrayRef<CXXCtorInitializer *> Inits, - RecordDataImpl &Record); - - /// \brief Emit a CXXCtorInitializer array. - void AddCXXCtorInitializers( - const CXXCtorInitializer * const *CtorInitializers, - unsigned NumCtorInitializers, - RecordDataImpl &Record); - - void AddCXXDefinitionData(const CXXRecordDecl *D, RecordDataImpl &Record); - - /// \brief Add a string to the given record. - void AddString(StringRef Str, RecordDataImpl &Record); - - /// \brief Convert a path from this build process into one that is appropriate - /// for emission in the module file. - bool PreparePathForOutput(SmallVectorImpl<char> &Path); - - /// \brief Add a path to the given record. - void AddPath(StringRef Path, RecordDataImpl &Record); - - /// \brief Emit the current record with the given path as a blob. - void EmitRecordWithPath(unsigned Abbrev, RecordDataRef Record, - StringRef Path); - - /// \brief Add a version tuple to the given record - void AddVersionTuple(const VersionTuple &Version, RecordDataImpl &Record); - - /// \brief Infer the submodule ID that contains an entity at the given - /// source location. - serialization::SubmoduleID inferSubmoduleIDFromLocation(SourceLocation Loc); - - /// \brief Retrieve or create a submodule ID for this module, or return 0 if - /// the submodule is neither local (a submodle of the currently-written module) - /// nor from an imported module. - unsigned getLocalOrImportedSubmoduleID(Module *Mod); - - /// \brief Note that the identifier II occurs at the given offset - /// within the identifier table. - void SetIdentifierOffset(const IdentifierInfo *II, uint32_t Offset); - - /// \brief Note that the selector Sel occurs at the given offset - /// within the method pool/selector table. - void SetSelectorOffset(Selector Sel, uint32_t Offset); - - /// \brief Add the given statement or expression to the queue of - /// statements to emit. - /// - /// This routine should be used when emitting types and declarations - /// that have expressions as part of their formulation. Once the - /// type or declaration has been written, call FlushStmts() to write - /// the corresponding statements just after the type or - /// declaration. - void AddStmt(Stmt *S) { - CollectedStmts->push_back(S); - } - - /// \brief Flush all of the statements and expressions that have - /// been added to the queue via AddStmt(). - void FlushStmts(); - - /// \brief Flush all of the C++ base specifier sets that have been added - /// via \c AddCXXBaseSpecifiersRef(). - void FlushCXXBaseSpecifiers(); - - /// \brief Flush all of the C++ constructor initializer lists that have been - /// added via \c AddCXXCtorInitializersRef(). - void FlushCXXCtorInitializers(); - - /// \brief Flush all pending records that are tacked onto the end of - /// decl and decl update records. - void FlushPendingAfterDecl() { - FlushStmts(); - FlushCXXBaseSpecifiers(); - FlushCXXCtorInitializers(); - } - - /// \brief Record an ID for the given switch-case statement. - unsigned RecordSwitchCaseID(SwitchCase *S); - - /// \brief Retrieve the ID for the given switch-case statement. - unsigned getSwitchCaseID(SwitchCase *S); - - void ClearSwitchCaseIDs(); - - unsigned getTypeExtQualAbbrev() const { - return TypeExtQualAbbrev; - } - unsigned getTypeFunctionProtoAbbrev() const { - return TypeFunctionProtoAbbrev; - } - - unsigned getDeclParmVarAbbrev() const { return DeclParmVarAbbrev; } - unsigned getDeclRecordAbbrev() const { return DeclRecordAbbrev; } - unsigned getDeclTypedefAbbrev() const { return DeclTypedefAbbrev; } - unsigned getDeclVarAbbrev() const { return DeclVarAbbrev; } - unsigned getDeclFieldAbbrev() const { return DeclFieldAbbrev; } - unsigned getDeclEnumAbbrev() const { return DeclEnumAbbrev; } - unsigned getDeclObjCIvarAbbrev() const { return DeclObjCIvarAbbrev; } - unsigned getDeclCXXMethodAbbrev() const { return DeclCXXMethodAbbrev; } - - unsigned getDeclRefExprAbbrev() const { return DeclRefExprAbbrev; } - unsigned getCharacterLiteralAbbrev() const { return CharacterLiteralAbbrev; } - unsigned getIntegerLiteralAbbrev() const { return IntegerLiteralAbbrev; } - unsigned getExprImplicitCastAbbrev() const { return ExprImplicitCastAbbrev; } - - bool hasChain() const { return Chain; } - ASTReader *getChain() const { return Chain; } - - // ASTDeserializationListener implementation - void ReaderInitialized(ASTReader *Reader) override; - void IdentifierRead(serialization::IdentID ID, IdentifierInfo *II) override; - void MacroRead(serialization::MacroID ID, MacroInfo *MI) override; - void TypeRead(serialization::TypeIdx Idx, QualType T) override; - void SelectorRead(serialization::SelectorID ID, Selector Sel) override; - void MacroDefinitionRead(serialization::PreprocessedEntityID ID, - MacroDefinitionRecord *MD) override; - void ModuleRead(serialization::SubmoduleID ID, Module *Mod) override; - - // ASTMutationListener implementation. - void CompletedTagDefinition(const TagDecl *D) override; - void AddedVisibleDecl(const DeclContext *DC, const Decl *D) override; - void AddedCXXImplicitMember(const CXXRecordDecl *RD, const Decl *D) override; - void ResolvedExceptionSpec(const FunctionDecl *FD) override; - void DeducedReturnType(const FunctionDecl *FD, QualType ReturnType) override; - void ResolvedOperatorDelete(const CXXDestructorDecl *DD, - const FunctionDecl *Delete) override; - void CompletedImplicitDefinition(const FunctionDecl *D) override; - void StaticDataMemberInstantiated(const VarDecl *D) override; - void FunctionDefinitionInstantiated(const FunctionDecl *D) override; - void AddedObjCCategoryToInterface(const ObjCCategoryDecl *CatD, - const ObjCInterfaceDecl *IFD) override; - void DeclarationMarkedUsed(const Decl *D) override; - void DeclarationMarkedOpenMPThreadPrivate(const Decl *D) override; - void RedefinedHiddenDefinition(const NamedDecl *D, Module *M) override; - void AddedAttributeToRecord(const Attr *Attr, - const RecordDecl *Record) override; -}; - -/// \brief AST and semantic-analysis consumer that generates a -/// precompiled header from the parsed source code. -class PCHGenerator : public SemaConsumer { - const Preprocessor &PP; - std::string OutputFile; - clang::Module *Module; - std::string isysroot; - Sema *SemaPtr; - std::shared_ptr<PCHBuffer> Buffer; - llvm::BitstreamWriter Stream; - ASTWriter Writer; - bool AllowASTWithErrors; - -protected: - ASTWriter &getWriter() { return Writer; } - const ASTWriter &getWriter() const { return Writer; } - SmallVectorImpl<char> &getPCH() const { return Buffer->Data; } - -public: - PCHGenerator( - const Preprocessor &PP, StringRef OutputFile, - clang::Module *Module, StringRef isysroot, - std::shared_ptr<PCHBuffer> Buffer, - ArrayRef<llvm::IntrusiveRefCntPtr<ModuleFileExtension>> Extensions, - bool AllowASTWithErrors = false, - bool IncludeTimestamps = true); - ~PCHGenerator() override; - void InitializeSema(Sema &S) override { SemaPtr = &S; } - void HandleTranslationUnit(ASTContext &Ctx) override; - ASTMutationListener *GetASTMutationListener() override; - ASTDeserializationListener *GetASTDeserializationListener() override; - bool hasEmittedPCH() const { return Buffer->IsComplete; } -}; - -} // end namespace clang - -#endif diff --git a/include/clang/Serialization/CMakeLists.txt b/include/clang/Serialization/CMakeLists.txt deleted file mode 100644 index d91513d..0000000 --- a/include/clang/Serialization/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -clang_tablegen(AttrPCHRead.inc -gen-clang-attr-pch-read - -I ${CMAKE_CURRENT_SOURCE_DIR}/../../ - SOURCE ../Basic/Attr.td - TARGET ClangAttrPCHRead) - -clang_tablegen(AttrPCHWrite.inc -gen-clang-attr-pch-write - -I ${CMAKE_CURRENT_SOURCE_DIR}/../../ - SOURCE ../Basic/Attr.td - TARGET ClangAttrPCHWrite) diff --git a/include/clang/Serialization/ContinuousRangeMap.h b/include/clang/Serialization/ContinuousRangeMap.h deleted file mode 100644 index 244b01b..0000000 --- a/include/clang/Serialization/ContinuousRangeMap.h +++ /dev/null @@ -1,139 +0,0 @@ -//===--- ContinuousRangeMap.h - Map with int range as key -------*- 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 ContinuousRangeMap class, which is a highly -// specialized container used by serialization. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_CLANG_SERIALIZATION_CONTINUOUSRANGEMAP_H -#define LLVM_CLANG_SERIALIZATION_CONTINUOUSRANGEMAP_H - -#include "clang/Basic/LLVM.h" -#include "llvm/ADT/SmallVector.h" -#include <algorithm> -#include <utility> - -namespace clang { - -/// \brief A map from continuous integer ranges to some value, with a very -/// specialized interface. -/// -/// CRM maps from integer ranges to values. The ranges are continuous, i.e. -/// where one ends, the next one begins. So if the map contains the stops I0-3, -/// the first range is from I0 to I1, the second from I1 to I2, the third from -/// I2 to I3 and the last from I3 to infinity. -/// -/// Ranges must be inserted in order. Inserting a new stop I4 into the map will -/// shrink the fourth range to I3 to I4 and add the new range I4 to inf. -template <typename Int, typename V, unsigned InitialCapacity> -class ContinuousRangeMap { -public: - typedef std::pair<Int, V> value_type; - typedef value_type &reference; - typedef const value_type &const_reference; - typedef value_type *pointer; - typedef const value_type *const_pointer; - -private: - typedef SmallVector<value_type, InitialCapacity> Representation; - Representation Rep; - - struct Compare { - bool operator ()(const_reference L, Int R) const { - return L.first < R; - } - bool operator ()(Int L, const_reference R) const { - return L < R.first; - } - bool operator ()(Int L, Int R) const { - return L < R; - } - bool operator ()(const_reference L, const_reference R) const { - return L.first < R.first; - } - }; - -public: - void insert(const value_type &Val) { - if (!Rep.empty() && Rep.back() == Val) - return; - - assert((Rep.empty() || Rep.back().first < Val.first) && - "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; - - iterator begin() { return Rep.begin(); } - iterator end() { return Rep.end(); } - const_iterator begin() const { return Rep.begin(); } - const_iterator end() const { return Rep.end(); } - - iterator find(Int K) { - iterator I = std::upper_bound(Rep.begin(), Rep.end(), K, Compare()); - // I points to the first entry with a key > K, which is the range that - // follows the one containing K. - if (I == Rep.begin()) - return Rep.end(); - --I; - return I; - } - const_iterator find(Int K) const { - return const_cast<ContinuousRangeMap*>(this)->find(K); - } - - reference back() { return Rep.back(); } - const_reference back() const { return Rep.back(); } - - /// \brief An object that helps properly build a continuous range map - /// from a set of values. - class Builder { - ContinuousRangeMap &Self; - - Builder(const Builder&) = delete; - Builder &operator=(const Builder&) = delete; - - public: - explicit Builder(ContinuousRangeMap &Self) : Self(Self) { } - - ~Builder() { - std::sort(Self.Rep.begin(), Self.Rep.end(), Compare()); - std::unique(Self.Rep.begin(), Self.Rep.end(), - [](const_reference A, const_reference B) { - // FIXME: we should not allow any duplicate keys, but there are a lot of - // duplicate 0 -> 0 mappings to remove first. - assert((A == B || A.first != B.first) && - "ContinuousRangeMap::Builder given non-unique keys"); - return A == B; - }); - } - - void insert(const value_type &Val) { - Self.Rep.push_back(Val); - } - }; - friend class Builder; -}; - -} - -#endif diff --git a/include/clang/Serialization/GlobalModuleIndex.h b/include/clang/Serialization/GlobalModuleIndex.h deleted file mode 100644 index 0f14eca..0000000 --- a/include/clang/Serialization/GlobalModuleIndex.h +++ /dev/null @@ -1,207 +0,0 @@ -//===--- GlobalModuleIndex.h - Global Module Index --------------*- 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 GlobalModuleIndex class, which manages a global index -// containing all of the identifiers known to the various modules within a given -// subdirectory of the module cache. It is used to improve the performance of -// queries such as "do any modules know about this identifier?" -// -//===----------------------------------------------------------------------===// -#ifndef LLVM_CLANG_SERIALIZATION_GLOBALMODULEINDEX_H -#define LLVM_CLANG_SERIALIZATION_GLOBALMODULEINDEX_H - -#include "llvm/ADT/DenseMap.h" -#include "llvm/ADT/SmallPtrSet.h" -#include "llvm/ADT/SmallVector.h" -#include "llvm/ADT/StringMap.h" -#include "llvm/ADT/StringRef.h" -#include <memory> -#include <utility> - -namespace llvm { -class BitstreamCursor; -class MemoryBuffer; -} - -namespace clang { - -class DirectoryEntry; -class FileEntry; -class FileManager; -class IdentifierIterator; -class PCHContainerOperations; -class PCHContainerReader; - -namespace serialization { - class ModuleFile; -} - -using llvm::SmallVector; -using llvm::SmallVectorImpl; -using llvm::StringRef; -using serialization::ModuleFile; - -/// \brief A global index for a set of module files, providing information about -/// the identifiers within those module files. -/// -/// The global index is an aid for name lookup into modules, offering a central -/// place where one can look for identifiers determine which -/// module files contain any information about that identifier. This -/// allows the client to restrict the search to only those module files known -/// to have a information about that identifier, improving performance. Moreover, -/// the global module index may know about module files that have not been -/// imported, and can be queried to determine which modules the current -/// translation could or should load to fix a problem. -class GlobalModuleIndex { - /// \brief Buffer containing the index file, which is lazily accessed so long - /// as the global module index is live. - std::unique_ptr<llvm::MemoryBuffer> Buffer; - - /// \brief The hash table. - /// - /// This pointer actually points to a IdentifierIndexTable object, - /// but that type is only accessible within the implementation of - /// GlobalModuleIndex. - void *IdentifierIndex; - - /// \brief Information about a given module file. - struct ModuleInfo { - ModuleInfo() : File(), Size(), ModTime() { } - - /// \brief The module file, once it has been resolved. - ModuleFile *File; - - /// \brief The module file name. - std::string FileName; - - /// \brief Size of the module file at the time the global index was built. - off_t Size; - - /// \brief Modification time of the module file at the time the global - /// index was built. - time_t ModTime; - - /// \brief The module IDs on which this module directly depends. - /// FIXME: We don't really need a vector here. - llvm::SmallVector<unsigned, 4> Dependencies; - }; - - /// \brief A mapping from module IDs to information about each module. - /// - /// This vector may have gaps, if module files have been removed or have - /// been updated since the index was built. A gap is indicated by an empty - /// file name. - llvm::SmallVector<ModuleInfo, 16> Modules; - - /// \brief Lazily-populated mapping from module files to their - /// corresponding index into the \c Modules vector. - llvm::DenseMap<ModuleFile *, unsigned> ModulesByFile; - - /// \brief The set of modules that have not yet been resolved. - /// - /// The string is just the name of the module itself, which maps to the - /// module ID. - llvm::StringMap<unsigned> UnresolvedModules; - - /// \brief The number of identifier lookups we performed. - unsigned NumIdentifierLookups; - - /// \brief The number of identifier lookup hits, where we recognize the - /// identifier. - unsigned NumIdentifierLookupHits; - - /// \brief Internal constructor. Use \c readIndex() to read an index. - explicit GlobalModuleIndex(std::unique_ptr<llvm::MemoryBuffer> Buffer, - llvm::BitstreamCursor Cursor); - - GlobalModuleIndex(const GlobalModuleIndex &) = delete; - GlobalModuleIndex &operator=(const GlobalModuleIndex &) = delete; - -public: - ~GlobalModuleIndex(); - - /// \brief An error code returned when trying to read an index. - enum ErrorCode { - /// \brief No error occurred. - EC_None, - /// \brief No index was found. - EC_NotFound, - /// \brief Some other process is currently building the index; it is not - /// available yet. - EC_Building, - /// \brief There was an unspecified I/O error reading or writing the index. - EC_IOError - }; - - /// \brief Read a global index file for the given directory. - /// - /// \param Path The path to the specific module cache where the module files - /// for the intended configuration reside. - /// - /// \returns A pair containing the global module index (if it exists) and - /// the error code. - static std::pair<GlobalModuleIndex *, ErrorCode> - readIndex(StringRef Path); - - /// \brief Returns an iterator for identifiers stored in the index table. - /// - /// The caller accepts ownership of the returned object. - IdentifierIterator *createIdentifierIterator() const; - - /// \brief Retrieve the set of modules that have up-to-date indexes. - /// - /// \param ModuleFiles Will be populated with the set of module files that - /// have been indexed. - void getKnownModules(SmallVectorImpl<ModuleFile *> &ModuleFiles); - - /// \brief Retrieve the set of module files on which the given module file - /// directly depends. - void getModuleDependencies(ModuleFile *File, - SmallVectorImpl<ModuleFile *> &Dependencies); - - /// \brief A set of module files in which we found a result. - typedef llvm::SmallPtrSet<ModuleFile *, 4> HitSet; - - /// \brief Look for all of the module files with information about the given - /// identifier, e.g., a global function, variable, or type with that name. - /// - /// \param Name The identifier to look for. - /// - /// \param Hits Will be populated with the set of module files that have - /// information about this name. - /// - /// \returns true if the identifier is known to the index, false otherwise. - bool lookupIdentifier(StringRef Name, HitSet &Hits); - - /// \brief Note that the given module file has been loaded. - /// - /// \returns false if the global module index has information about this - /// module file, and true otherwise. - bool loadedModuleFile(ModuleFile *File); - - /// \brief Print statistics to standard error. - void printStats(); - - /// \brief Print debugging view to standard error. - void dump(); - - /// \brief Write a global index into the given - /// - /// \param FileMgr The file manager to use to load module files. - /// \param PCHContainerRdr - The PCHContainerOperations to use for loading and - /// creating modules. - /// \param Path The path to the directory containing module files, into - /// which the global index will be written. - static ErrorCode writeIndex(FileManager &FileMgr, - const PCHContainerReader &PCHContainerRdr, - StringRef Path); -}; -} - -#endif diff --git a/include/clang/Serialization/Makefile b/include/clang/Serialization/Makefile deleted file mode 100644 index 386f453..0000000 --- a/include/clang/Serialization/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -CLANG_LEVEL := ../../.. -TD_SRC_DIR = $(PROJ_SRC_DIR)/../Basic -BUILT_SOURCES = AttrPCHRead.inc AttrPCHWrite.inc - -TABLEGEN_INC_FILES_COMMON = 1 - -include $(CLANG_LEVEL)/Makefile - -$(ObjDir)/AttrPCHRead.inc.tmp : $(TD_SRC_DIR)/Attr.td $(CLANG_TBLGEN) \ - $(ObjDir)/.dir - $(Echo) "Building Clang PCH reader with tblgen" - $(Verb) $(ClangTableGen) -gen-clang-attr-pch-read -o $(call SYSPATH, $@) \ - -I $(PROJ_SRC_DIR)/../../ $< - -$(ObjDir)/AttrPCHWrite.inc.tmp : $(TD_SRC_DIR)/Attr.td $(CLANG_TBLGEN) \ - $(ObjDir)/.dir - $(Echo) "Building Clang PCH writer with tblgen" - $(Verb) $(ClangTableGen) -gen-clang-attr-pch-write -o $(call SYSPATH, $@) \ - -I $(PROJ_SRC_DIR)/../../ $< diff --git a/include/clang/Serialization/Module.h b/include/clang/Serialization/Module.h deleted file mode 100644 index d6d16a0..0000000 --- a/include/clang/Serialization/Module.h +++ /dev/null @@ -1,475 +0,0 @@ -//===--- Module.h - Module description --------------------------*- 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 Module class, which describes a module that has -// been loaded from an AST file. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_CLANG_SERIALIZATION_MODULE_H -#define LLVM_CLANG_SERIALIZATION_MODULE_H - -#include "clang/Basic/FileManager.h" -#include "clang/Basic/SourceLocation.h" -#include "clang/Serialization/ASTBitCodes.h" -#include "clang/Serialization/ContinuousRangeMap.h" -#include "clang/Serialization/ModuleFileExtension.h" -#include "llvm/ADT/SetVector.h" -#include "llvm/Bitcode/BitstreamReader.h" -#include "llvm/Support/Endian.h" -#include <memory> -#include <string> - -namespace llvm { -template <typename Info> class OnDiskChainedHashTable; -template <typename Info> class OnDiskIterableChainedHashTable; -} - -namespace clang { - -class DeclContext; -class Module; - -namespace serialization { - -namespace reader { - class ASTDeclContextNameLookupTrait; -} - -/// \brief Specifies the kind of module that has been loaded. -enum ModuleKind { - MK_ImplicitModule, ///< File is an implicitly-loaded module. - MK_ExplicitModule, ///< File is an explicitly-loaded module. - MK_PCH, ///< File is a PCH file treated as such. - MK_Preamble, ///< File is a PCH file treated as the preamble. - MK_MainFile ///< File is a PCH file treated as the actual main file. -}; - -/// \brief The input file that has been loaded from this AST file, along with -/// bools indicating whether this was an overridden buffer or if it was -/// out-of-date or not-found. -class InputFile { - enum { - Overridden = 1, - OutOfDate = 2, - NotFound = 3 - }; - llvm::PointerIntPair<const FileEntry *, 2, unsigned> Val; - -public: - InputFile() {} - InputFile(const FileEntry *File, - bool isOverridden = false, bool isOutOfDate = false) { - assert(!(isOverridden && isOutOfDate) && - "an overridden cannot be out-of-date"); - unsigned intVal = 0; - if (isOverridden) - intVal = Overridden; - else if (isOutOfDate) - intVal = OutOfDate; - Val.setPointerAndInt(File, intVal); - } - - static InputFile getNotFound() { - InputFile File; - File.Val.setInt(NotFound); - return File; - } - - const FileEntry *getFile() const { return Val.getPointer(); } - bool isOverridden() const { return Val.getInt() == Overridden; } - bool isOutOfDate() const { return Val.getInt() == OutOfDate; } - bool isNotFound() const { return Val.getInt() == NotFound; } -}; - -typedef unsigned ASTFileSignature; - -/// \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 -/// other modules. -class ModuleFile { -public: - ModuleFile(ModuleKind Kind, unsigned Generation); - ~ModuleFile(); - - // === General information === - - /// \brief The index of this module in the list of modules. - unsigned Index; - - /// \brief The type of this module. - ModuleKind Kind; - - /// \brief The file name of the module file. - std::string FileName; - - /// \brief The name of the module. - std::string ModuleName; - - /// \brief The base directory of the module. - std::string BaseDirectory; - - std::string getTimestampFilename() const { - return FileName + ".timestamp"; - } - - /// \brief The original source file name that was used to build the - /// primary AST file, which may have been modified for - /// relocatable-pch support. - std::string OriginalSourceFileName; - - /// \brief The actual original source file name that was used to - /// build this AST file. - std::string ActualOriginalSourceFileName; - - /// \brief The file ID for the original source file that was used to - /// build this AST file. - FileID OriginalSourceFileID; - - /// \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; - - std::string ModuleMapPath; - - /// \brief Whether this precompiled header is a relocatable PCH file. - bool RelocatablePCH; - - /// \brief Whether timestamps are included in this module file. - bool HasTimestamps; - - /// \brief The file entry for the module file. - const FileEntry *File; - - /// \brief The signature of the module file, which may be used along with size - /// and modification time to identify this particular file. - ASTFileSignature Signature; - - /// \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. - std::unique_ptr<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 the module was explicitly or implicitly - /// imported in the local translation unit. - /// - /// If module A depends on and imports module B, both modules will have the - /// same DirectImportLoc, but different ImportLoc (B's ImportLoc will be a - /// source location inside module A). - /// - /// WARNING: This is largely useless. It doesn't tell you when a module was - /// made visible, just when the first submodule of that module was imported. - SourceLocation DirectImportLoc; - - /// \brief The source location where this module was first imported. - SourceLocation ImportLoc; - - /// \brief The first source location in this module. - SourceLocation FirstLoc; - - /// The list of extension readers that are attached to this module - /// file. - std::vector<std::unique_ptr<ModuleFileExtensionReader>> ExtensionReaders; - - // === Input Files === - /// \brief The cursor to the start of the input-files block. - llvm::BitstreamCursor InputFilesCursor; - - /// \brief Offsets for all of the input file entries in the AST file. - const llvm::support::unaligned_uint64_t *InputFileOffsets; - - /// \brief The input files that have been loaded from this AST file. - std::vector<InputFile> InputFilesLoaded; - - /// \brief If non-zero, specifies the time when we last validated input - /// files. Zero means we never validated them. - /// - /// The time is specified in seconds since the start of the Epoch. - uint64_t InputFilesValidationTimestamp; - - // === 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 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; - - /// \brief Offsets of identifiers that we're going to preload within - /// IdentifierTableData. - std::vector<unsigned> PreloadIdentifierOffsets; - - // === Macros === - - /// \brief The cursor to the start of the preprocessor block, which stores - /// all of the macro definitions. - llvm::BitstreamCursor MacroCursor; - - /// \brief The number of macros in this AST file. - unsigned LocalNumMacros; - - /// \brief Offsets of macros in the preprocessor block. - /// - /// This array is indexed by the macro ID (-1), and provides - /// the offset into the preprocessor block where macro definitions are - /// stored. - const uint32_t *MacroOffsets; - - /// \brief Base macro ID for macros local to this module. - serialization::MacroID BaseMacroID; - - /// \brief Remapping table for macro IDs in this module. - ContinuousRangeMap<uint32_t, int, 2> MacroRemap; - - /// \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 - /// 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 - /// 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 - /// 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; - - // === Submodule information === - /// \brief The number of submodules in this module. - unsigned LocalNumSubmodules; - - /// \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 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; - - /// \brief The number of C++ ctor initializer lists in this AST file. - unsigned LocalNumCXXCtorInitializers; - - /// \brief Offset of each C++ ctor initializer list within the bitstream, - /// indexed by the C++ ctor initializer list ID minus 1. - const uint32_t *CXXCtorInitializersOffsets; - - /// \brief Array of file-level DeclIDs sorted by file. - const serialization::DeclID *FileSortedDecls; - unsigned NumFileSortedDecls; - - /// \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 - /// 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 List of modules which depend on this module - llvm::SetVector<ModuleFile *> ImportedBy; - - /// \brief List of modules which this module depends on - llvm::SetVector<ModuleFile *> Imports; - - /// \brief Determine whether this module was directly imported at - /// any point during translation. - bool isDirectlyImported() const { return DirectlyImported; } - - /// \brief Is this a module file for a module (rather than a PCH or similar). - bool isModule() const { - return Kind == MK_ImplicitModule || Kind == MK_ExplicitModule; - } - - /// \brief Dump debugging output for this module. - void dump(); -}; - -} // end namespace serialization - -} // end namespace clang - -#endif diff --git a/include/clang/Serialization/ModuleFileExtension.h b/include/clang/Serialization/ModuleFileExtension.h deleted file mode 100644 index ba2e2fd..0000000 --- a/include/clang/Serialization/ModuleFileExtension.h +++ /dev/null @@ -1,149 +0,0 @@ -//===-- ModuleFileExtension.h - Module File Extensions ----------*- 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_SERIALIZATION_MODULEFILEEXTENSION_H -#define LLVM_CLANG_SERIALIZATION_MODULEFILEEXTENSION_H - -#include "llvm/ADT/IntrusiveRefCntPtr.h" -#include <memory> -#include <string> - -namespace llvm { -class BitstreamCursor; -class BitstreamWriter; -class hash_code; -class raw_ostream; -} - -namespace clang { - -class ASTReader; -class ASTWriter; -class Sema; - -namespace serialization { - class ModuleFile; -} // end namespace serialization - -/// Metadata for a module file extension. -struct ModuleFileExtensionMetadata { - /// The name used to identify this particular extension block within - /// the resulting module file. It should be unique to the particular - /// extension, because this name will be used to match the name of - /// an extension block to the appropriate reader. - std::string BlockName; - - /// The major version of the extension data. - unsigned MajorVersion; - - /// The minor version of the extension data. - unsigned MinorVersion; - - /// A string containing additional user information that will be - /// stored with the metadata. - std::string UserInfo; -}; - -class ModuleFileExtensionReader; -class ModuleFileExtensionWriter; - -/// An abstract superclass that describes a custom extension to the -/// module/precompiled header file format. -/// -/// A module file extension can introduce additional information into -/// compiled module files (.pcm) and precompiled headers (.pch) via a -/// custom writer that can then be accessed via a custom reader when -/// the module file or precompiled header is loaded. -class ModuleFileExtension : public llvm::RefCountedBase<ModuleFileExtension> { -public: - virtual ~ModuleFileExtension(); - - /// Retrieves the metadata for this module file extension. - virtual ModuleFileExtensionMetadata getExtensionMetadata() const = 0; - - /// Hash information about the presence of this extension into the - /// module hash code. - /// - /// The module hash code is used to distinguish different variants - /// of a module that are incompatible. If the presence, absence, or - /// version of the module file extension should force the creation - /// of a separate set of module files, override this method to - /// combine that distinguishing information into the module hash - /// code. - /// - /// The default implementation of this function simply returns the - /// hash code as given, so the presence/absence of this extension - /// does not distinguish module files. - virtual llvm::hash_code hashExtension(llvm::hash_code c) const; - - /// Create a new module file extension writer, which will be - /// responsible for writing the extension contents into a particular - /// module file. - virtual std::unique_ptr<ModuleFileExtensionWriter> - createExtensionWriter(ASTWriter &Writer) = 0; - - /// Create a new module file extension reader, given the - /// metadata read from the block and the cursor into the extension - /// block. - /// - /// May return null to indicate that an extension block with the - /// given metadata cannot be read. - virtual std::unique_ptr<ModuleFileExtensionReader> - createExtensionReader(const ModuleFileExtensionMetadata &Metadata, - ASTReader &Reader, serialization::ModuleFile &Mod, - const llvm::BitstreamCursor &Stream) = 0; -}; - -/// Abstract base class that writes a module file extension block into -/// a module file. -class ModuleFileExtensionWriter { - ModuleFileExtension *Extension; - -protected: - ModuleFileExtensionWriter(ModuleFileExtension *Extension) - : Extension(Extension) { } - -public: - virtual ~ModuleFileExtensionWriter(); - - /// Retrieve the module file extension with which this writer is - /// associated. - ModuleFileExtension *getExtension() const { return Extension; } - - /// Write the contents of the extension block into the given bitstream. - /// - /// Responsible for writing the contents of the extension into the - /// given stream. All of the contents should be written into custom - /// records with IDs >= FIRST_EXTENSION_RECORD_ID. - virtual void writeExtensionContents(Sema &SemaRef, - llvm::BitstreamWriter &Stream) = 0; -}; - -/// Abstract base class that reads a module file extension block from -/// a module file. -/// -/// Subclasses -class ModuleFileExtensionReader { - ModuleFileExtension *Extension; - -protected: - ModuleFileExtensionReader(ModuleFileExtension *Extension) - : Extension(Extension) { } - -public: - /// Retrieve the module file extension with which this reader is - /// associated. - ModuleFileExtension *getExtension() const { return Extension; } - - virtual ~ModuleFileExtensionReader(); -}; - -} // end namespace clang - -#endif // LLVM_CLANG_FRONTEND_MODULEFILEEXTENSION_H diff --git a/include/clang/Serialization/ModuleManager.h b/include/clang/Serialization/ModuleManager.h deleted file mode 100644 index 08e7d40..0000000 --- a/include/clang/Serialization/ModuleManager.h +++ /dev/null @@ -1,289 +0,0 @@ -//===--- ModuleManager.cpp - Module Manager ---------------------*- 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 ModuleManager class, which manages a set of loaded -// modules for the ASTReader. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_CLANG_SERIALIZATION_MODULEMANAGER_H -#define LLVM_CLANG_SERIALIZATION_MODULEMANAGER_H - -#include "clang/Basic/FileManager.h" -#include "clang/Serialization/Module.h" -#include "llvm/ADT/DenseMap.h" -#include "llvm/ADT/SmallPtrSet.h" - -namespace clang { - -class GlobalModuleIndex; -class ModuleMap; -class PCHContainerReader; - -namespace serialization { - -/// \brief Manages the set of modules loaded by an AST reader. -class ModuleManager { - /// \brief The chain of AST files, in the order in which we started to load - /// them (this order isn't really useful for anything). - SmallVector<ModuleFile *, 2> Chain; - - /// \brief The chain of non-module PCH files. The first entry is the one named - /// by the user, the last one is the one that doesn't depend on anything - /// further. - SmallVector<ModuleFile *, 2> PCHChain; - - // \brief The roots of the dependency DAG of AST files. This is used - // to implement short-circuiting logic when running DFS over the dependencies. - SmallVector<ModuleFile *, 2> Roots; - - /// \brief All loaded modules, indexed by name. - llvm::DenseMap<const FileEntry *, ModuleFile *> Modules; - - /// \brief FileManager that handles translating between filenames and - /// FileEntry *. - FileManager &FileMgr; - - /// \brief Knows how to unwrap module containers. - const PCHContainerReader &PCHContainerRdr; - - /// \brief A lookup of in-memory (virtual file) buffers - llvm::DenseMap<const FileEntry *, std::unique_ptr<llvm::MemoryBuffer>> - InMemoryBuffers; - - /// \brief The visitation order. - SmallVector<ModuleFile *, 4> VisitOrder; - - /// \brief The list of module files that both we and the global module index - /// know about. - /// - /// Either the global index or the module manager may have modules that the - /// other does not know about, because the global index can be out-of-date - /// (in which case the module manager could have modules it does not) and - /// this particular translation unit might not have loaded all of the modules - /// known to the global index. - SmallVector<ModuleFile *, 4> ModulesInCommonWithGlobalIndex; - - /// \brief The global module index, if one is attached. - /// - /// The global module index will actually be owned by the ASTReader; this is - /// just an non-owning pointer. - GlobalModuleIndex *GlobalIndex; - - /// \brief State used by the "visit" operation to avoid malloc traffic in - /// calls to visit(). - struct VisitState { - explicit VisitState(unsigned N) - : VisitNumber(N, 0), NextVisitNumber(1), NextState(nullptr) - { - Stack.reserve(N); - } - - ~VisitState() { - delete NextState; - } - - /// \brief The stack used when marking the imports of a particular module - /// as not-to-be-visited. - SmallVector<ModuleFile *, 4> Stack; - - /// \brief The visit number of each module file, which indicates when - /// this module file was last visited. - SmallVector<unsigned, 4> VisitNumber; - - /// \brief The next visit number to use to mark visited module files. - unsigned NextVisitNumber; - - /// \brief The next visit state. - VisitState *NextState; - }; - - /// \brief The first visit() state in the chain. - VisitState *FirstVisitState; - - VisitState *allocateVisitState(); - void returnVisitState(VisitState *State); - -public: - typedef SmallVectorImpl<ModuleFile*>::iterator ModuleIterator; - typedef SmallVectorImpl<ModuleFile*>::const_iterator ModuleConstIterator; - typedef SmallVectorImpl<ModuleFile*>::reverse_iterator ModuleReverseIterator; - typedef std::pair<uint32_t, StringRef> ModuleOffset; - - explicit ModuleManager(FileManager &FileMgr, - const PCHContainerReader &PCHContainerRdr); - ~ModuleManager(); - - /// \brief Forward iterator to traverse all loaded modules. - ModuleIterator begin() { return Chain.begin(); } - /// \brief Forward iterator end-point to traverse all loaded modules - ModuleIterator end() { return Chain.end(); } - - /// \brief Const forward iterator to traverse all loaded modules. - ModuleConstIterator begin() const { return Chain.begin(); } - /// \brief Const forward iterator end-point to traverse all loaded modules - ModuleConstIterator end() const { return Chain.end(); } - - /// \brief Reverse iterator to traverse all loaded modules. - ModuleReverseIterator rbegin() { return Chain.rbegin(); } - /// \brief Reverse iterator end-point to traverse all loaded modules. - ModuleReverseIterator rend() { return Chain.rend(); } - - /// \brief A range covering the PCH and preamble module files loaded. - llvm::iterator_range<ModuleConstIterator> pch_modules() const { - return llvm::make_range(PCHChain.begin(), PCHChain.end()); - } - - /// \brief Returns the primary module associated with the manager, that is, - /// the first module loaded - ModuleFile &getPrimaryModule() { return *Chain[0]; } - - /// \brief Returns the primary module associated with the manager, that is, - /// the first module loaded. - ModuleFile &getPrimaryModule() const { return *Chain[0]; } - - /// \brief Returns the module associated with the given index - ModuleFile &operator[](unsigned Index) const { return *Chain[Index]; } - - /// \brief Returns the module associated with the given name - ModuleFile *lookup(StringRef Name); - - /// \brief Returns the module associated with the given module file. - ModuleFile *lookup(const FileEntry *File); - - /// \brief Returns the in-memory (virtual file) buffer with the given name - std::unique_ptr<llvm::MemoryBuffer> lookupBuffer(StringRef Name); - - /// \brief Number of modules loaded - unsigned size() const { return Chain.size(); } - - /// \brief The result of attempting to add a new module. - enum AddModuleResult { - /// \brief The module file had already been loaded. - AlreadyLoaded, - /// \brief The module file was just loaded in response to this call. - NewlyLoaded, - /// \brief The module file is missing. - Missing, - /// \brief The module file is out-of-date. - OutOfDate - }; - - typedef ASTFileSignature(*ASTFileSignatureReader)(llvm::BitstreamReader &); - - /// \brief Attempts to create a new module and add it to the list of known - /// modules. - /// - /// \param FileName The file name of the module to be loaded. - /// - /// \param Type The kind of module being loaded. - /// - /// \param ImportLoc The location at which the module is imported. - /// - /// \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 ExpectedSize The expected size of the module file, used for - /// validation. This will be zero if unknown. - /// - /// \param ExpectedModTime The expected modification time of the module - /// file, used for validation. This will be zero if unknown. - /// - /// \param ExpectedSignature The expected signature of the module file, used - /// for validation. This will be zero if unknown. - /// - /// \param ReadSignature Reads the signature from an AST file without actually - /// loading it. - /// - /// \param Module A pointer to the module file if the module was successfully - /// 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 value indicating whether the module was loaded. - AddModuleResult addModule(StringRef FileName, ModuleKind Type, - SourceLocation ImportLoc, - ModuleFile *ImportedBy, unsigned Generation, - off_t ExpectedSize, time_t ExpectedModTime, - ASTFileSignature ExpectedSignature, - ASTFileSignatureReader ReadSignature, - ModuleFile *&Module, - std::string &ErrorStr); - - /// \brief Remove the given set of modules. - void removeModules(ModuleIterator first, ModuleIterator last, - llvm::SmallPtrSetImpl<ModuleFile *> &LoadedSuccessfully, - ModuleMap *modMap); - - /// \brief Add an in-memory buffer the list of known buffers - void addInMemoryBuffer(StringRef FileName, - std::unique_ptr<llvm::MemoryBuffer> Buffer); - - /// \brief Set the global module index. - void setGlobalIndex(GlobalModuleIndex *Index); - - /// \brief Notification from the AST reader that the given module file - /// has been "accepted", and will not (can not) be unloaded. - void moduleFileAccepted(ModuleFile *MF); - - /// \brief Visit each of the modules. - /// - /// This routine visits each of the modules, starting with the - /// "root" modules that no other loaded modules depend on, and - /// proceeding to the leaf modules, visiting each module only once - /// during the traversal. - /// - /// This traversal is intended to support various "lookup" - /// operations that can find data in any of the loaded modules. - /// - /// \param Visitor A visitor function that will be invoked with each - /// module. The return value must be convertible to bool; when false, the - /// visitation continues to modules that the current module depends on. When - /// true, the visitation skips any modules that the current module depends on. - /// - /// \param ModuleFilesHit If non-NULL, contains the set of module files - /// that we know we need to visit because the global module index told us to. - /// Any module that is known to both the global module index and the module - /// manager that is *not* in this set can be skipped. - void visit(llvm::function_ref<bool(ModuleFile &M)> Visitor, - llvm::SmallPtrSetImpl<ModuleFile *> *ModuleFilesHit = nullptr); - - /// \brief Attempt to resolve the given module file name to a file entry. - /// - /// \param FileName The name of the module file. - /// - /// \param ExpectedSize The size that the module file is expected to have. - /// If the actual size differs, the resolver should return \c true. - /// - /// \param ExpectedModTime The modification time that the module file is - /// expected to have. If the actual modification time differs, the resolver - /// should return \c true. - /// - /// \param File Will be set to the file if there is one, or null - /// otherwise. - /// - /// \returns True if a file exists but does not meet the size/ - /// modification time criteria, false if the file is either available and - /// suitable, or is missing. - bool lookupModuleFile(StringRef FileName, - off_t ExpectedSize, - time_t ExpectedModTime, - const FileEntry *&File); - - /// \brief View the graphviz representation of the module graph. - void viewGraph(); -}; - -} } // end namespace clang::serialization - -#endif diff --git a/include/clang/Serialization/SerializationDiagnostic.h b/include/clang/Serialization/SerializationDiagnostic.h deleted file mode 100644 index d50422a..0000000 --- a/include/clang/Serialization/SerializationDiagnostic.h +++ /dev/null @@ -1,28 +0,0 @@ -//===--- 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_SERIALIZATION_SERIALIZATIONDIAGNOSTIC_H -#define LLVM_CLANG_SERIALIZATION_SERIALIZATIONDIAGNOSTIC_H - -#include "clang/Basic/Diagnostic.h" - -namespace clang { - namespace diag { - enum { -#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,\ - SFINAE,NOWERROR,SHOWINSYSHEADER,CATEGORY) ENUM, -#define SERIALIZATIONSTART -#include "clang/Basic/DiagnosticSerializationKinds.inc" -#undef DIAG - NUM_BUILTIN_SERIALIZATION_DIAGNOSTICS - }; - } // end namespace diag -} // end namespace clang - -#endif |