commit:     1ea0e9a3ed747a8d800d1a1c25abdbd03e5b8275
Author:     Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
AuthorDate: Mon Mar  4 16:06:48 2024 +0000
Commit:     Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
CommitDate: Mon Mar  4 22:17:40 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1ea0e9a3

dev-util/clazy: Add yet another patch to support LLVM-17

Signed-off-by: Andreas Sturmlechner <asturm <AT> gentoo.org>

 dev-util/clazy/clazy-1.11-r4.ebuild                | 57 ++++++++++++++++++++++
 dev-util/clazy/files/clazy-1.11-fix-llvm-17.patch  | 38 +++++++++++++++
 .../clazy/files/clazy-1.11-jobs-for-tests.patch    | 41 ++++++++++++++++
 3 files changed, 136 insertions(+)

diff --git a/dev-util/clazy/clazy-1.11-r4.ebuild 
b/dev-util/clazy/clazy-1.11-r4.ebuild
new file mode 100644
index 000000000000..81393e677b0e
--- /dev/null
+++ b/dev-util/clazy/clazy-1.11-r4.ebuild
@@ -0,0 +1,57 @@
+# Copyright 1999-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+LLVM_MAX_SLOT=17
+PYTHON_COMPAT=( python3_{10..12} )
+inherit cmake llvm python-any-r1
+
+DESCRIPTION="Compiler plugin which allows clang to understand Qt semantics"
+HOMEPAGE="https://apps.kde.org/clazy";
+SRC_URI="mirror://kde/stable/${PN}/${PV}/src/${P}.tar.xz"
+
+LICENSE="LGPL-2+"
+SLOT="0"
+KEYWORDS="~amd64 ~arm64 ~x86"
+IUSE="test"
+RESTRICT="!test? ( test )"
+
+RDEPEND="<sys-devel/clang-$((${LLVM_MAX_SLOT} + 1)):="
+DEPEND="${RDEPEND}"
+BDEPEND="test? ( ${PYTHON_DEPS} )"
+
+PATCHES=(
+       "${FILESDIR}"/${P}-fix-regex-detect.patch
+       "${FILESDIR}"/${P}-fix-llvm-{15,16,17}.patch
+       "${FILESDIR}"/${P}-jobs-for-tests.patch
+)
+
+llvm_check_deps() {
+       has_version "sys-devel/clang:${LLVM_SLOT}" && has_version 
"sys-devel/llvm:${LLVM_SLOT}"
+}
+
+pkg_setup() {
+       use test && python-any-r1_pkg_setup
+
+       llvm_pkg_setup
+}
+
+src_prepare() {
+       cmake_src_prepare
+
+       sed -e '/install(FILES README.md COPYING-LGPL2.txt checks.json 
DESTINATION/d' \
+               -i CMakeLists.txt || die
+}
+
+src_configure() {
+       export LLVM_ROOT="$(get_llvm_prefix -d ${LLVM_MAX_SLOT})"
+
+       cmake_src_configure
+}
+
+src_test() {
+       # Run tests against built copy, not installed
+       # bug #811723
+       PATH="${BUILD_DIR}/bin:${PATH}" LD_LIBRARY_PATH="${BUILD_DIR}/lib" 
cmake_src_test
+}

diff --git a/dev-util/clazy/files/clazy-1.11-fix-llvm-17.patch 
b/dev-util/clazy/files/clazy-1.11-fix-llvm-17.patch
new file mode 100644
index 000000000000..6550b63a3506
--- /dev/null
+++ b/dev-util/clazy/files/clazy-1.11-fix-llvm-17.patch
@@ -0,0 +1,38 @@
+From a9aabd821d8be7932c954e1cdd8d4e10f38f8785 Mon Sep 17 00:00:00 2001
+From: Cristian Adam <[email protected]>
+Date: Mon, 14 Aug 2023 18:16:01 +0200
+Subject: [PATCH] Fix compilation with LLVM 17.0.0 (rc2)
+
+Change-Id: I9d3fc86185c1e7c86145da043e1982d2979b36e9
+---
+ .../manuallevel/unexpected-flag-enumerator-value.cpp   | 10 ++++++++++
+ 1 file changed, 10 insertions(+)
+
+--- a/src/checks/manuallevel/unexpected-flag-enumerator-value.cpp
++++ b/src/checks/manuallevel/unexpected-flag-enumerator-value.cpp
+@@ -61,8 +61,13 @@ static bool isIntentionallyNotPowerOf2(E
+     if (val.isMask() && val.countTrailingOnes() >= MinOnesToQualifyAsMask)
+         return true;
+ 
++#if LLVM_VERSION_MAJOR >= 17
++    if (val.isShiftedMask() && val.popcount() >= MinOnesToQualifyAsMask)
++        return true;
++#else
+     if (val.isShiftedMask() && val.countPopulation() >= 
MinOnesToQualifyAsMask)
+         return true;
++#endif
+ 
+     if (clazy::contains_lower(en->getName(), "mask"))
+         return true;
+@@ -158,7 +163,11 @@ void UnexpectedFlagEnumeratorValue::Visi
+ 
+     for (EnumConstantDecl* enumerator : enumerators) {
+         const auto &initVal = enumerator->getInitVal();
++#if LLVM_VERSION_MAJOR >= 17
++        if (!initVal.isPowerOf2() && !initVal.isZero() && 
!initVal.isNegative()) {
++#else
+         if (!initVal.isPowerOf2() && !initVal.isNullValue() && 
!initVal.isNegative()) {
++#endif
+             if (isIntentionallyNotPowerOf2(enumerator))
+                 continue;
+             const auto value = enumerator->getInitVal().getLimitedValue();

diff --git a/dev-util/clazy/files/clazy-1.11-jobs-for-tests.patch 
b/dev-util/clazy/files/clazy-1.11-jobs-for-tests.patch
new file mode 100644
index 000000000000..372aed3ca09a
--- /dev/null
+++ b/dev-util/clazy/files/clazy-1.11-jobs-for-tests.patch
@@ -0,0 +1,41 @@
+From ab8993c9e10e09cb24210f76bb5e67f01bb37a9e Mon Sep 17 00:00:00 2001
+From: Pino Toscano <[email protected]>
+Date: Thu, 17 Nov 2022 19:09:47 +0100
+Subject: [PATCH] tests: add -j/--jobs option for run_tests.py
+
+This way it is possible to customize the number of parallel jobs to
+spawn for the tests, instead of unconditionally using all available
+CPUs. This can be helpful to run the tests without overloading the
+system.
+
+The default is still the number of available CPUs, so there is no
+behaviour change by default.
+---
+ tests/run_tests.py | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/tests/run_tests.py b/tests/run_tests.py
+index bf4967d1..ea03ab4c 100755
+--- a/tests/run_tests.py
++++ b/tests/run_tests.py
+@@ -443,6 +443,8 @@ parser.add_argument("--dump-ast", action='store_true',
+                     help='Dump a unit-test AST to file')
+ parser.add_argument(
+     "--exclude", help='Comma separated list of checks to ignore')
++parser.add_argument("-j", "--jobs", type=int, 
default=multiprocessing.cpu_count(),
++                    help='Parallel jobs to run (defaults to %(default)s)')
+ parser.add_argument("check_names", nargs='*',
+                     help="The name of the check whose unit-tests will be run. 
Defaults to running all checks.")
+ args = parser.parse_args()
+@@ -460,7 +462,7 @@ _verbose = args.verbose
+ _no_standalone = args.no_standalone
+ _no_fixits = args.no_fixits
+ _only_standalone = args.only_standalone
+-_num_threads = multiprocessing.cpu_count()
++_num_threads = args.jobs
+ _lock = threading.Lock()
+ _was_successful = True
+ _qt5_installation = find_qt_installation(
+-- 
+2.35.1
+

Reply via email to