Commit a1c18d9e authored by Daniel Teske's avatar Daniel Teske Committed by Nikolai Kosjar

TypeRewriter: Handle rvalue references correctly

Task-number: QTCREATORBUG-10555
Change-Id: Icb9859f96220f613476c097b747dec8c2d1bc2ed
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@digia.com>
parent e6e74b61
......@@ -91,7 +91,7 @@ public:
PointerType *pointerType(const FullySpecifiedType &elementType);
/// Returns a Type object of type ReferenceType.
ReferenceType *referenceType(const FullySpecifiedType &elementType, bool rvalueRef = false);
ReferenceType *referenceType(const FullySpecifiedType &elementType, bool rvalueRef);
/// Retruns a Type object of type ArrayType.
ArrayType *arrayType(const FullySpecifiedType &elementType, unsigned size = 0);
......
......@@ -87,7 +87,7 @@ void CloneType::visit(PointerType *type)
void CloneType::visit(ReferenceType *type)
{
_type.setType(_control->referenceType(_clone->type(type->elementType(), _subst)));
_type.setType(_control->referenceType(_clone->type(type->elementType(), _subst), type->isRvalueReference()));
}
void CloneType::visit(ArrayType *type)
......
......@@ -117,7 +117,7 @@ public:
virtual void visit(ReferenceType *type)
{
const FullySpecifiedType elementType = rewrite->rewriteType(type->elementType());
temps.append(control()->referenceType(elementType));
temps.append(control()->referenceType(elementType, type->isRvalueReference()));
}
virtual void visit(ArrayType *type)
......
......@@ -112,7 +112,7 @@ private:
virtual void visit(ReferenceType *refTy)
{
_type.setType(control()->referenceType(q->apply(refTy->elementType())));
_type.setType(control()->referenceType(q->apply(refTy->elementType()), refTy->isRvalueReference()));
}
virtual void visit(ArrayType *arrayTy)
......
......@@ -143,6 +143,7 @@ private slots:
void test_quickfix_InsertDefFromDecl_macroUsesAtEndOfFile1();
void test_quickfix_InsertDefFromDecl_macroUsesAtEndOfFile2();
void test_quickfix_InsertDefFromDecl_erroneousStatementAtEndOfFile();
void test_quickfix_InsertDefFromDecl_rvalueReference();
void test_quickfix_InsertDeclFromDef();
......
......@@ -1852,6 +1852,36 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_erroneousStatementAtEndOfF
data.run(&factory);
}
/// Check: Respect rvalue references
void CppEditorPlugin::test_quickfix_InsertDefFromDecl_rvalueReference()
{
QList<TestDocumentPtr> testFiles;
QByteArray original;
QByteArray expected;
// Header File
original = "void f(Foo &&)@;\n";
expected = original + "\n";
testFiles << TestDocument::create(original, expected, QLatin1String("file.h"));
// Source File
original = "";
expected =
"\n"
"void f(Foo &&)\n"
"{\n"
"\n"
"}\n"
"\n"
;
testFiles << TestDocument::create(original, expected, QLatin1String("file.cpp"));
InsertDefFromDecl factory;
TestCase data(testFiles);
data.run(&factory);
}
// Function for one of InsertDeclDef section cases
void insertToSectionDeclFromDef(const QByteArray &section, int sectionIndex)
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment