aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergio Martins <smartins@kde.org>2021-11-05 15:49:34 +0000
committerSergio Martins <smartins@kde.org>2021-11-05 15:51:08 +0000
commit3e25e9e28c7391d5d04f6add07010d0be5ee1b8e (patch)
tree3d9c47554a609690dc9a87fcfa13236b797ac18a
parentc4b3f46af893e7f9067c6f4c63c901af52edfe6c (diff)
Fix compile with LLVM-13
StringRef::contains_lower() was removed in llvm-13 linking still fails
-rw-r--r--src/SourceCompatibilityHelpers.h9
-rw-r--r--src/checks/manuallevel/unexpected-flag-enumerator-value.cpp2
2 files changed, 10 insertions, 1 deletions
diff --git a/src/SourceCompatibilityHelpers.h b/src/SourceCompatibilityHelpers.h
index b01f16ac..27309f7f 100644
--- a/src/SourceCompatibilityHelpers.h
+++ b/src/SourceCompatibilityHelpers.h
@@ -139,6 +139,15 @@ inline bool isFinal(const clang::CXXRecordDecl *record)
#endif
}
+inline bool contains_lower(clang::StringRef haystack, clang::StringRef needle)
+{
+#if LLVM_VERSION_MAJOR >= 13
+ return haystack.contains_insensitive(needle);
+#else
+ return haystack.contains_lower(needle);
+#endif
+}
+
}
#endif
diff --git a/src/checks/manuallevel/unexpected-flag-enumerator-value.cpp b/src/checks/manuallevel/unexpected-flag-enumerator-value.cpp
index 6bc98699..ae1e6072 100644
--- a/src/checks/manuallevel/unexpected-flag-enumerator-value.cpp
+++ b/src/checks/manuallevel/unexpected-flag-enumerator-value.cpp
@@ -64,7 +64,7 @@ static bool isIntentionallyNotPowerOf2(EnumConstantDecl *en) {
if (val.isShiftedMask() && val.countPopulation() >= MinOnesToQualifyAsMask)
return true;
- if (en->getName().contains_lower("mask"))
+ if (clazy::contains_lower(en->getName(), "mask"))
return true;
auto *cexpr = getConstantExpr(en);