Added the ability for the user to override the -std=<version> flag used by lit 
on the command line by passing --param std=<version>.

http://reviews.llvm.org/D4329

Files:
  CMakeLists.txt
  cmake/config-ix.cmake
  test/CMakeLists.txt
  test/lit.cfg
  test/lit.site.cfg.in
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -41,6 +41,9 @@
 option(LIBCXX_ENABLE_PEDANTIC "Compile with pedantic enabled." ON)
 option(LIBCXX_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF)
 option(LIBCXX_ENABLE_CXX0X "Enable -std=c++0x and use of c++0x language features if the compiler supports it." ON)
+option(LIBCXX_ENABLE_CXX11 "Enable -std=c++11 and use of c++11 language features if the compiler supports it." ON)
+option(LIBCXX_ENABLE_CXX1Y "Enable -std=c++1y and use of c++1y language features if the compiler supports it." ON)
+option(LIBCXX_ENABLE_CXX1Z "Enable -std=c++1z and use of c++1z language features if the compiler supports it." OFF)
 option(LIBCXX_ENABLE_SHARED "Build libc++ as a shared library." ON)
 option(LIBCXX_INSTALL_SUPPORT_HEADERS "Install libc++ support headers." ON)
 
@@ -178,8 +181,17 @@
     list(APPEND LIBCXX_CXX_REQUIRED_FLAGS -nostdinc++)
     string(REPLACE "-stdlib=libc++" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
   endif()
-  if (LIBCXX_ENABLE_CXX0X AND LIBCXX_HAS_STDCXX0X_FLAG)
-    list(APPEND LIBCXX_CXX_REQUIRED_FLAGS -std=c++0x)
+  if (LIBCXX_ENABLE_CXX1Z AND LIBCXX_HAS_CXX1Z_FLAG)
+    set(LIBCXX_STD_VERSION c++1z)
+  elseif(LIBCXX_ENABLE_CXX1Y AND LIBCXX_HAS_STDCXX1Y_FLAG)
+    set(LIBCXX_STD_VERSION c++1y)
+  elseif(LIBCXX_ENABLE_CXX11 AND LIBCXX_HAS_CXX11_FLAG)
+    set(LIBCXX_STD_VERSION c++11)
+  elseif (LIBCXX_ENABLE_CXX0X AND LIBCXX_HAS_STDCXX0X_FLAG)
+    set(LIBCXX_STD_VERSION c++0x)
+  endif()
+  if (DEFINED LIBCXX_STD_VERSION)
+    list(APPEND LIBCXX_CXX_REQUIRED_FLAGS -std=${LIBCXX_STD_VERSION})
   endif()
 endif()
 
Index: cmake/config-ix.cmake
===================================================================
--- cmake/config-ix.cmake
+++ cmake/config-ix.cmake
@@ -3,6 +3,9 @@
 
 # Check compiler flags
 check_cxx_compiler_flag(-std=c++0x            LIBCXX_HAS_STDCXX0X_FLAG)
+check_cxx_compiler_flag(-std=c++11            LIBCXX_HAS_STDCXX11_FLAG)
+check_cxx_compiler_flag(-std=c++1y            LIBCXX_HAS_STDCXX1Y_FLAG)
+check_cxx_compiler_flag(-std=c++1z            LIBCXX_HAS_STDCXX1Z_FLAG)
 check_cxx_compiler_flag(-fPIC                 LIBCXX_HAS_FPIC_FLAG)
 check_cxx_compiler_flag(-nodefaultlibs        LIBCXX_HAS_NODEFAULTLIBS_FLAG)
 check_cxx_compiler_flag(-nostdinc++           LIBCXX_HAS_NOSTDINCXX_FLAG)
Index: test/CMakeLists.txt
===================================================================
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -28,7 +28,6 @@
   set(LIBCXX_BINARY_DIR ${CMAKE_BINARY_DIR})
   set(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE})
   pythonize_bool(LIBCXX_ENABLE_SHARED)
-  pythonize_bool(LIBCXX_HAS_STDCXX0X_FLAG)
 
   set(AUTO_GEN_COMMENT "## Autogenerated by libcxx configuration.\n# Do not edit!")
 
Index: test/lit.cfg
===================================================================
--- test/lit.cfg
+++ test/lit.cfg
@@ -202,17 +202,33 @@
     if libcxx_obj_root is None:
         libcxx_obj_root = libcxx_src_root
 
-cxx_has_stdcxx0x_flag_str = lit_config.params.get('cxx_has_stdcxx0x_flag', None)
-if cxx_has_stdcxx0x_flag_str is not None:
-    if cxx_has_stdcxx0x_flag_str.lower() in ('1', 'true'):
-        cxx_has_stdcxx0x_flag = True
-    elif cxx_has_stdcxx0x_flag_str.lower() in ('', '0', 'false'):
-        cxx_has_stdcxx0x_flag = False
-    else:
-        lit_config.fatal(
-            'user parameter cxx_has_stdcxx0x_flag_str should be 0 or 1')
-else:
-    cxx_has_stdcxx0x_flag = getattr(config, 'cxx_has_stdcxx0x_flag', True)
+cxx_std_flag = None
+
+# Allow --param std=<value> to be passed to the lit invokation to specify the
+# the standard version to be specified.
+std_version = lit_config.params.get('std', None)
+if std_version != None:
+    cxx_std_flag = '-std=' + std_version
+
+# Read the default_std_flag from either the global config or the lit.site.cfg
+default_std_version = lit_config.params.get('default_std_version', None)
+if default_std_version is None:
+    default_std_version = getattr(config, 'default_std_version', None)
+
+# If cxx_std_flag has not been set and we have a non-empty default version
+# set that as the standard flag.
+if cxx_std_flag is None and default_std_version:
+    cxx_std_flag = '-std=' + default_std_version
+
+# Configure extra compiler flags.
+include_paths = ['-I' + libcxx_src_root + '/include',
+    '-I' + libcxx_src_root + '/test/support']
+library_paths = ['-L' + libcxx_obj_root + '/lib']
+compile_flags = []
+if cxx_std_flag:
+    compile_flags += [cxx_std_flag]
+    lit_config.note("using std_flags as: %s" % (cxx_std_flag,))
+        
 
 # This test suite supports testing against either the system library or the
 # locally built one; the former mode is useful for testing ABI compatibility
@@ -259,13 +275,6 @@
 if not link_flags_str is None:
     link_flags += shlex.split(link_flags_str)
 
-# Configure extra compiler flags.
-include_paths = ['-I' + libcxx_src_root + '/include',
-    '-I' + libcxx_src_root + '/test/support']
-library_paths = ['-L' + libcxx_obj_root + '/lib']
-compile_flags = []
-if cxx_has_stdcxx0x_flag:
-    compile_flags += ['-std=c++0x']
 
 # Configure extra linker parameters.
 exec_env = {}
Index: test/lit.site.cfg.in
===================================================================
--- test/lit.site.cfg.in
+++ test/lit.site.cfg.in
@@ -1,6 +1,6 @@
 @AUTO_GEN_COMMENT@
 config.cxx_under_test        = "@LIBCXX_COMPILER@"
-config.cxx_has_stdcxx0x_flag = @LIBCXX_HAS_STDCXX0X_FLAG@
+config.default_std_version   = "@LIBCXX_STD_VERSION@"
 config.libcxx_src_root       = "@LIBCXX_SOURCE_DIR@"
 config.libcxx_obj_root       = "@LIBCXX_BINARY_DIR@"
 config.python_executable     = "@PYTHON_EXECUTABLE@"
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to