aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorIvan Donchevskii <ivan.donchevskii@qt.io>2017-07-04 14:56:04 +0200
committerIvan Donchevskii <ivan.donchevskii@qt.io>2017-07-11 13:38:56 +0000
commit550ed2927d69b637f4d1a0fa1351b408963cdeac (patch)
tree127aa9bf627e24f208e86b47143bc823b376f9ba /src
parent53c85a26765152ba6b24bead30810d800621f683 (diff)
C++: fix lookups for functions with const args
Make declarations equal in case they differ only by argument const and/or volatile (13.1.3.4). Task-number: QTCREATORBUG-18475 Change-Id: Id0561fda3b9081b92716a8739ba9963e90b5d709 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/libs/3rdparty/cplusplus/Symbols.cpp16
-rw-r--r--src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp28
2 files changed, 43 insertions, 1 deletions
diff --git a/src/libs/3rdparty/cplusplus/Symbols.cpp b/src/libs/3rdparty/cplusplus/Symbols.cpp
index f7423e7742..9a84ccacd6 100644
--- a/src/libs/3rdparty/cplusplus/Symbols.cpp
+++ b/src/libs/3rdparty/cplusplus/Symbols.cpp
@@ -337,8 +337,22 @@ bool Function::isSignatureEqualTo(const Function *other, Matcher *matcher) const
for (unsigned i = 0; i < argc; ++i) {
Symbol *l = argumentAt(i);
Symbol *r = other->argumentAt(i);
- if (! l->type().match(r->type(), matcher))
+ if (! l->type().match(r->type(), matcher)) {
+ if (!l->type()->isReferenceType() && !l->type()->isPointerType()
+ && !l->type()->isPointerToMemberType()
+ && !r->type()->isReferenceType() && !r->type()->isPointerType()
+ && !r->type()->isPointerToMemberType()) {
+ FullySpecifiedType lType = l->type();
+ FullySpecifiedType rType = r->type();
+ lType.setConst(false);
+ lType.setVolatile(false);
+ rType.setConst(false);
+ rType.setVolatile(false);
+ if (lType.match(rType))
+ continue;
+ }
return false;
+ }
}
return true;
}
diff --git a/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp b/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp
index b2e1c98294..4fbd7c554d 100644
--- a/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp
+++ b/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp
@@ -941,6 +941,34 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_data()
"};\n"
);
+ QTest::newRow("matchFunctionSignature_Follow_6") << _(
+ "class Foo {\n"
+ " void $foo(int);\n"
+ "};\n"
+ "void Foo::@foo(const volatile int) {}\n"
+ );
+
+ QTest::newRow("matchFunctionSignature_Follow_7") << _(
+ "class Foo {\n"
+ " void $foo(const volatile int);\n"
+ "};\n"
+ "void Foo::@foo(int) {}\n"
+ );
+
+ QTest::newRow("matchFunctionSignature_Follow_8") << _(
+ "class Foo {\n"
+ " void @$foo(int *);\n"
+ "};\n"
+ "void Foo::foo(const int *) {}\n"
+ );
+
+ QTest::newRow("matchFunctionSignature_Follow_9") << _(
+ "class Foo {\n"
+ " void @$foo(int&);\n"
+ "};\n"
+ "void Foo::foo(const int&) {}\n"
+ );
+
QTest::newRow("infiniteLoopLocalTypedef_QTCREATORBUG-11999") << _(
"template<class MyTree>\n"
"class TreeConstIterator\n"