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

Eli Friedman via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 2 12:42:31 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:

Okay, I think I follow what this is doing, then... but it seems like a terrible way to structure the code; it's repeating code, and the relevant logic is split over multiple disconnected functions.

Can we add an argument to ConstantLValueEmitter() so users can request that functions are either signed or unsigned, or something like that?

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


More information about the cfe-commits mailing list