Skip to content
Snippets Groups Projects
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: default avatarOrgad Shaneh <orgads@gmail.com>
Reviewed-by: default avatarKai Koehne <kai.koehne@digia.com>
parent 190fb448
No related branches found
No related tags found
No related merge requests found
......@@ -130,10 +130,23 @@ bool TemplateNameId::isEqualTo(const Name *other) const
bool TemplateNameId::Compare::operator()(const TemplateNameId *name,
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 *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
if (name->isSpecialization() == other->isSpecialization()) {
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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment