diff options
author | Akira Hatanaka <ahatanak@gmail.com> | 2024-07-24 02:04:37 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-24 02:04:37 -0700 |
commit | 666e3326fedfb6a033494c36c36aa95c4124d642 (patch) | |
tree | 4d9508e3feee150710270c8c167ae550d43a5f90 /clang/lib/Sema/SemaChecking.cpp | |
parent | eff6250494b4bc7feb0199912245e5bacad6f984 (diff) | |
download | llvm-666e3326fedfb6a033494c36c36aa95c4124d642.zip llvm-666e3326fedfb6a033494c36c36aa95c4124d642.tar.gz llvm-666e3326fedfb6a033494c36c36aa95c4124d642.tar.bz2 |
[PAC] Define __builtin_ptrauth_type_discriminator (#100204)
The builtin computes the discriminator for a type, which can be used to
sign/authenticate function pointers and member function pointers.
If the type passed to the builtin is a C++ member function pointer type,
the result is the discriminator used to signed member function pointers
of that type. If the type is a function, function pointer, or function
reference type, the result is the discriminator used to sign functions
of that type. It is ill-formed to use this builtin with any other type.
A call to this function is an integer constant expression.
Co-Authored-By: John McCall rjmccall@apple.com
Diffstat (limited to 'clang/lib/Sema/SemaChecking.cpp')
-rw-r--r-- | clang/lib/Sema/SemaChecking.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 45b9bbb..cf1196a 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -1489,14 +1489,18 @@ enum PointerAuthOpKind { }; } -static bool checkPointerAuthEnabled(Sema &S, Expr *E) { - if (S.getLangOpts().PointerAuthIntrinsics) +bool Sema::checkPointerAuthEnabled(SourceLocation Loc, SourceRange Range) { + if (getLangOpts().PointerAuthIntrinsics) return false; - S.Diag(E->getExprLoc(), diag::err_ptrauth_disabled) << E->getSourceRange(); + Diag(Loc, diag::err_ptrauth_disabled) << Range; return true; } +static bool checkPointerAuthEnabled(Sema &S, Expr *E) { + return S.checkPointerAuthEnabled(E->getExprLoc(), E->getSourceRange()); +} + static bool checkPointerAuthKey(Sema &S, Expr *&Arg) { // Convert it to type 'int'. if (convertArgumentToType(S, Arg, S.Context.IntTy)) |