C++: Remove concurrent access to TemplateNameId

The modification of the TemplateNameId changed "global state" because
the TemplateNameId is potentially accessed by multiple threads doing
lookup (access to same document and thus same symbol names).

Depending on the thread scheduling and access to
ClassOrNamespace::_specializations, the changed TemplateNameId
"suddenly" led to inconsistent results of TemplateNameId::Compare and
thus broke the std::map assertions.

Get rid of the const_cast, the setter and simply construct a temporary
TemplateNameId with isSpecializaton = true.

Task-number: QTCREATORBUG-14911
Change-Id: Ie381d132cc0d06af351ace4257773637d1ebee4e
Reviewed-by: Przemyslaw Gorszkowski <pgorszkowski@gmail.com>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
Nikolai Kosjar
2016-11-03 11:19:38 +01:00
parent 6494278d70
commit 624bfeb70b
2 changed files with 8 additions and 10 deletions

View File

@@ -99,9 +99,6 @@ public:
TemplateArgumentIterator firstTemplateArgument() const { return _templateArguments.begin(); }
TemplateArgumentIterator lastTemplateArgument() const { return _templateArguments.end(); }
bool isSpecialization() const { return _isSpecialization; }
// this is temporary solution needed in ClassOrNamespace::nestedType
// when we try to find correct specialization for instantiation
void setIsSpecialization(bool isSpecialization) { _isSpecialization = isSpecialization; }
// Comparator needed to distinguish between two different TemplateNameId(e.g.:used in std::map)
struct Compare: std::binary_function<const TemplateNameId *, const TemplateNameId *, bool> {