diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index 385befab1..06a083121 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -2952,6 +2952,9 @@ bool CheckClass::analyseWholeProgram(const CTU::FileInfo *ctu, const std::listsecond.hash == nameLoc.hash) continue; + // Same location, sometimes the hash is different wrongly (possibly because of different token simplifications). + if (it->second.isSameLocation(nameLoc)) + continue; std::list locationList; locationList.emplace_back(nameLoc.fileName, nameLoc.lineNumber, nameLoc.column); diff --git a/lib/checkclass.h b/lib/checkclass.h index 54eeed275..2e4ca2dc2 100644 --- a/lib/checkclass.h +++ b/lib/checkclass.h @@ -161,10 +161,13 @@ public: std::size_t hash; bool operator==(const NameLoc& other) const { + return isSameLocation(other) && hash == other.hash; + } + + bool isSameLocation(const NameLoc& other) const { return fileName == other.fileName && lineNumber == other.lineNumber && - column == other.column && - hash == other.hash; + column == other.column; } }; std::vector classDefinitions;