forked from qt-creator/qt-creator
Check the scope of class and fwd-class declarations
This commit is contained in:
@@ -166,6 +166,26 @@ protected:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool checkScope(Symbol *symbol, Symbol *otherSymbol) const
|
||||||
|
{
|
||||||
|
if (! (symbol && otherSymbol))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
else if (symbol->scope() == otherSymbol->scope())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
else if (symbol->name() && otherSymbol->name()) {
|
||||||
|
|
||||||
|
if (! symbol->name()->isEqualTo(otherSymbol->name()))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
} else if (symbol->name() != otherSymbol->name()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return checkScope(symbol->enclosingSymbol(), otherSymbol->enclosingSymbol());
|
||||||
|
}
|
||||||
|
|
||||||
bool isDeclSymbol(Symbol *symbol) const
|
bool isDeclSymbol(Symbol *symbol) const
|
||||||
{
|
{
|
||||||
if (! symbol)
|
if (! symbol)
|
||||||
@@ -180,11 +200,11 @@ protected:
|
|||||||
|
|
||||||
} else if (symbol->isForwardClassDeclaration() && (_declSymbol->isClass() ||
|
} else if (symbol->isForwardClassDeclaration() && (_declSymbol->isClass() ||
|
||||||
_declSymbol->isForwardClassDeclaration())) {
|
_declSymbol->isForwardClassDeclaration())) {
|
||||||
return true;
|
return checkScope(symbol, _declSymbol);
|
||||||
|
|
||||||
} else if (_declSymbol->isForwardClassDeclaration() && (symbol->isClass() ||
|
} else if (_declSymbol->isForwardClassDeclaration() && (symbol->isClass() ||
|
||||||
symbol->isForwardClassDeclaration())) {
|
symbol->isForwardClassDeclaration())) {
|
||||||
return true;
|
return checkScope(symbol, _declSymbol);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@@ -314,6 +314,14 @@ void Symbol::setScope(Scope *scope)
|
|||||||
_scope = scope;
|
_scope = scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Symbol *Symbol::enclosingSymbol() const
|
||||||
|
{
|
||||||
|
if (! _scope)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return _scope->owner();
|
||||||
|
}
|
||||||
|
|
||||||
Scope *Symbol::enclosingNamespaceScope() const
|
Scope *Symbol::enclosingNamespaceScope() const
|
||||||
{
|
{
|
||||||
if (! _scope)
|
if (! _scope)
|
||||||
|
@@ -281,6 +281,8 @@ public:
|
|||||||
|
|
||||||
bool isGenerated() const;
|
bool isGenerated() const;
|
||||||
|
|
||||||
|
Symbol *enclosingSymbol() const;
|
||||||
|
|
||||||
/// Returns the eclosing namespace scope.
|
/// Returns the eclosing namespace scope.
|
||||||
Scope *enclosingNamespaceScope() const;
|
Scope *enclosingNamespaceScope() const;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user