From: Eric Fiselier Date: Tue, 6 Dec 2016 01:02:15 +0000 (+0000) Subject: Add support for writing -verify shell tests X-Git-Tag: llvmorg-4.0.0-rc1~2922 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9642b36e91c28b888db018ebec8998b5bee33338;p=platform%2Fupstream%2Fllvm.git Add support for writing -verify shell tests llvm-svn: 288743 --- diff --git a/libcxx/test/libcxx/compiler.py b/libcxx/test/libcxx/compiler.py index 4071c48..de716ec 100644 --- a/libcxx/test/libcxx/compiler.py +++ b/libcxx/test/libcxx/compiler.py @@ -20,14 +20,21 @@ class CXXCompiler(object): CM_Link = 3 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, cxx_type=None, cxx_version=None): self.path = path self.flags = list(flags or []) self.compile_flags = list(compile_flags or []) - self.warning_flags = list(warning_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.use_modules = use_modules assert not use_modules or modules_flags is not None @@ -46,12 +53,30 @@ class CXXCompiler(object): new_cxx = CXXCompiler( self.path, flags=self.flags, compile_flags=self.compile_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, use_ccache=self.use_ccache, use_warnings=self.use_warnings, compile_env=self.compile_env, cxx_type=self.type, cxx_version=self.version) 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): self.use_modules = value assert not self.use_modules or self.modules_flags is not None @@ -108,6 +133,9 @@ class CXXCompiler(object): elif mode == self.CM_Compile: cmd += ['-c'] cmd += self.flags + if self.use_verify: + cmd += self.verify_flags + assert mode in [self.CM_Default, self.CM_Compile] if self.use_modules: cmd += self.modules_flags if mode != self.CM_Link: diff --git a/libcxx/test/libcxx/test/config.py b/libcxx/test/libcxx/test/config.py index f9ab22f..229c582 100644 --- a/libcxx/test/libcxx/test/config.py +++ b/libcxx/test/libcxx/test/config.py @@ -251,8 +251,9 @@ class Configuration(object): if self.use_clang_verify is None: # NOTE: We do not test for the -verify flag directly because # -verify will always exit with non-zero on an empty file. - self.use_clang_verify = self.cxx.hasCompileFlag( - ['-Xclang', '-verify-ignore-unexpected']) + self.use_clang_verify = self.cxx.isVerifySupported() + if self.use_clang_verify: + self.config.available_features.add('verify-support') self.lit_config.note( "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(('%link_flags', link_flags_str)) 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 compile_str = (self.cxx.path + ' -o %t.o %s -c ' + flags_str - + compile_flags_str) - link_str = (self.cxx.path + ' -o %t.exe %t.o ' + flags_str + + ' ' + compile_flags_str) + link_str = (self.cxx.path + ' -o %t.exe %t.o ' + flags_str + ' ' + link_flags_str) assert type(link_str) is str 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: + sub.append(('%compile_module', compile_str)) sub.append(('%build_module', build_str)) elif self.cxx.modules_flags is not None: 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(('%compile', compile_str)) + sub.append(('%link', link_str)) sub.append(('%build', build_str)) # Configure exec prefix substitutions. exec_env_str = 'env ' if len(self.env) != 0 else '' @@ -800,8 +805,8 @@ class Configuration(object): sub.append(('%run', exec_str + ' %t.exe')) # Configure not program substitutions not_py = os.path.join(self.libcxx_src_root, 'utils', 'not', 'not.py') - not_str = '%s %s' % (sys.executable, not_py) - sub.append(('not', not_str)) + not_str = '%s %s ' % (sys.executable, not_py) + sub.append(('not ', not_str)) def configure_triple(self): # Get or infer the target triple. diff --git a/libcxx/test/libcxx/test/format.py b/libcxx/test/libcxx/test/format.py index b958b21..ee6ab82 100644 --- a/libcxx/test/libcxx/test/format.py +++ b/libcxx/test/libcxx/test/format.py @@ -227,9 +227,7 @@ class LibcxxTestFormat(object): if test_cxx.type != 'gcc': test_cxx.flags += ['-fsyntax-only'] if use_verify: - test_cxx.flags += ['-Xclang', '-verify', - '-Xclang', '-verify-ignore-unexpected=note', - '-ferror-limit=1024'] + test_cxx.useVerify() cmd, out, err, rc = test_cxx.compile(source_path, out=os.devnull) expected_rc = 0 if use_verify else 1 if rc == expected_rc: