LLVM 17.0.0
The following patch allows clazy to compile with LLVM 17.0.0 (rc2)
commit 79af1e105223e6794d9177ef8e1cd98fb3f5e249
Author: Cristian Adam <cristian.adam@gmail.com>
Date: Mon Aug 14 18:16:01 2023 +0200
Fix compilation with LLVM 17.0
diff --git a/src/checks/manuallevel/unexpected-flag-enumerator-value.cpp b/src/checks/manuallevel/unexpected-flag-enumerator-value.cpp
index 7bf00b3d..13039c53 100644
--- a/src/checks/manuallevel/unexpected-flag-enumerator-value.cpp
+++ b/src/checks/manuallevel/unexpected-flag-enumerator-value.cpp
@@ -62,11 +62,14 @@ static bool isIntentionallyNotPowerOf2(EnumConstantDecl *en)
return true;
}
- if (val.isShiftedMask() && val.countPopulation() >= MinOnesToQualifyAsMask) {
+#if LLVM_VERSION_MAJOR >= 17
+ if (val.isShiftedMask() && val.popcount() >= MinOnesToQualifyAsMask)
return true;
- }
-
- if (clazy::contains_lower(en->getName(), "mask")) {
+#else
+ if (val.isShiftedMask() && val.countPopulation() >= MinOnesToQualifyAsMask)
+ return true;
+#endif
+ if (clazy::contains_lower(en->getName(), "mask"))
return true;
}
@@ -167,8 +170,12 @@ void UnexpectedFlagEnumeratorValue::VisitDecl(clang::Decl *decl)
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()) {
- if (isIntentionallyNotPowerOf2(enumerator)) {
+#endif
+ if (isIntentionallyNotPowerOf2(enumerator))
continue;
}
const auto value = enumerator->getInitVal().getLimitedValue();
I've tried doing a merge request but git gets stuck at:
Pushing to https://invent.kde.org/cadam/clazy.git
Enumerating objects: 1381, done.
Counting objects: 100% (1132/1132), done.
Delta compression using up to 32 threads
Compressing objects: 100% (195/195), done.
Writing objects: 100% (829/829), 182.27 KiB | 22.78 MiB/s, done.
Total 829 (delta 749), reused 704 (delta 634), pack-reused 0
POST git-receive-pack (186828 bytes)