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

Eli Friedman via cfe-commits cfe-commits at lists.llvm.org
Sat Jun 29 14:54:56 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);
----------------
efriedma-quic wrote:

In that case, why are you special-casing functions here?  This looks like emitPointerAuthPointer can return either a signed pointer or an unsigned pointer, depending on what exactly the expression is referring to, which seems bad.

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


More information about the cfe-commits mailing list