[cfe-commits] [PATCH] CFG automatic object destructors
Zhongxing Xu
xuzhongxing at gmail.com
Wed Sep 29 19:43:17 PDT 2010
Hi Marcin,
+ // Check if type is a C++ class with non-trivial destructor.
+ const RecordType* RT = QT.getTypePtr()->getAs<RecordType>();
+ if (!RT || cast<CXXRecordDecl>(RT->getDecl())->hasTrivialDestructor())
+ return Scope;
RecordType is not necessarily CXXRecordType. cast<CXXRecordDecl> would cause
crashes. We could do something like this:
if (const RecordType *RT = QT->getAs<RecordType>())
if (CXXRecordDecl *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl()))
if (!ClassDecl->hasTrivialDestructor()) {
// Add the variable to scope
Scope = createOrReuseLocalScope(Scope);
Scope->addVar(VD);
ScopePos = Scope->begin();
}
return Scope;
2010/9/28 Marcin Ĺwiderski <marcin.sfider at gmail.com>
> Patch adds implicit destructors generation for objects with automatic
> storage duration. Patch is rather big, but it contains all cases (that I
> thought of), as it will be easier to review as a whole IMO. While commiting
> I can divide it to smaller chuncks.
>
> I've added some test cases. They can be later used to create regresion
> tests.
>
> Please approve for commit.
>
> Marcin
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20100930/6ee44806/attachment.html>
More information about the cfe-commits
mailing list