From b2691bda8894999205ec8045fc85f949a3c78755 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 20 Mar 2021 18:53:17 +0100 Subject: [PATCH] Fixed false positive in self check --- lib/checkclass.cpp | 3 +++ lib/symboldatabase.h | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index d36cd5f40..064b5c892 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -2844,6 +2844,9 @@ Check::FileInfo *CheckClass::getFileInfo(const Tokenizer *tokenizer, const Setti // One definition rule std::vector classDefinitions; for (const Scope * classScope : tokenizer->getSymbolDatabase()->classAndStructScopes) { + if (classScope->isAnonymous()) + continue; + // the full definition must be compared bool fullDefinition = std::all_of(classScope->functionList.begin(), classScope->functionList.end(), diff --git a/lib/symboldatabase.h b/lib/symboldatabase.h index 4ed3c3ae3..7745966f1 100644 --- a/lib/symboldatabase.h +++ b/lib/symboldatabase.h @@ -1029,6 +1029,11 @@ public: std::vector enumeratorList; + bool isAnonymous() const { + // TODO: Check if class/struct is anonymous + return className.size() > 9 && className.compare(0,9,"Anonymous") == 0 && std::isdigit(className[9]); + } + const Enumerator * findEnumerator(const std::string & name) const { for (const Enumerator & i : enumeratorList) { if (i.name->str() == name)