Skip to content

Conversation

@jhuber6
Copy link
Contributor

@jhuber6 jhuber6 commented Oct 9, 2024

Summary:
This had some leftover references to the old namespace and didn't put
restrict on it.

Summary:
This had some leftover references to the old namespace and didn't put
restrict on it.
@llvmbot
Copy link
Member

llvmbot commented Oct 9, 2024

@llvm/pr-subscribers-libc

Author: Joseph Huber (jhuber6)

Changes

Summary:
This had some leftover references to the old namespace and didn't put
restrict on it.


Full diff: https://github.com/llvm/llvm-project/pull/111761.diff

5 Files Affected:

  • (modified) libc/src/stdio/asprintf.cpp (+4-3)
  • (modified) libc/src/stdio/asprintf.h (+1-1)
  • (modified) libc/src/stdio/printf_core/vasprintf_internal.h (+3-3)
  • (modified) libc/src/stdio/vasprintf.cpp (+4-3)
  • (modified) libc/src/stdio/vasprintf.h (+2-1)
diff --git a/libc/src/stdio/asprintf.cpp b/libc/src/stdio/asprintf.cpp
index 88b458a9e103bf..f8cfb74ce48ea2 100644
--- a/libc/src/stdio/asprintf.cpp
+++ b/libc/src/stdio/asprintf.cpp
@@ -11,10 +11,11 @@
 #include "src/__support/macros/config.h"
 #include "src/stdio/printf_core/vasprintf_internal.h"
 
-namespace LIBC_NAMESPACE {
+namespace LIBC_NAMESPACE_DECL {
 
 LLVM_LIBC_FUNCTION(int, asprintf,
-                   (char **__restrict buffer, const char *format, ...)) {
+                   (char **__restrict buffer, const char *__restrict format,
+                    ...)) {
   va_list vlist;
   va_start(vlist, format);
   internal::ArgList args(vlist); // This holder class allows for easier copying
@@ -25,4 +26,4 @@ LLVM_LIBC_FUNCTION(int, asprintf,
   return ret;
 }
 
-} // namespace LIBC_NAMESPACE
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/stdio/asprintf.h b/libc/src/stdio/asprintf.h
index 0c0d5a350829e7..222dfdee9d4fd7 100644
--- a/libc/src/stdio/asprintf.h
+++ b/libc/src/stdio/asprintf.h
@@ -13,7 +13,7 @@
 
 namespace LIBC_NAMESPACE {
 
-int asprintf(char **__restrict s, const char *format, ...);
+int asprintf(char **__restrict s, const char *__restrict format, ...);
 
 } // namespace LIBC_NAMESPACE
 
diff --git a/libc/src/stdio/printf_core/vasprintf_internal.h b/libc/src/stdio/printf_core/vasprintf_internal.h
index 24ebc02a0b33f2..e3448eebd302b7 100644
--- a/libc/src/stdio/printf_core/vasprintf_internal.h
+++ b/libc/src/stdio/printf_core/vasprintf_internal.h
@@ -13,7 +13,7 @@
 #include "src/stdio/printf_core/writer.h"
 #include <stdlib.h> // malloc, realloc, free
 
-namespace LIBC_NAMESPACE {
+namespace LIBC_NAMESPACE_DECL {
 namespace printf_core {
 
 LIBC_INLINE int resize_overflow_hook(cpp::string_view new_str, void *target) {
@@ -40,7 +40,7 @@ LIBC_INLINE int resize_overflow_hook(cpp::string_view new_str, void *target) {
 
 constexpr size_t DEFAULT_BUFFER_SIZE = 200;
 
-LIBC_INLINE int vasprintf_internal(char **ret, const char *format,
+LIBC_INLINE int vasprintf_internal(char **ret, const char *__restrict format,
                                    internal::ArgList args) {
   char init_buff_on_stack[DEFAULT_BUFFER_SIZE];
   printf_core::WriteBuffer wb(init_buff_on_stack, DEFAULT_BUFFER_SIZE,
@@ -64,4 +64,4 @@ LIBC_INLINE int vasprintf_internal(char **ret, const char *format,
   return ret_val;
 }
 } // namespace printf_core
-} // namespace LIBC_NAMESPACE
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/stdio/vasprintf.cpp b/libc/src/stdio/vasprintf.cpp
index 7fa4cc6f127dda..4a44d4a0f88426 100644
--- a/libc/src/stdio/vasprintf.cpp
+++ b/libc/src/stdio/vasprintf.cpp
@@ -10,14 +10,15 @@
 #include "src/__support/arg_list.h"
 #include "src/stdio/printf_core/vasprintf_internal.h"
 
-namespace LIBC_NAMESPACE {
+namespace LIBC_NAMESPACE_DECL {
 
 LLVM_LIBC_FUNCTION(int, vasprintf,
-                   (char **__restrict ret, const char *format, va_list vlist)) {
+                   (char **__restrict ret, const char *__restrict format,
+                    va_list vlist)) {
   internal::ArgList args(vlist); // This holder class allows for easier copying
                                  // and pointer semantics, as well as handling
                                  // destruction automatically.
   return printf_core::vasprintf_internal(ret, format, args);
 }
 
-} // namespace LIBC_NAMESPACE
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/stdio/vasprintf.h b/libc/src/stdio/vasprintf.h
index 792e948cf1850c..8b286fe69bf203 100644
--- a/libc/src/stdio/vasprintf.h
+++ b/libc/src/stdio/vasprintf.h
@@ -13,7 +13,8 @@
 
 namespace LIBC_NAMESPACE {
 
-int vasprintf(char **__restrict s, const char *format, va_list vlist);
+int vasprintf(char **__restrict s, const char *__restrict format,
+              va_list vlist);
 
 } // namespace LIBC_NAMESPACE
 

@jhuber6 jhuber6 merged commit 545e059 into llvm:main Oct 10, 2024
9 checks passed
Copy link
Contributor

@michaelrj-google michaelrj-google left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Patch LGTM, just looks like you missed the namespace in the headers


#include "src/__support/macros/config.h"

namespace LIBC_NAMESPACE {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like this namespace might have gotten missed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could've sworn I added those, maybe I forgot to save the file or something. I'll just push it in a follow up.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That made the bot unhappy it seems, I'll fix it.


#include <stdarg.h>

namespace LIBC_NAMESPACE {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and this namespace

@jhuber6 jhuber6 deleted the vasprintf branch October 14, 2024 19:20
DanielCChen pushed a commit to DanielCChen/llvm-project that referenced this pull request Oct 16, 2024
Summary:
This had some leftover references to the old namespace and didn't put
restrict on it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants