One definition rule; avoid false positives when location is same

This commit is contained in:
Daniel Marjamäki 2021-02-10 11:44:05 +01:00
parent fbf63b932e
commit c2c40a18fd
2 changed files with 8 additions and 2 deletions

View File

@ -2952,6 +2952,9 @@ bool CheckClass::analyseWholeProgram(const CTU::FileInfo *ctu, const std::list<C
}
if (it->second.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<ErrorMessage::FileLocation> locationList;
locationList.emplace_back(nameLoc.fileName, nameLoc.lineNumber, nameLoc.column);

View File

@ -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<NameLoc> classDefinitions;