forked from qt-creator/qt-creator
C++: Stricter checking in TemplateNameId::Compare
Change-Id: I96dbce004d18147fd91485b1117dc65c4bbc08a0 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com> Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Kai Koehne <kai.koehne@digia.com>
This commit is contained in:
17
src/libs/3rdparty/cplusplus/Names.cpp
vendored
17
src/libs/3rdparty/cplusplus/Names.cpp
vendored
@@ -130,10 +130,23 @@ bool TemplateNameId::isEqualTo(const Name *other) const
|
|||||||
bool TemplateNameId::Compare::operator()(const TemplateNameId *name,
|
bool TemplateNameId::Compare::operator()(const TemplateNameId *name,
|
||||||
const TemplateNameId *other) const
|
const TemplateNameId *other) const
|
||||||
{
|
{
|
||||||
|
if (name == 0)
|
||||||
|
return other != 0;
|
||||||
|
if (other == 0)
|
||||||
|
return false;
|
||||||
|
if (name == other)
|
||||||
|
return false;
|
||||||
|
|
||||||
const Identifier *id = name->identifier();
|
const Identifier *id = name->identifier();
|
||||||
const Identifier *otherId = other->identifier();
|
const Identifier *otherId = other->identifier();
|
||||||
|
|
||||||
if (id == otherId) {
|
if (id == 0)
|
||||||
|
return otherId != 0;
|
||||||
|
if (otherId == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
const int c = std::strcmp(id->chars(), otherId->chars());
|
||||||
|
if (c == 0) {
|
||||||
// we have to differentiate TemplateNameId with respect to specialization or instantiation
|
// we have to differentiate TemplateNameId with respect to specialization or instantiation
|
||||||
if (name->isSpecialization() == other->isSpecialization()) {
|
if (name->isSpecialization() == other->isSpecialization()) {
|
||||||
return std::lexicographical_compare(name->firstTemplateArgument(),
|
return std::lexicographical_compare(name->firstTemplateArgument(),
|
||||||
@@ -145,7 +158,7 @@ bool TemplateNameId::Compare::operator()(const TemplateNameId *name,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return id < otherId;
|
return c < 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
OperatorNameId::OperatorNameId(Kind kind)
|
OperatorNameId::OperatorNameId(Kind kind)
|
||||||
|
|||||||
Reference in New Issue
Block a user