[clang] 9e95699 - [clang][Headers] Do not define varargs macros for __need___va_list

Adhemerval Zanella via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 8 11:30:13 PST 2022


Author: Adhemerval Zanella
Date: 2022-11-08T16:29:35-03:00
New Revision: 9e956995db1fc7e792e3dfb3a465a52626195557

URL: https://github.com/llvm/llvm-project/commit/9e956995db1fc7e792e3dfb3a465a52626195557
DIFF: https://github.com/llvm/llvm-project/commit/9e956995db1fc7e792e3dfb3a465a52626195557.diff

LOG: [clang][Headers] Do not define varargs macros for __need___va_list

The glibc uses the define to avoid namespace polution on headers
that requires variadic argument, where the inclusion of stdarg.h is
required to obtain the va_list definition.

For such cases only __gnuc_va_list is required.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D137268

Added: 
    

Modified: 
    clang/lib/Headers/stdarg.h
    compiler-rt/test/sanitizer_common/TestCases/Linux/signal_send.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Headers/stdarg.h b/clang/lib/Headers/stdarg.h
index dc7becff670f4..4fbfe0985a160 100644
--- a/clang/lib/Headers/stdarg.h
+++ b/clang/lib/Headers/stdarg.h
@@ -8,8 +8,16 @@
  */
 
 #ifndef __STDARG_H
-#define __STDARG_H
 
+#ifndef __GNUC_VA_LIST
+#define __GNUC_VA_LIST
+typedef __builtin_va_list __gnuc_va_list;
+#endif
+
+#ifdef __need___va_list
+#undef __need___va_list
+#else
+#define __STDARG_H
 #ifndef _VA_LIST
 typedef __builtin_va_list va_list;
 #define _VA_LIST
@@ -29,9 +37,6 @@ typedef __builtin_va_list va_list;
 #define va_copy(dest, src)  __builtin_va_copy(dest, src)
 #endif
 
-#ifndef __GNUC_VA_LIST
-#define __GNUC_VA_LIST 1
-typedef __builtin_va_list __gnuc_va_list;
-#endif
-
 #endif /* __STDARG_H */
+
+#endif /* not __STDARG_H */

diff  --git a/compiler-rt/test/sanitizer_common/TestCases/Linux/signal_send.cpp b/compiler-rt/test/sanitizer_common/TestCases/Linux/signal_send.cpp
index 84084b9291a70..f5dcc4bc3208c 100644
--- a/compiler-rt/test/sanitizer_common/TestCases/Linux/signal_send.cpp
+++ b/compiler-rt/test/sanitizer_common/TestCases/Linux/signal_send.cpp
@@ -5,6 +5,7 @@
 
 #include <assert.h>
 #include <signal.h>
+#include <stdarg.h>
 #include <stdio.h>
 #include <sys/time.h>
 #include <sys/wait.h>


        


More information about the cfe-commits mailing list