Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
devel/clazy: unbreak with LLVM >= 17
Reported by: poudriere failure
- Loading branch information
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
devel/clazy/files/patch-src_checks_manuallevel_unexpected-flag-enumerator-value.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- src/checks/manuallevel/unexpected-flag-enumerator-value.cpp.orig 2022-01-20 23:18:47 UTC | ||
+++ src/checks/manuallevel/unexpected-flag-enumerator-value.cpp | ||
@@ -61,8 +61,13 @@ static bool isIntentionallyNotPowerOf2(EnumConstantDec | ||
if (val.isMask() && val.countTrailingOnes() >= MinOnesToQualifyAsMask) | ||
return true; | ||
|
||
+#if LLVM_VERSION_MAJOR >= 17 | ||
+ if (val.isMask() && 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::VisitDecl(clang::D | ||
|
||
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(); |