https://github.com/MatzeB updated https://github.com/llvm/llvm-project/pull/91275
>From c0b7ec2e336476b1a1d6cf05d07bfde2f3dc88a4 Mon Sep 17 00:00:00 2001 From: Matthias Braun <ma...@braunis.de> Date: Mon, 6 May 2024 14:39:37 -0700 Subject: [PATCH 1/6] Use cmake to find perl executable --- clang/CMakeLists.txt | 2 ++ clang/test/Analysis/scan-build/cxx-name.test | 2 +- clang/test/Analysis/scan-build/deduplication.test | 3 +-- clang/test/Analysis/scan-build/exclude_directories.test | 3 +-- clang/test/Analysis/scan-build/help.test | 3 +-- clang/test/Analysis/scan-build/html_output.test | 3 +-- clang/test/Analysis/scan-build/lit.local.cfg | 3 ++- clang/test/Analysis/scan-build/plist_html_output.test | 3 +-- clang/test/Analysis/scan-build/plist_output.test | 3 +-- .../test/Analysis/scan-build/rebuild_index/rebuild_index.test | 3 +-- clang/test/Analysis/scan-build/silence-core-checkers.test | 3 +-- clang/test/lit.cfg.py | 3 +++ clang/test/lit.site.cfg.py.in | 1 + 13 files changed, 17 insertions(+), 18 deletions(-) diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt index cf97e3c6e851ae..c20ce47a12abbd 100644 --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -523,6 +523,8 @@ endif() if( CLANG_INCLUDE_TESTS ) + find_package(Perl) + add_subdirectory(unittests) list(APPEND CLANG_TEST_DEPS ClangUnitTests) list(APPEND CLANG_TEST_PARAMS diff --git a/clang/test/Analysis/scan-build/cxx-name.test b/clang/test/Analysis/scan-build/cxx-name.test index 483762d619d178..789f7e0ac197c6 100644 --- a/clang/test/Analysis/scan-build/cxx-name.test +++ b/clang/test/Analysis/scan-build/cxx-name.test @@ -1,4 +1,4 @@ -REQUIRES: shell +REQUIRES: perl RUN: %scan-build sh -c 'echo "CLANG_CXX=/$(basename "$CLANG_CXX")/"' | FileCheck %s diff --git a/clang/test/Analysis/scan-build/deduplication.test b/clang/test/Analysis/scan-build/deduplication.test index 56d888e5fc12a2..62375d9aadfa85 100644 --- a/clang/test/Analysis/scan-build/deduplication.test +++ b/clang/test/Analysis/scan-build/deduplication.test @@ -1,5 +1,4 @@ -// FIXME: Actually, "perl". -REQUIRES: shell +REQUIRES: perl RUN: rm -rf %t.output_dir && mkdir %t.output_dir RUN: %scan-build -o %t.output_dir \ diff --git a/clang/test/Analysis/scan-build/exclude_directories.test b/clang/test/Analysis/scan-build/exclude_directories.test index c161e51b6d26c5..c15568f0b6bb9e 100644 --- a/clang/test/Analysis/scan-build/exclude_directories.test +++ b/clang/test/Analysis/scan-build/exclude_directories.test @@ -1,5 +1,4 @@ -// FIXME: Actually, "perl". -REQUIRES: shell +REQUIRES: perl RUN: rm -rf %t.output_dir && mkdir %t.output_dir RUN: %scan-build -o %t.output_dir %clang -S \ diff --git a/clang/test/Analysis/scan-build/help.test b/clang/test/Analysis/scan-build/help.test index 61915d32609439..2966507b6080cd 100644 --- a/clang/test/Analysis/scan-build/help.test +++ b/clang/test/Analysis/scan-build/help.test @@ -1,5 +1,4 @@ -// FIXME: Actually, "perl". -REQUIRES: shell +REQUIRES: perl RUN: %scan-build -h | FileCheck %s RUN: %scan-build --help | FileCheck %s diff --git a/clang/test/Analysis/scan-build/html_output.test b/clang/test/Analysis/scan-build/html_output.test index add35d83b95887..2d5c001e83960d 100644 --- a/clang/test/Analysis/scan-build/html_output.test +++ b/clang/test/Analysis/scan-build/html_output.test @@ -1,5 +1,4 @@ -// FIXME: Actually, "perl". -REQUIRES: shell +REQUIRES: perl RUN: rm -rf %t.output_dir && mkdir %t.output_dir RUN: %scan-build -o %t.output_dir %clang -S %S/Inputs/single_null_dereference.c \ diff --git a/clang/test/Analysis/scan-build/lit.local.cfg b/clang/test/Analysis/scan-build/lit.local.cfg index fab52b1c7bd679..e606243ea73a48 100644 --- a/clang/test/Analysis/scan-build/lit.local.cfg +++ b/clang/test/Analysis/scan-build/lit.local.cfg @@ -12,8 +12,9 @@ clang_path = config.clang if config.have_llvm_driver else os.path.realpath(confi config.substitutions.append( ( "%scan-build", - "'%s' --use-analyzer=%s " + "'%s' '%s' --use-analyzer=%s " % ( + config.perl_executable, lit.util.which( "scan-build", os.path.join(config.clang_src_dir, "tools", "scan-build", "bin"), diff --git a/clang/test/Analysis/scan-build/plist_html_output.test b/clang/test/Analysis/scan-build/plist_html_output.test index c07891e35fbf33..811bca22b07643 100644 --- a/clang/test/Analysis/scan-build/plist_html_output.test +++ b/clang/test/Analysis/scan-build/plist_html_output.test @@ -1,5 +1,4 @@ -// FIXME: Actually, "perl". -REQUIRES: shell +REQUIRES: perl RUN: rm -rf %t.output_dir && mkdir %t.output_dir RUN: %scan-build -plist-html -o %t.output_dir %clang -S %S/Inputs/single_null_dereference.c \ diff --git a/clang/test/Analysis/scan-build/plist_output.test b/clang/test/Analysis/scan-build/plist_output.test index 0112e84630eda2..45c9dd0a5aa2e7 100644 --- a/clang/test/Analysis/scan-build/plist_output.test +++ b/clang/test/Analysis/scan-build/plist_output.test @@ -1,5 +1,4 @@ -// FIXME: Actually, "perl". -REQUIRES: shell +REQUIRES: perl RUN: rm -rf %t.output_dir && mkdir %t.output_dir RUN: %scan-build -plist -o %t.output_dir %clang -S %S/Inputs/single_null_dereference.c \ diff --git a/clang/test/Analysis/scan-build/rebuild_index/rebuild_index.test b/clang/test/Analysis/scan-build/rebuild_index/rebuild_index.test index ab70435c60542f..5ce04e132f9fbc 100644 --- a/clang/test/Analysis/scan-build/rebuild_index/rebuild_index.test +++ b/clang/test/Analysis/scan-build/rebuild_index/rebuild_index.test @@ -1,5 +1,4 @@ -// FIXME: Actually, "perl". -REQUIRES: shell +REQUIRES: perl RUN: rm -rf %t.output_dir && mkdir %t.output_dir RUN: cp %S/report-1.html %t.output_dir diff --git a/clang/test/Analysis/scan-build/silence-core-checkers.test b/clang/test/Analysis/scan-build/silence-core-checkers.test index 6d9a3017fcd612..dae54cbfb6579c 100644 --- a/clang/test/Analysis/scan-build/silence-core-checkers.test +++ b/clang/test/Analysis/scan-build/silence-core-checkers.test @@ -1,5 +1,4 @@ -// FIXME: Actually, "perl". -REQUIRES: shell +REQUIRES: perl RUN: rm -rf %t.output_dir && mkdir %t.output_dir RUN: %scan-build -o %t.output_dir \ diff --git a/clang/test/lit.cfg.py b/clang/test/lit.cfg.py index e5630a07424c7c..f82981a0880f08 100644 --- a/clang/test/lit.cfg.py +++ b/clang/test/lit.cfg.py @@ -181,6 +181,9 @@ def have_host_clang_repl_cuda(): ) ) +if config.perl_executable: + config.available_features.add("perl") + llvm_config.add_tool_substitutions(tools, tool_dirs) config.substitutions.append( diff --git a/clang/test/lit.site.cfg.py.in b/clang/test/lit.site.cfg.py.in index 6641811c588395..24d9a64bcbf6a6 100644 --- a/clang/test/lit.site.cfg.py.in +++ b/clang/test/lit.site.cfg.py.in @@ -35,6 +35,7 @@ config.enable_threads = @LLVM_ENABLE_THREADS@ config.reverse_iteration = @LLVM_ENABLE_REVERSE_ITERATION@ config.host_arch = "@HOST_ARCH@" config.python_executable = "@Python3_EXECUTABLE@" +config.perl_executable = "@PERL_EXECUTABLE@" config.use_z3_solver = lit_config.params.get('USE_Z3_SOLVER', "@USE_Z3_SOLVER@") config.has_plugins = @CLANG_PLUGIN_SUPPORT@ config.clang_vendor_uti = "@CLANG_VENDOR_UTI@" >From f722911c6ed82676169522fa84305f403c3c4abf Mon Sep 17 00:00:00 2001 From: Matthias Braun <ma...@braunis.de> Date: Mon, 6 May 2024 15:37:08 -0700 Subject: [PATCH 2/6] address review feedback --- clang/test/Analysis/scan-build/cxx-name.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/test/Analysis/scan-build/cxx-name.test b/clang/test/Analysis/scan-build/cxx-name.test index 789f7e0ac197c6..239c5a447879a4 100644 --- a/clang/test/Analysis/scan-build/cxx-name.test +++ b/clang/test/Analysis/scan-build/cxx-name.test @@ -1,4 +1,4 @@ -REQUIRES: perl +REQUIRES: perl, shell RUN: %scan-build sh -c 'echo "CLANG_CXX=/$(basename "$CLANG_CXX")/"' | FileCheck %s >From cc6f556e17ebfd4d65f84c2328cad875c7157835 Mon Sep 17 00:00:00 2001 From: Matthias Braun <ma...@braunis.de> Date: Mon, 6 May 2024 15:38:19 -0700 Subject: [PATCH 3/6] sort alphabetically --- clang/test/lit.site.cfg.py.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/test/lit.site.cfg.py.in b/clang/test/lit.site.cfg.py.in index 24d9a64bcbf6a6..ec6d30e6c2203a 100644 --- a/clang/test/lit.site.cfg.py.in +++ b/clang/test/lit.site.cfg.py.in @@ -34,8 +34,8 @@ config.enable_backtrace = @ENABLE_BACKTRACES@ config.enable_threads = @LLVM_ENABLE_THREADS@ config.reverse_iteration = @LLVM_ENABLE_REVERSE_ITERATION@ config.host_arch = "@HOST_ARCH@" -config.python_executable = "@Python3_EXECUTABLE@" config.perl_executable = "@PERL_EXECUTABLE@" +config.python_executable = "@Python3_EXECUTABLE@" config.use_z3_solver = lit_config.params.get('USE_Z3_SOLVER', "@USE_Z3_SOLVER@") config.has_plugins = @CLANG_PLUGIN_SUPPORT@ config.clang_vendor_uti = "@CLANG_VENDOR_UTI@" >From 5e5b18a31057f0d086ce9731d2b58aa70d55eef5 Mon Sep 17 00:00:00 2001 From: Matthias Braun <ma...@braunis.de> Date: Mon, 6 May 2024 16:20:22 -0700 Subject: [PATCH 4/6] Address review feedback --- clang/test/Analysis/scan-build/cxx-name.test | 2 +- clang/test/Analysis/scan-build/deduplication.test | 2 -- clang/test/Analysis/scan-build/exclude_directories.test | 2 -- clang/test/Analysis/scan-build/help.test | 2 -- clang/test/Analysis/scan-build/html_output.test | 2 -- clang/test/Analysis/scan-build/lit.local.cfg | 3 +++ clang/test/Analysis/scan-build/plist_html_output.test | 2 -- clang/test/Analysis/scan-build/plist_output.test | 2 -- .../test/Analysis/scan-build/rebuild_index/rebuild_index.test | 2 -- clang/test/Analysis/scan-build/silence-core-checkers.test | 2 -- clang/test/lit.cfg.py | 3 --- 11 files changed, 4 insertions(+), 20 deletions(-) diff --git a/clang/test/Analysis/scan-build/cxx-name.test b/clang/test/Analysis/scan-build/cxx-name.test index 239c5a447879a4..483762d619d178 100644 --- a/clang/test/Analysis/scan-build/cxx-name.test +++ b/clang/test/Analysis/scan-build/cxx-name.test @@ -1,4 +1,4 @@ -REQUIRES: perl, shell +REQUIRES: shell RUN: %scan-build sh -c 'echo "CLANG_CXX=/$(basename "$CLANG_CXX")/"' | FileCheck %s diff --git a/clang/test/Analysis/scan-build/deduplication.test b/clang/test/Analysis/scan-build/deduplication.test index 62375d9aadfa85..067a5153d67db1 100644 --- a/clang/test/Analysis/scan-build/deduplication.test +++ b/clang/test/Analysis/scan-build/deduplication.test @@ -1,5 +1,3 @@ -REQUIRES: perl - RUN: rm -rf %t.output_dir && mkdir %t.output_dir RUN: %scan-build -o %t.output_dir \ RUN: %clang -S %S/Inputs/deduplication/1.c \ diff --git a/clang/test/Analysis/scan-build/exclude_directories.test b/clang/test/Analysis/scan-build/exclude_directories.test index c15568f0b6bb9e..2c79ed842af113 100644 --- a/clang/test/Analysis/scan-build/exclude_directories.test +++ b/clang/test/Analysis/scan-build/exclude_directories.test @@ -1,5 +1,3 @@ -REQUIRES: perl - RUN: rm -rf %t.output_dir && mkdir %t.output_dir RUN: %scan-build -o %t.output_dir %clang -S \ RUN: %S/Inputs/multidirectory_project/directory1/file1.c \ diff --git a/clang/test/Analysis/scan-build/help.test b/clang/test/Analysis/scan-build/help.test index 2966507b6080cd..d1f17cd69f51d1 100644 --- a/clang/test/Analysis/scan-build/help.test +++ b/clang/test/Analysis/scan-build/help.test @@ -1,5 +1,3 @@ -REQUIRES: perl - RUN: %scan-build -h | FileCheck %s RUN: %scan-build --help | FileCheck %s diff --git a/clang/test/Analysis/scan-build/html_output.test b/clang/test/Analysis/scan-build/html_output.test index 2d5c001e83960d..1eb4e73611cf29 100644 --- a/clang/test/Analysis/scan-build/html_output.test +++ b/clang/test/Analysis/scan-build/html_output.test @@ -1,5 +1,3 @@ -REQUIRES: perl - RUN: rm -rf %t.output_dir && mkdir %t.output_dir RUN: %scan-build -o %t.output_dir %clang -S %S/Inputs/single_null_dereference.c \ RUN: | FileCheck %s -check-prefix CHECK-STDOUT diff --git a/clang/test/Analysis/scan-build/lit.local.cfg b/clang/test/Analysis/scan-build/lit.local.cfg index e606243ea73a48..21311f222c8e81 100644 --- a/clang/test/Analysis/scan-build/lit.local.cfg +++ b/clang/test/Analysis/scan-build/lit.local.cfg @@ -23,3 +23,6 @@ config.substitutions.append( ), ) ) + +if not config.perl_executable: + config.unsupported = True diff --git a/clang/test/Analysis/scan-build/plist_html_output.test b/clang/test/Analysis/scan-build/plist_html_output.test index 811bca22b07643..b995aa6d5d36ac 100644 --- a/clang/test/Analysis/scan-build/plist_html_output.test +++ b/clang/test/Analysis/scan-build/plist_html_output.test @@ -1,5 +1,3 @@ -REQUIRES: perl - RUN: rm -rf %t.output_dir && mkdir %t.output_dir RUN: %scan-build -plist-html -o %t.output_dir %clang -S %S/Inputs/single_null_dereference.c \ RUN: | FileCheck %s -check-prefix CHECK-STDOUT diff --git a/clang/test/Analysis/scan-build/plist_output.test b/clang/test/Analysis/scan-build/plist_output.test index 45c9dd0a5aa2e7..1e7bef1035b51c 100644 --- a/clang/test/Analysis/scan-build/plist_output.test +++ b/clang/test/Analysis/scan-build/plist_output.test @@ -1,5 +1,3 @@ -REQUIRES: perl - RUN: rm -rf %t.output_dir && mkdir %t.output_dir RUN: %scan-build -plist -o %t.output_dir %clang -S %S/Inputs/single_null_dereference.c \ RUN: | FileCheck %s -check-prefix CHECK-STDOUT diff --git a/clang/test/Analysis/scan-build/rebuild_index/rebuild_index.test b/clang/test/Analysis/scan-build/rebuild_index/rebuild_index.test index 5ce04e132f9fbc..711a74f3fd02bd 100644 --- a/clang/test/Analysis/scan-build/rebuild_index/rebuild_index.test +++ b/clang/test/Analysis/scan-build/rebuild_index/rebuild_index.test @@ -1,5 +1,3 @@ -REQUIRES: perl - RUN: rm -rf %t.output_dir && mkdir %t.output_dir RUN: cp %S/report-1.html %t.output_dir RUN: cp %S/report-2.html %t.output_dir diff --git a/clang/test/Analysis/scan-build/silence-core-checkers.test b/clang/test/Analysis/scan-build/silence-core-checkers.test index dae54cbfb6579c..7ffa744a545cff 100644 --- a/clang/test/Analysis/scan-build/silence-core-checkers.test +++ b/clang/test/Analysis/scan-build/silence-core-checkers.test @@ -1,5 +1,3 @@ -REQUIRES: perl - RUN: rm -rf %t.output_dir && mkdir %t.output_dir RUN: %scan-build -o %t.output_dir \ RUN: %clang -S %S/Inputs/null_dereference_and_division_by_zero.c \ diff --git a/clang/test/lit.cfg.py b/clang/test/lit.cfg.py index f82981a0880f08..e5630a07424c7c 100644 --- a/clang/test/lit.cfg.py +++ b/clang/test/lit.cfg.py @@ -181,9 +181,6 @@ def have_host_clang_repl_cuda(): ) ) -if config.perl_executable: - config.available_features.add("perl") - llvm_config.add_tool_substitutions(tools, tool_dirs) config.substitutions.append( >From d18a90300f8739c4fdcf3f15f62f0c359ba56b58 Mon Sep 17 00:00:00 2001 From: Matthias Braun <ma...@braunis.de> Date: Mon, 6 May 2024 16:27:14 -0700 Subject: [PATCH 5/6] Address feedback --- clang/test/Analysis/scan-build/deduplication.test | 2 ++ clang/test/Analysis/scan-build/html_output.test | 2 ++ clang/test/Analysis/scan-build/plist_html_output.test | 2 ++ clang/test/Analysis/scan-build/plist_output.test | 2 ++ 4 files changed, 8 insertions(+) diff --git a/clang/test/Analysis/scan-build/deduplication.test b/clang/test/Analysis/scan-build/deduplication.test index 067a5153d67db1..2ec3061701fceb 100644 --- a/clang/test/Analysis/scan-build/deduplication.test +++ b/clang/test/Analysis/scan-build/deduplication.test @@ -1,3 +1,5 @@ +REQUIRES: shell + RUN: rm -rf %t.output_dir && mkdir %t.output_dir RUN: %scan-build -o %t.output_dir \ RUN: %clang -S %S/Inputs/deduplication/1.c \ diff --git a/clang/test/Analysis/scan-build/html_output.test b/clang/test/Analysis/scan-build/html_output.test index 1eb4e73611cf29..c2b509d9ef6611 100644 --- a/clang/test/Analysis/scan-build/html_output.test +++ b/clang/test/Analysis/scan-build/html_output.test @@ -1,3 +1,5 @@ +REQUIRES: shell + RUN: rm -rf %t.output_dir && mkdir %t.output_dir RUN: %scan-build -o %t.output_dir %clang -S %S/Inputs/single_null_dereference.c \ RUN: | FileCheck %s -check-prefix CHECK-STDOUT diff --git a/clang/test/Analysis/scan-build/plist_html_output.test b/clang/test/Analysis/scan-build/plist_html_output.test index b995aa6d5d36ac..ca9c5256b9d75a 100644 --- a/clang/test/Analysis/scan-build/plist_html_output.test +++ b/clang/test/Analysis/scan-build/plist_html_output.test @@ -1,3 +1,5 @@ +REQUIRES: shell + RUN: rm -rf %t.output_dir && mkdir %t.output_dir RUN: %scan-build -plist-html -o %t.output_dir %clang -S %S/Inputs/single_null_dereference.c \ RUN: | FileCheck %s -check-prefix CHECK-STDOUT diff --git a/clang/test/Analysis/scan-build/plist_output.test b/clang/test/Analysis/scan-build/plist_output.test index 1e7bef1035b51c..4d01640bff6eab 100644 --- a/clang/test/Analysis/scan-build/plist_output.test +++ b/clang/test/Analysis/scan-build/plist_output.test @@ -1,3 +1,5 @@ +REQUIRES: shell + RUN: rm -rf %t.output_dir && mkdir %t.output_dir RUN: %scan-build -plist -o %t.output_dir %clang -S %S/Inputs/single_null_dereference.c \ RUN: | FileCheck %s -check-prefix CHECK-STDOUT >From 1bb5098f0f7f3913040c1799623b57c32539e8f9 Mon Sep 17 00:00:00 2001 From: Matthias Braun <ma...@braunis.de> Date: Tue, 7 May 2024 09:15:42 -0700 Subject: [PATCH 6/6] Now that we explicitely specify a perl interpreter we should no longer use lit.util.which so we don't pick up scan-build.bat on windows --- clang/test/Analysis/scan-build/lit.local.cfg | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/clang/test/Analysis/scan-build/lit.local.cfg b/clang/test/Analysis/scan-build/lit.local.cfg index 21311f222c8e81..f8bd6f7963bcdb 100644 --- a/clang/test/Analysis/scan-build/lit.local.cfg +++ b/clang/test/Analysis/scan-build/lit.local.cfg @@ -15,9 +15,8 @@ config.substitutions.append( "'%s' '%s' --use-analyzer=%s " % ( config.perl_executable, - lit.util.which( - "scan-build", - os.path.join(config.clang_src_dir, "tools", "scan-build", "bin"), + os.path.join( + config.clang_src_dir, "tools", "scan-build", "bin", "scan-build" ), clang_path, ), _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits