diff options
author | Eike Ziller <[email protected]> | 2017-02-27 15:17:30 +0100 |
---|---|---|
committer | Eike Ziller <[email protected]> | 2017-02-27 15:17:37 +0100 |
commit | 1704c484a83e845fc44ffe82d1af0bcdca028964 (patch) | |
tree | 82c1335b0ff852d2c6a237a52a73ff599f528a44 /src/libs/cplusplus | |
parent | 0995cf22ab422467fe68ad53f617471731a3629c (diff) | |
parent | 126a031ee2eae741095657f01c3ce3ac0129fecf (diff) |
Merge remote-tracking branch 'origin/4.2'
Change-Id: I9006dd493707ae626ae3502541599c8789e1aab0
Diffstat (limited to 'src/libs/cplusplus')
-rw-r--r-- | src/libs/cplusplus/LookupContext.cpp | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/src/libs/cplusplus/LookupContext.cpp b/src/libs/cplusplus/LookupContext.cpp index 0a9138911e7..881c985f866 100644 --- a/src/libs/cplusplus/LookupContext.cpp +++ b/src/libs/cplusplus/LookupContext.cpp @@ -230,6 +230,32 @@ static bool symbolIdentical(Symbol *s1, Symbol *s2) return QByteArray(s1->fileName()) == QByteArray(s2->fileName()); } +static const Name *toName(const QList<const Name *> &names, Control *control) +{ + const Name *n = 0; + for (int i = names.size() - 1; i >= 0; --i) { + if (! n) + n = names.at(i); + else + n = control->qualifiedNameId(names.at(i), n); + } + + return n; +} + +static bool isInlineNamespace(ClassOrNamespace *con, const Name *name) +{ + const QList<LookupItem> items = con->find(name); + if (!items.isEmpty()) { + if (const Symbol *declaration = items.first().declaration() ) { + if (const Namespace *ns = declaration->asNamespace()) + return ns->isInline(); + } + } + + return false; +} + const Name *LookupContext::minimalName(Symbol *symbol, ClassOrNamespace *target, Control *control) { const Name *n = 0; @@ -245,8 +271,17 @@ const Name *LookupContext::minimalName(Symbol *symbol, ClassOrNamespace *target, if (target) { const QList<LookupItem> tresults = target->lookup(n); foreach (const LookupItem &tr, tresults) { - if (symbolIdentical(tr.declaration(), symbol)) - return n; + if (symbolIdentical(tr.declaration(), symbol)) { + // eliminate inline namespaces + QList<const Name *> minimal = names.mid(i); + for (int i = minimal.size() - 2; i >= 0; --i) { + const Name *candidate = toName(minimal.mid(0, i + 1), control); + if (isInlineNamespace(target, candidate)) + minimal.removeAt(i); + } + + return toName(minimal, control); + } } } } |