llvm-svn: 83035
This commit is contained in:
Mike Stump 2009-09-29 00:50:50 +00:00
parent ba4a6fdd17
commit e7a2b48572
6 changed files with 36 additions and 1 deletions

View File

@ -973,6 +973,7 @@ public:
void setPreviousDeclaration(FunctionDecl * PrevDecl);
virtual const FunctionDecl *getCanonicalDecl() const;
virtual FunctionDecl *getCanonicalDecl();
unsigned getBuiltinID() const;

View File

@ -785,6 +785,13 @@ public:
return (CD->begin_overridden_methods() != CD->end_overridden_methods());
}
const CXXMethodDecl *getCanonicalDecl() const {
return cast<CXXMethodDecl>(FunctionDecl::getCanonicalDecl());
}
CXXMethodDecl *getCanonicalDecl() {
return cast<CXXMethodDecl>(FunctionDecl::getCanonicalDecl());
}
///
void addOverriddenMethod(const CXXMethodDecl *MD);

View File

@ -79,6 +79,15 @@ public:
return D;
}
/// \brief Return the first declaration of this declaration or itself if this
/// is the only declaration.
const decl_type *getFirstDeclaration() const {
const decl_type *D = static_cast<const decl_type*>(this);
while (D->getPreviousDeclaration())
D = D->getPreviousDeclaration();
return D;
}
/// \brief Set the previous declaration. If PrevDecl is NULL, set this as the
/// first and only declaration.
void setPreviousDeclaration(decl_type *PrevDecl) {

View File

@ -653,6 +653,10 @@ FunctionDecl::setPreviousDeclaration(FunctionDecl *PrevDecl) {
}
}
const FunctionDecl *FunctionDecl::getCanonicalDecl() const {
return getFirstDeclaration();
}
FunctionDecl *FunctionDecl::getCanonicalDecl() {
return getFirstDeclaration();
}

View File

@ -221,7 +221,8 @@ RValue CodeGenFunction::EmitCXXMemberCallExpr(const CXXMemberCallExpr *CE) {
// virtual call mechanism.
llvm::Value *Callee;
if (MD->isVirtual() && !ME->hasQualifier())
Callee = BuildVirtualCall(MD, This, Ty);
// FIXME: push getCanonicalDecl as a conversion using the static type system (CanCXXMethodDecl).
Callee = BuildVirtualCall(MD->getCanonicalDecl(), This, Ty);
else if (const CXXDestructorDecl *Destructor
= dyn_cast<CXXDestructorDecl>(MD))
Callee = CGM.GetAddrOfFunction(GlobalDecl(Destructor, Dtor_Complete), Ty);

View File

@ -920,6 +920,19 @@ struct test13_D : test13_NV1, virtual test13_B2 {
// CHECK-LP64-NEXT: .quad __ZN2D14bar4Ev
// CHECK-LP64-NEXT: .quad __ZN2D14bar5Ev
class test14 {
public:
virtual void initWithInt(int a);
static test14 *withInt(int a);
};
void test14::initWithInt(int a) { }
test14 *test14::withInt(int a) {
test14 *me = new test14;
me->initWithInt(a);
return me;
}
test11_D d11;
test10_D d10;