[cfe-commits] r135705 - in /cfe/trunk: include/clang/Serialization/ASTReader.h lib/Serialization/ASTReader.cpp
Jonathan D. Turner
jonathan.d.turner at gmail.com
Thu Jul 21 14:15:19 PDT 2011
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;
+
break;
}
@@ -3920,14 +3931,6 @@
return I->second;
}
-unsigned ASTReader::getTotalNumCXXBaseSpecifiers() const {
- unsigned Result = 0;
- for (unsigned I = 0, N = Chain.size(); I != N; ++I)
- Result += Chain[I]->LocalNumCXXBaseSpecifiers;
-
- return Result;
-}
-
TemplateArgumentLocInfo
ASTReader::GetTemplateArgumentLocInfo(PerFileData &F,
TemplateArgument::ArgKind Kind,
@@ -3984,21 +3987,17 @@
ASTReader::GetCXXBaseSpecifiersOffset(serialization::CXXBaseSpecifiersID ID) {
if (ID == 0)
return 0;
-
- --ID;
- uint64_t Offset = 0;
- for (unsigned I = 0, N = Chain.size(); I != N; ++I) {
- PerFileData &F = *Chain[N - I - 1];
- if (ID < F.LocalNumCXXBaseSpecifiers)
- return Offset + F.CXXBaseSpecifiersOffsets[ID];
-
- ID -= F.LocalNumCXXBaseSpecifiers;
- Offset += F.SizeInBits;
- }
+ GlobalCXXBaseSpecifiersMapType::iterator I =
+ GlobalCXXBaseSpecifiersMap.find(ID);
+
+ assert (I != GlobalCXXBaseSpecifiersMap.end() &&
+ "Corrupted global CXX base specifiers map");
- assert(false && "CXXBaseSpecifiers not found");
- return 0;
+ return I->second.first->CXXBaseSpecifiersOffsets[ID - 1 +
+ I->second.second] +
+ I->second.first->GlobalBitOffset;
+
}
CXXBaseSpecifier *ASTReader::GetExternalCXXBaseSpecifiers(uint64_t Offset) {
@@ -5309,8 +5308,9 @@
TotalNumMacros(0), NumSelectorsRead(0), NumMethodPoolEntriesRead(0),
NumMethodPoolMisses(0), TotalNumMethodPoolEntries(0),
NumLexicalDeclContextsRead(0), TotalLexicalDeclContexts(0),
- NumVisibleDeclContextsRead(0), TotalVisibleDeclContexts(0),
- NumCurrentElementsDeserializing(0)
+ NumVisibleDeclContextsRead(0), TotalVisibleDeclContexts(0),
+ TotalModulesSizeInBits(0), NumCurrentElementsDeserializing(0),
+ NumCXXBaseSpecifiersLoaded(0)
{
SourceMgr.setExternalSLocEntrySource(this);
}
@@ -5328,7 +5328,8 @@
NumSelectorsRead(0), NumMethodPoolEntriesRead(0), NumMethodPoolMisses(0),
TotalNumMethodPoolEntries(0), NumLexicalDeclContextsRead(0),
TotalLexicalDeclContexts(0), NumVisibleDeclContextsRead(0),
- TotalVisibleDeclContexts(0), NumCurrentElementsDeserializing(0)
+ TotalVisibleDeclContexts(0), TotalModulesSizeInBits(0),
+ NumCurrentElementsDeserializing(0), NumCXXBaseSpecifiersLoaded(0)
{
SourceMgr.setExternalSLocEntrySource(this);
}
More information about the cfe-commits
mailing list