[cfe-dev] Analyzer - CXXDestructorCall functioning

Péter Szécsi via cfe-dev cfe-dev at lists.llvm.org
Tue Aug 30 02:06:24 PDT 2016


Hi!

I was implementing a SA checker when I ran into the next (problem?) :
Whenever I write a callback PostCall/PreCall with the next body:

{
if (dyn_cast<CXXDestructorCall>(&Call))
    llvm::errs() << "DtorCall\n";

  if (dyn_cast<CXXDestructorDecl>(Call.getDecl()))
    llvm::errs() << "DtorDecl\n";

  return;
}

Then I could not find a case where the cast to CXXDestructorCall is
successful.
Running this simple "checker" on the *below example emitted no output* to
errs:

class A {
};
int main()
{
A a;
 {
 A b;
 }
}

However if change the inner block this way:
 {
 A b;
 b.~A();
 }
then "DtorDecl" is displayed which makes sense.

The detailed description of the CXXDestructorCall says:

> Represents an implicit call to a C++ destructor.
>
> This *can* occur at the end of a scope (for automatic objects), at the
> end of a full-expression (for temporaries), or as part of a delete.
>
My question is: Does "can" mean in this context that the callback is quite
unreliable even in trivial cases or is it a bug and the destructor call
should trigger?

Thanks,

Peter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160830/9d979466/attachment.html>


More information about the cfe-dev mailing list