Skip to content

Commit

Permalink
[clang][bytecode] Handle UETT_PtrAuthTypeDiscriminator (#122941)
Browse files Browse the repository at this point in the history
  • Loading branch information
tbaederr authored Jan 15, 2025
1 parent 7201cae commit d1d2564
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions clang/lib/AST/ByteCode/Compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2141,6 +2141,16 @@ bool Compiler<Emitter>::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<ASTContext &>(ASTCtx).getPointerAuthTypeDiscriminator(
E->getArgumentType()),
E);
}

return false;
}

Expand Down
3 changes: 3 additions & 0 deletions clang/test/SemaCXX/ptrauth-type-discriminator.cpp
Original file line number Diff line number Diff line change
@@ -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

Expand Down

0 comments on commit d1d2564

Please sign in to comment.