Stop wrapping __has_include in another macro

Summary:
This is not guaranteed to work since the characters after '__has_include('
have special lexing rules that can't possibly be applied when
__has_include is generated by a macro. It also breaks the crash reproducers
generated by -frewrite-includes (see https://llvm.org/pr37990).

Reviewers: EricWF, rsmith, mclow.lists
Reviewed By: mclow.lists
Differential Revision: https://reviews.llvm.org/D49067

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@337824 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Alexander Richardson
2018-07-24 12:40:56 +00:00
parent ad7e93552d
commit 2be41bb90b
2 changed files with 6 additions and 10 deletions

View File

@@ -149,10 +149,8 @@
#define __has_keyword(__x) !(__is_identifier(__x)) #define __has_keyword(__x) !(__is_identifier(__x))
#ifdef __has_include #ifndef __has_include
# define __libcpp_has_include(__x) __has_include(__x) #define __has_include(...) 0
#else
# define __libcpp_has_include(__x) 0
#endif #endif
#if defined(__clang__) #if defined(__clang__)
@@ -1066,7 +1064,7 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
defined(__APPLE__) || \ defined(__APPLE__) || \
defined(__CloudABI__) || \ defined(__CloudABI__) || \
defined(__sun__) || \ defined(__sun__) || \
(defined(__MINGW32__) && __libcpp_has_include(<pthread.h>)) (defined(__MINGW32__) && __has_include(<pthread.h>))
# define _LIBCPP_HAS_THREAD_API_PTHREAD # define _LIBCPP_HAS_THREAD_API_PTHREAD
# elif defined(_LIBCPP_WIN32API) # elif defined(_LIBCPP_WIN32API)
# define _LIBCPP_HAS_THREAD_API_WIN32 # define _LIBCPP_HAS_THREAD_API_WIN32

View File

@@ -27,10 +27,8 @@
#define TEST_HAS_FEATURE(X) 0 #define TEST_HAS_FEATURE(X) 0
#endif #endif
#ifdef __has_include #ifndef __has_include
#define TEST_HAS_INCLUDE(X) __has_include(X) #define __has_include(...) 0
#else
#define TEST_HAS_INCLUDE(X) 0
#endif #endif
#ifdef __has_extension #ifdef __has_extension
@@ -90,7 +88,7 @@
#endif #endif
// Attempt to deduce GCC version // Attempt to deduce GCC version
#if defined(_LIBCPP_VERSION) && TEST_HAS_INCLUDE(<features.h>) #if defined(_LIBCPP_VERSION) && __has_include(<features.h>)
#include <features.h> #include <features.h>
#define TEST_HAS_GLIBC #define TEST_HAS_GLIBC
#define TEST_GLIBC_PREREQ(major, minor) __GLIBC_PREREQ(major, minor) #define TEST_GLIBC_PREREQ(major, minor) __GLIBC_PREREQ(major, minor)