Commit 18bba097 authored by Nikolai Kosjar's avatar Nikolai Kosjar
Browse files

C++: Stricter checking in TemplateNameId::Compare



Change-Id: I96dbce004d18147fd91485b1117dc65c4bbc08a0
Reviewed-by: default avatarErik Verbruggen <erik.verbruggen@digia.com>
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
Reviewed-by: default avatarKai Koehne <kai.koehne@digia.com>
parent 190fb448
...@@ -130,10 +130,23 @@ bool TemplateNameId::isEqualTo(const Name *other) const ...@@ -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, ...@@ -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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment