[cfe-commits] r117873 - /cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
Anders Carlsson
andersca at mac.com
Sun Oct 31 14:22:43 PDT 2010
Author: andersca
Date: Sun Oct 31 16:22:43 2010
New Revision: 117873
URL: http://llvm.org/viewvc/llvm-project?rev=117873&view=rev
Log:
Use CharUnits in the EmptyClassOffsets map.
Modified:
cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayoutBuilder.cpp?rev=117873&r1=117872&r2=117873&view=diff
==============================================================================
--- cfe/trunk/lib/AST/RecordLayoutBuilder.cpp (original)
+++ cfe/trunk/lib/AST/RecordLayoutBuilder.cpp Sun Oct 31 16:22:43 2010
@@ -63,7 +63,7 @@
/// EmptyClassOffsets - A map from offsets to empty record decls.
typedef llvm::SmallVector<const CXXRecordDecl *, 1> ClassVectorTy;
- typedef llvm::DenseMap<uint64_t, ClassVectorTy> EmptyClassOffsetsMapTy;
+ typedef llvm::DenseMap<CharUnits, ClassVectorTy> EmptyClassOffsetsMapTy;
EmptyClassOffsetsMapTy EmptyClassOffsets;
/// MaxEmptyClassOffset - The highest offset known to contain an empty
@@ -90,6 +90,14 @@
return Offset <= MaxEmptyClassOffset;
}
+ // FIXME: Remove these.
+ CharUnits toCharUnits(uint64_t Offset) const {
+ return CharUnits::fromQuantity(Offset / Context.getCharWidth());
+ }
+ uint64_t toOffset(CharUnits Offset) const {
+ return Offset.getQuantity() * Context.getCharWidth();
+ }
+
protected:
bool CanPlaceSubobjectAtOffset(const CXXRecordDecl *RD,
uint64_t Offset) const;
@@ -183,7 +191,8 @@
if (!RD->isEmpty())
return true;
- EmptyClassOffsetsMapTy::const_iterator I = EmptyClassOffsets.find(Offset);
+ EmptyClassOffsetsMapTy::const_iterator I =
+ EmptyClassOffsets.find(toCharUnits(Offset));
if (I == EmptyClassOffsets.end())
return true;
@@ -201,7 +210,7 @@
if (!RD->isEmpty())
return;
- ClassVectorTy& Classes = EmptyClassOffsets[Offset];
+ ClassVectorTy& Classes = EmptyClassOffsets[toCharUnits(Offset)];
assert(std::find(Classes.begin(), Classes.end(), RD) == Classes.end() &&
"Duplicate empty class detected!");
More information about the cfe-commits
mailing list