CppEditor: Make value vs const ref return type configurable

... in the quickfix settings.
Also change the default: With mandatory RVO and move semantics, value
return types are the right choice most of the time.

Fixes: QTCREATORBUG-25790
Change-Id: I68fc6c616358478ba893101b3e04aa6bbbe79348
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
This commit is contained in:
Christian Kandeler
2022-09-12 17:36:52 +02:00
parent 75e35cc4f2
commit 4119181762
7 changed files with 27 additions and 15 deletions

View File

@@ -3881,7 +3881,7 @@ void GetterSetterRefactoringHelper::performGeneration(ExistingGetterSetterData d
}
const FullySpecifiedType returnTypeHeader = [&] {
if (!getSetTemplate.returnTypeTemplate.has_value())
return parameterType;
return m_settings->returnByConstRef ? parameterType : memberVariableType;
QString typeTemplate = getSetTemplate.returnTypeTemplate.value();
if (returnTypeTemplateParameter.has_value())
typeTemplate.replace(Pattern::TEMPLATE_PARAMETER_PATTERN,
@@ -3947,7 +3947,7 @@ void GetterSetterRefactoringHelper::performGeneration(ExistingGetterSetterData d
data.clazz,
targetFile,
targetLoc);
if (!isValueType)
if (m_settings->returnByConstRef && !isValueType)
return makeConstRef(returnType);
return returnType;
}