Bug 711683 - Use Clang's feature-detection macros, not its version number, for feature testing. r=cjones
authorJeff Walden <jwalden@mit.edu>
Sat, 17 Dec 2011 16:45:29 -0500
changeset 82945 87be07cf8c10d4f8b9c0249529c6a4afa3983dac
parent 82944 38a35f0db9ff1bab21c7de76462fd06e50fa58cd
child 82946 326455c9793d0c716038b3335fd427e0d262b873
push id21712
push usermak77@bonardo.net
push dateMon, 19 Dec 2011 11:48:25 +0000
treeherdermozilla-central@bc9b34bb121e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscjones
bugs711683
milestone11.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 711683 - Use Clang's feature-detection macros, not its version number, for feature testing. r=cjones
mfbt/Attributes.h
--- a/mfbt/Attributes.h
+++ b/mfbt/Attributes.h
@@ -56,24 +56,30 @@
  * g++ requires -std=c++0x or -std=gnu++0x to support C++11 functionality
  * without warnings (functionality used by the macros below).  These modes are
  * detectable by checking whether __GXX_EXPERIMENTAL_CXX0X__ is defined or, more
  * standardly, by checking whether __cplusplus has a C++11 or greater value.
  * Current versions of g++ do not correctly set __cplusplus, so we check both
  * for forward compatibility.
  */
 #if defined(__clang__)
-#  if __clang_major__ >= 3
+   /*
+    * Per Clang documentation, "Note that marketing version numbers should not
+    * be used to check for language features, as different vendors use different
+    * numbering schemes. Instead, use the feature checking macros."
+    */
+#  ifndef __has_extension
+#    define __has_extension __has_feature /* compatibility, for older versions of clang */
+#  endif
+#  if __has_extension(cxx_deleted_functions)
 #    define MOZ_HAVE_CXX11_DELETE
+#  endif
+#  if __has_extension(cxx_override_control)
 #    define MOZ_HAVE_CXX11_OVERRIDE
 #    define MOZ_HAVE_CXX11_FINAL         final
-#  elif __clang_major__ == 2
-#    if __clang_minor__ >= 9
-#      define MOZ_HAVE_CXX11_DELETE
-#    endif
 #  endif
 #elif defined(__GNUC__)
 #  if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L
 #    if __GNUC__ > 4
 #      define MOZ_HAVE_CXX11_DELETE
 #      define MOZ_HAVE_CXX11_OVERRIDE
 #      define MOZ_HAVE_CXX11_FINAL       final
 #    elif __GNUC__ == 4