forked from qt-creator/qt-creator
C++: fix support for nested anonymous classes
A member of nested anonymous class should be visible as a member of enclosing class(if there is no declaration of this nested anonymous class). Fix: * marking * find usage * follow symbol * completion Task-number: QTCREATORBUG-10876 Task-number: QTCREATORBUG-11170 Change-Id: If5b4d198e9075f2a8aa899ae59190f2c05f7b1ff Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Przemyslaw Gorszkowski <pgorszkowski@gmail.com> Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
committed by
Erik Verbruggen
parent
b96bb6172e
commit
376f77952e
@@ -680,6 +680,15 @@ void ClassOrNamespace::lookup_helper(const Name *name, ClassOrNamespace *binding
|
||||
|
||||
foreach (ClassOrNamespace *u, binding->usings())
|
||||
lookup_helper(name, u, result, processed, binding->_templateId);
|
||||
|
||||
Anonymouses::const_iterator cit = binding->_anonymouses.begin();
|
||||
Anonymouses::const_iterator citEnd = binding->_anonymouses.end();
|
||||
for (; cit != citEnd; ++cit) {
|
||||
const AnonymousNameId *anonymousNameId = cit.key();
|
||||
ClassOrNamespace *a = cit.value();
|
||||
if (!binding->_declaredAnonymouses.contains(anonymousNameId))
|
||||
lookup_helper(name, a, result, processed, binding->_templateId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1578,8 +1587,12 @@ bool CreateBindings::visit(Declaration *decl)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (Class *clazz = decl->type()->asClassType()) {
|
||||
if (const Name *name = clazz->name()) {
|
||||
if (const AnonymousNameId *anonymousNameId = name->asAnonymousNameId())
|
||||
_currentClassOrNamespace->_declaredAnonymouses.insert(anonymousNameId);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -93,6 +93,7 @@ public:
|
||||
private:
|
||||
typedef std::map<const Name *, ClassOrNamespace *, Name::Compare> Table;
|
||||
typedef std::map<const TemplateNameId *, ClassOrNamespace *, TemplateNameId::Compare> TemplateNameIdTable;
|
||||
typedef QHash<const AnonymousNameId *, ClassOrNamespace *> Anonymouses;
|
||||
|
||||
/// \internal
|
||||
void flush();
|
||||
@@ -138,7 +139,8 @@ private:
|
||||
QSharedPointer<Control> _control;
|
||||
TemplateNameIdTable _specializations;
|
||||
QMap<const TemplateNameId *, ClassOrNamespace *> _instantiations;
|
||||
QHash<const AnonymousNameId *, ClassOrNamespace *> _anonymouses;
|
||||
Anonymouses _anonymouses;
|
||||
QSet<const AnonymousNameId *> _declaredAnonymouses;
|
||||
|
||||
QHash<Internal::FullyQualifiedName, Symbol *> *_scopeLookupCache;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user