forked from OSchip/llvm-project
Add code for emitting C++ destructors. Not used yet.
llvm-svn: 72591
This commit is contained in:
parent
7de5966d76
commit
0a63741a3f
|
@ -439,6 +439,9 @@ public:
|
|||
TemplateOrInstantiation = Template;
|
||||
}
|
||||
|
||||
/// getDestructor - Returns the destructor decl for this class.
|
||||
const CXXDestructorDecl *getDestructor(ASTContext &Context);
|
||||
|
||||
/// viewInheritance - Renders and displays an inheritance diagram
|
||||
/// for this C++ class and all of its base classes (transitively) using
|
||||
/// GraphViz.
|
||||
|
|
|
@ -187,6 +187,23 @@ void CXXRecordDecl::addConversionFunction(ASTContext &Context,
|
|||
Conversions.addOverload(ConvDecl);
|
||||
}
|
||||
|
||||
const CXXDestructorDecl *
|
||||
CXXRecordDecl::getDestructor(ASTContext &Context) {
|
||||
QualType ClassType = Context.getTypeDeclType(this);
|
||||
|
||||
DeclarationName Name
|
||||
= Context.DeclarationNames.getCXXDestructorName(ClassType);
|
||||
|
||||
DeclContext::lookup_iterator I, E;
|
||||
llvm::tie(I, E) = lookup(Context, Name);
|
||||
assert(I != E && "Did not find a destructor!");
|
||||
|
||||
const CXXDestructorDecl *Dtor = cast<CXXDestructorDecl>(*I);
|
||||
assert(++I == E && "Found more than one destructor!");
|
||||
|
||||
return Dtor;
|
||||
}
|
||||
|
||||
CXXMethodDecl *
|
||||
CXXMethodDecl::Create(ASTContext &C, CXXRecordDecl *RD,
|
||||
SourceLocation L, DeclarationName N,
|
||||
|
|
|
@ -166,6 +166,14 @@ CodeGenFunction::EmitCXXConstructorCall(const CXXConstructorDecl *D,
|
|||
EmitCXXMemberCall(D, Callee, This, ArgBeg, ArgEnd);
|
||||
}
|
||||
|
||||
void CodeGenFunction::EmitCXXDestructorCall(const CXXDestructorDecl *D,
|
||||
CXXDtorType Type,
|
||||
llvm::Value *This) {
|
||||
llvm::Value *Callee = CGM.GetAddrOfCXXDestructor(D, Type);
|
||||
|
||||
EmitCXXMemberCall(D, Callee, This, 0, 0);
|
||||
}
|
||||
|
||||
void
|
||||
CodeGenFunction::EmitCXXConstructExpr(llvm::Value *Dest,
|
||||
const CXXConstructExpr *E) {
|
||||
|
|
|
@ -37,6 +37,7 @@ namespace llvm {
|
|||
|
||||
namespace clang {
|
||||
class ASTContext;
|
||||
class CXXDestructorDecl;
|
||||
class Decl;
|
||||
class EnumConstantDecl;
|
||||
class FunctionDecl;
|
||||
|
@ -476,6 +477,9 @@ public:
|
|||
CallExpr::const_arg_iterator ArgBeg,
|
||||
CallExpr::const_arg_iterator ArgEnd);
|
||||
|
||||
void EmitCXXDestructorCall(const CXXDestructorDecl *D, CXXDtorType Type,
|
||||
llvm::Value *This);
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
// Declaration Emission
|
||||
//===--------------------------------------------------------------------===//
|
||||
|
|
|
@ -576,6 +576,8 @@ void CodeGenModule::EmitGlobalDefinition(GlobalDecl GD) {
|
|||
|
||||
if (const CXXConstructorDecl *CD = dyn_cast<CXXConstructorDecl>(D))
|
||||
EmitCXXConstructor(CD, GD.getCtorType());
|
||||
else if (const CXXDestructorDecl *DD = dyn_cast<CXXDestructorDecl>(D))
|
||||
EmitCXXDestructor(DD, GD.getDtorType());
|
||||
else if (isa<FunctionDecl>(D))
|
||||
EmitGlobalFunctionDefinition(GD);
|
||||
else if (const VarDecl *VD = dyn_cast<VarDecl>(D))
|
||||
|
|
Loading…
Reference in New Issue