[test] Port clang tests to canonicalized booleans

Use the new llvm_canonicalize_cmake_booleans() function to canonicalize
booleans for lit tests. Replace the duplicate ENABLE_CLANG* variables
used to hold canonicalized values with in-place canonicalization. Use
implicit logic in Python code to avoid overrelying on exact 0/1 values.

Differential Revision: https://reviews.llvm.org/D28529

llvm-svn: 293052
This commit is contained in:
Michal Gorny 2017-01-25 13:11:45 +00:00
parent ac93aa7022
commit 638ac70a92
8 changed files with 21 additions and 31 deletions

View File

@ -364,18 +364,7 @@ option(CLANG_BUILD_TOOLS
"Build the Clang tools. If OFF, just generate build targets." ON)
option(CLANG_ENABLE_ARCMT "Build ARCMT." ON)
if (CLANG_ENABLE_ARCMT)
set(ENABLE_CLANG_ARCMT "1")
else()
set(ENABLE_CLANG_ARCMT "0")
endif()
option(CLANG_ENABLE_STATIC_ANALYZER "Build static analyzer." ON)
if (CLANG_ENABLE_STATIC_ANALYZER)
set(ENABLE_CLANG_STATIC_ANALYZER "1")
else()
set(ENABLE_CLANG_STATIC_ANALYZER "0")
endif()
if (NOT CLANG_ENABLE_STATIC_ANALYZER AND CLANG_ENABLE_ARCMT)
message(FATAL_ERROR "Cannot disable static analyzer while enabling ARCMT")
@ -415,11 +404,6 @@ add_subdirectory(tools)
add_subdirectory(runtime)
option(CLANG_BUILD_EXAMPLES "Build CLANG example programs by default." OFF)
if (CLANG_BUILD_EXAMPLES)
set(ENABLE_CLANG_EXAMPLES "1")
else()
set(ENABLE_CLANG_EXAMPLES "0")
endif()
add_subdirectory(examples)
if(APPLE)

View File

@ -1,2 +1,2 @@
if config.root.clang_arcmt == 0:
if not config.root.clang_arcmt:
config.unsupported = True

View File

@ -1,2 +1,2 @@
if config.root.clang_staticanalyzer == 0:
if not config.root.clang_staticanalyzer:
config.unsupported = True

View File

@ -18,6 +18,12 @@ if(CLANG_BUILT_STANDALONE)
endif()
endif()
llvm_canonicalize_cmake_booleans(
CLANG_BUILD_EXAMPLES
CLANG_ENABLE_ARCMT
CLANG_ENABLE_STATIC_ANALYZER
ENABLE_BACKTRACES)
configure_lit_site_cfg(
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
@ -55,7 +61,7 @@ if (CLANG_ENABLE_ARCMT)
)
endif ()
if (ENABLE_CLANG_EXAMPLES)
if (CLANG_BUILD_EXAMPLES)
list(APPEND CLANG_TEST_DEPS
AnnotateFunctions
clang-interpreter
@ -63,7 +69,7 @@ if (ENABLE_CLANG_EXAMPLES)
)
endif ()
if (ENABLE_CLANG_STATIC_ANALYZER AND ENABLE_CLANG_EXAMPLES)
if (CLANG_ENABLE_STATIC_ANALYZER AND CLANG_BUILD_EXAMPLES)
list(APPEND CLANG_TEST_DEPS
SampleAnalyzerPlugin
)

View File

@ -1,3 +1,3 @@
# The Objective-C rewriters are currently grouped with ARCMT.
if config.root.clang_arcmt == 0:
if not config.root.clang_arcmt:
config.unsupported = True

View File

@ -1,2 +1,2 @@
if config.root.clang_staticanalyzer == 0:
if not config.root.clang_staticanalyzer:
config.unsupported = True

View File

@ -202,7 +202,7 @@ if not lit_config.quiet:
# Plugins (loadable modules)
# TODO: This should be supplied by Makefile or autoconf.
if sys.platform in ['win32', 'cygwin']:
has_plugins = (config.enable_shared == 1)
has_plugins = config.enable_shared
else:
has_plugins = True
@ -353,7 +353,7 @@ if config.clang_default_cxx_stdlib != '':
config.available_features.add('default-cxx-stdlib-set')
# Enabled/disabled features
if config.clang_staticanalyzer != 0:
if config.clang_staticanalyzer:
config.available_features.add("staticanalyzer")
# As of 2011.08, crash-recovery tests still do not pass on FreeBSD.
@ -474,10 +474,10 @@ if 'Undefined' in config.llvm_use_sanitizer:
else:
config.available_features.add("not_ubsan")
if config.enable_backtrace == "1":
if config.enable_backtrace:
config.available_features.add("backtrace")
if config.have_zlib == "1":
if config.have_zlib:
config.available_features.add("zlib")
else:
config.available_features.add("nozlib")

View File

@ -14,13 +14,13 @@ config.clang_tools_dir = "@CLANG_TOOLS_DIR@"
config.host_triple = "@LLVM_HOST_TRIPLE@"
config.target_triple = "@TARGET_TRIPLE@"
config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
config.have_zlib = "@HAVE_LIBZ@"
config.clang_arcmt = @ENABLE_CLANG_ARCMT@
config.have_zlib = @HAVE_LIBZ@
config.clang_arcmt = @CLANG_ENABLE_ARCMT@
config.clang_default_cxx_stdlib = "@CLANG_DEFAULT_CXX_STDLIB@"
config.clang_staticanalyzer = @ENABLE_CLANG_STATIC_ANALYZER@
config.clang_examples = @ENABLE_CLANG_EXAMPLES@
config.clang_staticanalyzer = @CLANG_ENABLE_STATIC_ANALYZER@
config.clang_examples = @CLANG_BUILD_EXAMPLES@
config.enable_shared = @ENABLE_SHARED@
config.enable_backtrace = "@ENABLE_BACKTRACES@"
config.enable_backtrace = @ENABLE_BACKTRACES@
config.host_arch = "@HOST_ARCH@"
# Support substitution of the tools and libs dirs with user parameters. This is