This is an archive of the discontinued LLVM Phabricator instance.

[clang] fix constexpr code generation for user conversions.
ClosedPublic

Authored by mizvekov on Jul 5 2021, 3:32 PM.

Details

Summary

When building the member call to a user conversion function during an
implicit cast, the expression was not being checked for immediate
invocation, so we were never adding the ConstantExpr node to AST.

This would cause the call to the user conversion operator to be emitted
even if it was constantexpr evaluated, and this would even trip an
assert when said user conversion was declared consteval:
Assertion failed: !cast<FunctionDecl>(GD.getDecl())->isConsteval() && "consteval function should never be emitted", file clang\lib\CodeGen\CodeGenModule.cpp, line 3530

Fixes PR48855.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>

Diff Detail

Event Timeline

mizvekov requested review of this revision.Jul 5 2021, 3:32 PM
mizvekov created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptJul 5 2021, 3:32 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
mizvekov retitled this revision from [clang] fix constexpr code generation for user conversions. to DRAFT: [clang] fix constexpr code generation for user conversions..Jul 5 2021, 4:21 PM
mizvekov retitled this revision from DRAFT: [clang] fix constexpr code generation for user conversions. to [clang] fix constexpr code generation for user conversions..Jul 8 2021, 10:22 AM
mizvekov added a reviewer: rsmith.
rsmith accepted this revision.Jul 8 2021, 10:26 AM
This revision is now accepted and ready to land.Jul 8 2021, 10:26 AM