[PATCH] D156482: [clang][CGExprConstant] handle FunctionToPointerDecay
Eli Friedman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 2 16:00:54 PDT 2023
efriedma added inline comments.
================
Comment at: clang/lib/CodeGen/CGExprConstant.cpp:1128
+ case CK_NoOp:
+ case CK_NonAtomicToAtomic:
return Visit(subExpr, destType);
----------------
I think I'd prefer to continue treating an undecayed function as an "lvalue", to keep things straightforward. To that end, I'd prefer a separate "ConstLValueExprEmitter", or something like that, so ConstExprEmitter only visits rvalues.
The new emitter should reuse code from ConstLValueExprEmitter where possible.
================
Comment at: clang/lib/CodeGen/CGExprConstant.cpp:1247
+ if (isa<FunctionDecl>(VD))
+ return CGM.getModule().getNamedValue(VD->getName());
+ return nullptr;
----------------
You 100% can't use `VD->getName()` like this; I'm shocked this isn't causing any test failures. GetAddrOfFunction() resolves names correctly.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D156482/new/
https://reviews.llvm.org/D156482
More information about the cfe-commits
mailing list