[PATCH] D149514: Check if First argument in _builtin_assume_aligned_ is of pointer type

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon May 1 07:22:15 PDT 2023


aaron.ballman added a comment.

Generally looks good to me, but there were a few minor things. Do you need someone to commit on your behalf once those are addressed? If so, what name and email address would you like used for patch attribution?



================
Comment at: clang/docs/ReleaseNotes.rst:343
+  ``__builtin_assume_aligned``.
+  (`#62305 <https://github.com/llvm/llvm-project/issues/62305>`)
 
----------------



================
Comment at: clang/lib/Sema/SemaChecking.cpp:7982-7983
         DefaultFunctionArrayLvalueConversion(FirstArg);
-    if (FirstArgResult.isInvalid())
+    /// Type-check first argument normally.
+    if (checkBuiltinArgument(*this, TheCall, 0))
       return true;
----------------
The comment doesn't really add too much value, so removing it.


================
Comment at: clang/test/Sema/builtin-assume-aligned.c:79
+
+int test15(int *b) {
+  int arr[3] = {1, 2, 3};
----------------
yronglin wrote:
> Please add a test for function type
+1, test to make sure function to pointer decay happens.


================
Comment at: clang/test/Sema/builtin-assume-aligned.c:75
+int test14(int *a, int b) {
+  a = (int *)__builtin_assume_aligned(b, 32); // expected-error {{passing 'int' to parameter of incompatible type 'int *'}}
+  return a[0];
----------------
barannikov88 wrote:
> The expected type is not `int *`, it is `cost void *` (according to the definition of the builtin in Builtins.def).
> 
The GCC documentation for this builtin says `const void *`, Clang has no documentation for this one specifically.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D149514/new/

https://reviews.llvm.org/D149514



More information about the cfe-commits mailing list