зеркало из https://github.com/microsoft/clang-1.git
Add and implement CodeGenVTables::getSecondaryVirtualPointerIndex (not used yet).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99608 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
799e75088d
Коммит
e1dcc22401
|
@ -44,9 +44,13 @@ class VTTBuilder {
|
|||
typedef llvm::DenseMap<BaseSubobject, uint64_t> AddressPointsMapTy;
|
||||
|
||||
/// SubVTTIndicies - The sub-VTT indices for the bases of the most derived
|
||||
/// class whose VTT is being built.
|
||||
/// class.
|
||||
llvm::DenseMap<const CXXRecordDecl *, uint64_t> SubVTTIndicies;
|
||||
|
||||
/// SecondaryVirtualPointerIndices - The secondary virtual pointer indices of
|
||||
/// all subobjects of the most derived class.
|
||||
llvm::DenseMap<BaseSubobject, uint64_t> SecondaryVirtualPointerIndices;
|
||||
|
||||
/// GenerateDefinition - Whether the VTT builder should generate LLVM IR for
|
||||
/// the VTT.
|
||||
bool GenerateDefinition;
|
||||
|
@ -108,14 +112,24 @@ public:
|
|||
VTTBuilder(CodeGenModule &CGM, const CXXRecordDecl *MostDerivedClass,
|
||||
bool GenerateDefinition);
|
||||
|
||||
llvm::DenseMap<const CXXRecordDecl *, uint64_t> &getSubVTTIndicies() {
|
||||
return SubVTTIndicies;
|
||||
}
|
||||
|
||||
// getVTTComponents - Returns a reference to the VTT components.
|
||||
const VTTComponentsVectorTy &getVTTComponents() const {
|
||||
return VTTComponents;
|
||||
}
|
||||
|
||||
/// getSubVTTIndicies - Returns a reference to the sub-VTT indices.
|
||||
const llvm::DenseMap<const CXXRecordDecl *, uint64_t> &
|
||||
getSubVTTIndicies() const {
|
||||
return SubVTTIndicies;
|
||||
}
|
||||
|
||||
/// getSecondaryVirtualPointerIndices - Returns a reference to the secondary
|
||||
/// virtual pointer indices.
|
||||
const llvm::DenseMap<BaseSubobject, uint64_t> &
|
||||
getSecondaryVirtualPointerIndices() const {
|
||||
return SecondaryVirtualPointerIndices;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
VTTBuilder::VTTBuilder(CodeGenModule &CGM,
|
||||
|
@ -420,14 +434,13 @@ uint64_t CodeGenVTables::getSubVTTIndex(const CXXRecordDecl *RD,
|
|||
const CXXRecordDecl *Base) {
|
||||
ClassPairTy ClassPair(RD, Base);
|
||||
|
||||
SubVTTIndiciesTy::iterator I =
|
||||
SubVTTIndicies.find(ClassPair);
|
||||
SubVTTIndiciesMapTy::iterator I = SubVTTIndicies.find(ClassPair);
|
||||
if (I != SubVTTIndicies.end())
|
||||
return I->second;
|
||||
|
||||
VTTBuilder Builder(CGM, RD, /*GenerateDefinition=*/false);
|
||||
|
||||
for (llvm::DenseMap<const CXXRecordDecl *, uint64_t>::iterator I =
|
||||
for (llvm::DenseMap<const CXXRecordDecl *, uint64_t>::const_iterator I =
|
||||
Builder.getSubVTTIndicies().begin(),
|
||||
E = Builder.getSubVTTIndicies().end(); I != E; ++I) {
|
||||
// Insert all indices.
|
||||
|
@ -441,3 +454,31 @@ uint64_t CodeGenVTables::getSubVTTIndex(const CXXRecordDecl *RD,
|
|||
|
||||
return I->second;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
CodeGenVTables::getSecondaryVirtualPointerIndex(const CXXRecordDecl *RD,
|
||||
BaseSubobject Base) {
|
||||
SecondaryVirtualPointerIndicesMapTy::iterator I =
|
||||
SecondaryVirtualPointerIndices.find(std::make_pair(RD, Base));
|
||||
|
||||
if (I != SecondaryVirtualPointerIndices.end())
|
||||
return I->second;
|
||||
|
||||
VTTBuilder Builder(CGM, RD, /*GenerateDefinition=*/false);
|
||||
|
||||
// Insert all secondary vpointer indices.
|
||||
for (llvm::DenseMap<BaseSubobject, uint64_t>::const_iterator I =
|
||||
Builder.getSecondaryVirtualPointerIndices().begin(),
|
||||
E = Builder.getSecondaryVirtualPointerIndices().end(); I != E; ++I) {
|
||||
std::pair<const CXXRecordDecl *, BaseSubobject> Pair =
|
||||
std::make_pair(RD, I->first);
|
||||
|
||||
SecondaryVirtualPointerIndices.insert(std::make_pair(Pair, I->second));
|
||||
}
|
||||
|
||||
I = SecondaryVirtualPointerIndices.find(std::make_pair(RD, Base));
|
||||
assert(I != SecondaryVirtualPointerIndices.end() && "Did not find index!");
|
||||
|
||||
return I->second;
|
||||
}
|
||||
|
||||
|
|
|
@ -292,8 +292,19 @@ private:
|
|||
return VTableLayoutMap.lookup(RD)[0];
|
||||
}
|
||||
|
||||
typedef llvm::DenseMap<ClassPairTy, uint64_t> SubVTTIndiciesTy;
|
||||
SubVTTIndiciesTy SubVTTIndicies;
|
||||
typedef llvm::DenseMap<ClassPairTy, uint64_t> SubVTTIndiciesMapTy;
|
||||
|
||||
/// SubVTTIndicies - Contains indices into the various sub-VTTs.
|
||||
SubVTTIndiciesMapTy SubVTTIndicies;
|
||||
|
||||
|
||||
typedef llvm::DenseMap<std::pair<const CXXRecordDecl *,
|
||||
BaseSubobject>, uint64_t>
|
||||
SecondaryVirtualPointerIndicesMapTy;
|
||||
|
||||
/// SecondaryVirtualPointerIndices - Contains the secondary virtual pointer
|
||||
/// indices.
|
||||
SecondaryVirtualPointerIndicesMapTy SecondaryVirtualPointerIndices;
|
||||
|
||||
/// getNumVirtualFunctionPointers - Return the number of virtual function
|
||||
/// pointers in the vtable for a given record decl.
|
||||
|
@ -344,6 +355,11 @@ public:
|
|||
/// given record decl.
|
||||
uint64_t getSubVTTIndex(const CXXRecordDecl *RD, const CXXRecordDecl *Base);
|
||||
|
||||
/// getSecondaryVirtualPointerIndex - Return the index in the VTT where the
|
||||
/// virtual pointer for the given subobject is located.
|
||||
uint64_t getSecondaryVirtualPointerIndex(const CXXRecordDecl *RD,
|
||||
BaseSubobject Base);
|
||||
|
||||
/// getMethodVtableIndex - Return the index (relative to the vtable address
|
||||
/// point) where the function pointer for the given virtual function is
|
||||
/// stored.
|
||||
|
|
Загрузка…
Ссылка в новой задаче