[clang] ae1c564 - [clang][Interp] Cast dummy pointers to other pointer type if necessary

Timm Bäder via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 24 07:17:12 PDT 2024


Author: Timm Bäder
Date: 2024-06-24T16:17:03+02:00
New Revision: ae1c564d1522f1202d05b698dce8d9c8ca46667c

URL: https://github.com/llvm/llvm-project/commit/ae1c564d1522f1202d05b698dce8d9c8ca46667c
DIFF: https://github.com/llvm/llvm-project/commit/ae1c564d1522f1202d05b698dce8d9c8ca46667c.diff

LOG: [clang][Interp] Cast dummy pointers to other pointer type if necessary

Added: 
    

Modified: 
    clang/lib/AST/Interp/ByteCodeExprGen.cpp
    clang/test/Sema/ptrauth.c

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index 3c96059375360..69661a590b9c2 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -3574,8 +3574,14 @@ bool ByteCodeExprGen<Emitter>::VisitBuiltinCallExpr(const CallExpr *E) {
       Builtin == Builtin::BI__builtin___NSStringMakeConstantString ||
       Builtin == Builtin::BI__builtin_ptrauth_sign_constant ||
       Builtin == Builtin::BI__builtin_function_start) {
-    if (std::optional<unsigned> GlobalOffset = P.createGlobal(E))
-      return this->emitGetPtrGlobal(*GlobalOffset, E);
+    if (std::optional<unsigned> GlobalOffset = P.createGlobal(E)) {
+      if (!this->emitGetPtrGlobal(*GlobalOffset, E))
+        return false;
+
+      if (PrimType PT = classifyPrim(E); PT != PT_Ptr && isPtrType(PT))
+        return this->emitDecayPtr(PT_Ptr, PT, E);
+      return true;
+    }
     return false;
   }
 

diff  --git a/clang/test/Sema/ptrauth.c b/clang/test/Sema/ptrauth.c
index cd069881793c5..fc1ae954fa36b 100644
--- a/clang/test/Sema/ptrauth.c
+++ b/clang/test/Sema/ptrauth.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple arm64-apple-ios -fsyntax-only -verify -fptrauth-intrinsics %s
+// RUN: %clang_cc1 -triple arm64-apple-ios -fsyntax-only -verify -fptrauth-intrinsics %s -fexperimental-new-constant-interpreter
 
 #if __has_feature(ptrauth_intrinsics)
 #warning Pointer authentication enabled!


        


More information about the cfe-commits mailing list