- Revision
- 162707
- Author
- ander...@apple.com
- Date
- 2014-01-24 10:20:06 -0800 (Fri, 24 Jan 2014)
Log Message
Simplify Compiler.h
https://bugs.webkit.org/show_bug.cgi?id=127491
Patch by Darin Adler <da...@apple.com> on 2014-01-24
Reviewed by Anders Carlsson.
* wtf/Assertions.h: Remove COMPILER_SUPPORTS(CXX_STATIC_ASSERT), since
we now have that for all compilers that can build WebKit.
* wtf/Compiler.h: Removed always true feature flags, including:
COMPILER_SUPPORTS(CXX_VARIADIC_TEMPLATES), COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES),
COMPILER_SUPPORTS(CXX_DELETED_FUNCTIONS), COMPILER_SUPPORTS(CXX_NULLPTR),
COMPILER_SUPPORTS(CXX_EXPLICIT_CONVERSIONS), COMPILER_SUPPORTS(CXX_STATIC_ASSERT),
COMPILER_SUPPORTS(CXX_OVERRIDE_CONTROL), COMPILER_SUPPORTS(CXX_STRONG_ENUMS), and
COMPILER_SUPPORTS(CXX_AUTO_TYPE). Sorted sections alphabetically. Separated out
nested #if and #else into separate checks for greater readability. Removed obsolete
check for COMPILER(RVCT). Removed unused COMPILER(GCCE) detection.
* wtf/RefPtr.h: Remove COMPILER_SUPPORTS(CXX_NULLPTR), since we now have
that for all compilers that can build WebKit.
* wtf/RetainPtr.h: Ditto.
Modified Paths
Diff
Modified: trunk/Source/WTF/ChangeLog (162706 => 162707)
--- trunk/Source/WTF/ChangeLog 2014-01-24 18:09:18 UTC (rev 162706)
+++ trunk/Source/WTF/ChangeLog 2014-01-24 18:20:06 UTC (rev 162707)
@@ -1,3 +1,26 @@
+2014-01-24 Darin Adler <da...@apple.com>
+
+ Simplify Compiler.h
+ https://bugs.webkit.org/show_bug.cgi?id=127491
+
+ Reviewed by Anders Carlsson.
+
+ * wtf/Assertions.h: Remove COMPILER_SUPPORTS(CXX_STATIC_ASSERT), since
+ we now have that for all compilers that can build WebKit.
+
+ * wtf/Compiler.h: Removed always true feature flags, including:
+ COMPILER_SUPPORTS(CXX_VARIADIC_TEMPLATES), COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES),
+ COMPILER_SUPPORTS(CXX_DELETED_FUNCTIONS), COMPILER_SUPPORTS(CXX_NULLPTR),
+ COMPILER_SUPPORTS(CXX_EXPLICIT_CONVERSIONS), COMPILER_SUPPORTS(CXX_STATIC_ASSERT),
+ COMPILER_SUPPORTS(CXX_OVERRIDE_CONTROL), COMPILER_SUPPORTS(CXX_STRONG_ENUMS), and
+ COMPILER_SUPPORTS(CXX_AUTO_TYPE). Sorted sections alphabetically. Separated out
+ nested #if and #else into separate checks for greater readability. Removed obsolete
+ check for COMPILER(RVCT). Removed unused COMPILER(GCCE) detection.
+
+ * wtf/RefPtr.h: Remove COMPILER_SUPPORTS(CXX_NULLPTR), since we now have
+ that for all compilers that can build WebKit.
+ * wtf/RetainPtr.h: Ditto.
+
2014-01-23 Max Vujovic <mvujo...@adobe.com>
Remove CSS Custom Filters code and tests
Modified: trunk/Source/WTF/wtf/Assertions.h (162706 => 162707)
--- trunk/Source/WTF/wtf/Assertions.h 2014-01-24 18:09:18 UTC (rev 162706)
+++ trunk/Source/WTF/wtf/Assertions.h 2014-01-24 18:20:06 UTC (rev 162707)
@@ -322,10 +322,8 @@
#if COMPILER_SUPPORTS(C_STATIC_ASSERT)
/* Unlike static_assert below, this also works in plain C code. */
#define COMPILE_ASSERT(exp, name) _Static_assert((exp), #name)
-#elif COMPILER_SUPPORTS(CXX_STATIC_ASSERT)
-#define COMPILE_ASSERT(exp, name) static_assert((exp), #name)
#else
-#define COMPILE_ASSERT(exp, name) typedef int dummy##name [(exp) ? 1 : -1]
+#define COMPILE_ASSERT(exp, name) static_assert((exp), #name)
#endif
#endif
Modified: trunk/Source/WTF/wtf/Compiler.h (162706 => 162707)
--- trunk/Source/WTF/wtf/Compiler.h 2014-01-24 18:09:18 UTC (rev 162706)
+++ trunk/Source/WTF/wtf/Compiler.h 2014-01-24 18:20:06 UTC (rev 162707)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011, 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2011, 2012, 2014 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -35,263 +35,225 @@
/* COMPILER_QUIRK() - whether the compiler being used to build the project requires a given quirk. */
#define COMPILER_QUIRK(WTF_COMPILER_QUIRK) (defined WTF_COMPILER_QUIRK_##WTF_COMPILER_QUIRK && WTF_COMPILER_QUIRK_##WTF_COMPILER_QUIRK)
-/* ==== COMPILER() - the compiler being used to build the project ==== */
+/* ==== COMPILER() - primary detection of the compiler being used to build the project, in alphabetical order ==== */
/* COMPILER(CLANG) - Clang */
+
#if defined(__clang__)
#define WTF_COMPILER_CLANG 1
-
-/* Specific compiler features */
-#define WTF_COMPILER_SUPPORTS_CXX_VARIADIC_TEMPLATES __has_feature(cxx_variadic_templates)
-#define WTF_COMPILER_SUPPORTS_CXX_RVALUE_REFERENCES __has_feature(cxx_rvalue_references)
-#define WTF_COMPILER_SUPPORTS_CXX_DELETED_FUNCTIONS __has_feature(cxx_deleted_functions)
-#define WTF_COMPILER_SUPPORTS_CXX_NULLPTR __has_feature(cxx_nullptr)
-#define WTF_COMPILER_SUPPORTS_CXX_EXPLICIT_CONVERSIONS __has_feature(cxx_explicit_conversions)
#define WTF_COMPILER_SUPPORTS_BLOCKS __has_feature(blocks)
#define WTF_COMPILER_SUPPORTS_C_STATIC_ASSERT __has_feature(c_static_assert)
-#define WTF_COMPILER_SUPPORTS_CXX_STATIC_ASSERT __has_feature(cxx_static_assert)
-#define WTF_COMPILER_SUPPORTS_CXX_OVERRIDE_CONTROL __has_feature(cxx_override_control)
-#define WTF_COMPILER_SUPPORTS_CXX_STRONG_ENUMS __has_feature(cxx_strong_enums)
#define WTF_COMPILER_SUPPORTS_CXX_REFERENCE_QUALIFIED_FUNCTIONS __has_feature(cxx_reference_qualified_functions)
-#define WTF_COMPILER_SUPPORTS_CXX_AUTO_TYPE __has_feature(cxx_auto_type)
#define WTF_COMPILER_SUPPORTS_CXX_GENERALIZED_INITIALIZERS __has_feature(cxx_generalized_initializers)
-
#endif
-/* COMPILER(MSVC) - Microsoft Visual C++ */
-#if defined(_MSC_VER)
-#if _MSC_VER < 1800
-#error "Please use a newer version of Visual Studio. WebKit requires VS2013 or newer to compile."
-#endif
-#define WTF_COMPILER_MSVC 1
+/* COMPILER(GCC) - GNU Compiler Collection */
-/* Specific compiler features */
-#define WTF_COMPILER_SUPPORTS_CXX_NULLPTR 1
-#define WTF_COMPILER_SUPPORTS_CXX_OVERRIDE_CONTROL 1
-#define WTF_COMPILER_SUPPORTS_CXX_RVALUE_REFERENCES 1
-#define WTF_COMPILER_SUPPORTS_CXX_STATIC_ASSERT 1
-#define WTF_COMPILER_SUPPORTS_CXX_AUTO_TYPE 1
-#define WTF_COMPILER_SUPPORTS_CXX_STRONG_ENUMS 1
-#define WTF_COMPILER_SUPPORTS_CXX_OVERRIDE_CONTROL 1
-#define WTF_COMPILER_SUPPORTS_CXX_DELETED_FUNCTIONS 1
-#define WTF_COMPILER_SUPPORTS_CXX_EXPLICIT_CONVERSIONS 1
-#define WTF_COMPILER_SUPPORTS_CXX_GENERALIZED_INITIALIZERS 1
-#define WTF_COMPILER_SUPPORTS_CXX_VARIADIC_TEMPLATES 1
+/* Note: This section must come after the Clang section since we check !COMPILER(CLANG) here. */
-#endif /* defined(_MSC_VER) */
-
-/* COMPILER(GCCE) - GNU Compiler Collection for Embedded */
-#if defined(__GCCE__)
-#define WTF_COMPILER_GCCE 1
-#define GCCE_VERSION (__GCCE__ * 10000 + __GCCE_MINOR__ * 100 + __GCCE_PATCHLEVEL__)
-#define GCCE_VERSION_AT_LEAST(major, minor, patch) (GCCE_VERSION >= (major * 10000 + minor * 100 + patch))
-#endif
-
-/* COMPILER(GCC) - GNU Compiler Collection */
#if defined(__GNUC__)
#define WTF_COMPILER_GCC 1
#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
#define GCC_VERSION_AT_LEAST(major, minor, patch) (GCC_VERSION >= (major * 10000 + minor * 100 + patch))
-#else
-/* Define this for !GCC compilers, just so we can write things like GCC_VERSION_AT_LEAST(4, 1, 0). */
+#endif
+
+/* Define GCC_VERSION_AT_LEAST for all compilers, so we can write things like GCC_VERSION_AT_LEAST(4, 1, 0). */
+/* FIXME: Doesn't seem all that valuable. Can we remove this? */
+#if !defined(GCC_VERSION_AT_LEAST)
#define GCC_VERSION_AT_LEAST(major, minor, patch) 0
#endif
-/* Specific compiler features */
-#if COMPILER(GCC) && !COMPILER(CLANG)
-#if !GCC_VERSION_AT_LEAST(4, 7, 0)
+#if COMPILER(GCC) && !COMPILER(CLANG) && !GCC_VERSION_AT_LEAST(4, 7, 0)
#error "Please use a newer version of GCC. WebKit requires GCC 4.7.0 or newer to compile."
#endif
-#if GCC_VERSION_AT_LEAST(4, 8, 0)
-#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
-#endif
-#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
-/* C11 support */
+
+#if COMPILER(GCC) && !COMPILER(CLANG) && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
#define WTF_COMPILER_SUPPORTS_C_STATIC_ASSERT 1
#endif
-#if defined(__GXX_EXPERIMENTAL_CXX0X__) || (defined(__cplusplus) && __cplusplus >= 201103L)
-/* C++11 support */
-#define WTF_COMPILER_SUPPORTS_CXX_RVALUE_REFERENCES 1
-#define WTF_COMPILER_SUPPORTS_CXX_STATIC_ASSERT 1
-#define WTF_COMPILER_SUPPORTS_CXX_VARIADIC_TEMPLATES 1
-#define WTF_COMPILER_SUPPORTS_CXX_AUTO_TYPE 1
-#define WTF_COMPILER_SUPPORTS_CXX_DELETED_FUNCTIONS 1
-#define WTF_COMPILER_SUPPORTS_CXX_EXPLICIT_CONVERSIONS 1
-#define WTF_COMPILER_SUPPORTS_CXX_NULLPTR 1
-/* Strong enums should work from gcc 4.4, but doesn't seem to support some operators */
-#define WTF_COMPILER_SUPPORTS_CXX_STRONG_ENUMS 1
+
+#if COMPILER(GCC) && !COMPILER(CLANG) && GCC_VERSION_AT_LEAST(4, 8, 0)
+#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
+#endif
+
+#if COMPILER(GCC) && !COMPILER(CLANG) && (defined(__GXX_EXPERIMENTAL_CXX0X__) || (defined(__cplusplus) && __cplusplus >= 201103L))
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
-#define WTF_COMPILER_SUPPORTS_CXX_OVERRIDE_CONTROL 1
-#endif /* defined(__GXX_EXPERIMENTAL_CXX0X__) || (defined(__cplusplus) && __cplusplus >= 201103L) */
-#endif /* COMPILER(GCC) */
+#endif
/* COMPILER(MINGW) - MinGW GCC */
-/* COMPILER(MINGW64) - mingw-w64 GCC - only used as additional check to exclude mingw.org specific functions */
+
#if defined(__MINGW32__)
#define WTF_COMPILER_MINGW 1
-#include <_mingw.h> /* private MinGW header */
- #if defined(__MINGW64_VERSION_MAJOR) /* best way to check for mingw-w64 vs mingw.org */
- #define WTF_COMPILER_MINGW64 1
- #endif /* __MINGW64_VERSION_MAJOR */
-#endif /* __MINGW32__ */
-
-/* COMPILER(SUNCC) */
-#if defined(__SUNPRO_CC) || defined(__SUNPRO_C)
-#define WTF_COMPILER_SUNCC 1
+#include <_mingw.h>
#endif
-/* ABI */
-#if defined(__ARM_EABI__) || defined(__EABI__)
-#define WTF_COMPILER_SUPPORTS_EABI 1
-#endif
+/* COMPILER(MINGW64) - mingw-w64 GCC - used as additional check to exclude mingw.org specific functions */
-/* ==== Compiler features ==== */
+/* Note: This section must come after the MinGW section since we check COMPILER(MINGW) here. */
-/* Required C++11 features. We can remove these once they've been required for some time */
-
-#ifdef __cplusplus
-#if !COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES)
-#error "Please use a compiler that supports C++11 rvalue references."
+#if COMPILER(MINGW) && defined(__MINGW64_VERSION_MAJOR) /* best way to check for mingw-w64 vs mingw.org */
+#define WTF_COMPILER_MINGW64 1
#endif
-#if !COMPILER_SUPPORTS(CXX_STATIC_ASSERT)
-#error "Please use a compiler that supports C++11 static_assert."
-#endif
-#if !COMPILER_SUPPORTS(CXX_AUTO_TYPE)
-#error "Please use a compiler that supports C++11 auto."
-#endif
-#if !COMPILER_SUPPORTS(CXX_VARIADIC_TEMPLATES)
-#error "Please use a compiler that supports C++11 variadic templates."
-#endif
-#endif
-/* PURE_FUNCTION */
+/* COMPILER(MSVC) - Microsoft Visual C++ */
-#if COMPILER(GCC)
-#define PURE_FUNCTION __attribute__ ((__pure__))
-#else
-#define PURE_FUNCTION
+#if defined(_MSC_VER)
+#define WTF_COMPILER_MSVC 1
+#define WTF_COMPILER_SUPPORTS_CXX_GENERALIZED_INITIALIZERS 1
#endif
-/* ALWAYS_INLINE */
+#if defined(_MSC_VER) && _MSC_VER < 1800
+#error "Please use a newer version of Visual Studio. WebKit requires VS2013 or newer to compile."
+#endif
-#ifndef ALWAYS_INLINE
-#if COMPILER(GCC) && defined(NDEBUG) && !COMPILER(MINGW)
-#define ALWAYS_INLINE inline __attribute__((__always_inline__))
-#elif COMPILER(MSVC) && defined(NDEBUG)
-#define ALWAYS_INLINE __forceinline
-#else
-#define ALWAYS_INLINE inline
+/* COMPILER(SUNCC) */
+
+#if defined(__SUNPRO_CC) || defined(__SUNPRO_C)
+#define WTF_COMPILER_SUNCC 1
#endif
-#endif
+/* ==== COMPILER_SUPPORTS - additional compiler feature detection, in alphabetical order ==== */
-/* NEVER_INLINE */
+/* COMPILER_SUPPORTS(EABI) */
-#ifndef NEVER_INLINE
-#if COMPILER(GCC)
-#define NEVER_INLINE __attribute__((__noinline__))
-#elif COMPILER(MSVC) || COMPILER(RVCT)
-#define NEVER_INLINE __declspec(noinline)
-#else
-#define NEVER_INLINE
+#if defined(__ARM_EABI__) || defined(__EABI__)
+#define WTF_COMPILER_SUPPORTS_EABI 1
#endif
-#endif
+/* ==== Compiler-independent macros for various compiler features ==== */
-/* UNLIKELY */
+/* ALWAYS_INLINE */
-#ifndef UNLIKELY
-#if COMPILER(GCC)
-#define UNLIKELY(x) __builtin_expect(!!(x), 0)
-#else
-#define UNLIKELY(x) (x)
+#if !defined(ALWAYS_INLINE) && COMPILER(GCC) && defined(NDEBUG) && !COMPILER(MINGW)
+#define ALWAYS_INLINE inline __attribute__((__always_inline__))
#endif
+
+#if !defined(ALWAYS_INLINE) && COMPILER(MSVC) && defined(NDEBUG)
+#define ALWAYS_INLINE __forceinline
#endif
+#if !defined(ALWAYS_INLINE)
+#define ALWAYS_INLINE inline
+#endif
/* LIKELY */
-#ifndef LIKELY
-#if COMPILER(GCC)
+#if !defined(LIKELY) && COMPILER(GCC)
#define LIKELY(x) __builtin_expect(!!(x), 1)
-#else
+#endif
+
+#if !defined(LIKELY)
#define LIKELY(x) (x)
#endif
+
+/* NEVER_INLINE */
+
+#if !defined(NEVER_INLINE) && COMPILER(GCC)
+#define NEVER_INLINE __attribute__((__noinline__))
#endif
+#if !defined(NEVER_INLINE) && COMPILER(MSVC)
+#define NEVER_INLINE __declspec(noinline)
+#endif
+#if !defined(NEVER_INLINE)
+#define NEVER_INLINE
+#endif
+
/* NO_RETURN */
-
-#ifndef NO_RETURN
-#if COMPILER(GCC)
+#if !defined(NO_RETURN) && COMPILER(GCC)
#define NO_RETURN __attribute((__noreturn__))
-#elif COMPILER(MSVC)
+#endif
+
+#if !defined(NO_RETURN) && COMPILER(MSVC)
#define NO_RETURN __declspec(noreturn)
-#else
+#endif
+
+#if !defined(NO_RETURN)
#define NO_RETURN
#endif
-#endif
-
/* NO_RETURN_WITH_VALUE */
-#ifndef NO_RETURN_WITH_VALUE
-#if !COMPILER(MSVC)
+#if !defined(NO_RETURN_WITH_VALUE) && !COMPILER(MSVC)
#define NO_RETURN_WITH_VALUE NO_RETURN
-#else
+#endif
+
+#if !defined(NO_RETURN_WITH_VALUE)
#define NO_RETURN_WITH_VALUE
#endif
+
+/* OBJC_CLASS */
+
+#if !defined(OBJC_CLASS) && defined(__OBJC__)
+#define OBJC_CLASS @class
#endif
+#if !defined(OBJC_CLASS)
+#define OBJC_CLASS class
+#endif
-/* WARN_UNUSED_RETURN */
+/* PURE_FUNCTION */
-#if COMPILER(GCC)
-#define WARN_UNUSED_RETURN __attribute__ ((warn_unused_result))
-#else
-#define WARN_UNUSED_RETURN
+#if !defined(PURE_FUNCTION) && COMPILER(GCC)
+#define PURE_FUNCTION __attribute__((__pure__))
#endif
+#if !defined(PURE_FUNCTION)
+#define PURE_FUNCTION
+#endif
/* REFERENCED_FROM_ASM */
-#ifndef REFERENCED_FROM_ASM
-#if COMPILER(GCC)
-#define REFERENCED_FROM_ASM __attribute__((used))
-#else
+#if !defined(REFERENCED_FROM_ASM) && COMPILER(GCC)
+#define REFERENCED_FROM_ASM __attribute__((__used__))
+#endif
+
+#if !defined(REFERENCED_FROM_ASM)
#define REFERENCED_FROM_ASM
#endif
+
+/* UNLIKELY */
+
+#if !defined(UNLIKELY) && COMPILER(GCC)
+#define UNLIKELY(x) __builtin_expect(!!(x), 0)
#endif
-/* OBJC_CLASS */
+#if !defined(UNLIKELY)
+#define UNLIKELY(x) (x)
+#endif
-#ifndef OBJC_CLASS
-#ifdef __OBJC__
-#define OBJC_CLASS @class
-#else
-#define OBJC_CLASS class
+/* UNUSED_LABEL */
+
+/* Keep the compiler from complaining for a local label that is defined but not referenced. */
+/* Helpful when mixing hand-written and autogenerated code. */
+
+#if !defined(UNUSED_LABEL) && COMPILER(MSVC)
+#define UNUSED_LABEL(label) if (false) goto label
#endif
+
+#if !defined(UNUSED_LABEL)
+#define UNUSED_LABEL(label) UNUSED_PARAM(&& label)
#endif
/* UNUSED_PARAM */
-#if COMPILER(MSVC)
+#if !defined(UNUSED_PARAM) && COMPILER(MSVC)
#define UNUSED_PARAM(variable) (void)&variable
-#else
+#endif
+
+#if !defined(UNUSED_PARAM)
#define UNUSED_PARAM(variable) (void)variable
#endif
-/* UNUSED_LABEL */
+/* WARN_UNUSED_RETURN */
-/* This is to keep the compiler from complaining when for local labels are
- declared but not referenced. For example, this can happen with code that
- works with auto-generated code.
- */
-#if COMPILER(MSVC)
-#define UNUSED_LABEL(label) if (false) goto label
-#else
-#define UNUSED_LABEL(label) UNUSED_PARAM(&& label)
+#if !defined(WARN_UNUSED_RETURN) && COMPILER(GCC)
+#define WARN_UNUSED_RETURN __attribute__((__warn_unused_result__))
#endif
+#if !defined(WARN_UNUSED_RETURN)
+#define WARN_UNUSED_RETURN
+#endif
+
#endif /* WTF_Compiler_h */
Modified: trunk/Source/WTF/wtf/RefPtr.h (162706 => 162707)
--- trunk/Source/WTF/wtf/RefPtr.h 2014-01-24 18:09:18 UTC (rev 162706)
+++ trunk/Source/WTF/wtf/RefPtr.h 2014-01-24 18:20:06 UTC (rev 162707)
@@ -72,9 +72,6 @@
RefPtr& operator=(const RefPtr&);
RefPtr& operator=(T*);
RefPtr& operator=(const PassRefPtr<T>&);
-#if !COMPILER_SUPPORTS(CXX_NULLPTR)
- RefPtr& operator=(std::nullptr_t) { clear(); return *this; }
-#endif
template<typename U> RefPtr& operator=(const RefPtr<U>&);
template<typename U> RefPtr& operator=(const PassRefPtr<U>&);
RefPtr& operator=(RefPtr&&);
Modified: trunk/Source/WTF/wtf/RetainPtr.h (162706 => 162707)
--- trunk/Source/WTF/wtf/RetainPtr.h 2014-01-24 18:09:18 UTC (rev 162706)
+++ trunk/Source/WTF/wtf/RetainPtr.h 2014-01-24 18:20:06 UTC (rev 162707)
@@ -136,10 +136,6 @@
RetainPtr& operator=(RetainPtr&&);
template<typename U> RetainPtr& operator=(RetainPtr<U>&&);
-#if !COMPILER_SUPPORTS(CXX_NULLPTR)
- RetainPtr& operator=(std::nullptr_t) { clear(); return *this; }
-#endif
-
void swap(RetainPtr&);
private: