[PATCH] D108479: [Clang] Add __builtin_addressof_nocfi
John McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 23 18:26:45 PST 2021
rjmccall added a comment.
Your builtin is using custom type-checking (`t`), which suppresses all the normal conversions that happen on expressions. Specifically, it skips lvalue-to-rvalue conversion, so in this example the argument ends up being an l-value reference to a variable rather than an r-value loaded from that variable. In addition to confusing constant evaluation, it would also make this look like an ODR-use of the variable, which would be subtly wrong in some C++ cases. The fix is to explicitly request the standard l-value conversions, which you can do with code like:
ExprResult Arg = S.DefaultFunctionArrayLvalueConversion(TheCall->getArg(0));
if (Arg.isInvalid()) return true;
TheCall->setArg(0, Arg.get());
After that, constant-evaluating the argument expression in your example should give you a `FunctionDecl*` as expected.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D108479/new/
https://reviews.llvm.org/D108479
More information about the cfe-commits
mailing list