diff options
author | Nikolai Kosjar <nikolai.kosjar@digia.com> | 2013-11-01 14:43:24 +0100 |
---|---|---|
committer | Nikolai Kosjar <nikolai.kosjar@digia.com> | 2013-11-12 16:42:22 +0100 |
commit | 0c1675708541f9dda89f9157bf0e721e12288da5 (patch) | |
tree | 389446b6107aa0484fc155160c8846ad2fc7f3ef /src/libs/cplusplus/LookupContext.cpp | |
parent | 03270ad3012d8136c8fb703f29c692fd2d024359 (diff) | |
download | qt-creator-0c1675708541f9dda89f9157bf0e721e12288da5.tar.gz |
C++: Remember the class a ClassOrNamespace is based on
Change-Id: I0d333ff9489e46c4fa1923d70ca950f67ffa3f44
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Diffstat (limited to 'src/libs/cplusplus/LookupContext.cpp')
-rw-r--r-- | src/libs/cplusplus/LookupContext.cpp | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/libs/cplusplus/LookupContext.cpp b/src/libs/cplusplus/LookupContext.cpp index 09ce5d0f40..e5bb6158d9 100644 --- a/src/libs/cplusplus/LookupContext.cpp +++ b/src/libs/cplusplus/LookupContext.cpp @@ -529,6 +529,7 @@ ClassOrNamespace::ClassOrNamespace(CreateBindings *factory, ClassOrNamespace *pa , _scopeLookupCache(0) , _templateId(0) , _instantiationOrigin(0) + , _rootClass(0) #ifdef DEBUG_LOOKUP , _name(0) #endif // DEBUG_LOOKUP @@ -1067,6 +1068,8 @@ ClassOrNamespace *ClassOrNamespace::nestedType(const Name *name, ClassOrNamespac instantiation->_enums.append(reference->unscopedEnums()); instantiation->_usings.append(reference->usings()); + instantiation->_rootClass = reference->rootClass(); + // It gets a bit complicated if the reference is actually a class template because we // now must worry about dependent names in base classes. if (Template *templateSpecialization = referenceClass->enclosingTemplate()) { @@ -1347,7 +1350,8 @@ void ClassOrNamespace::addNestedType(const Name *alias, ClassOrNamespace *e) _classOrNamespaces[alias] = e; } -ClassOrNamespace *ClassOrNamespace::findOrCreateType(const Name *name, ClassOrNamespace *origin) +ClassOrNamespace *ClassOrNamespace::findOrCreateType(const Name *name, ClassOrNamespace *origin, + Class *clazz) { if (! name) return this; @@ -1356,15 +1360,16 @@ ClassOrNamespace *ClassOrNamespace::findOrCreateType(const Name *name, ClassOrNa if (const QualifiedNameId *q = name->asQualifiedNameId()) { if (! q->base()) - return globalNamespace()->findOrCreateType(q->name(), origin); + return globalNamespace()->findOrCreateType(q->name(), origin, clazz); - return findOrCreateType(q->base(), origin)->findOrCreateType(q->name(), origin); + return findOrCreateType(q->base(), origin)->findOrCreateType(q->name(), origin, clazz); } else if (name->isNameId() || name->isTemplateNameId() || name->isAnonymousNameId()) { ClassOrNamespace *e = nestedType(name, origin); if (! e) { e = _factory->allocClassOrNamespace(this); + e->_rootClass = clazz; #ifdef DEBUG_LOOKUP e->_name = name; #endif // DEBUG_LOOKUP @@ -1470,7 +1475,8 @@ void CreateBindings::process(Document::Ptr doc) ClassOrNamespace *CreateBindings::enterClassOrNamespaceBinding(Symbol *symbol) { - ClassOrNamespace *entity = _currentClassOrNamespace->findOrCreateType(symbol->name()); + ClassOrNamespace *entity = _currentClassOrNamespace->findOrCreateType(symbol->name(), 0, + symbol->asClass()); entity->addSymbol(symbol); return switchCurrentClassOrNamespace(entity); @@ -1478,7 +1484,8 @@ ClassOrNamespace *CreateBindings::enterClassOrNamespaceBinding(Symbol *symbol) ClassOrNamespace *CreateBindings::enterGlobalClassOrNamespace(Symbol *symbol) { - ClassOrNamespace *entity = _globalNamespace->findOrCreateType(symbol->name()); + ClassOrNamespace *entity = _globalNamespace->findOrCreateType(symbol->name(), 0, + symbol->asClass()); entity->addSymbol(symbol); return switchCurrentClassOrNamespace(entity); @@ -1516,7 +1523,7 @@ bool CreateBindings::visit(Class *klass) binding = _currentClassOrNamespace->lookupType(klass->name()); if (! binding) - binding = _currentClassOrNamespace->findOrCreateType(klass->name()); + binding = _currentClassOrNamespace->findOrCreateType(klass->name(), 0, klass); _currentClassOrNamespace = binding; _currentClassOrNamespace->addSymbol(klass); @@ -1568,7 +1575,8 @@ bool CreateBindings::visit(Declaration *decl) } } else if (Class *klass = ty->asClassType()) { if (const Identifier *nameId = decl->name()->asNameId()) { - ClassOrNamespace *binding = _currentClassOrNamespace->findOrCreateType(nameId); + ClassOrNamespace *binding + = _currentClassOrNamespace->findOrCreateType(nameId, 0, klass); binding->addSymbol(klass); } } |