[llvm] r316798 - Force #define GTEST_LANG_CXX11.

Zachary Turner via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 27 14:12:28 PDT 2017


Author: zturner
Date: Fri Oct 27 14:12:28 2017
New Revision: 316798

URL: http://llvm.org/viewvc/llvm-project?rev=316798&view=rev
Log:
Force #define GTEST_LANG_CXX11.

gtest depends on this #define to determine whether it can
use various classes like std::tuple, or whether it has to fall
back to experimental classes in the std::tr1 namespace.  The
check in the current version of gtest relies on the value of
the `__cplusplus` macro, but MSVC provides a non-conformant
value of this macro, making it effectively impossible to detect
C++11.  In short, LLVM compiled with MSVC has been silently
using the tr1 versions of several classes since the beginning of
time.

This would normally be pretty benign, except that in the latest
preview of MSVC they have marked all of the tr1 classes
deprecated, so it spews thousands of warnings.

Modified:
    llvm/trunk/cmake/modules/AddLLVM.cmake
    llvm/trunk/lib/Testing/Support/CMakeLists.txt
    llvm/trunk/utils/unittest/CMakeLists.txt

Modified: llvm/trunk/cmake/modules/AddLLVM.cmake
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/AddLLVM.cmake?rev=316798&r1=316797&r2=316798&view=diff
==============================================================================
--- llvm/trunk/cmake/modules/AddLLVM.cmake (original)
+++ llvm/trunk/cmake/modules/AddLLVM.cmake Fri Oct 27 14:12:28 2017
@@ -1037,6 +1037,13 @@ function(add_unittest test_suite test_na
     set(EXCLUDE_FROM_ALL ON)
   endif()
 
+  # Our current version of gtest does not properly recognize C++11 support
+  # with MSVC, so it falls back to tr1 / experimental classes.  Since LLVM
+  # itself requires C++11, we can safely force it on unconditionally so that
+  # we don't have to fight with the buggy gtest check.  
+  add_definitions(-DGTEST_LANG_CXX11=1)
+  add_definitions(-DGTEST_HAS_TR1_TUPLE=0)
+
   include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include)
   include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googlemock/include)
   if (NOT LLVM_ENABLE_THREADS)

Modified: llvm/trunk/lib/Testing/Support/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Testing/Support/CMakeLists.txt?rev=316798&r1=316797&r2=316798&view=diff
==============================================================================
--- llvm/trunk/lib/Testing/Support/CMakeLists.txt (original)
+++ llvm/trunk/lib/Testing/Support/CMakeLists.txt Fri Oct 27 14:12:28 2017
@@ -1,3 +1,6 @@
+add_definitions(-DGTEST_LANG_CXX11=1)
+add_definitions(-DGTEST_HAS_TR1_TUPLE=0)
+
 add_llvm_library(LLVMTestingSupport
   Error.cpp
 

Modified: llvm/trunk/utils/unittest/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/unittest/CMakeLists.txt?rev=316798&r1=316797&r2=316798&view=diff
==============================================================================
--- llvm/trunk/utils/unittest/CMakeLists.txt (original)
+++ llvm/trunk/utils/unittest/CMakeLists.txt Fri Oct 27 14:12:28 2017
@@ -19,6 +19,11 @@ include_directories(
   googlemock
   )
 
+# LLVM requires C++11 but gtest doesn't correctly detect the availability
+# of C++11 on MSVC, so we force it on.
+add_definitions(-DGTEST_LANG_CXX11=1)
+add_definitions(-DGTEST_HAS_TR1_TUPLE=0)
+
 if(WIN32)
   add_definitions(-DGTEST_OS_WINDOWS=1)
 endif()




More information about the llvm-commits mailing list