Skip to content

Fix the signature for __builtin___clear_cache #134376

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion clang/include/clang/Basic/Builtins.td
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 12 additions & 0 deletions clang/test/Sema/clear_cache.c
Original file line number Diff line number Diff line change
@@ -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}}
}