diff options
author | Nikolai Kosjar <nikolai.kosjar@digia.com> | 2013-07-08 15:28:07 +0200 |
---|---|---|
committer | Nikolai Kosjar <nikolai.kosjar@digia.com> | 2013-07-16 08:26:19 +0200 |
commit | f7e26babba3b645fd39a9b5691d513bc314d7759 (patch) | |
tree | c08743d151267bec14d119a7e642cc34b7fb2780 | |
parent | 42e0e229afba2f9ccc01441346e0f53ae29c4feb (diff) | |
download | qt-creator-f7e26babba3b645fd39a9b5691d513bc314d7759.tar.gz |
C++: Fix names of functions dealing with enclosing scopes
...in order to better tell apart the type related functions
isScope()/asScope() and the functions dealing with enclosing scopes:
* scope() --> enclosingScope()
* setScope() --> setEnclosingScope()
* resetScope() --> resetEnclosingScope()
Change-Id: Id743a7d1b6a1a1a0ffcd8568cbd8ebbdfc16eaa1
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@digia.com>
-rw-r--r-- | src/libs/3rdparty/cplusplus/Bind.cpp | 2 | ||||
-rw-r--r-- | src/libs/3rdparty/cplusplus/Scope.cpp | 4 | ||||
-rw-r--r-- | src/libs/3rdparty/cplusplus/Symbol.cpp | 35 | ||||
-rw-r--r-- | src/libs/3rdparty/cplusplus/Symbol.h | 7 | ||||
-rw-r--r-- | src/libs/3rdparty/cplusplus/Templates.cpp | 4 | ||||
-rw-r--r-- | src/libs/cplusplus/CppRewriter.cpp | 2 | ||||
-rw-r--r-- | src/libs/cplusplus/DeprecatedGenTemplateInstance.cpp | 2 | ||||
-rw-r--r-- | src/libs/cplusplus/LookupContext.cpp | 6 | ||||
-rw-r--r-- | src/plugins/cppeditor/cppquickfixes.cpp | 2 |
9 files changed, 29 insertions, 35 deletions
diff --git a/src/libs/3rdparty/cplusplus/Bind.cpp b/src/libs/3rdparty/cplusplus/Bind.cpp index 61140f4120..663f87f48a 100644 --- a/src/libs/3rdparty/cplusplus/Bind.cpp +++ b/src/libs/3rdparty/cplusplus/Bind.cpp @@ -1862,7 +1862,7 @@ bool Bind::visit(SimpleDeclarationAST *ast) setDeclSpecifiers(decl, type); if (Function *fun = decl->type()->asFunctionType()) { - fun->setScope(_scope); + fun->setEnclosingScope(_scope); fun->setSourceLocation(sourceLocation, translationUnit()); setDeclSpecifiers(fun, type); diff --git a/src/libs/3rdparty/cplusplus/Scope.cpp b/src/libs/3rdparty/cplusplus/Scope.cpp index 66d422ad35..ab1ba2710d 100644 --- a/src/libs/3rdparty/cplusplus/Scope.cpp +++ b/src/libs/3rdparty/cplusplus/Scope.cpp @@ -109,7 +109,7 @@ SymbolTable::~SymbolTable() void SymbolTable::enterSymbol(Symbol *symbol) { - CPP_ASSERT(! symbol->_scope || symbol->enclosingScope() == _owner, return); + CPP_ASSERT(! symbol->_enclosingScope || symbol->enclosingScope() == _owner, return); if (++_symbolCount == _allocatedSymbols) { _allocatedSymbols <<= 1; @@ -120,7 +120,7 @@ void SymbolTable::enterSymbol(Symbol *symbol) } symbol->_index = _symbolCount; - symbol->_scope = _owner; + symbol->_enclosingScope = _owner; _symbols[_symbolCount] = symbol; if (_symbolCount * 5 >= _hashSize * 3) diff --git a/src/libs/3rdparty/cplusplus/Symbol.cpp b/src/libs/3rdparty/cplusplus/Symbol.cpp index f5506b8c89..cb55c559b0 100644 --- a/src/libs/3rdparty/cplusplus/Symbol.cpp +++ b/src/libs/3rdparty/cplusplus/Symbol.cpp @@ -87,7 +87,7 @@ private: Symbol::Symbol(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name) : _name(0), - _scope(0), + _enclosingScope(0), _next(0), _fileId(0), _sourceLocation(0), @@ -107,7 +107,7 @@ Symbol::Symbol(TranslationUnit *translationUnit, unsigned sourceLocation, const Symbol::Symbol(Clone *clone, Subst *subst, Symbol *original) : _name(clone->name(original->_name, subst)), - _scope(0), + _enclosingScope(0), _next(0), _fileId(clone->control()->stringLiteral(original->fileName(), original->fileNameLength())), _sourceLocation(original->_sourceLocation), @@ -231,22 +231,22 @@ const Identifier *Symbol::identifier() const } Scope *Symbol::enclosingScope() const -{ return _scope; } +{ return _enclosingScope; } -void Symbol::setScope(Scope *scope) +void Symbol::setEnclosingScope(Scope *scope) { - CPP_CHECK(! _scope); - _scope = scope; + CPP_CHECK(! _enclosingScope); + _enclosingScope = scope; } -void Symbol::resetScope() +void Symbol::resetEnclosingScope() { - _scope = 0; + _enclosingScope = 0; } Namespace *Symbol::enclosingNamespace() const { - for (Scope *s = _scope; s; s = s->enclosingScope()) { + for (Scope *s = _enclosingScope; s; s = s->enclosingScope()) { if (Namespace *ns = s->asNamespace()) return ns; } @@ -255,7 +255,7 @@ Namespace *Symbol::enclosingNamespace() const Template *Symbol::enclosingTemplate() const { - for (Scope *s = _scope; s; s = s->enclosingScope()) { + for (Scope *s = _enclosingScope; s; s = s->enclosingScope()) { if (Template *templ = s->asTemplate()) return templ; } @@ -264,7 +264,7 @@ Template *Symbol::enclosingTemplate() const Class *Symbol::enclosingClass() const { - for (Scope *s = _scope; s; s = s->enclosingScope()) { + for (Scope *s = _enclosingScope; s; s = s->enclosingScope()) { if (Class *klass = s->asClass()) return klass; } @@ -273,7 +273,7 @@ Class *Symbol::enclosingClass() const Enum *Symbol::enclosingEnum() const { - for (Scope *s = _scope; s; s = s->enclosingScope()) { + for (Scope *s = _enclosingScope; s; s = s->enclosingScope()) { if (Enum *e = s->asEnum()) return e; } @@ -282,7 +282,7 @@ Enum *Symbol::enclosingEnum() const Function *Symbol::enclosingFunction() const { - for (Scope *s = _scope; s; s = s->enclosingScope()) { + for (Scope *s = _enclosingScope; s; s = s->enclosingScope()) { if (Function *fun = s->asFunction()) return fun; } @@ -291,18 +291,13 @@ Function *Symbol::enclosingFunction() const Block *Symbol::enclosingBlock() const { - for (Scope *s = _scope; s; s = s->enclosingScope()) { + for (Scope *s = _enclosingScope; s; s = s->enclosingScope()) { if (Block *block = s->asBlock()) return block; } return 0; } -Scope *Symbol::scope() const -{ - return _scope; -} - unsigned Symbol::index() const { return _index; } @@ -430,7 +425,7 @@ void Symbol::copy(Symbol *other) _hashCode = other->_hashCode; _storage = other->_storage; _visibility = other->_visibility; - _scope = other->_scope; + _enclosingScope = other->_enclosingScope; _index = other->_index; _next = other->_next; _fileId = other->_fileId; diff --git a/src/libs/3rdparty/cplusplus/Symbol.h b/src/libs/3rdparty/cplusplus/Symbol.h index 30cd28797b..919268b14b 100644 --- a/src/libs/3rdparty/cplusplus/Symbol.h +++ b/src/libs/3rdparty/cplusplus/Symbol.h @@ -290,9 +290,8 @@ public: /// Returns the enclosing Block scope. Block *enclosingBlock() const; - Scope *scope() const; - void setScope(Scope *enclosingScope); // ### make me private - void resetScope(); // ### make me private + void setEnclosingScope(Scope *enclosingScope); // ### make me private + void resetEnclosingScope(); // ### make me private void setSourceLocation(unsigned sourceLocation, TranslationUnit *translationUnit); // ### make me private void visitSymbol(SymbolVisitor *visitor); @@ -305,7 +304,7 @@ protected: private: const Name *_name; - Scope *_scope; + Scope *_enclosingScope; Symbol *_next; const StringLiteral *_fileId; unsigned _sourceLocation; diff --git a/src/libs/3rdparty/cplusplus/Templates.cpp b/src/libs/3rdparty/cplusplus/Templates.cpp index 8e9e2d8170..557ac7d08e 100644 --- a/src/libs/3rdparty/cplusplus/Templates.cpp +++ b/src/libs/3rdparty/cplusplus/Templates.cpp @@ -188,7 +188,7 @@ Symbol *CloneSymbol::cloneSymbol(Symbol *symbol, Subst *subst) SymbolSubstPair symbolSubstPair = std::make_pair(symbol, subst); if (_cache.find(symbolSubstPair) != _cache.end()) { Symbol *cachedSymbol = _cache[symbolSubstPair]; - if (cachedSymbol->scope() == symbol->scope()) + if (cachedSymbol->enclosingScope() == symbol->enclosingScope()) return cachedSymbol; } @@ -531,7 +531,7 @@ Symbol *Clone::instantiate(Template *templ, const FullySpecifiedType *const args } } if (Symbol *inst = symbol(templ->declaration(), &subst)) { - inst->setScope(templ->enclosingScope()); + inst->setEnclosingScope(templ->enclosingScope()); return inst; } return 0; diff --git a/src/libs/cplusplus/CppRewriter.cpp b/src/libs/cplusplus/CppRewriter.cpp index 65191194e2..0224da4b02 100644 --- a/src/libs/cplusplus/CppRewriter.cpp +++ b/src/libs/cplusplus/CppRewriter.cpp @@ -158,7 +158,7 @@ public: // the copy() call above set the scope to 'type' // reset it to 0 before adding addMember to avoid assert - newArg->resetScope(); + newArg->resetEnclosingScope(); funTy->addMember(newArg); } diff --git a/src/libs/cplusplus/DeprecatedGenTemplateInstance.cpp b/src/libs/cplusplus/DeprecatedGenTemplateInstance.cpp index 0f482141ae..027c561cef 100644 --- a/src/libs/cplusplus/DeprecatedGenTemplateInstance.cpp +++ b/src/libs/cplusplus/DeprecatedGenTemplateInstance.cpp @@ -129,7 +129,7 @@ private: virtual void visit(Function *funTy) { Function *fun = control()->newFunction(/*sourceLocation=*/ 0, funTy->name()); - fun->setScope(funTy->enclosingScope()); + fun->setEnclosingScope(funTy->enclosingScope()); fun->setConst(funTy->isConst()); fun->setVolatile(funTy->isVolatile()); fun->setVirtual(funTy->isVirtual()); diff --git a/src/libs/cplusplus/LookupContext.cpp b/src/libs/cplusplus/LookupContext.cpp index d2ef0243da..f707601dba 100644 --- a/src/libs/cplusplus/LookupContext.cpp +++ b/src/libs/cplusplus/LookupContext.cpp @@ -256,7 +256,7 @@ QList<LookupItem> LookupContext::lookupByUsing(const Name *name, Scope *scope) c // if it is not a global scope(scope of scope is not equal 0) // then add current using declaration as a candidate - if (scope->scope()) { + if (scope->enclosingScope()) { LookupItem item; item.setDeclaration(u); item.setScope(scope); @@ -1087,7 +1087,7 @@ ClassOrNamespace *ClassOrNamespace::nestedType(const Name *name, ClassOrNamespac foreach (Symbol *s, reference->symbols()) { Symbol *clone = cloner.symbol(s, &subst); - clone->setScope(s->scope()); + clone->setEnclosingScope(s->enclosingScope()); instantiation->_symbols.append(clone); #ifdef DEBUG_LOOKUP Overview oo;oo.showFunctionSignatures = true; @@ -1242,7 +1242,7 @@ void ClassOrNamespace::NestedClassInstantiator::instantiate(ClassOrNamespace *en foreach (Symbol *s, nestedClassOrNamespace->_symbols) { Symbol *clone = _cloner.symbol(s, &_subst); if (!clone->enclosingScope()) // Not from the cache but just cloned. - clone->setScope(s->enclosingScope()); + clone->setEnclosingScope(s->enclosingScope()); nestedClassOrNamespaceInstantiation->_symbols.append(clone); } } diff --git a/src/plugins/cppeditor/cppquickfixes.cpp b/src/plugins/cppeditor/cppquickfixes.cpp index 14d8db4ed9..5eb4a4152a 100644 --- a/src/plugins/cppeditor/cppquickfixes.cpp +++ b/src/plugins/cppeditor/cppquickfixes.cpp @@ -4615,7 +4615,7 @@ public: const LookupContext targetContext(headerFile->cppDocument(), assistInterface()->snapshot()); const Class *targetClass = m_classAST->symbol; - ClassOrNamespace *targetCoN = targetContext.lookupType(targetClass->scope()); + ClassOrNamespace *targetCoN = targetContext.lookupType(targetClass->enclosingScope()); if (!targetCoN) targetCoN = targetContext.globalNamespace(); UseMinimalNames useMinimalNames(targetCoN); |