29 lines
1.1 KiB
Diff
29 lines
1.1 KiB
Diff
|
--- a/src/checks/manuallevel/unexpected-flag-enumerator-value.cpp 2022-01-20 18:18:47.000000000 -0500
|
||
|
+++ b/src/checks/manuallevel/unexpected-flag-enumerator-value.cpp 2023-11-03 17:12:24.669027622 -0400
|
||
|
@@ -61,8 +61,13 @@
|
||
|
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 @@
|
||
|
|
||
|
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();
|