[clang] [clang] Implement function pointer type discrimination (PR #96992)

John McCall via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 5 11:53:12 PDT 2024


================
@@ -2220,6 +2220,11 @@ llvm::Constant *ConstantLValueEmitter::emitPointerAuthPointer(const Expr *E) {
 
   // The assertions here are all checked by Sema.
   assert(Result.Val.isLValue());
+  auto *Base = Result.Val.getLValueBase().get<const ValueDecl *>();
+  if (auto *Decl = dyn_cast_or_null<FunctionDecl>(Base)) {
+    assert(Result.Val.getLValueOffset().isZero());
+    return CGM.getRawFunctionPointer(Decl);
----------------
rjmccall wrote:

You mean to `ConstantEmitter`?  I'd be okay with a flag that specifically requests a raw pointer; that doesn't seem too error-prone.

https://github.com/llvm/llvm-project/pull/96992


More information about the cfe-commits mailing list