From d1d25641f4cb87ab2c07a4136ba1cec4fb6cf578 Mon Sep 17 00:00:00 2001 From: Timm Baeder Date: Wed, 15 Jan 2025 08:41:20 +0100 Subject: [PATCH] [clang][bytecode] Handle UETT_PtrAuthTypeDiscriminator (#122941) --- clang/lib/AST/ByteCode/Compiler.cpp | 10 ++++++++++ clang/test/SemaCXX/ptrauth-type-discriminator.cpp | 3 +++ 2 files changed, 13 insertions(+) diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp index a5dfaaf3196559..c6e2a1e50a2aa7 100644 --- a/clang/lib/AST/ByteCode/Compiler.cpp +++ b/clang/lib/AST/ByteCode/Compiler.cpp @@ -2141,6 +2141,16 @@ bool Compiler::VisitUnaryExprOrTypeTraitExpr( return this->emitConst(ASTCtx.toCharUnitsFromBits(Bits).getQuantity(), E); } + if (Kind == UETT_PtrAuthTypeDiscriminator) { + if (E->getArgumentType()->isDependentType()) + return this->emitInvalid(E); + + return this->emitConst( + const_cast(ASTCtx).getPointerAuthTypeDiscriminator( + E->getArgumentType()), + E); + } + return false; } diff --git a/clang/test/SemaCXX/ptrauth-type-discriminator.cpp b/clang/test/SemaCXX/ptrauth-type-discriminator.cpp index 685ca1f03fdddf..f5b71ed86acf74 100644 --- a/clang/test/SemaCXX/ptrauth-type-discriminator.cpp +++ b/clang/test/SemaCXX/ptrauth-type-discriminator.cpp @@ -1,6 +1,9 @@ // RUN: %clang_cc1 -triple arm64-apple-ios -std=c++17 -Wno-vla -fsyntax-only -verify -fptrauth-intrinsics %s // RUN: %clang_cc1 -triple aarch64-linux-gnu -std=c++17 -Wno-vla -fsyntax-only -verify -fptrauth-intrinsics %s +// RUN: %clang_cc1 -triple arm64-apple-ios -std=c++17 -Wno-vla -fsyntax-only -verify -fptrauth-intrinsics -fexperimental-new-constant-interpreter %s +// RUN: %clang_cc1 -triple aarch64-linux-gnu -std=c++17 -Wno-vla -fsyntax-only -verify -fptrauth-intrinsics -fexperimental-new-constant-interpreter %s + // RUN: not %clang_cc1 -triple arm64-apple-ios -std=c++17 -Wno-vla -fsyntax-only %s 2>&1 | FileCheck %s // CHECK: this target does not support pointer authentication