summaryrefslogtreecommitdiff
path: root/src/plugins/cppeditor/cppquickfix_test.cpp
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2022-04-04 18:05:31 +0200
committerChristian Kandeler <christian.kandeler@qt.io>2022-04-05 11:38:46 +0000
commitcb86ca547ae9ddc020ac446b5947376da48ff211 (patch)
tree8acb4578978c6b8086e9dd99b1999daccf2a56a1 /src/plugins/cppeditor/cppquickfix_test.cpp
parent0ee4322dfdc5e03eb4c50c0b826ad6aa58786b28 (diff)
downloadqt-creator-cb86ca547ae9ddc020ac446b5947376da48ff211.tar.gz
CppEditor: Fix "move function definition"
... for member functions with exception specification and/or reference qualifiers. The FunctionDeclaratorAST::cv_qualifier_list member can contain both the proper qualifiers "const" and "volatile" as well as the pseudo-qualifiers "override" and "final". The problem is that the former appear before exception specification and reference qualifiers, whereas the latter come afterwards. Therefore, when calculating the declarator's first and last tokens, we can't just mechanically check the different declarator members in order. Instead, we need to compare the token values to see which comes first. Task-number: QTCREATORBUG-27132 Change-Id: I924f9afe49453fa51b4a2fe010d1cc00c9defad1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'src/plugins/cppeditor/cppquickfix_test.cpp')
-rw-r--r--src/plugins/cppeditor/cppquickfix_test.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/plugins/cppeditor/cppquickfix_test.cpp b/src/plugins/cppeditor/cppquickfix_test.cpp
index dd85e95470..93845b51c8 100644
--- a/src/plugins/cppeditor/cppquickfix_test.cpp
+++ b/src/plugins/cppeditor/cppquickfix_test.cpp
@@ -6110,6 +6110,41 @@ void QuickfixTest::testMoveFuncDefOutsideMemberFuncToCppWithInlinePartOfName()
QuickFixOperationTest(testDocuments, &factory);
}
+void QuickfixTest::testMoveFuncDefOutsideMixedQualifiers()
+{
+ QList<TestDocumentPtr> testDocuments;
+ QByteArray original;
+ QByteArray expected;
+
+ // Header File
+ original = R"(
+struct Base {
+ virtual auto func() const && noexcept -> void = 0;
+};
+struct Derived : public Base {
+ auto @func() const && noexcept -> void override {}
+};)";
+ expected = R"(
+struct Base {
+ virtual auto func() const && noexcept -> void = 0;
+};
+struct Derived : public Base {
+ auto func() const && noexcept -> void override;
+};)";
+ testDocuments << CppTestDocument::create("file.h", original, expected);
+
+ // Source File
+ original = "#include \"file.h\"\n";
+ expected = R"DELIM(#include "file.h"
+
+void Derived::func() const &&noexcept {}
+)DELIM";
+ testDocuments << CppTestDocument::create("file.cpp", original, expected);
+
+ MoveFuncDefOutside factory;
+ QuickFixOperationTest(testDocuments, &factory);
+}
+
void QuickfixTest::testMoveFuncDefOutsideMemberFuncToCppInsideNS()
{
QList<TestDocumentPtr> testDocuments;