From f1b30c41adaeaf5e0ab8dc10e26832789bd08097 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Fri, 13 Feb 2015 22:15:32 +0000 Subject: [PATCH] Handle function name conflicts in _LIBCPP_MSVCRT mode Visual Studio's SAL extension uses a macro named __deallocate. This macro is used pervasively, and gets included through various different ways. This conflicts with the similarly named interfaces in libc++. Introduce a undef header similar to __undef_min_max to handle this. This fixes a number of errors due to the macro replacing the function name. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@229162 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/__hash_table | 1 + include/__sso_allocator | 2 ++ include/__undef___deallocate | 18 ++++++++++++++++++ include/experimental/dynarray | 2 ++ include/memory | 1 + include/module.modulemap | 1 + include/new | 2 ++ include/valarray | 1 + 8 files changed, 28 insertions(+) create mode 100644 include/__undef___deallocate diff --git a/include/__hash_table b/include/__hash_table index 3a2de1d52..71cf5fbf0 100644 --- a/include/__hash_table +++ b/include/__hash_table @@ -19,6 +19,7 @@ #include #include <__undef_min_max> +#include <__undef___deallocate> #include <__debug> diff --git a/include/__sso_allocator b/include/__sso_allocator index 645f2ba17..ca3b937c0 100644 --- a/include/__sso_allocator +++ b/include/__sso_allocator @@ -15,6 +15,8 @@ #include #include +#include <__undef___deallocate> + #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif diff --git a/include/__undef___deallocate b/include/__undef___deallocate new file mode 100644 index 000000000..2b4ad99da --- /dev/null +++ b/include/__undef___deallocate @@ -0,0 +1,18 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifdef __deallocate +#if defined(_MSC_VER) && !defined(__clang__) +_LIBCPP_WARNING("macro __deallocate is incompatible with C++. #undefining __deallocate") +#else +#warning: macro __deallocate is incompatible with C++. #undefining __deallocate +#endif +#undef __deallocate +#endif diff --git a/include/experimental/dynarray b/include/experimental/dynarray index 0bc8dfe2c..a0258628d 100644 --- a/include/experimental/dynarray +++ b/include/experimental/dynarray @@ -104,6 +104,8 @@ public: #include #include +#include <__undef___deallocate> + #if defined(_LIBCPP_NO_EXCEPTIONS) #include #endif diff --git a/include/memory b/include/memory index 40fc8ae07..7085cedad 100644 --- a/include/memory +++ b/include/memory @@ -615,6 +615,7 @@ void* align(size_t alignment, size_t size, void*& ptr, size_t& space); #endif #include <__undef_min_max> +#include <__undef___deallocate> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header diff --git a/include/module.modulemap b/include/module.modulemap index 6aeb23f02..3c0700eca 100644 --- a/include/module.modulemap +++ b/include/module.modulemap @@ -469,4 +469,5 @@ module std [system] { module __tree { header "__tree" export * } module __tuple { header "__tuple" export * } module __undef_min_max { header "__undef_min_max" export * } + module __undef___deallocate { header "__undef___deallocate" export * } } diff --git a/include/new b/include/new index a710ed93f..eebe5af30 100644 --- a/include/new +++ b/include/new @@ -68,6 +68,8 @@ void operator delete[](void* ptr, void*) noexcept; #include #include +#include <__undef___deallocate> + #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif diff --git a/include/valarray b/include/valarray index 2b942046d..bdaa58836 100644 --- a/include/valarray +++ b/include/valarray @@ -348,6 +348,7 @@ template unspecified2 end(const valarray& v); #include #include <__undef_min_max> +#include <__undef___deallocate> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header