One definition rule; avoid false positives when location is same
This commit is contained in:
parent
fbf63b932e
commit
c2c40a18fd
|
@ -2952,6 +2952,9 @@ bool CheckClass::analyseWholeProgram(const CTU::FileInfo *ctu, const std::list<C
|
||||||
}
|
}
|
||||||
if (it->second.hash == nameLoc.hash)
|
if (it->second.hash == nameLoc.hash)
|
||||||
continue;
|
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;
|
std::list<ErrorMessage::FileLocation> locationList;
|
||||||
locationList.emplace_back(nameLoc.fileName, nameLoc.lineNumber, nameLoc.column);
|
locationList.emplace_back(nameLoc.fileName, nameLoc.lineNumber, nameLoc.column);
|
||||||
|
|
|
@ -161,10 +161,13 @@ public:
|
||||||
std::size_t hash;
|
std::size_t hash;
|
||||||
|
|
||||||
bool operator==(const NameLoc& other) const {
|
bool operator==(const NameLoc& other) const {
|
||||||
|
return isSameLocation(other) && hash == other.hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isSameLocation(const NameLoc& other) const {
|
||||||
return fileName == other.fileName &&
|
return fileName == other.fileName &&
|
||||||
lineNumber == other.lineNumber &&
|
lineNumber == other.lineNumber &&
|
||||||
column == other.column &&
|
column == other.column;
|
||||||
hash == other.hash;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
std::vector<NameLoc> classDefinitions;
|
std::vector<NameLoc> classDefinitions;
|
||||||
|
|
Loading…
Reference in New Issue