From 99690460938d131443680b910780920f7b075b8f Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Thu, 5 Dec 2024 12:46:17 +0100 Subject: [PATCH] CppEditor: Fix pretty-printing of auto type Task-number: QTCREATORBUG-31678 Change-Id: I2c1684c71315d50c98f451b280fbfd08b5d8d3e8 Reviewed-by: Christian Stenger --- src/libs/cplusplus/TypePrettyPrinter.cpp | 3 +++ .../cppeditor/quickfixes/insertfunctiondefinition.cpp | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/libs/cplusplus/TypePrettyPrinter.cpp b/src/libs/cplusplus/TypePrettyPrinter.cpp index 0e7ba193427..5b617054fd4 100644 --- a/src/libs/cplusplus/TypePrettyPrinter.cpp +++ b/src/libs/cplusplus/TypePrettyPrinter.cpp @@ -116,6 +116,9 @@ void TypePrettyPrinter::visit(UndefinedType *) _text.prepend(QLatin1String("signed")); else if (_fullySpecifiedType.isUnsigned()) _text.prepend(QLatin1String("unsigned")); + } else if (_fullySpecifiedType.isAuto()) { + prependSpaceUnlessBracket(); + _text.prepend("auto"); } prependCv(_fullySpecifiedType); diff --git a/src/plugins/cppeditor/quickfixes/insertfunctiondefinition.cpp b/src/plugins/cppeditor/quickfixes/insertfunctiondefinition.cpp index 0f9f8461380..f8ff21cd6ad 100644 --- a/src/plugins/cppeditor/quickfixes/insertfunctiondefinition.cpp +++ b/src/plugins/cppeditor/quickfixes/insertfunctiondefinition.cpp @@ -1883,17 +1883,17 @@ foo::foo2::MyType foo::foo2::bar() QByteArray original = "class Foo\n" "{\n" - " template\n" + " template\n" " void fun@c();\n" "};\n"; QByteArray expected = "class Foo\n" "{\n" - " template\n" + " template\n" " void fun@c();\n" "};\n" "\n" - "template\n" + "template\n" "inline void Foo::func()\n" "{\n" "\n"