Re: [PATCH] D11333: [libcxx] Add special warning flag detection logic to compiler.py

2015-08-26 Thread Eric Fiselier via cfe-commits
EricWF updated this revision to Diff 33236.
EricWF added a comment.

Remove unused "CompileString" functions. The reason they can't be used to 
implement `addWarningFlagIfSupported` is because we have to fuss with the flags 
before invoking the compiler .


http://reviews.llvm.org/D11333

Files:
  test/libcxx/compiler.py
  test/libcxx/test/config.py

Index: test/libcxx/test/config.py
===
--- test/libcxx/test/config.py
+++ test/libcxx/test/config.py
@@ -574,16 +574,15 @@
 '-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()
Index: test/libcxx/compiler.py
===
--- test/libcxx/compiler.py
+++ test/libcxx/compiler.py
@@ -161,3 +161,28 @@
 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-" flags are unsupported. If flag is a
+"-Wno-" 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


Index: test/libcxx/test/config.py
===
--- test/libcxx/test/config.py
+++ test/libcxx/test/config.py
@@ -574,16 +574,15 @@
 '-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()
Index: test/libcxx/compiler.py
===
--- test/libcxx/compiler.py
+++ test/libcxx/compiler.py
@@ -161,3 +161,28 @@
 return True
 else:
 return False
+
+def addWarningFlagIfSupported(self, flag):
+"""
+addWarningFlagIfSupported - Add a warning flag if

Re: [PATCH] D11333: [libcxx] Add special warning flag detection logic to compiler.py

2015-08-26 Thread Jonathan Roelofs via cfe-commits
jroelofs added inline comments.


Comment at: test/libcxx/compiler.py:195
@@ +194,3 @@
+cmd.remove('-v')
+out, err, rc = lit.util.executeCommand(cmd, input='#error\n')
+assert rc != 0

... you could at least use `compileString` here.


http://reviews.llvm.org/D11333



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11333: [libcxx] Add special warning flag detection logic to compiler.py

2015-08-26 Thread Jonathan Roelofs via cfe-commits
jroelofs added a comment.

I'd say put them in when you have actual uses for them


http://reviews.llvm.org/D11333



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11333: [libcxx] Add special warning flag detection logic to compiler.py

2015-08-26 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

Those methods are currently unused but are you opposed to me adding them in 
this patch? They will be useful for compiling short tests to check for compiler 
features.


http://reviews.llvm.org/D11333



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11333: [libcxx] Add special warning flag detection logic to compiler.py

2015-08-26 Thread Jonathan Roelofs via cfe-commits
jroelofs added a comment.

the `addWarningFlagIfSupported` part of this patch LGTM.



Comment at: test/libcxx/compiler.py:88
@@ -87,1 +87,3 @@
 
+def compileString(self, source, out=None, flags=[], env=None, cwd=None):
+cmd = self.compileCmd('-', out, flags)

this looks unused to me.


Comment at: test/libcxx/compiler.py:105
@@ -98,1 +104,3 @@
 
+def compileLinkString(self, source, out=None, flags=[], env=None, 
cwd=None):
+cmd = self.compileLinkCmd('-', out, flags)

this looks unused to me.


http://reviews.llvm.org/D11333



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits