Commit c5d48034 authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Compare the scope pointers for local scopes.

parent 5f13608c
...@@ -203,6 +203,16 @@ bool FindUsages::compareName(const Name *name, const Name *other) ...@@ -203,6 +203,16 @@ bool FindUsages::compareName(const Name *name, const Name *other)
return false; return false;
} }
bool FindUsages::isLocalScope(Scope *scope)
{
if (scope) {
if (scope->isBlock() || scope->isTemplate() || scope->isFunction())
return true;
}
return false;
}
bool FindUsages::checkCandidates(const QList<LookupItem> &candidates) const bool FindUsages::checkCandidates(const QList<LookupItem> &candidates) const
{ {
for (int i = candidates.size() - 1; i != -1; --i) { for (int i = candidates.size() - 1; i != -1; --i) {
...@@ -214,7 +224,7 @@ bool FindUsages::checkCandidates(const QList<LookupItem> &candidates) const ...@@ -214,7 +224,7 @@ bool FindUsages::checkCandidates(const QList<LookupItem> &candidates) const
return false; return false;
} }
if (_declSymbol->scope() && (_declSymbol->scope()->isFunction() || _declSymbol->scope()->isBlock())) { if (isLocalScope(_declSymbol->scope()) || isLocalScope(s->scope())) {
if (s->scope() != _declSymbol->scope()) if (s->scope() != _declSymbol->scope())
return false; return false;
} }
......
...@@ -83,6 +83,7 @@ protected: ...@@ -83,6 +83,7 @@ protected:
static bool compareFullyQualifiedName(const QList<const Name *> &path, const QList<const Name *> &other); static bool compareFullyQualifiedName(const QList<const Name *> &path, const QList<const Name *> &other);
static bool compareName(const Name *name, const Name *other); static bool compareName(const Name *name, const Name *other);
static bool isLocalScope(Scope *scope);
void statement(StatementAST *ast); void statement(StatementAST *ast);
void expression(ExpressionAST *ast); void expression(ExpressionAST *ast);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment