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 <[email protected]>

> 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
>
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to