HomePhabricator

For P0784R7: add support for explicit destructor calls and pseudo-destructor…

Authored by Richard Smith <richard-llvm@metafoo.co.uk> on Sep 27 2019, 1:24 PM.

Description

For P0784R7: add support for explicit destructor calls and pseudo-destructor calls in constant evaluation.

llvm-svn: 373122

Event Timeline

Richard Smith <richard-llvm@metafoo.co.uk> committed rG61422f96653f: For P0784R7: add support for explicit destructor calls and pseudo-destructor… (authored by Richard Smith <richard-llvm@metafoo.co.uk>).Sep 27 2019, 1:24 PM
rogfer01 added inline comments.
/clang/lib/AST/ExprConstant.cpp
6551

Hi Richard,

One of the codes in the llvm testsuite (MultiSource/Applications/minisat/Solver.cpp) has as input this->data[this->sz].~Clause *().

EvaluateObjectArgument invokes EvaluatePointer because the object is an lvalue of pointer type (this->data[this->sz]) but the latter does not expect an lvalue at this point and an assert fails.

ArraySubscriptExpr 0xd652c30 'class Clause *':'class Clause *' lvalue
|-ImplicitCastExpr 0xd652c00 'class Clause **' <LValueToRValue>
| `-MemberExpr 0xd652b90 'class Clause **' lvalue ->data 0xd37a780
|   `-CXXThisExpr 0xd652b80 'class vec<class Clause *> *' implicit this
`-ImplicitCastExpr 0xd652c18 'int' <LValueToRValue>
  `-MemberExpr 0xd652bd0 'int' lvalue ->sz 0xd37a7d0
    `-CXXThisExpr 0xd652bc0 'class vec<class Clause *> *' implicit this

I'm not sure, but from a quick read, looks like the first check in EvaluateObjectArgument needs to check lvalueness to avoid this case.

Kind regards,