[libc-commits] [libc] [clang] [Libc] Give more functions restrict qualifiers (PR #78061)
via libc-commits
libc-commits at lists.llvm.org
Sat Jan 13 11:10:40 PST 2024
https://github.com/AtariDreams created https://github.com/llvm/llvm-project/pull/78061
strsep has restrict qualifiers, as well as strtok_r. Add the restrict qualifiers to them.
Source: https://man7.org/linux/man-pages/man3/strsep.3.html
>From 04e6077b5f22d50e8ccc2aace3af7b27af922b76 Mon Sep 17 00:00:00 2001
From: Rose <83477269+AtariDreams at users.noreply.github.com>
Date: Sat, 13 Jan 2024 14:09:17 -0500
Subject: [PATCH] [Libc] Give more functions restrict qualifiers
strsep has restrict qualifiers, as well as strtok_r. Add the restrict qualifiers to them.
Source: https://man7.org/linux/man-pages/man3/strsep.3.html
---
clang/test/Analysis/Inputs/system-header-simulator.h | 6 +++---
clang/test/Analysis/string.c | 4 ++--
libc/src/string/strsep.cpp | 2 +-
libc/src/string/strsep.h | 2 +-
4 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/clang/test/Analysis/Inputs/system-header-simulator.h b/clang/test/Analysis/Inputs/system-header-simulator.h
index cd7ac616bcc67f..5f969adfdd92cd 100644
--- a/clang/test/Analysis/Inputs/system-header-simulator.h
+++ b/clang/test/Analysis/Inputs/system-header-simulator.h
@@ -71,9 +71,9 @@ int fflush(FILE *stream);
size_t strlen(const char *);
char *strcpy(char *restrict, const char *restrict);
-char *strncpy(char *dst, const char *src, size_t n);
-char *strsep(char **stringp, const char *delim);
-void *memcpy(void *dst, const void *src, size_t n);
+char *strncpy(char *restrict dst, const char * restrict src, size_t n);
+char *strsep(char ** restrict stringp, const char * restrict delim);
+void *memcpy(void * restrict dst, const void * restrict src, size_t n);
void *memset(void *s, int c, size_t n);
typedef unsigned long __darwin_pthread_key_t;
diff --git a/clang/test/Analysis/string.c b/clang/test/Analysis/string.c
index d47de9db8228e5..85232624160c06 100644
--- a/clang/test/Analysis/string.c
+++ b/clang/test/Analysis/string.c
@@ -71,7 +71,7 @@ void clang_analyzer_eval(int);
int scanf(const char *restrict format, ...);
void *malloc(size_t);
void free(void *);
-void *memcpy(void *dest, const void *src, size_t n);
+void *memcpy(void *restrict dest, const void *restrict src, size_t n);
//===----------------------------------------------------------------------===
// strlen()
@@ -1252,7 +1252,7 @@ int strncasecmp_null_argument(char *a, size_t n) {
// strsep()
//===----------------------------------------------------------------------===
-char *strsep(char **stringp, const char *delim);
+char *strsep(char ** restrict stringp, const char * restrict delim);
void strsep_null_delim(char *s) {
strsep(&s, NULL); // expected-warning{{Null pointer passed as 2nd argument to strsep()}}
diff --git a/libc/src/string/strsep.cpp b/libc/src/string/strsep.cpp
index edd2cf07e20a45..ce74223ee7721d 100644
--- a/libc/src/string/strsep.cpp
+++ b/libc/src/string/strsep.cpp
@@ -12,7 +12,7 @@
namespace LIBC_NAMESPACE {
-LLVM_LIBC_FUNCTION(char *, strsep, (char **stringp, const char *delim)) {
+LLVM_LIBC_FUNCTION(char *, strsep, (char ** __restrict stringp, const char * __restrict delim)) {
if (!*stringp)
return nullptr;
return internal::string_token<false>(*stringp, delim, stringp);
diff --git a/libc/src/string/strsep.h b/libc/src/string/strsep.h
index 48f55a899d7f33..d0a22f4af89119 100644
--- a/libc/src/string/strsep.h
+++ b/libc/src/string/strsep.h
@@ -11,7 +11,7 @@
namespace LIBC_NAMESPACE {
-char *strsep(char **stringp, const char *delim);
+char *strsep(char ** __restrict stringp, const char * __restrict delim);
} // namespace LIBC_NAMESPACE
More information about the libc-commits
mailing list