forked from OSchip/llvm-project
Move overrider out into a separate struct.
llvm-svn: 95984
This commit is contained in:
parent
b9ce3cc458
commit
136bd19224
|
@ -119,6 +119,16 @@ namespace {
|
||||||
/// FinalOverriders - Contains the final overrider member functions for all
|
/// FinalOverriders - Contains the final overrider member functions for all
|
||||||
/// member functions in the base subobjects of a class.
|
/// member functions in the base subobjects of a class.
|
||||||
class FinalOverriders {
|
class FinalOverriders {
|
||||||
|
public:
|
||||||
|
/// OverriderInfo - Information about a final overrider.
|
||||||
|
struct OverriderInfo {
|
||||||
|
/// Method - The method decl of the overrider.
|
||||||
|
const CXXMethodDecl *Method;
|
||||||
|
|
||||||
|
OverriderInfo() : Method(0) { }
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
/// MostDerivedClass - The most derived class for which the final overriders
|
/// MostDerivedClass - The most derived class for which the final overriders
|
||||||
/// are stored.
|
/// are stored.
|
||||||
const CXXRecordDecl *MostDerivedClass;
|
const CXXRecordDecl *MostDerivedClass;
|
||||||
|
@ -129,7 +139,7 @@ class FinalOverriders {
|
||||||
const ASTRecordLayout &MostDerivedClassLayout;
|
const ASTRecordLayout &MostDerivedClassLayout;
|
||||||
|
|
||||||
typedef llvm::DenseMap<std::pair<BaseSubobject, const CXXMethodDecl *>,
|
typedef llvm::DenseMap<std::pair<BaseSubobject, const CXXMethodDecl *>,
|
||||||
const CXXMethodDecl *> OverridersMapTy;
|
OverriderInfo> OverridersMapTy;
|
||||||
|
|
||||||
/// OverridersMap - The final overriders for all virtual member functions of
|
/// OverridersMap - The final overriders for all virtual member functions of
|
||||||
/// all the base subobjects of the most derived class.
|
/// all the base subobjects of the most derived class.
|
||||||
|
@ -183,7 +193,7 @@ public:
|
||||||
|
|
||||||
/// getOverrider - Get the final overrider for the given method declaration in
|
/// getOverrider - Get the final overrider for the given method declaration in
|
||||||
/// the given base subobject.
|
/// the given base subobject.
|
||||||
const CXXMethodDecl *getOverrider(BaseSubobject Base,
|
const OverriderInfo getOverrider(BaseSubobject Base,
|
||||||
const CXXMethodDecl *MD) const {
|
const CXXMethodDecl *MD) const {
|
||||||
assert(OverridersMap.count(std::make_pair(Base, MD)) &&
|
assert(OverridersMap.count(std::make_pair(Base, MD)) &&
|
||||||
"Did not find overrider!");
|
"Did not find overrider!");
|
||||||
|
@ -229,10 +239,10 @@ void FinalOverriders::AddOverriders(BaseSubobject Base,
|
||||||
PropagateOverrider(MD, MD, Offsets);
|
PropagateOverrider(MD, MD, Offsets);
|
||||||
|
|
||||||
// Add the overrider as the final overrider of itself.
|
// Add the overrider as the final overrider of itself.
|
||||||
const CXXMethodDecl *&Overrider = OverridersMap[std::make_pair(Base, MD)];
|
OverriderInfo& Overrider = OverridersMap[std::make_pair(Base, MD)];
|
||||||
assert(!Overrider && "Overrider should not exist yet!");
|
assert(!Overrider.Method && "Overrider should not exist yet!");
|
||||||
|
|
||||||
Overrider = MD;
|
Overrider.Method = MD;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,16 +268,16 @@ void FinalOverriders::PropagateOverrider(const CXXMethodDecl *OldMD,
|
||||||
for (unsigned I = 0, E = OffsetVector.size(); I != E; ++I) {
|
for (unsigned I = 0, E = OffsetVector.size(); I != E; ++I) {
|
||||||
uint64_t Offset = OffsetVector[I];
|
uint64_t Offset = OffsetVector[I];
|
||||||
|
|
||||||
const CXXMethodDecl *&Overrider =
|
OverriderInfo &Overrider =
|
||||||
OverridersMap[std::make_pair(BaseSubobject(OverriddenRD, Offset),
|
OverridersMap[std::make_pair(BaseSubobject(OverriddenRD, Offset),
|
||||||
OverriddenMD)];
|
OverriddenMD)];
|
||||||
assert(Overrider && "Did not find existing overrider!");
|
assert(Overrider.Method && "Did not find existing overrider!");
|
||||||
|
|
||||||
assert(!ReturnTypeConversionRequiresAdjustment(Context, NewMD,
|
assert(!ReturnTypeConversionRequiresAdjustment(Context, NewMD,
|
||||||
OverriddenMD) &&
|
OverriddenMD) &&
|
||||||
"FIXME: Covariant return types not handled yet!");
|
"FIXME: Covariant return types not handled yet!");
|
||||||
// Set the new overrider.
|
// Set the new overrider.
|
||||||
Overrider = NewMD;
|
Overrider.Method = NewMD;
|
||||||
|
|
||||||
// And propagate it further.
|
// And propagate it further.
|
||||||
PropagateOverrider(OverriddenMD, NewMD, Offsets);
|
PropagateOverrider(OverriddenMD, NewMD, Offsets);
|
||||||
|
@ -356,10 +366,10 @@ void FinalOverriders::dump(llvm::raw_ostream &Out, BaseSubobject Base) const {
|
||||||
if (!MD->isVirtual())
|
if (!MD->isVirtual())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const CXXMethodDecl *Overrider = getOverrider(Base, MD);
|
OverriderInfo Overrider = getOverrider(Base, MD);
|
||||||
|
|
||||||
Out << " " << MD->getQualifiedNameAsString() << " - ";
|
Out << " " << MD->getQualifiedNameAsString() << " - ";
|
||||||
Out << Overrider->getQualifiedNameAsString() << "\n";
|
Out << Overrider.Method->getQualifiedNameAsString() << "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -577,13 +587,15 @@ VtableBuilder::layoutVirtualMemberFunctions(BaseSubobject Base,
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Get the final overrider.
|
// Get the final overrider.
|
||||||
const CXXMethodDecl *Overrider = Overriders.getOverrider(Base, MD);
|
FinalOverriders::OverriderInfo Overrider =
|
||||||
|
Overriders.getOverrider(Base, MD);
|
||||||
|
|
||||||
// Check if this virtual member function overrides a method in a primary
|
// Check if this virtual member function overrides a method in a primary
|
||||||
// base. If this is the case, and the return type doesn't require adjustment
|
// base. If this is the case, and the return type doesn't require adjustment
|
||||||
// then we can just use the member function from the primary base.
|
// then we can just use the member function from the primary base.
|
||||||
if (OverridesMethodInPrimaryBase(MD, PrimaryBases)) {
|
if (OverridesMethodInPrimaryBase(MD, PrimaryBases)) {
|
||||||
assert(!ReturnTypeConversionRequiresAdjustment(Context, Overrider, MD) &&
|
assert(!ReturnTypeConversionRequiresAdjustment(Context, Overrider.Method,
|
||||||
|
MD) &&
|
||||||
"FIXME: Handle covariant thunks!");
|
"FIXME: Handle covariant thunks!");
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Reference in New Issue