summaryrefslogtreecommitdiffstats
path: root/libcxx/test
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2015-08-26 20:17:33 +0000
committerEric Fiselier <eric@efcs.ca>2015-08-26 20:17:33 +0000
commit4b30e569be72f6dfcdf811c12eb34e2d4e4d4ce5 (patch)
treed82f8d6d5a54103baaaa54d7f1e3f9a67737c266 /libcxx/test
parent70192a9efb72800cd83f09496f5168332c46f060 (diff)
downloadbcm5719-llvm-4b30e569be72f6dfcdf811c12eb34e2d4e4d4ce5.tar.gz
bcm5719-llvm-4b30e569be72f6dfcdf811c12eb34e2d4e4d4ce5.zip
[libcxx] Add special warning flag detection logic to compiler.py
Summary: Detecting `-Wno-<warning>` flags can be tricky with GCC (See https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html). This patch adds a special `addWarningFlagIfSupported(<flag>)` method to the test compiler object that can be used to add warning flags. The goal of this patch is to help get the test suite running with more warnings. Reviewers: danalbert, jroelofs Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D11333 llvm-svn: 246069
Diffstat (limited to 'libcxx/test')
-rw-r--r--libcxx/test/libcxx/compiler.py25
-rw-r--r--libcxx/test/libcxx/test/config.py11
2 files changed, 30 insertions, 6 deletions
diff --git a/libcxx/test/libcxx/compiler.py b/libcxx/test/libcxx/compiler.py
index 24ac431e22d..4962038cbbe 100644
--- a/libcxx/test/libcxx/compiler.py
+++ b/libcxx/test/libcxx/compiler.py
@@ -161,3 +161,28 @@ class CXXCompiler(object):
return True
else:
return False
+
+ def addWarningFlagIfSupported(self, flag):
+ """
+ addWarningFlagIfSupported - Add a warning flag if the compiler
+ supports it. Unlike addCompileFlagIfSupported, this function detects
+ when "-Wno-<warning>" flags are unsupported. If flag is a
+ "-Wno-<warning>" GCC will not emit an unknown option diagnostic unless
+ another error is triggered during compilation.
+ """
+ assert isinstance(flag, str)
+ if not flag.startswith('-Wno-'):
+ return self.addCompileFlagIfSupported(flag)
+ flags = ['-Werror', flag]
+ cmd = self.compileCmd('-', os.devnull, flags)
+ # 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
+ self.compile_flags += [flag]
+ return True
diff --git a/libcxx/test/libcxx/test/config.py b/libcxx/test/libcxx/test/config.py
index 502b688fb4e..5171f25ae04 100644
--- a/libcxx/test/libcxx/test/config.py
+++ b/libcxx/test/libcxx/test/config.py
@@ -574,16 +574,15 @@ class Configuration(object):
'-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER',
'-Wall', '-Werror'
]
- self.cxx.addCompileFlagIfSupported('-Wno-attributes')
- if self.cxx.type == 'clang' or self.cxx.type == 'apple-clang':
- self.cxx.addCompileFlagIfSupported('-Wno-pessimizing-move')
- self.cxx.addCompileFlagIfSupported('-Wno-c++11-extensions')
- self.cxx.addCompileFlagIfSupported('-Wno-user-defined-literals')
+ self.cxx.addWarningFlagIfSupported('-Wno-attributes')
+ self.cxx.addWarningFlagIfSupported('-Wno-pessimizing-move')
+ self.cxx.addWarningFlagIfSupported('-Wno-c++11-extensions')
+ self.cxx.addWarningFlagIfSupported('-Wno-user-defined-literals')
std = self.get_lit_conf('std', None)
if std in ['c++98', 'c++03']:
# The '#define static_assert' provided by libc++ in C++03 mode
# causes an unused local typedef whenever it is used.
- self.cxx.addCompileFlagIfSupported('-Wno-unused-local-typedef')
+ self.cxx.addWarningFlagIfSupported('-Wno-unused-local-typedef')
def configure_sanitizer(self):
san = self.get_lit_conf('use_sanitizer', '').strip()
OpenPOWER on IntegriCloud