From faaab90a15b003011f4324cff11a8806b20c44b7 Mon Sep 17 00:00:00 2001
From: Roberto Raggi <roberto.raggi@nokia.com>
Date: Thu, 28 May 2009 12:10:16 +0200
Subject: [PATCH] Added LookupContext::resolveOperatorNameId() with the bits
 needed to resolve operator name ids.

---
 src/libs/cplusplus/LookupContext.cpp | 41 +++++++++++++++++++---------
 src/libs/cplusplus/LookupContext.h   |  4 +++
 2 files changed, 32 insertions(+), 13 deletions(-)

diff --git a/src/libs/cplusplus/LookupContext.cpp b/src/libs/cplusplus/LookupContext.cpp
index f79ebfd701e..5723433aca0 100644
--- a/src/libs/cplusplus/LookupContext.cpp
+++ b/src/libs/cplusplus/LookupContext.cpp
@@ -181,20 +181,45 @@ QList<Symbol *> LookupContext::resolveQualifiedNameId(QualifiedNameId *q,
     return candidates;
 }
 
+QList<Symbol *> LookupContext::resolveOperatorNameId(OperatorNameId *opId,
+                                                     const QList<Scope *> &visibleScopes,
+                                                     ResolveMode) const
+{
+    QList<Symbol *> candidates;
+
+    for (int scopeIndex = 0; scopeIndex < visibleScopes.size(); ++scopeIndex) {
+        Scope *scope = visibleScopes.at(scopeIndex);
+
+        for (Symbol *symbol = scope->lookat(opId->kind()); symbol; symbol = symbol->next()) {
+            if (! opId->isEqualTo(symbol->name()))
+                continue;
+
+            if (! candidates.contains(symbol))
+                candidates.append(symbol);
+        }
+    }
+
+    return candidates;
+}
+
 QList<Symbol *> LookupContext::resolve(Name *name, const QList<Scope *> &visibleScopes,
                                        ResolveMode mode) const
 {
     QList<Symbol *> candidates;
 
     if (!name)
-        return candidates;
+        return candidates; // nothing to do, the symbol is anonymous.
 
-    if (QualifiedNameId *q = name->asQualifiedNameId())
+    else if (QualifiedNameId *q = name->asQualifiedNameId())
         return resolveQualifiedNameId(q, visibleScopes, mode);
 
-    if (Identifier *id = identifier(name)) {
+    else if (OperatorNameId *opId = name->asOperatorNameId())
+        return resolveOperatorNameId(opId, visibleScopes, mode);
+
+    else if (Identifier *id = identifier(name)) {
         for (int scopeIndex = 0; scopeIndex < visibleScopes.size(); ++scopeIndex) {
             Scope *scope = visibleScopes.at(scopeIndex);
+
             for (Symbol *symbol = scope->lookat(id); symbol; symbol = symbol->next()) {
                 if (! symbol->name()) {
                     continue;
@@ -237,16 +262,6 @@ QList<Symbol *> LookupContext::resolve(Name *name, const QList<Scope *> &visible
                 candidates.append(symbol);
             }
         }
-    } else if (OperatorNameId *opId = name->asOperatorNameId()) {
-        for (int scopeIndex = 0; scopeIndex < visibleScopes.size(); ++scopeIndex) {
-            Scope *scope = visibleScopes.at(scopeIndex);
-            for (Symbol *symbol = scope->lookat(opId->kind()); symbol; symbol = symbol->next()) {
-                if (! opId->isEqualTo(symbol->name()))
-                    continue;
-                else if (! candidates.contains(symbol))
-                    candidates.append(symbol);
-            }
-        }
     }
 
     return candidates;
diff --git a/src/libs/cplusplus/LookupContext.h b/src/libs/cplusplus/LookupContext.h
index d9be051a77f..4985e11f741 100644
--- a/src/libs/cplusplus/LookupContext.h
+++ b/src/libs/cplusplus/LookupContext.h
@@ -119,6 +119,10 @@ private:
                                            const QList<Scope *> &visibleScopes,
                                            ResolveMode mode) const;
 
+    QList<Symbol *> resolveOperatorNameId(OperatorNameId *opId,
+                                          const QList<Scope *> &visibleScopes,
+                                          ResolveMode mode) const;
+
     Identifier *identifier(const Name *name) const;
 
     QList<Scope *> buildVisibleScopes();
-- 
GitLab