-
Notifications
You must be signed in to change notification settings - Fork 10.8k
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
[Support] Give llvm_strlcpy restrict semantics #78168
Conversation
@llvm/pr-subscribers-llvm-support Author: AtariDreams (AtariDreams) Changesstrlcpy has restrict semantics, so llvm_strlcpy should have them too. Source: https://man.freebsd.org/cgi/man.cgi?strlcpy Full diff: https://github.com/llvm/llvm-project/pull/78168.diff 2 Files Affected:
diff --git a/llvm/lib/Support/regex_impl.h b/llvm/lib/Support/regex_impl.h
index 8f0c532205edc3..6b780da10e35fe 100644
--- a/llvm/lib/Support/regex_impl.h
+++ b/llvm/lib/Support/regex_impl.h
@@ -99,7 +99,7 @@ size_t llvm_regerror(int, const llvm_regex_t *, char *, size_t);
int llvm_regexec(const llvm_regex_t *, const char *, size_t,
llvm_regmatch_t [], int);
void llvm_regfree(llvm_regex_t *);
-size_t llvm_strlcpy(char *dst, const char *src, size_t siz);
+size_t llvm_strlcpy(char *__restrict dst, const char * __restrict src, size_t siz);
#ifdef __cplusplus
}
diff --git a/llvm/lib/Support/regstrlcpy.c b/llvm/lib/Support/regstrlcpy.c
index 8b68afdf75f16a..1e55c4f36af7b9 100644
--- a/llvm/lib/Support/regstrlcpy.c
+++ b/llvm/lib/Support/regstrlcpy.c
@@ -26,7 +26,7 @@
* Returns strlen(src); if retval >= siz, truncation occurred.
*/
size_t
-llvm_strlcpy(char *dst, const char *src, size_t siz)
+llvm_strlcpy(char *__restrict dst, const char *__restrict src, size_t siz)
{
char *d = dst;
const char *s = src;
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
c0e928d
to
646bb37
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like an unnecessary change for the sake of change.
It is just for consistency. |
9fbf06f
to
6b1f4de
Compare
strlcpy has restrict semantics, so llvm_strlcpy should have them too. Source: https://man.freebsd.org/cgi/man.cgi?strlcpy
Consistency with what? This is an utterly unimportant helper used only by the regex implementation, which is imported from a 3rd party to boot. The code is not performance critical, so why would we care to sprinkle about dangerous optimization attributes in its implementation? |
strlcpy has restrict semantics, so llvm_strlcpy should have them too.
Source: https://man.freebsd.org/cgi/man.cgi?strlcpy