diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2020-07-16 15:09:34 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2020-07-20 08:24:06 +0000 |
commit | 3b14051db50f65f0e6c1319adad2224bfa6e3871 (patch) | |
tree | 70d3e4cf4d3471eb9ca4f22eebf98a6505220cec /src/libs/3rdparty/cplusplus/Symbols.cpp | |
parent | 9026dd00331bd108367e64703c67cdda3e120352 (diff) |
CPlusPlus: Do not ignore namespaces
... when comparing type names. For instance, this is relevant when
deciding whether to offer the "Apply signature changes" refactoring
action.
Add fallback code for function lookups, which was relying on the relaxed
semantics for parameter types.
Fixes: QTCREATORBUG-9856
Change-Id: I2001b77034ff15e96a23e3359d19654d0f43f60b
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'src/libs/3rdparty/cplusplus/Symbols.cpp')
-rw-r--r-- | src/libs/3rdparty/cplusplus/Symbols.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/libs/3rdparty/cplusplus/Symbols.cpp b/src/libs/3rdparty/cplusplus/Symbols.cpp index 22f355dce4..79dd116df7 100644 --- a/src/libs/3rdparty/cplusplus/Symbols.cpp +++ b/src/libs/3rdparty/cplusplus/Symbols.cpp @@ -339,6 +339,28 @@ bool Function::isSignatureEqualTo(const Function *other, Matcher *matcher) const else if (! Matcher::match(unqualifiedName(), other->unqualifiedName(), matcher)) return false; + class FallbackMatcher : public Matcher + { + public: + explicit FallbackMatcher(Matcher *baseMatcher) : m_baseMatcher(baseMatcher) {} + + private: + bool match(const NamedType *type, const NamedType *otherType) override + { + if (type == otherType) + return true; + const Name *name = type->name(); + if (const QualifiedNameId *q = name->asQualifiedNameId()) + name = q->name(); + const Name *otherName = otherType->name(); + if (const QualifiedNameId *q = otherName->asQualifiedNameId()) + otherName = q->name(); + return Matcher::match(name, otherName, m_baseMatcher); + } + + Matcher * const m_baseMatcher; + } fallbackMatcher(matcher); + const int argc = argumentCount(); if (argc != other->argumentCount()) return false; @@ -359,6 +381,8 @@ bool Function::isSignatureEqualTo(const Function *other, Matcher *matcher) const if (lType.match(rType)) continue; } + if (l->type().match(r->type(), &fallbackMatcher)) + continue; return false; } } |