From 18bba097bdc2fbec9a23aa2152e16a6c201b5929 Mon Sep 17 00:00:00 2001 From: Nikolai Kosjar <nikolai.kosjar@digia.com> Date: Wed, 11 Sep 2013 13:26:46 +0200 Subject: [PATCH] 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> --- src/libs/3rdparty/cplusplus/Names.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/libs/3rdparty/cplusplus/Names.cpp b/src/libs/3rdparty/cplusplus/Names.cpp index 41bd890312d..7f26ea1ad6b 100644 --- a/src/libs/3rdparty/cplusplus/Names.cpp +++ b/src/libs/3rdparty/cplusplus/Names.cpp @@ -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) -- GitLab