[libc++] Fix broken Lit features based on __config_site macros
authorLouis Dionne <ldionne@apple.com>
Fri, 15 May 2020 16:24:05 +0000 (12:24 -0400)
committerLouis Dionne <ldionne@apple.com>
Fri, 15 May 2020 16:25:19 +0000 (12:25 -0400)
Because of Python's funny scoping rules with lambdas, we were always
using the value of `macro` as set in the last iteration of the loop.
This problem was introduced by e7bdfba4f00d.

libcxx/utils/libcxx/test/features.py

index 969cce5..b6c2ba7 100644 (file)
@@ -71,16 +71,16 @@ macros = {
 }
 for macro, feature in macros.items():
   features += [
-    Feature(name=lambda cfg, feature=feature: feature + (
-              '={}'.format(compilerMacros(cfg)[macro]) if compilerMacros(cfg)[macro] else ''
+    Feature(name=lambda cfg, m=macro, f=feature: f + (
+              '={}'.format(compilerMacros(cfg)[m]) if compilerMacros(cfg)[m] else ''
             ),
-            when=lambda cfg, macro=macro: macro in compilerMacros(cfg),
+            when=lambda cfg, m=macro: m in compilerMacros(cfg),
 
             # FIXME: This is a hack that should be fixed using module maps.
             # If modules are enabled then we have to lift all of the definitions
             # in <__config_site> onto the command line.
-            compileFlag=lambda cfg, macro=macro: '-Wno-macro-redefined -D{}'.format(macro) + (
-              '={}'.format(compilerMacros(cfg)[macro]) if compilerMacros(cfg)[macro] else ''
+            compileFlag=lambda cfg, m=macro: '-Wno-macro-redefined -D{}'.format(m) + (
+              '={}'.format(compilerMacros(cfg)[m]) if compilerMacros(cfg)[m] else ''
             )
     )
   ]