[PATCH] D156175: [clang][ConstExprEmitter] handle NullToPointer ImplicitCastExpr
Eli Friedman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 24 16:29:52 PDT 2023
efriedma added inline comments.
================
Comment at: clang/lib/CodeGen/CGExprConstant.cpp:1131-1132
+ case CK_NullToPointer: {
+ if (llvm::Constant *C = Visit(subExpr, destType))
+ if (C->isNullValue())
+ return CGM.EmitNullConstant(destType);
----------------
nickdesaulniers wrote:
> FWIW, I would have thought these might be unnecessary, but we do trip 2 tests without these guards IIRC.
The fact that the Visit can fail doesn't surprise me; you can write arbitrary expressions of type nullptr_t (for example, `nullptr_t f(); void* g = f();`. I can't think of any reason you'd need to check C->isNullValue(), though; do you have a testcase for that?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D156175/new/
https://reviews.llvm.org/D156175
More information about the cfe-commits
mailing list