https://github.com/AaronBallman created https://github.com/llvm/llvm-project/pull/134376
The signature was changed from void(char *, char *) to void(void *, void *) to match GCC's signature for the same builtin. Fixes #47833 >From e37b125713c436d88b49516a1adbbff7c78154c3 Mon Sep 17 00:00:00 2001 From: Aaron Ballman <aa...@aaronballman.com> Date: Fri, 4 Apr 2025 09:02:35 -0400 Subject: [PATCH] Fix the signature for __builtin___clear_cache The signature was changed from void(char *, char *) to void(void *, void *) to match GCC's signature for the same builtin. Fixes #47833 --- clang/docs/ReleaseNotes.rst | 4 ++++ clang/include/clang/Basic/Builtins.td | 2 +- clang/test/Sema/clear_cache.c | 12 ++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 clang/test/Sema/clear_cache.c diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 3055394dd8b6c..969bfb04623ed 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -354,6 +354,10 @@ Bug Fixes to Compiler Builtins - The behvaiour of ``__add_pointer`` and ``__remove_pointer`` for Objective-C++'s ``id`` and interfaces has been fixed. +- The signature for ``__builtin___clear_cache`` was changed from + ``void(char *, char *)`` to ``void(void *, void *)`` to match GCC's signature + for the same builtin. (#GH47833) + Bug Fixes to Attribute Support ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - Fixed crash when a parameter to the ``clang::annotate`` attribute evaluates to ``void``. See #GH119125 diff --git a/clang/include/clang/Basic/Builtins.td b/clang/include/clang/Basic/Builtins.td index b2c7ddb43de55..868e5b92acdc9 100644 --- a/clang/include/clang/Basic/Builtins.td +++ b/clang/include/clang/Basic/Builtins.td @@ -920,7 +920,7 @@ def FrameAddress : Builtin { def ClearCache : Builtin { let Spellings = ["__builtin___clear_cache"]; let Attributes = [NoThrow]; - let Prototype = "void(char*, char*)"; + let Prototype = "void(void*, void*)"; } def BuiltinSetjmp : Builtin { diff --git a/clang/test/Sema/clear_cache.c b/clang/test/Sema/clear_cache.c new file mode 100644 index 0000000000000..e6a3421309967 --- /dev/null +++ b/clang/test/Sema/clear_cache.c @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// Ensure that __builtin___clear_cache has the expected signature. Clang used +// to have a signature accepting char * while GCC had a signature accepting +// void * that was documented incorrectly. +void test(void) { + int n = 0; + __builtin___clear_cache(&n, &n + 1); // Ok + + __builtin___clear_cache((const void *)&n, (const void *)(&n + 1)); // expected-warning 2 {{passing 'const void *' to parameter of type 'void *' discards qualifiers}} +} + _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits