[cfe-commits] r135705 - in /cfe/trunk: include/clang/Serialization/ASTReader.h lib/Serialization/ASTReader.cpp
Douglas Gregor
dgregor at apple.com
Thu Jul 21 14:23:32 PDT 2011
On Jul 21, 2011, at 2:15 PM, Jonathan D. Turner wrote:
> Author: jonturner
> Date: Thu Jul 21 16:15:19 2011
> New Revision: 135705
>
> URL: http://llvm.org/viewvc/llvm-project?rev=135705&view=rev
> Log:
> Cleaning up more of the ID situation in the AST reader. This patch relaxes and generalizes how CXX base specifiers are identified and loaded by using a ContinuousRangeMap. This also adds a global bit offset (or base) to the PerFileData.
>
>
> Modified:
> cfe/trunk/include/clang/Serialization/ASTReader.h
> cfe/trunk/lib/Serialization/ASTReader.cpp
>
> Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=135705&r1=135704&r2=135705&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
> +++ cfe/trunk/include/clang/Serialization/ASTReader.h Thu Jul 21 16:15:19 2011
> @@ -244,6 +244,9 @@
> /// \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;
>
> @@ -613,6 +616,15 @@
> /// added to the global preprocessing entitiy ID to produce a local ID.
> GlobalPreprocessedEntityMapType GlobalPreprocessedEntityMap;
>
> + typedef ContinuousRangeMap<serialization::CXXBaseSpecifiersID,
> + std::pair<PerFileData *, int32_t>, 4>
> + GlobalCXXBaseSpecifiersMapType;
> +
> + /// \brief Mapping from global CXX base specifier IDs to the module in which the
> + /// CXX base specifier resides along with the offset that should be added to the
> + /// global CXX base specifer ID to produce a local ID.
> + GlobalCXXBaseSpecifiersMapType GlobalCXXBaseSpecifiersMap;
> +
> /// \name CodeGen-relevant special data
> /// \brief Fields containing data that is relevant to CodeGen.
> //@{
> @@ -793,9 +805,15 @@
> /// 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;
>
> + /// Number of CXX base specifiers currently loaded
> + unsigned NumCXXBaseSpecifiersLoaded;
> +
> /// \brief An IdentifierInfo that has been loaded but whose top-level
> /// declarations of the same name have not (yet) been loaded.
> struct PendingIdentifierInfo {
> @@ -1067,7 +1085,9 @@
> }
>
> /// \brief Returns the number of C++ base specifiers found in the chain.
> - unsigned getTotalNumCXXBaseSpecifiers() const;
> + unsigned getTotalNumCXXBaseSpecifiers() const {
> + return NumCXXBaseSpecifiersLoaded;
> + }
>
> /// \brief Reads a TemplateArgumentLocInfo appropriate for the
> /// given TemplateArgument kind.
>
> Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=135705&r1=135704&r2=135705&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
> +++ cfe/trunk/lib/Serialization/ASTReader.cpp Thu Jul 21 16:15:19 2011
> @@ -2427,6 +2427,17 @@
>
> F.LocalNumCXXBaseSpecifiers = Record[0];
> F.CXXBaseSpecifiersOffsets = (const uint32_t *)BlobStart;
> +
> + GlobalCXXBaseSpecifiersMap.insert(std::make_pair(
> + getTotalNumCXXBaseSpecifiers() + 1,
> + std::make_pair(&F,
> + -getTotalNumCXXBaseSpecifiers())));
> +
> + NumCXXBaseSpecifiersLoaded += F.LocalNumCXXBaseSpecifiers;
> +
> + F.GlobalBitOffset = TotalModulesSizeInBits;
> + TotalModulesSizeInBits += F.SizeInBits;
This isn't the right place to update TotalModulesSizeInBits; it would break if some AST file in the chain didn't have any CXXBaseSpecifiers!
- Doug
More information about the cfe-commits
mailing list