Skip to content

Commit 11e7dcc

Browse files
committed
Address review feedback.
- tweaks to header/doc comments - add test for wide string literal
1 parent 30be782 commit 11e7dcc

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

clang/docs/PointerAuthentication.rst

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -335,13 +335,15 @@ result has type ``ptrauth_extra_data_t``.
335335
336336
ptrauth_string_discriminator(string)
337337
338-
Produce a discriminator value for the given string. ``string`` must be
339-
a string literal of ``char`` character type. The result has type
340-
``ptrauth_extra_data_t``.
338+
Compute a constant discriminator from the given string.
341339

342-
The result is always a constant expression. The result value is never zero and
343-
always within range for both the ``__ptrauth`` qualifier and
344-
``ptrauth_blend_discriminator``.
340+
``string`` must be a string literal of ``char`` character type. The result has
341+
type ``ptrauth_extra_data_t``.
342+
343+
The result value is never zero and always within range for both the
344+
``__ptrauth`` qualifier and ``ptrauth_blend_discriminator``.
345+
346+
This can be used in constant expressions.
345347

346348
``ptrauth_strip``
347349
^^^^^^^^^^^^^^^^^

clang/lib/Headers/ptrauth.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,14 @@ typedef __UINTPTR_TYPE__ ptrauth_generic_signature_t;
127127

128128
/* Compute a constant discriminator from the given string.
129129
130-
The result can be used as the second argument to
131-
ptrauth_blend_discriminator or the third argument to the
132-
__ptrauth qualifier. It has type size_t.
130+
The argument must be a string literal of char character type. The result
131+
has type ptrauth_extra_data_t.
133132
134-
The argument must be a string literal.
135-
A call to this function is an integer constant expression. */
133+
The result value is never zero and always within range for both the
134+
__ptrauth qualifier and ptrauth_blend_discriminator.
135+
136+
This can be used in constant expressions.
137+
*/
136138
#define ptrauth_string_discriminator(__string) \
137139
__builtin_ptrauth_string_discriminator(__string)
138140

clang/test/Sema/ptrauth.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ void test_string_discriminator(const char *str) {
5353
(void) __builtin_ptrauth_string_discriminator("test string"); // no warning
5454

5555
__builtin_ptrauth_string_discriminator(str); // expected-error {{argument must be a string literal}}
56+
__builtin_ptrauth_string_discriminator(L"wide test"); // expected-error {{argument must be a string literal}} expected-warning {{incompatible pointer types passing 'int[10]' to parameter of type 'const char *'}}
5657

5758
void *mismatch = __builtin_ptrauth_string_discriminator("test string"); // expected-error {{incompatible integer to pointer conversion initializing 'void *' with an expression of type 'unsigned long'}}
5859
}

0 commit comments

Comments
 (0)