CppQuickFixes: Add "auto" as local declaration incase cxx11

Add local declaration function add "auto " incase
cxx11 features are enabled.

Fixes: QTCREATORBUG-26004
Change-Id: I10da77e8baa52740b1c4df5a21d78ac5f0d1c5d6
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Artem Sokolovskii
2022-06-15 13:16:05 +02:00
parent 189fe7fab3
commit 5d8f13bfd4
2 changed files with 15 additions and 2 deletions

View File

@@ -1634,6 +1634,10 @@ private:
{
CppRefactoringChanges refactoring(snapshot());
CppRefactoringFilePtr currentFile = refactoring.file(filePath());
Overview oo = CppCodeStyleSettings::currentProjectCodeStyleOverview();
if (currentFile->cppDocument()->languageFeatures().cxx11Enabled)
return "auto " + oo.prettyName(simpleNameAST->name);
TypeOfExpression typeOfExpression;
typeOfExpression.init(semanticInfo().doc, snapshot(), context().bindings());
@@ -1656,7 +1660,6 @@ private:
Control *control = context().bindings()->control().data();
FullySpecifiedType tn = rewriteType(result.first().type(), &env, control);
Overview oo = CppCodeStyleSettings::currentProjectCodeStyleOverview();
QString declaration = oo.prettyType(tn, simpleNameAST->name);
return declaration;
}
@@ -3864,7 +3867,7 @@ void GetterSetterRefactoringHelper::performGeneration(ExistingGetterSetterData d
FullySpecifiedType memberVariableType = data.declarationSymbol->type();
memberVariableType.setConst(false);
const bool isMemberVariableStatic = data.declarationSymbol->isStatic();
const bool isMemberVariableStatic = memberVariableType.isStatic();
memberVariableType.setStatic(false);
Overview overview = CppCodeStyleSettings::currentProjectCodeStyleOverview();
overview.showTemplateParameters = false;