Add support for writing -verify shell tests
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@288743 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -20,14 +20,21 @@ class CXXCompiler(object):
|
|||||||
CM_Link = 3
|
CM_Link = 3
|
||||||
|
|
||||||
def __init__(self, path, flags=None, compile_flags=None, link_flags=None,
|
def __init__(self, path, flags=None, compile_flags=None, link_flags=None,
|
||||||
warning_flags=None, modules_flags=None, use_modules=False,
|
warning_flags=None, verify_supported=None,
|
||||||
|
verify_flags=None, use_verify=False,
|
||||||
|
modules_flags=None, use_modules=False,
|
||||||
use_ccache=False, use_warnings=False, compile_env=None,
|
use_ccache=False, use_warnings=False, compile_env=None,
|
||||||
cxx_type=None, cxx_version=None):
|
cxx_type=None, cxx_version=None):
|
||||||
self.path = path
|
self.path = path
|
||||||
self.flags = list(flags or [])
|
self.flags = list(flags or [])
|
||||||
self.compile_flags = list(compile_flags or [])
|
self.compile_flags = list(compile_flags or [])
|
||||||
self.warning_flags = list(warning_flags or [])
|
|
||||||
self.link_flags = list(link_flags or [])
|
self.link_flags = list(link_flags or [])
|
||||||
|
self.warning_flags = list(warning_flags or [])
|
||||||
|
self.verify_supported = verify_supported
|
||||||
|
self.use_verify = use_verify
|
||||||
|
self.verify_flags = list(verify_flags or [])
|
||||||
|
assert not use_verify or verify_supported
|
||||||
|
assert not use_verify or verify_flags is not None
|
||||||
self.modules_flags = list(modules_flags or [])
|
self.modules_flags = list(modules_flags or [])
|
||||||
self.use_modules = use_modules
|
self.use_modules = use_modules
|
||||||
assert not use_modules or modules_flags is not None
|
assert not use_modules or modules_flags is not None
|
||||||
@@ -46,12 +53,30 @@ class CXXCompiler(object):
|
|||||||
new_cxx = CXXCompiler(
|
new_cxx = CXXCompiler(
|
||||||
self.path, flags=self.flags, compile_flags=self.compile_flags,
|
self.path, flags=self.flags, compile_flags=self.compile_flags,
|
||||||
link_flags=self.link_flags, warning_flags=self.warning_flags,
|
link_flags=self.link_flags, warning_flags=self.warning_flags,
|
||||||
|
verify_supported=self.verify_supported,
|
||||||
|
verify_flags=self.verify_flags, use_verify=self.use_verify,
|
||||||
modules_flags=self.modules_flags, use_modules=self.use_modules,
|
modules_flags=self.modules_flags, use_modules=self.use_modules,
|
||||||
use_ccache=self.use_ccache, use_warnings=self.use_warnings,
|
use_ccache=self.use_ccache, use_warnings=self.use_warnings,
|
||||||
compile_env=self.compile_env, cxx_type=self.type,
|
compile_env=self.compile_env, cxx_type=self.type,
|
||||||
cxx_version=self.version)
|
cxx_version=self.version)
|
||||||
return new_cxx
|
return new_cxx
|
||||||
|
|
||||||
|
def isVerifySupported(self):
|
||||||
|
if self.verify_supported is None:
|
||||||
|
self.verify_supported = self.hasCompileFlag(['-Xclang',
|
||||||
|
'-verify-ignore-unexpected'])
|
||||||
|
if self.verify_supported:
|
||||||
|
self.verify_flags = [
|
||||||
|
'-Xclang', '-verify',
|
||||||
|
'-Xclang', '-verify-ignore-unexpected=note',
|
||||||
|
'-ferror-limit=1024'
|
||||||
|
]
|
||||||
|
return self.verify_supported
|
||||||
|
|
||||||
|
def useVerify(self, value=True):
|
||||||
|
self.use_verify = value
|
||||||
|
assert not self.use_verify or self.verify_flags is not None
|
||||||
|
|
||||||
def useModules(self, value=True):
|
def useModules(self, value=True):
|
||||||
self.use_modules = value
|
self.use_modules = value
|
||||||
assert not self.use_modules or self.modules_flags is not None
|
assert not self.use_modules or self.modules_flags is not None
|
||||||
@@ -108,6 +133,9 @@ class CXXCompiler(object):
|
|||||||
elif mode == self.CM_Compile:
|
elif mode == self.CM_Compile:
|
||||||
cmd += ['-c']
|
cmd += ['-c']
|
||||||
cmd += self.flags
|
cmd += self.flags
|
||||||
|
if self.use_verify:
|
||||||
|
cmd += self.verify_flags
|
||||||
|
assert mode in [self.CM_Default, self.CM_Compile]
|
||||||
if self.use_modules:
|
if self.use_modules:
|
||||||
cmd += self.modules_flags
|
cmd += self.modules_flags
|
||||||
if mode != self.CM_Link:
|
if mode != self.CM_Link:
|
||||||
|
|||||||
@@ -251,8 +251,9 @@ class Configuration(object):
|
|||||||
if self.use_clang_verify is None:
|
if self.use_clang_verify is None:
|
||||||
# NOTE: We do not test for the -verify flag directly because
|
# NOTE: We do not test for the -verify flag directly because
|
||||||
# -verify will always exit with non-zero on an empty file.
|
# -verify will always exit with non-zero on an empty file.
|
||||||
self.use_clang_verify = self.cxx.hasCompileFlag(
|
self.use_clang_verify = self.cxx.isVerifySupported()
|
||||||
['-Xclang', '-verify-ignore-unexpected'])
|
if self.use_clang_verify:
|
||||||
|
self.config.available_features.add('verify-support')
|
||||||
self.lit_config.note(
|
self.lit_config.note(
|
||||||
"inferred use_clang_verify as: %r" % self.use_clang_verify)
|
"inferred use_clang_verify as: %r" % self.use_clang_verify)
|
||||||
|
|
||||||
@@ -771,21 +772,25 @@ class Configuration(object):
|
|||||||
sub.append(('%compile_flags', compile_flags_str))
|
sub.append(('%compile_flags', compile_flags_str))
|
||||||
sub.append(('%link_flags', link_flags_str))
|
sub.append(('%link_flags', link_flags_str))
|
||||||
sub.append(('%all_flags', all_flags))
|
sub.append(('%all_flags', all_flags))
|
||||||
|
if self.cxx.isVerifySupported():
|
||||||
|
verify_str = ' ' + ' '.join(self.cxx.verify_flags) + ' '
|
||||||
|
sub.append(('%verify', verify_str))
|
||||||
# Add compile and link shortcuts
|
# Add compile and link shortcuts
|
||||||
compile_str = (self.cxx.path + ' -o %t.o %s -c ' + flags_str
|
compile_str = (self.cxx.path + ' -o %t.o %s -c ' + flags_str
|
||||||
+ compile_flags_str)
|
+ ' ' + compile_flags_str)
|
||||||
link_str = (self.cxx.path + ' -o %t.exe %t.o ' + flags_str
|
link_str = (self.cxx.path + ' -o %t.exe %t.o ' + flags_str + ' '
|
||||||
+ link_flags_str)
|
+ link_flags_str)
|
||||||
assert type(link_str) is str
|
assert type(link_str) is str
|
||||||
build_str = self.cxx.path + ' -o %t.exe %s ' + all_flags
|
build_str = self.cxx.path + ' -o %t.exe %s ' + all_flags
|
||||||
sub.append(('%compile', compile_str))
|
|
||||||
sub.append(('%link', link_str))
|
|
||||||
if self.cxx.use_modules:
|
if self.cxx.use_modules:
|
||||||
|
sub.append(('%compile_module', compile_str))
|
||||||
sub.append(('%build_module', build_str))
|
sub.append(('%build_module', build_str))
|
||||||
elif self.cxx.modules_flags is not None:
|
elif self.cxx.modules_flags is not None:
|
||||||
modules_str = ' '.join(self.cxx.modules_flags) + ' '
|
modules_str = ' '.join(self.cxx.modules_flags) + ' '
|
||||||
|
sub.append(('%compile_module', compile_str + ' ' + modules_str))
|
||||||
sub.append(('%build_module', build_str + ' ' + modules_str))
|
sub.append(('%build_module', build_str + ' ' + modules_str))
|
||||||
|
sub.append(('%compile', compile_str))
|
||||||
|
sub.append(('%link', link_str))
|
||||||
sub.append(('%build', build_str))
|
sub.append(('%build', build_str))
|
||||||
# Configure exec prefix substitutions.
|
# Configure exec prefix substitutions.
|
||||||
exec_env_str = 'env ' if len(self.env) != 0 else ''
|
exec_env_str = 'env ' if len(self.env) != 0 else ''
|
||||||
@@ -800,8 +805,8 @@ class Configuration(object):
|
|||||||
sub.append(('%run', exec_str + ' %t.exe'))
|
sub.append(('%run', exec_str + ' %t.exe'))
|
||||||
# Configure not program substitutions
|
# Configure not program substitutions
|
||||||
not_py = os.path.join(self.libcxx_src_root, 'utils', 'not', 'not.py')
|
not_py = os.path.join(self.libcxx_src_root, 'utils', 'not', 'not.py')
|
||||||
not_str = '%s %s' % (sys.executable, not_py)
|
not_str = '%s %s ' % (sys.executable, not_py)
|
||||||
sub.append(('not', not_str))
|
sub.append(('not ', not_str))
|
||||||
|
|
||||||
def configure_triple(self):
|
def configure_triple(self):
|
||||||
# Get or infer the target triple.
|
# Get or infer the target triple.
|
||||||
|
|||||||
@@ -227,9 +227,7 @@ class LibcxxTestFormat(object):
|
|||||||
if test_cxx.type != 'gcc':
|
if test_cxx.type != 'gcc':
|
||||||
test_cxx.flags += ['-fsyntax-only']
|
test_cxx.flags += ['-fsyntax-only']
|
||||||
if use_verify:
|
if use_verify:
|
||||||
test_cxx.flags += ['-Xclang', '-verify',
|
test_cxx.useVerify()
|
||||||
'-Xclang', '-verify-ignore-unexpected=note',
|
|
||||||
'-ferror-limit=1024']
|
|
||||||
cmd, out, err, rc = test_cxx.compile(source_path, out=os.devnull)
|
cmd, out, err, rc = test_cxx.compile(source_path, out=os.devnull)
|
||||||
expected_rc = 0 if use_verify else 1
|
expected_rc = 0 if use_verify else 1
|
||||||
if rc == expected_rc:
|
if rc == expected_rc:
|
||||||
|
|||||||
Reference in New Issue
Block a user