зеркало из 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;
|
typedef llvm::DenseMap<BaseSubobject, uint64_t> AddressPointsMapTy;
|
||||||
|
|
||||||
/// SubVTTIndicies - The sub-VTT indices for the bases of the most derived
|
/// 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;
|
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
|
/// GenerateDefinition - Whether the VTT builder should generate LLVM IR for
|
||||||
/// the VTT.
|
/// the VTT.
|
||||||
bool GenerateDefinition;
|
bool GenerateDefinition;
|
||||||
|
@ -107,15 +111,25 @@ class VTTBuilder {
|
||||||
public:
|
public:
|
||||||
VTTBuilder(CodeGenModule &CGM, const CXXRecordDecl *MostDerivedClass,
|
VTTBuilder(CodeGenModule &CGM, const CXXRecordDecl *MostDerivedClass,
|
||||||
bool GenerateDefinition);
|
bool GenerateDefinition);
|
||||||
|
|
||||||
llvm::DenseMap<const CXXRecordDecl *, uint64_t> &getSubVTTIndicies() {
|
|
||||||
return SubVTTIndicies;
|
|
||||||
}
|
|
||||||
|
|
||||||
// getVTTComponents - Returns a reference to the VTT components.
|
// getVTTComponents - Returns a reference to the VTT components.
|
||||||
const VTTComponentsVectorTy &getVTTComponents() const {
|
const VTTComponentsVectorTy &getVTTComponents() const {
|
||||||
return VTTComponents;
|
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,
|
VTTBuilder::VTTBuilder(CodeGenModule &CGM,
|
||||||
|
@ -420,14 +434,13 @@ uint64_t CodeGenVTables::getSubVTTIndex(const CXXRecordDecl *RD,
|
||||||
const CXXRecordDecl *Base) {
|
const CXXRecordDecl *Base) {
|
||||||
ClassPairTy ClassPair(RD, Base);
|
ClassPairTy ClassPair(RD, Base);
|
||||||
|
|
||||||
SubVTTIndiciesTy::iterator I =
|
SubVTTIndiciesMapTy::iterator I = SubVTTIndicies.find(ClassPair);
|
||||||
SubVTTIndicies.find(ClassPair);
|
|
||||||
if (I != SubVTTIndicies.end())
|
if (I != SubVTTIndicies.end())
|
||||||
return I->second;
|
return I->second;
|
||||||
|
|
||||||
VTTBuilder Builder(CGM, RD, /*GenerateDefinition=*/false);
|
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(),
|
Builder.getSubVTTIndicies().begin(),
|
||||||
E = Builder.getSubVTTIndicies().end(); I != E; ++I) {
|
E = Builder.getSubVTTIndicies().end(); I != E; ++I) {
|
||||||
// Insert all indices.
|
// Insert all indices.
|
||||||
|
@ -441,3 +454,31 @@ uint64_t CodeGenVTables::getSubVTTIndex(const CXXRecordDecl *RD,
|
||||||
|
|
||||||
return I->second;
|
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];
|
return VTableLayoutMap.lookup(RD)[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef llvm::DenseMap<ClassPairTy, uint64_t> SubVTTIndiciesTy;
|
typedef llvm::DenseMap<ClassPairTy, uint64_t> SubVTTIndiciesMapTy;
|
||||||
SubVTTIndiciesTy SubVTTIndicies;
|
|
||||||
|
/// 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
|
/// getNumVirtualFunctionPointers - Return the number of virtual function
|
||||||
/// pointers in the vtable for a given record decl.
|
/// pointers in the vtable for a given record decl.
|
||||||
|
@ -344,6 +355,11 @@ public:
|
||||||
/// given record decl.
|
/// given record decl.
|
||||||
uint64_t getSubVTTIndex(const CXXRecordDecl *RD, const CXXRecordDecl *Base);
|
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
|
/// getMethodVtableIndex - Return the index (relative to the vtable address
|
||||||
/// point) where the function pointer for the given virtual function is
|
/// point) where the function pointer for the given virtual function is
|
||||||
/// stored.
|
/// stored.
|
||||||
|
|
Загрузка…
Ссылка в новой задаче