aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergio Martins <smartins@kde.org>2021-07-27 22:18:53 +0100
committerSergio Martins <smartins@kde.org>2021-07-27 22:18:53 +0100
commitb6289109fad553bd02a6592f00a1e256031aa0db (patch)
tree5aac77415a08fdca65ae9ad185af9e7c09e4c8f8
parentaca3c76c1564f871db5dba3a9ae13eae1c860274 (diff)
unexpected-flag-enumerator-value: Don't warn for unnamed enums
Fixes a bunch of false positives. Unnamed enums are just a bag of mixed stuff.
-rw-r--r--src/checks/manuallevel/unexpected-flag-enumerator-value.cpp2
-rw-r--r--tests/unexpected-flag-enumerator-value/main.cpp8
2 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 32f5aba2..bf4e4c22 100644
--- a/src/checks/manuallevel/unexpected-flag-enumerator-value.cpp
+++ b/src/checks/manuallevel/unexpected-flag-enumerator-value.cpp
@@ -107,7 +107,7 @@ static IsFlagEnumResult isFlagEnum(const SmallVector<EnumConstantDecl*, 16>& enu
void UnexpectedFlagEnumeratorValue::VisitDecl(clang::Decl *decl)
{
auto enDecl = dyn_cast_or_null<EnumDecl>(decl);
- if (!enDecl)
+ if (!enDecl || !enDecl->hasNameForLinkage())
return;
const SmallVector<EnumConstantDecl*, 16> enumerators = getEnumerators(enDecl);
diff --git a/tests/unexpected-flag-enumerator-value/main.cpp b/tests/unexpected-flag-enumerator-value/main.cpp
index c3209c36..0dd0c2d8 100644
--- a/tests/unexpected-flag-enumerator-value/main.cpp
+++ b/tests/unexpected-flag-enumerator-value/main.cpp
@@ -46,3 +46,11 @@ enum {
BLACK = 4,
WHITE = 5,
};
+
+#include <QtCore/qtypeinfo.h>
+
+class FooBar {
+ public:
+ int m = 0;
+};
+Q_DECLARE_TYPEINFO(FooBar, Q_RELOCATABLE_TYPE);