Enable -Wunreachable-code and fix duplicate warning flags

llvm-svn: 290486
This commit is contained in:
Eric Fiselier 2016-12-24 04:34:33 +00:00
parent 2c3fb80b23
commit dee07a6a9f
3 changed files with 9 additions and 9 deletions

View File

@ -147,9 +147,6 @@ class CXXCompiler(object):
cmd += flags
return cmd
def _getWarningFlags(self):
return self.warning_flags if self.use_warnings else []
def preprocessCmd(self, source_files, out=None, flags=[]):
return self._basicCmd(source_files, out, flags=flags,
mode=self.CM_PreProcess,
@ -277,22 +274,21 @@ class CXXCompiler(object):
another error is triggered during compilation.
"""
assert isinstance(flag, str)
assert flag.startswith('-W')
if not flag.startswith('-Wno-'):
if self.hasCompileFlag(flag):
self.warning_flags += [flag]
return True
return False
return self.hasCompileFlag(flag)
flags = ['-Werror', flag]
old_use_warnings = self.use_warnings
self.useWarnings(False)
cmd = self.compileCmd('-', os.devnull, flags)
self.useWarnings(True)
self.useWarnings(old_use_warnings)
# Remove '-v' because it will cause the command line invocation
# to be printed as part of the error output.
# TODO(EricWF): Are there other flags we need to worry about?
if '-v' in cmd:
cmd.remove('-v')
out, err, rc = lit.util.executeCommand(cmd, input='#error\n')
assert rc != 0
if flag in err:
return False
@ -300,6 +296,7 @@ class CXXCompiler(object):
def addWarningFlagIfSupported(self, flag):
if self.hasWarningFlag(flag):
assert flag not in self.warning_flags
self.warning_flags += [flag]
return True
return False

View File

@ -646,6 +646,7 @@ class Configuration(object):
enable_warnings = self.get_lit_bool('enable_warnings',
default_enable_warnings)
if enable_warnings:
self.cxx.useWarnings(True)
self.cxx.warning_flags += [
'-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER',
'-Wall', '-Wextra', '-Werror'
@ -662,6 +663,7 @@ class Configuration(object):
self.cxx.addWarningFlagIfSupported('-Wsign-compare')
self.cxx.addWarningFlagIfSupported('-Wunused-variable')
self.cxx.addWarningFlagIfSupported('-Wunused-parameter')
self.cxx.addWarningFlagIfSupported('-Wunreachable-code')
# FIXME: Enable the two warnings below.
self.cxx.addWarningFlagIfSupported('-Wno-conversion')
self.cxx.addWarningFlagIfSupported('-Wno-unused-local-typedef')

View File

@ -72,7 +72,8 @@ std::unique_ptr<int> f4(std::unique_ptr<int>&& p)
void f5(int j)
{
std::this_thread::sleep_for(ms(200));
TEST_THROW(j); ((void)j);
((void)j);
TEST_THROW(j);
}
template <class Ret, class CheckLamdba, class ...Args>