[libcxx-commits] [libcxx] 32c9efb - [libc++] Add support for a new keyword ADDITIONAL_COMPILE_FLAGS

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Mon Mar 30 09:42:14 PDT 2020


Author: Louis Dionne
Date: 2020-03-30T12:40:48-04:00
New Revision: 32c9efb423035ef7c5db6cb6e7b68ac935a8d15b

URL: https://github.com/llvm/llvm-project/commit/32c9efb423035ef7c5db6cb6e7b68ac935a8d15b
DIFF: https://github.com/llvm/llvm-project/commit/32c9efb423035ef7c5db6cb6e7b68ac935a8d15b.diff

LOG: [libc++] Add support for a new keyword ADDITIONAL_COMPILE_FLAGS

This allows adding compilation flags for a single test, which can help
eliminate some .sh.cpp tests and some custom handling in the libc++
test format.

It also works around the issue that .sh.cpp substitutions are _not_
equivalent to the actual compiler command lines used to compile tests,
since the compiler flags can be modified in local lit configurations,
and substitutions are frozen at that point. For example using %{compile}
in a .sh.cpp test in the coroutines subdirectory will not include the
-fcoroutines-ts flag, which is added in the local lit config, because
the %{compile} substitution is created long before we add -fcoroutines-ts
to the compiler flags (in the lit.local.cfg for coroutines).

Added: 
    libcxx/test/libcxx/input.output/filesystems/class.directory_entry/directory_entry.mods/last_write_time.pass.cpp

Modified: 
    libcxx/test/libcxx/selftest/test.arc.fail.mm
    libcxx/test/libcxx/selftest/test.arc.pass.mm
    libcxx/test/libcxx/type_traits/is_pointer.arc.pass.mm
    libcxx/utils/libcxx/test/format.py

Removed: 
    libcxx/test/libcxx/input.output/filesystems/class.directory_entry/directory_entry.mods/last_write_time.sh.cpp


################################################################################
diff  --git a/libcxx/test/libcxx/input.output/filesystems/class.directory_entry/directory_entry.mods/last_write_time.sh.cpp b/libcxx/test/libcxx/input.output/filesystems/class.directory_entry/directory_entry.mods/last_write_time.pass.cpp
similarity index 97%
rename from libcxx/test/libcxx/input.output/filesystems/class.directory_entry/directory_entry.mods/last_write_time.sh.cpp
rename to libcxx/test/libcxx/input.output/filesystems/class.directory_entry/directory_entry.mods/last_write_time.pass.cpp
index 90b3a4369cfb..e4c5a1892972 100644
--- a/libcxx/test/libcxx/input.output/filesystems/class.directory_entry/directory_entry.mods/last_write_time.sh.cpp
+++ b/libcxx/test/libcxx/input.output/filesystems/class.directory_entry/directory_entry.mods/last_write_time.pass.cpp
@@ -7,14 +7,12 @@
 //===----------------------------------------------------------------------===//
 
 // UNSUPPORTED: c++98, c++03
+// ADDITIONAL_COMPILE_FLAGS: -I%{libcxx_src_root}/src/filesystem
 
 // <filesystem>
 
 // class directory_entry
 
-// RUN: %{build} -I%{libcxx_src_root}/src/filesystem
-// RUN: %{run}
-
 #include "filesystem_include.h"
 #include <type_traits>
 #include <cassert>

diff  --git a/libcxx/test/libcxx/selftest/test.arc.fail.mm b/libcxx/test/libcxx/selftest/test.arc.fail.mm
index 712947bcae50..0e8b62c09db5 100644
--- a/libcxx/test/libcxx/selftest/test.arc.fail.mm
+++ b/libcxx/test/libcxx/selftest/test.arc.fail.mm
@@ -7,6 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+// ADDITIONAL_COMPILE_FLAGS: -fobjc-arc
+
 #if __has_feature(objc_arc)
 #error This test should not compile.
 #endif

diff  --git a/libcxx/test/libcxx/selftest/test.arc.pass.mm b/libcxx/test/libcxx/selftest/test.arc.pass.mm
index eecdbb616185..0c83cc825542 100644
--- a/libcxx/test/libcxx/selftest/test.arc.pass.mm
+++ b/libcxx/test/libcxx/selftest/test.arc.pass.mm
@@ -7,6 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+// ADDITIONAL_COMPILE_FLAGS: -fobjc-arc
+
 #if __has_feature(objc_arc) == 0
 #error "arc should be enabled"
 #endif

diff  --git a/libcxx/test/libcxx/type_traits/is_pointer.arc.pass.mm b/libcxx/test/libcxx/type_traits/is_pointer.arc.pass.mm
index 1f4c5089af94..3b297d5c2271 100644
--- a/libcxx/test/libcxx/type_traits/is_pointer.arc.pass.mm
+++ b/libcxx/test/libcxx/type_traits/is_pointer.arc.pass.mm
@@ -8,6 +8,8 @@
 //
 // UNSUPPORTED: c++98, c++03
 
+// ADDITIONAL_COMPILE_FLAGS: -fobjc-arc
+
 // <type_traits>
 
 // std::is_pointer

diff  --git a/libcxx/utils/libcxx/test/format.py b/libcxx/utils/libcxx/test/format.py
index 833159eaabde..e29d58fbf400 100644
--- a/libcxx/utils/libcxx/test/format.py
+++ b/libcxx/utils/libcxx/test/format.py
@@ -46,7 +46,9 @@ def _make_custom_parsers(test):
             IntegratedTestKeywordParser('MODULES_DEFINES:', ParserKind.LIST,
                                         initial_value=[]),
             IntegratedTestKeywordParser('FILE_DEPENDENCIES:', ParserKind.LIST,
-                                        initial_value=test.file_dependencies)
+                                        initial_value=test.file_dependencies),
+            IntegratedTestKeywordParser('ADDITIONAL_COMPILE_FLAGS:', ParserKind.LIST,
+                                        initial_value=[])
         ]
 
     @staticmethod
@@ -89,8 +91,6 @@ def _execute(self, test, lit_config):
         is_pass_test = name.endswith('.pass.cpp') or name.endswith('.pass.mm')
         is_fail_test = name.endswith('.fail.cpp') or name.endswith('.fail.mm')
         is_objcxx_test = name.endswith('.mm')
-        is_objcxx_arc_test = name.endswith('.arc.pass.mm') or \
-                             name.endswith('.arc.fail.mm')
         assert is_sh_test or name_ext == '.cpp' or name_ext == '.mm', \
             'non-cpp file must be sh test'
 
@@ -145,12 +145,14 @@ def _execute(self, test, lit_config):
                 if b'#define _LIBCPP_ASSERT' in contents:
                     test_cxx.useModules(False)
 
+        # Handle ADDITIONAL_COMPILE_FLAGS keywords by adding those compilation
+        # flags, but first perform substitutions in those flags.
+        extra_compile_flags = self._get_parser('ADDITIONAL_COMPILE_FLAGS:', parsers).getValue()
+        extra_compile_flags = lit.TestRunner.applySubstitutions(extra_compile_flags, substitutions)
+        test_cxx.compile_flags.extend(extra_compile_flags)
+
         if is_objcxx_test:
             test_cxx.source_lang = 'objective-c++'
-            if is_objcxx_arc_test:
-                test_cxx.compile_flags += ['-fobjc-arc']
-            else:
-                test_cxx.compile_flags += ['-fno-objc-arc']
             test_cxx.link_flags += ['-framework', 'Foundation']
 
         # Dispatch the test based on its suffix.


        


More information about the libcxx-commits mailing list