[PATCH] D51265: Headers: fix collisions with .h files of other projects

2018-08-25 Thread Andrew Kelley via Phabricator via cfe-commits
andrewrk created this revision.
andrewrk added reviewers: eli.friedman, krememek, ddunbar, lattner.
andrewrk added a project: clang.
Herald added a subscriber: cfe-commits.

stdarg.h:

- va_list - macos _va_list.h was duplicately defining va_list. Fixed by this 
ifndef _VA_LIST_T
- additionally define _VA_LIST_DEFINED because glibc stdio.h was duplicately 
defining va_list

stddef.h

- ptrdiff_t - wrap in _PTRDIFF_T_DEFINED to protect against mingw defining it 
twice
- size_t - protections against collisions with mingw
- wchar_t - protections against duplicate definition with mingw

All of these came up in real world scenarios when using libclang to parse .h 
files in the Zig project.
These are the patches that Zig has on top of libclang headers, and if this 
patch is merged, then
Zig project will be tracking clang trunk.


Repository:
  rC Clang

https://reviews.llvm.org/D51265

Files:
  lib/Headers/stdarg.h
  lib/Headers/stddef.h


Index: lib/Headers/stddef.h
===
--- lib/Headers/stddef.h
+++ lib/Headers/stddef.h
@@ -48,7 +48,12 @@
 #if !__has_feature(modules)
 #define _PTRDIFF_T
 #endif
+
+#if !defined(_PTRDIFF_T_DEFINED)
 typedef __PTRDIFF_TYPE__ ptrdiff_t;
+#define _PTRDIFF_T_DEFINED
+#endif
+
 #endif
 #undef __need_ptrdiff_t
 #endif /* defined(__need_ptrdiff_t) */
@@ -59,7 +64,23 @@
 #if !__has_feature(modules)
 #define _SIZE_T
 #endif
+
+#if !defined(_SIZE_T_DEFINED_)
+#if !defined(_SIZE_T_DEFINED)
+#if !defined(_BSD_SIZE_T_DEFINED_)
+#if !defined(_SIZE_T_DECLARED)
 typedef __SIZE_TYPE__ size_t;
+#define _SIZE_T_DEFINED_
+#define _SIZE_T_DEFINED
+#define _BSD_SIZE_T_DEFINED_
+#define _SIZE_T_DECLARED
+#endif
+#endif
+#endif
+#endif
+
+
+
 #endif
 #undef __need_size_t
 #endif /*defined(__need_size_t) */
@@ -87,7 +108,21 @@
 #define _WCHAR_T_DEFINED
 #endif
 #endif
+
+#if !defined(__INT_WCHAR_T_H)
+#if !defined(_GCC_WCHAR_T)
+#if !defined(_WCHAR_T_DECLARED)
+#if !defined(_WCHAR_T_DEFINED)
+#define __INT_WCHAR_T_H
+#define _GCC_WCHAR_T
+#define _WCHAR_T_DECLARED
+#define _WCHAR_T_DEFINED
 typedef __WCHAR_TYPE__ wchar_t;
+#endif
+#endif
+#endif
+#endif
+
 #endif
 #endif
 #undef __need_wchar_t
Index: lib/Headers/stdarg.h
===
--- lib/Headers/stdarg.h
+++ lib/Headers/stdarg.h
@@ -27,9 +27,11 @@
 #define __STDARG_H
 
 #ifndef _VA_LIST
+#ifndef _VA_LIST_T
 typedef __builtin_va_list va_list;
 #define _VA_LIST
 #endif
+#endif
 #define va_start(ap, param) __builtin_va_start(ap, param)
 #define va_end(ap)  __builtin_va_end(ap)
 #define va_arg(ap, type)__builtin_va_arg(ap, type)
@@ -46,6 +48,7 @@
 #ifndef __GNUC_VA_LIST
 #define __GNUC_VA_LIST 1
 typedef __builtin_va_list __gnuc_va_list;
+#define _VA_LIST_DEFINED
 #endif
 
 #endif /* __STDARG_H */


Index: lib/Headers/stddef.h
===
--- lib/Headers/stddef.h
+++ lib/Headers/stddef.h
@@ -48,7 +48,12 @@
 #if !__has_feature(modules)
 #define _PTRDIFF_T
 #endif
+
+#if !defined(_PTRDIFF_T_DEFINED)
 typedef __PTRDIFF_TYPE__ ptrdiff_t;
+#define _PTRDIFF_T_DEFINED
+#endif
+
 #endif
 #undef __need_ptrdiff_t
 #endif /* defined(__need_ptrdiff_t) */
@@ -59,7 +64,23 @@
 #if !__has_feature(modules)
 #define _SIZE_T
 #endif
+
+#if !defined(_SIZE_T_DEFINED_)
+#if !defined(_SIZE_T_DEFINED)
+#if !defined(_BSD_SIZE_T_DEFINED_)
+#if !defined(_SIZE_T_DECLARED)
 typedef __SIZE_TYPE__ size_t;
+#define _SIZE_T_DEFINED_
+#define _SIZE_T_DEFINED
+#define _BSD_SIZE_T_DEFINED_
+#define _SIZE_T_DECLARED
+#endif
+#endif
+#endif
+#endif
+
+
+
 #endif
 #undef __need_size_t
 #endif /*defined(__need_size_t) */
@@ -87,7 +108,21 @@
 #define _WCHAR_T_DEFINED
 #endif
 #endif
+
+#if !defined(__INT_WCHAR_T_H)
+#if !defined(_GCC_WCHAR_T)
+#if !defined(_WCHAR_T_DECLARED)
+#if !defined(_WCHAR_T_DEFINED)
+#define __INT_WCHAR_T_H
+#define _GCC_WCHAR_T
+#define _WCHAR_T_DECLARED
+#define _WCHAR_T_DEFINED
 typedef __WCHAR_TYPE__ wchar_t;
+#endif
+#endif
+#endif
+#endif
+
 #endif
 #endif
 #undef __need_wchar_t
Index: lib/Headers/stdarg.h
===
--- lib/Headers/stdarg.h
+++ lib/Headers/stdarg.h
@@ -27,9 +27,11 @@
 #define __STDARG_H
 
 #ifndef _VA_LIST
+#ifndef _VA_LIST_T
 typedef __builtin_va_list va_list;
 #define _VA_LIST
 #endif
+#endif
 #define va_start(ap, param) __builtin_va_start(ap, param)
 #define va_end(ap)  __builtin_va_end(ap)
 #define va_arg(ap, type)__builtin_va_arg(ap, type)
@@ -46,6 +48,7 @@
 #ifndef __GNUC_VA_LIST
 #define __GNUC_VA_LIST 1
 typedef __builtin_va_list __gnuc_va_list;
+#define _VA_LIST_DEFINED
 #endif
 
 #endif /* __STDARG_H */
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51265: Headers: fix collisions with .h files of other projects

2018-08-25 Thread Andrew Kelley via Phabricator via cfe-commits
andrewrk updated this revision to Diff 162574.
andrewrk added a comment.

Addressed review feedback


Repository:
  rC Clang

https://reviews.llvm.org/D51265

Files:
  lib/Headers/stdarg.h
  lib/Headers/stddef.h


Index: lib/Headers/stddef.h
===
--- lib/Headers/stddef.h
+++ lib/Headers/stddef.h
@@ -48,7 +48,12 @@
 #if !__has_feature(modules)
 #define _PTRDIFF_T
 #endif
+
+#if !defined(_PTRDIFF_T_DEFINED)
 typedef __PTRDIFF_TYPE__ ptrdiff_t;
+#define _PTRDIFF_T_DEFINED
+#endif
+
 #endif
 #undef __need_ptrdiff_t
 #endif /* defined(__need_ptrdiff_t) */
@@ -59,7 +64,23 @@
 #if !__has_feature(modules)
 #define _SIZE_T
 #endif
+
+#if !defined(_SIZE_T_DEFINED_)
+#if !defined(_SIZE_T_DEFINED)
+#if !defined(_BSD_SIZE_T_DEFINED_)
+#if !defined(_SIZE_T_DECLARED)
 typedef __SIZE_TYPE__ size_t;
+#define _SIZE_T_DEFINED_
+#define _SIZE_T_DEFINED
+#define _BSD_SIZE_T_DEFINED_
+#define _SIZE_T_DECLARED
+#endif
+#endif
+#endif
+#endif
+
+
+
 #endif
 #undef __need_size_t
 #endif /*defined(__need_size_t) */
@@ -87,7 +108,21 @@
 #define _WCHAR_T_DEFINED
 #endif
 #endif
+
+#if !defined(__INT_WCHAR_T_H)
+#if !defined(_GCC_WCHAR_T)
+#if !defined(_WCHAR_T_DECLARED)
+#if !defined(_WCHAR_T_DEFINED)
+#define __INT_WCHAR_T_H
+#define _GCC_WCHAR_T
+#define _WCHAR_T_DECLARED
+#define _WCHAR_T_DEFINED
 typedef __WCHAR_TYPE__ wchar_t;
+#endif
+#endif
+#endif
+#endif
+
 #endif
 #endif
 #undef __need_wchar_t
Index: lib/Headers/stdarg.h
===
--- lib/Headers/stdarg.h
+++ lib/Headers/stdarg.h
@@ -26,7 +26,7 @@
 #ifndef __STDARG_H
 #define __STDARG_H
 
-#ifndef _VA_LIST
+#if !defined(_VA_LIST) && !defined(_VA_LIST_T)
 typedef __builtin_va_list va_list;
 #define _VA_LIST
 #endif
@@ -46,6 +46,7 @@
 #ifndef __GNUC_VA_LIST
 #define __GNUC_VA_LIST 1
 typedef __builtin_va_list __gnuc_va_list;
+#define _VA_LIST_DEFINED
 #endif
 
 #endif /* __STDARG_H */


Index: lib/Headers/stddef.h
===
--- lib/Headers/stddef.h
+++ lib/Headers/stddef.h
@@ -48,7 +48,12 @@
 #if !__has_feature(modules)
 #define _PTRDIFF_T
 #endif
+
+#if !defined(_PTRDIFF_T_DEFINED)
 typedef __PTRDIFF_TYPE__ ptrdiff_t;
+#define _PTRDIFF_T_DEFINED
+#endif
+
 #endif
 #undef __need_ptrdiff_t
 #endif /* defined(__need_ptrdiff_t) */
@@ -59,7 +64,23 @@
 #if !__has_feature(modules)
 #define _SIZE_T
 #endif
+
+#if !defined(_SIZE_T_DEFINED_)
+#if !defined(_SIZE_T_DEFINED)
+#if !defined(_BSD_SIZE_T_DEFINED_)
+#if !defined(_SIZE_T_DECLARED)
 typedef __SIZE_TYPE__ size_t;
+#define _SIZE_T_DEFINED_
+#define _SIZE_T_DEFINED
+#define _BSD_SIZE_T_DEFINED_
+#define _SIZE_T_DECLARED
+#endif
+#endif
+#endif
+#endif
+
+
+
 #endif
 #undef __need_size_t
 #endif /*defined(__need_size_t) */
@@ -87,7 +108,21 @@
 #define _WCHAR_T_DEFINED
 #endif
 #endif
+
+#if !defined(__INT_WCHAR_T_H)
+#if !defined(_GCC_WCHAR_T)
+#if !defined(_WCHAR_T_DECLARED)
+#if !defined(_WCHAR_T_DEFINED)
+#define __INT_WCHAR_T_H
+#define _GCC_WCHAR_T
+#define _WCHAR_T_DECLARED
+#define _WCHAR_T_DEFINED
 typedef __WCHAR_TYPE__ wchar_t;
+#endif
+#endif
+#endif
+#endif
+
 #endif
 #endif
 #undef __need_wchar_t
Index: lib/Headers/stdarg.h
===
--- lib/Headers/stdarg.h
+++ lib/Headers/stdarg.h
@@ -26,7 +26,7 @@
 #ifndef __STDARG_H
 #define __STDARG_H
 
-#ifndef _VA_LIST
+#if !defined(_VA_LIST) && !defined(_VA_LIST_T)
 typedef __builtin_va_list va_list;
 #define _VA_LIST
 #endif
@@ -46,6 +46,7 @@
 #ifndef __GNUC_VA_LIST
 #define __GNUC_VA_LIST 1
 typedef __builtin_va_list __gnuc_va_list;
+#define _VA_LIST_DEFINED
 #endif
 
 #endif /* __STDARG_H */
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51265: Headers: fix collisions with .h files of other projects

2018-08-27 Thread Andrew Kelley via Phabricator via cfe-commits
andrewrk marked an inline comment as done.
andrewrk added a comment.

In https://reviews.llvm.org/D51265#1215060, @efriedma wrote:

> What is this change actually solving?  Even if the typedef is actually 
> redundant, it shouldn't cause a compiler error: redundant typedefs are 
> allowed in the latest versions of the C and C++ standards. (And even if you 
> were targeting an earlier standard, we normally suppress warnings in system 
> headers.)


Here's an example use case that this solves:

- Install MXE (See https://mxe.cc/)
- Install the png package
- Use libclang API to parse png.h
- Expect that there are no errors, but there are errors


Repository:
  rC Clang

https://reviews.llvm.org/D51265



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58204: CMake: Fix stand-alone clang builds since r353268

2019-02-13 Thread Andrew Kelley via Phabricator via cfe-commits
andrewrk accepted this revision.
andrewrk added a comment.

I confirm this solves the issue.




Comment at: llvm/cmake/modules/AddLLVM.cmake:1739
   execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --git-dir
 WORKING_DIRECTORY ${path}
 RESULT_VARIABLE git_result

I think ${path} should still be quoted here for best practice, as well as 
${GIT_EXECUTABLE} above.



Comment at: llvm/cmake/modules/AddLLVM.cmake:1745
 string(STRIP "${git_output}" git_output)
 get_filename_component(git_dir ${git_output} ABSOLUTE BASE_DIR ${path})
 # Some branchless cases (e.g. 'repo') may not yet have .git/logs/HEAD

these variables should be quoted too


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58204/new/

https://reviews.llvm.org/D58204



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67455: [Clang][CodeGen] support alias attribute w/ gnu_inline

2019-09-11 Thread Andrew Kelley via Phabricator via cfe-commits
andrewrk requested changes to this revision.
andrewrk added inline comments.
This revision now requires changes to proceed.



Comment at: clang/lib/AST/Decl.cpp:3352
+  assert((doesThisDeclarationHaveABody() || willHaveBody()) ||
+ hasAttr() && "Must be a function definition");
   assert(isInlined() && "Function must be inline");

It looks like the rparen is in the wrong place. I'd expect:

assert((doesThisDeclarationHaveABody() || willHaveBody() ||
 hasAttr()) && "Must be a function definition");


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67455/new/

https://reviews.llvm.org/D67455



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D78658: [clang][Frontend] Add missing error handling

2020-09-18 Thread Andrew Kelley via Phabricator via cfe-commits
andrewrk accepted this revision.
andrewrk added a comment.
This revision is now accepted and ready to land.

ping?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78658/new/

https://reviews.llvm.org/D78658

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D128465: [llvm] add zstd to `llvm::compression` namespace

2022-09-19 Thread Andrew Kelley via Phabricator via cfe-commits
andrewrk added a comment.

  if(LLVM_ENABLE_ZSTD)
list(APPEND imported_libs zstd::libzstd_shared)
  endif()

This hard codes shared linking which breaks the use case of static linking LLVM.

Also LLVM needs to now include a Findzstd.cmake file or else we get this error:

  CMake Error at cmake/config-ix.cmake:144 (find_package):
By not providing "Findzstd.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "zstd", but
CMake did not find one.
  
Could not find a package configuration file provided by "zstd" with any of
the following names:
  
  zstdConfig.cmake
  zstd-config.cmake
  
Add the installation prefix of "zstd" to CMAKE_PREFIX_PATH or set
"zstd_DIR" to a directory containing one of the above files.  If "zstd"
provides a separate development package or SDK, be sure it has been
installed.
  Call Stack (most recent call first):
CMakeLists.txt:774 (include)

It is impossible to satisfy this dependency when bootstrapping a static build 
of zig without patching LLVM.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128465/new/

https://reviews.llvm.org/D128465

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D128465: [llvm] add zstd to `llvm::compression` namespace

2022-09-19 Thread Andrew Kelley via Phabricator via cfe-commits
andrewrk added a comment.

Compiler infrastructure should not assume the existence of a Linux 
distribution. The portable way is simple and can easily be supported. One 
should be able to install `$prefix/lib/libzstd.a` and `$prefix/include/zstd.h`, 
then have that prefix searched as part of the standard `CMAKE_PREFIX_PATH`.

If LLVM will not carry Findzstd.cmake then it should not use `FIND_PACKAGE` in 
the case of `-DLLVM_ENABLE_ZSTD=FORCE_ON`; it should just throw `-lzstd` on the 
linker line instead of throwing rakes in my path for no reason.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128465/new/

https://reviews.llvm.org/D128465

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits