From 205e03684ad01a93fb01baa409a620ab8b5f5847 Mon Sep 17 00:00:00 2001
From: Roberto Raggi <roberto.raggi@nokia.com>
Date: Wed, 4 Nov 2009 12:02:19 +0100
Subject: [PATCH] Don't process already visited nodes.

---
 src/libs/cplusplus/FindUsages.cpp | 9 +++++++++
 src/libs/cplusplus/FindUsages.h   | 1 +
 2 files changed, 10 insertions(+)

diff --git a/src/libs/cplusplus/FindUsages.cpp b/src/libs/cplusplus/FindUsages.cpp
index 5b3e77ee8d1..d6ecca8cbf9 100644
--- a/src/libs/cplusplus/FindUsages.cpp
+++ b/src/libs/cplusplus/FindUsages.cpp
@@ -59,6 +59,7 @@ void FindUsages::setGlobalNamespaceBinding(NamespaceBindingPtr globalNamespaceBi
 
 QList<int> FindUsages::operator()(Symbol *symbol, Identifier *id, AST *ast)
 {
+    _processed.clear();
     _references.clear();
     _declSymbol = symbol;
     _id = id;
@@ -92,6 +93,9 @@ QString FindUsages::matchingLine(const Token &tk) const
 
 void FindUsages::reportResult(unsigned tokenIndex, const QList<Symbol *> &candidates)
 {
+    if (_processed.contains(tokenIndex))
+        return;
+
     const bool isStrongResult = checkCandidates(candidates);
 
     if (isStrongResult)
@@ -100,6 +104,11 @@ void FindUsages::reportResult(unsigned tokenIndex, const QList<Symbol *> &candid
 
 void FindUsages::reportResult(unsigned tokenIndex)
 {
+    if (_processed.contains(tokenIndex))
+        return;
+
+    _processed.insert(tokenIndex);
+
     const Token &tk = tokenAt(tokenIndex);
     const QString lineText = matchingLine(tk);
 
diff --git a/src/libs/cplusplus/FindUsages.h b/src/libs/cplusplus/FindUsages.h
index 9f829493806..667ad18485a 100644
--- a/src/libs/cplusplus/FindUsages.h
+++ b/src/libs/cplusplus/FindUsages.h
@@ -114,6 +114,7 @@ private:
     QList<int> _references;
     LookupContext _previousContext;
     int _inSimpleDeclaration;
+    QSet<unsigned> _processed;
 };
 
 } // end of namespace CPlusPlus
-- 
GitLab