[PATCH] D155175: [Clang] Fix consteval propagation for aggregates and defaulted constructors
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 21 06:36:09 PDT 2023
aaron.ballman added a subscriber: rjmccall.
aaron.ballman added a comment.
In D155175#4518366 <https://reviews.llvm.org/D155175#4518366>, @cor3ntin wrote:
> Remove an assert (added in a previous iteration of this PR).
>
> Unfortunately, we sometimes do emit the address of an immediate function,
> after we establish the program is ill-formed - as we still proceed to code gen.
>
> cpp
>
> consteval int id(int i) { return i; }
> constexpr int f(auto t) {
> return t + id(t);
> }
>
> auto b = &f<int>;
>
> We establish taking the address of &f<int> is not possible
> when exiting the evaluation context.
> At this point b has an init expression, which codegen will try to emit.
> Ideally we should try to remove the init all together after the fact but so far
> I have not been able to do so.
The removed code was this:
llvm::Constant *CodeGenModule::GetAddrOfFunction(GlobalDecl GD,
llvm::Type *Ty,
bool ForVTable,
bool DontDefer,
ForDefinition_t IsForDefinition) {
assert(!cast<FunctionDecl>(GD.getDecl())->isImmediateFunction() &&
"an immediate function should never be emitted");
which seems like very reasonable assertion to have. Should we be marking the init expression/declaration as invalid to force codegen not to run on the expression? So it's not removing the init, but is marking the declaration its attached to as invalid. CC @efriedma @rjmccall
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D155175/new/
https://reviews.llvm.org/D155175
More information about the cfe-commits
mailing list