diff options
author | Cristian Adam <cristian.adam@gmail.com> | 2023-08-14 18:16:01 +0200 |
---|---|---|
committer | Cristian Adam <cristian.adam@qt.io> | 2023-08-14 16:37:22 +0000 |
commit | 641850bfe401d87c8d4277e3296838ecfdc4d633 (patch) | |
tree | 5a10d26f91cb2bc6752c53e96dcc93fb2141d17f | |
parent | beee0860f2f5ed2d92fb1b11c4c29c491247fd46 (diff) |
Fix compilation with LLVM 17.0.0 (rc2)
Change-Id: I9d3fc86185c1e7c86145da043e1982d2979b36e9
-rw-r--r-- | src/checks/manuallevel/unexpected-flag-enumerator-value.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/checks/manuallevel/unexpected-flag-enumerator-value.cpp b/src/checks/manuallevel/unexpected-flag-enumerator-value.cpp index ae1e6072..2735404e 100644 --- a/src/checks/manuallevel/unexpected-flag-enumerator-value.cpp +++ b/src/checks/manuallevel/unexpected-flag-enumerator-value.cpp @@ -61,9 +61,13 @@ static bool isIntentionallyNotPowerOf2(EnumConstantDecl *en) { 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 +162,11 @@ 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()) { +#endif if (isIntentionallyNotPowerOf2(enumerator)) continue; const auto value = enumerator->getInitVal().getLimitedValue(); |