diff options
author | Eike Ziller <eike.ziller@qt.io> | 2019-02-08 12:48:19 +0100 |
---|---|---|
committer | Eike Ziller <eike.ziller@qt.io> | 2019-02-08 12:48:19 +0100 |
commit | 67b3d256249e5001bfdc99a4f2c4e233d8632659 (patch) | |
tree | 1ceae8abc7166b96e5a54777ecb87dd5f0fc311d /src/plugins/cpptools | |
parent | 7c61cc31512a7e4a5d22a2cc14eeb351f0eacc71 (diff) | |
parent | d07d75a08af17305d317b363a7d3044ebeb54a2c (diff) | |
download | qt-creator-67b3d256249e5001bfdc99a4f2c4e233d8632659.tar.gz |
Merge remote-tracking branch 'origin/4.9'
Conflicts:
qtcreator.pri
Change-Id: I278bc79cb64705471b360d0b8d06a8db17db7904
Diffstat (limited to 'src/plugins/cpptools')
19 files changed, 73 insertions, 114 deletions
diff --git a/src/plugins/cpptools/builtincursorinfo.cpp b/src/plugins/cpptools/builtincursorinfo.cpp index ffbe196760..486db2c503 100644 --- a/src/plugins/cpptools/builtincursorinfo.cpp +++ b/src/plugins/cpptools/builtincursorinfo.cpp @@ -50,7 +50,7 @@ namespace { CursorInfo::Range toRange(const SemanticInfo::Use &use) { - return CursorInfo::Range(use.line, use.column, use.length); + return {use.line, use.column, use.length}; } CursorInfo::Range toRange(int tokenIndex, TranslationUnit *translationUnit) @@ -60,10 +60,9 @@ CursorInfo::Range toRange(int tokenIndex, TranslationUnit *translationUnit) if (column) --column; // adjust the column position. - return CursorInfo::Range( - line, - column +1, - translationUnit->tokenAt(static_cast<unsigned>(tokenIndex)).utf16chars()); + return {line, + column + 1, + translationUnit->tokenAt(static_cast<unsigned>(tokenIndex)).utf16chars()}; } CursorInfo::Range toRange(const QTextCursor &textCursor, @@ -74,10 +73,9 @@ CursorInfo::Range toRange(const QTextCursor &textCursor, cursor.setPosition(static_cast<int>(utf16offset)); const QTextBlock textBlock = cursor.block(); - return CursorInfo::Range( - static_cast<unsigned>(textBlock.blockNumber() + 1), - static_cast<unsigned>(cursor.position() - textBlock.position() + 1), - length); + return {static_cast<unsigned>(textBlock.blockNumber() + 1), + static_cast<unsigned>(cursor.position() - textBlock.position() + 1), + length}; } CursorInfo::Ranges toRanges(const SemanticUses &uses) @@ -216,8 +214,8 @@ private: bool good = false; foreach (const CppTools::SemanticInfo::Use &use, uses) { - unsigned l = static_cast<unsigned>(m_line); - unsigned c = static_cast<unsigned>(m_column); + const auto l = static_cast<unsigned>(m_line); + const auto c = static_cast<unsigned>(m_column); if (l == use.line && c >= use.column && c <= (use.column + use.length)) { good = true; break; diff --git a/src/plugins/cpptools/clangdiagnosticconfigswidget.cpp b/src/plugins/cpptools/clangdiagnosticconfigswidget.cpp index 6d45b428be..e5ff4cd9f5 100644 --- a/src/plugins/cpptools/clangdiagnosticconfigswidget.cpp +++ b/src/plugins/cpptools/clangdiagnosticconfigswidget.cpp @@ -51,6 +51,8 @@ #include <QStringListModel> #include <QUuid> +#include <memory> + namespace CppTools { using namespace Constants; @@ -383,7 +385,7 @@ private: } } - QVariant data(const QModelIndex &fullIndex, int role = Qt::DisplayRole) const override final + QVariant data(const QModelIndex &fullIndex, int role = Qt::DisplayRole) const final { if (!fullIndex.isValid() || role == Qt::DecorationRole) return QVariant(); @@ -447,7 +449,7 @@ private: QModelIndex indexForTree(const ClazyChecksTree *tree) const { if (!tree) - return QModelIndex(); + return {}; QModelIndex result; traverse(index(0, 0, QModelIndex()), [&](const QModelIndex &index){ @@ -989,11 +991,11 @@ static void setupTreeView(QTreeView *view, QAbstractItemModel *model, int expand void ClangDiagnosticConfigsWidget::setupTabs() { - m_clangBaseChecks.reset(new CppTools::Ui::ClangBaseChecks); + m_clangBaseChecks = std::make_unique<CppTools::Ui::ClangBaseChecks>(); m_clangBaseChecksWidget = new QWidget(); m_clangBaseChecks->setupUi(m_clangBaseChecksWidget); - m_clazyChecks.reset(new CppTools::Ui::ClazyChecks); + m_clazyChecks = std::make_unique<CppTools::Ui::ClazyChecks>(); m_clazyChecksWidget = new QWidget(); m_clazyChecks->setupUi(m_clazyChecksWidget); m_clazySortFilterProxyModel = new ClazyChecksSortFilterModel(this); @@ -1030,7 +1032,7 @@ void ClangDiagnosticConfigsWidget::setupTabs() = codeModelSettings()->enableLowerClazyLevels() ? Qt::Checked : Qt::Unchecked; m_clazyChecks->enableLowerLevelsCheckBox->setCheckState(checkEnableLowerClazyLevels); - m_tidyChecks.reset(new CppTools::Ui::TidyChecks); + m_tidyChecks = std::make_unique<CppTools::Ui::TidyChecks>(); m_tidyChecksWidget = new QWidget(); m_tidyChecks->setupUi(m_tidyChecksWidget); setupTreeView(m_tidyChecks->checksPrefixesTree, m_tidyTreeModel.get()); diff --git a/src/plugins/cpptools/cppcodeformatter.cpp b/src/plugins/cpptools/cppcodeformatter.cpp index 03a7da9180..069359d869 100644 --- a/src/plugins/cpptools/cppcodeformatter.cpp +++ b/src/plugins/cpptools/cppcodeformatter.cpp @@ -666,7 +666,7 @@ CodeFormatter::State CodeFormatter::state(int belowTop) const if (belowTop < m_currentState.size()) return m_currentState.at(m_currentState.size() - 1 - belowTop); else - return State(); + return {}; } int CodeFormatter::tokenIndex() const diff --git a/src/plugins/cpptools/cppcodemodelsettings.cpp b/src/plugins/cpptools/cppcodemodelsettings.cpp index 35b81a9b7a..2f8d0b3d42 100644 --- a/src/plugins/cpptools/cppcodemodelsettings.cpp +++ b/src/plugins/cpptools/cppcodemodelsettings.cpp @@ -36,7 +36,7 @@ using namespace CppTools; static Core::Id initialClangDiagnosticConfigId() -{ return Core::Id(Constants::CPP_CLANG_BUILTIN_CONFIG_ID_EVERYTHING_WITH_EXCEPTIONS); } +{ return {Constants::CPP_CLANG_BUILTIN_CONFIG_ID_EVERYTHING_WITH_EXCEPTIONS}; } static CppCodeModelSettings::PCHUsage initialPchUsage() { return CppCodeModelSettings::PchUse_BuildSystem; } @@ -90,7 +90,7 @@ static QString convertToNewClazyChecksFormat(const QString &checks) if (checks.size() == 6 && checks.startsWith("level")) { bool ok = false; - const int level = checks.mid(5).toInt(&ok); + const int level = checks.midRef(5).toInt(&ok); QTC_ASSERT(ok, return QString()); return clazyChecksForLevel(level); } diff --git a/src/plugins/cpptools/cppcodestylepreferences.cpp b/src/plugins/cpptools/cppcodestylepreferences.cpp index 6a49086d6b..ea7f100a59 100644 --- a/src/plugins/cpptools/cppcodestylepreferences.cpp +++ b/src/plugins/cpptools/cppcodestylepreferences.cpp @@ -76,7 +76,7 @@ CppCodeStyleSettings CppCodeStylePreferences::currentCodeStyleSettings() const QVariant v = currentValue(); if (!v.canConvert<CppCodeStyleSettings>()) { // warning - return CppCodeStyleSettings(); + return {}; } return v.value<CppCodeStyleSettings>(); } diff --git a/src/plugins/cpptools/cppcodestylesettings.cpp b/src/plugins/cpptools/cppcodestylesettings.cpp index 745ea3ab62..5b07d84334 100644 --- a/src/plugins/cpptools/cppcodestylesettings.cpp +++ b/src/plugins/cpptools/cppcodestylesettings.cpp @@ -67,30 +67,7 @@ using namespace CppTools; // ------------------ CppCodeStyleSettingsWidget -CppCodeStyleSettings::CppCodeStyleSettings() : - indentBlockBraces(false) - , indentBlockBody(true) - , indentClassBraces(false) - , indentEnumBraces(false) - , indentNamespaceBraces(false) - , indentNamespaceBody(false) - , indentAccessSpecifiers(false) - , indentDeclarationsRelativeToAccessSpecifiers(true) - , indentFunctionBody(true) - , indentFunctionBraces(false) - , indentSwitchLabels(false) - , indentStatementsRelativeToSwitchLabels(true) - , indentBlocksRelativeToSwitchLabels(false) - , indentControlFlowRelativeToSwitchLabels(true) - , bindStarToIdentifier(true) - , bindStarToTypeName(false) - , bindStarToLeftSpecifier(false) - , bindStarToRightSpecifier(false) - , extraPaddingForConditionsIfConfusingAlign(true) - , alignAssignments(false) - , preferGetterNameWithoutGetPrefix(true) -{ -} +CppCodeStyleSettings::CppCodeStyleSettings() = default; void CppCodeStyleSettings::toSettings(const QString &category, QSettings *s) const { @@ -203,21 +180,20 @@ bool CppCodeStyleSettings::equals(const CppCodeStyleSettings &rhs) const Utils::optional<CppCodeStyleSettings> CppCodeStyleSettings::currentProjectCodeStyle() { ProjectExplorer::Project *project = ProjectExplorer::ProjectTree::currentProject(); - using OptSettings = Utils::optional<CppCodeStyleSettings>; if (!project) - return OptSettings(); + return {}; ProjectExplorer::EditorConfiguration *editorConfiguration = project->editorConfiguration(); - QTC_ASSERT(editorConfiguration, return OptSettings()); + QTC_ASSERT(editorConfiguration, return {}); TextEditor::ICodeStylePreferences *codeStylePreferences = editorConfiguration->codeStyle(Constants::CPP_SETTINGS_ID); - QTC_ASSERT(codeStylePreferences, return OptSettings()); + QTC_ASSERT(codeStylePreferences, return {}); auto cppCodeStylePreferences = dynamic_cast<const CppCodeStylePreferences *>(codeStylePreferences); if (!cppCodeStylePreferences) - return OptSettings(); + return {}; return cppCodeStylePreferences->currentCodeStyleSettings(); } diff --git a/src/plugins/cpptools/cppcodestylesettings.h b/src/plugins/cpptools/cppcodestylesettings.h index 4e39e05afc..8b477be354 100644 --- a/src/plugins/cpptools/cppcodestylesettings.h +++ b/src/plugins/cpptools/cppcodestylesettings.h @@ -45,26 +45,26 @@ class CPPTOOLS_EXPORT CppCodeStyleSettings public: CppCodeStyleSettings(); - bool indentBlockBraces; - bool indentBlockBody; - bool indentClassBraces; - bool indentEnumBraces; - bool indentNamespaceBraces; - bool indentNamespaceBody; - bool indentAccessSpecifiers; - bool indentDeclarationsRelativeToAccessSpecifiers; - bool indentFunctionBody; - bool indentFunctionBraces; - bool indentSwitchLabels; - bool indentStatementsRelativeToSwitchLabels; - bool indentBlocksRelativeToSwitchLabels; - bool indentControlFlowRelativeToSwitchLabels; + bool indentBlockBraces = false; + bool indentBlockBody = true; + bool indentClassBraces = false; + bool indentEnumBraces = false; + bool indentNamespaceBraces = false; + bool indentNamespaceBody = false; + bool indentAccessSpecifiers = false; + bool indentDeclarationsRelativeToAccessSpecifiers = true; + bool indentFunctionBody = true; + bool indentFunctionBraces = false; + bool indentSwitchLabels = false; + bool indentStatementsRelativeToSwitchLabels = true; + bool indentBlocksRelativeToSwitchLabels = false; + bool indentControlFlowRelativeToSwitchLabels = true; // Formatting of pointer and reference declarations, see Overview::StarBindFlag. - bool bindStarToIdentifier; - bool bindStarToTypeName; - bool bindStarToLeftSpecifier; - bool bindStarToRightSpecifier; + bool bindStarToIdentifier = true; + bool bindStarToTypeName = false; + bool bindStarToLeftSpecifier = false; + bool bindStarToRightSpecifier = false; // false: if (a && // b) @@ -75,15 +75,15 @@ public: // but always: while (a && // b) // foo; - bool extraPaddingForConditionsIfConfusingAlign; + bool extraPaddingForConditionsIfConfusingAlign = true; // false: a = a + // b; // true: a = a + // b - bool alignAssignments; + bool alignAssignments = false; - bool preferGetterNameWithoutGetPrefix; + bool preferGetterNameWithoutGetPrefix = true; void toSettings(const QString &category, QSettings *s) const; void fromSettings(const QString &category, const QSettings *s); diff --git a/src/plugins/cpptools/cppcompletionassist.cpp b/src/plugins/cpptools/cppcompletionassist.cpp index ab125a86c7..12b226f756 100644 --- a/src/plugins/cpptools/cppcompletionassist.cpp +++ b/src/plugins/cpptools/cppcompletionassist.cpp @@ -1737,9 +1737,8 @@ void InternalCppCompletionAssistProcessor::addClassMembersToCompletion(Scope *sc else addCompletionItem(member); } - std::set<Class *>::const_iterator citEnd = nestedAnonymouses.end(); - for (std::set<Class *>::const_iterator cit = nestedAnonymouses.begin(); cit != citEnd; ++cit) - addClassMembersToCompletion(*cit, staticLookup); + for (Class *klass : nestedAnonymouses) + addClassMembersToCompletion(klass, staticLookup); } bool InternalCppCompletionAssistProcessor::completeQtMethod(const QList<LookupItem> &results, diff --git a/src/plugins/cpptools/cpppointerdeclarationformatter_test.cpp b/src/plugins/cpptools/cpppointerdeclarationformatter_test.cpp index f412c9ab69..7b9fff7f0e 100644 --- a/src/plugins/cpptools/cpppointerdeclarationformatter_test.cpp +++ b/src/plugins/cpptools/cpppointerdeclarationformatter_test.cpp @@ -490,7 +490,7 @@ void CppToolsPlugin::test_format_pointerdeclaration_multiple_declarators_data() QTest::newRow("function-pointer_in-start") << "char *s, @*(*foo)(char *s) = 0;" - << "char *s, *(*foo)(char * s) = 0;"; + << "char *s, * (*foo)(char * s) = 0;"; } void CppToolsPlugin::test_format_pointerdeclaration_multiple_matches() @@ -534,8 +534,8 @@ void CppToolsPlugin::test_format_pointerdeclaration_multiple_matches_data() << "int g() { for (char * s; char * t = 0; s++) { char * u = 0; } }"; QTest::newRow("multiple-declarators") - << "const char c, *s, *(*foo)(char *s) = 0;" - << "const char c, * s, *(*foo)(char * s) = 0;"; + << "const char c, *s, * (*foo)(char *s) = 0;" + << "const char c, * s, * (*foo)(char * s) = 0;"; QTest::newRow("complex") << @@ -568,7 +568,7 @@ void CppToolsPlugin::test_format_pointerdeclaration_multiple_matches_data() " int (*bar)[] = 0;\n" "\n" " char * s = 0, * f(int i) = 0;\n" - " const char c, * s, *(*foo)(char * s) = 0;" + " const char c, * s, * (*foo)(char * s) = 0;" "\n" " for (char * s; char * t = 0; s++) { char * u = 0; }" "\n" diff --git a/src/plugins/cpptools/cppprojectfilecategorizer.cpp b/src/plugins/cpptools/cppprojectfilecategorizer.cpp index ddb841f9de..35ec2d9263 100644 --- a/src/plugins/cpptools/cppprojectfilecategorizer.cpp +++ b/src/plugins/cpptools/cppprojectfilecategorizer.cpp @@ -47,7 +47,7 @@ ProjectFileCategorizer::ProjectFileCategorizer(const QString &projectPartName, QString ProjectFileCategorizer::partName(const QString &languageName) const { if (hasMultipleParts()) - return QString::fromLatin1("%1 (%2)").arg(m_partName).arg(languageName); + return QString::fromLatin1("%1 (%2)").arg(m_partName, languageName); return m_partName; } diff --git a/src/plugins/cpptools/cppqtstyleindenter.cpp b/src/plugins/cpptools/cppqtstyleindenter.cpp index fe9b17828e..8979ad62e8 100644 --- a/src/plugins/cpptools/cppqtstyleindenter.cpp +++ b/src/plugins/cpptools/cppqtstyleindenter.cpp @@ -179,7 +179,7 @@ CppCodeStyleSettings CppQtStyleIndenter::codeStyleSettings() const { if (m_cppCodeStylePreferences) return m_cppCodeStylePreferences->currentCodeStyleSettings(); - return CppCodeStyleSettings(); + return {}; } TextEditor::IndentationForBlock CppQtStyleIndenter::indentationForBlocks( diff --git a/src/plugins/cpptools/cpprefactoringchanges.cpp b/src/plugins/cpptools/cpprefactoringchanges.cpp index 138a5a3693..f3c27073a9 100644 --- a/src/plugins/cpptools/cpprefactoringchanges.cpp +++ b/src/plugins/cpptools/cpprefactoringchanges.cpp @@ -198,12 +198,12 @@ Utils::ChangeSet::Range CppRefactoringFile::range(unsigned tokenIndex) const unsigned line, column; cppDocument()->translationUnit()->getPosition(token.utf16charsBegin(), &line, &column); const int start = document()->findBlockByNumber(line - 1).position() + column - 1; - return Utils::ChangeSet::Range(start, start + token.utf16chars()); + return {start, static_cast<int>(start + token.utf16chars())}; } Utils::ChangeSet::Range CppRefactoringFile::range(AST *ast) const { - return Utils::ChangeSet::Range(startOf(ast), endOf(ast)); + return {startOf(ast), endOf(ast)}; } int CppRefactoringFile::startOf(unsigned index) const diff --git a/src/plugins/cpptools/cppselectionchanger.cpp b/src/plugins/cpptools/cppselectionchanger.cpp index e19c1711a6..98437c1ced 100644 --- a/src/plugins/cpptools/cppselectionchanger.cpp +++ b/src/plugins/cpptools/cppselectionchanger.cpp @@ -560,7 +560,6 @@ void CppSelectionChanger::fineTuneASTNodePositions(ASTNodePositions &positions) qDebug() << "Is raw literal."; // Start from positions that include quotes. - int newPosStart = positions.astPosStart; int newPosEnd = positions.astPosEnd; // Decrement last position to skip last quote. @@ -572,7 +571,7 @@ void CppSelectionChanger::fineTuneASTNodePositions(ASTNodePositions &positions) // Start position will be the end position minus the size of the actual contents of the // literal. - newPosStart = newPosEnd - static_cast<int>(firstToken.string->size()); + int newPosStart = newPosEnd - static_cast<int>(firstToken.string->size()); // Skip raw literal parentheses. if (isRawLiteral) @@ -591,13 +590,8 @@ void CppSelectionChanger::fineTuneASTNodePositions(ASTNodePositions &positions) if (debug) qDebug() << "Selecting inner contents of char literal."; - int newPosStart = positions.astPosStart; - int newPosEnd = positions.astPosEnd; - newPosEnd = newPosEnd - 1; - newPosStart = newPosEnd - static_cast<int>(firstToken.literal->size()); - - positions.astPosStart = newPosStart; - positions.astPosEnd = newPosEnd; + positions.astPosEnd = positions.astPosEnd - 1; + positions.astPosStart = positions.astPosEnd - int(firstToken.literal->size()); } } } else if (ForStatementAST *forStatementAST = ast->asForStatement()) { diff --git a/src/plugins/cpptools/doxygengenerator.cpp b/src/plugins/cpptools/doxygengenerator.cpp index 4ae67721cf..764930cbc9 100644 --- a/src/plugins/cpptools/doxygengenerator.cpp +++ b/src/plugins/cpptools/doxygengenerator.cpp @@ -42,12 +42,7 @@ using namespace CppTools; using namespace CPlusPlus; -DoxygenGenerator::DoxygenGenerator() - : m_addLeadingAsterisks(true) - , m_generateBrief(true) - , m_startComment(true) - , m_style(QtStyle) -{} +DoxygenGenerator::DoxygenGenerator() = default; void DoxygenGenerator::setStyle(DocumentationStyle style) { diff --git a/src/plugins/cpptools/doxygengenerator.h b/src/plugins/cpptools/doxygengenerator.h index 051ecfbd3e..780525b65e 100644 --- a/src/plugins/cpptools/doxygengenerator.h +++ b/src/plugins/cpptools/doxygengenerator.h @@ -85,10 +85,10 @@ private: void assignCommentOffset(QTextCursor cursor); QString offsetString() const; - bool m_addLeadingAsterisks; - bool m_generateBrief; - bool m_startComment; - DocumentationStyle m_style; + bool m_addLeadingAsterisks = true; + bool m_generateBrief = true; + bool m_startComment = true; + DocumentationStyle m_style = QtStyle; CPlusPlus::Overview m_printer; QString m_commentOffset; }; diff --git a/src/plugins/cpptools/insertionpointlocator.cpp b/src/plugins/cpptools/insertionpointlocator.cpp index b73d672306..e6db241d79 100644 --- a/src/plugins/cpptools/insertionpointlocator.cpp +++ b/src/plugins/cpptools/insertionpointlocator.cpp @@ -248,10 +248,7 @@ private: } // end of anonymous namespace -InsertionLocation::InsertionLocation() - : m_line(0) - , m_column(0) -{} +InsertionLocation::InsertionLocation() = default; InsertionLocation::InsertionLocation(const QString &fileName, const QString &prefix, @@ -316,11 +313,9 @@ class HighestValue { Key _key; Value _value; - bool _set; + bool _set = false; public: - HighestValue() - : _key(), _set(false) - {} + HighestValue() = default; HighestValue(const Key &initialKey, const Value &initialValue) : _key(initialKey) diff --git a/src/plugins/cpptools/insertionpointlocator.h b/src/plugins/cpptools/insertionpointlocator.h index 480d1b592b..c05bc0f6ff 100644 --- a/src/plugins/cpptools/insertionpointlocator.h +++ b/src/plugins/cpptools/insertionpointlocator.h @@ -63,8 +63,8 @@ private: QString m_fileName; QString m_prefix; QString m_suffix; - unsigned m_line; - unsigned m_column; + unsigned m_line = 0; + unsigned m_column = 0; }; class CPPTOOLS_EXPORT InsertionPointLocator diff --git a/src/plugins/cpptools/searchsymbols.h b/src/plugins/cpptools/searchsymbols.h index fdda209244..37e5de08eb 100644 --- a/src/plugins/cpptools/searchsymbols.h +++ b/src/plugins/cpptools/searchsymbols.h @@ -41,7 +41,7 @@ namespace CppTools { class SearchSymbols: protected CPlusPlus::SymbolVisitor { public: - typedef SymbolSearcher::SymbolTypes SymbolTypes; + using SymbolTypes = SymbolSearcher::SymbolTypes; static SymbolTypes AllTypes; diff --git a/src/plugins/cpptools/symbolsfindfilter.cpp b/src/plugins/cpptools/symbolsfindfilter.cpp index 1fd758a3fa..f6bc1f52ba 100644 --- a/src/plugins/cpptools/symbolsfindfilter.cpp +++ b/src/plugins/cpptools/symbolsfindfilter.cpp @@ -248,9 +248,9 @@ QString SymbolsFindFilter::toolTip(FindFlags findFlags) const if (m_symbolsToSearch & SymbolSearcher::Declarations) types.append(tr("Declarations")); return tr("Scope: %1\nTypes: %2\nFlags: %3") - .arg(searchScope() == SymbolSearcher::SearchGlobal ? tr("All") : tr("Projects")) - .arg(types.join(tr(", "))) - .arg(IFindFilter::descriptionForFindFlags(findFlags)); + .arg(searchScope() == SymbolSearcher::SearchGlobal ? tr("All") : tr("Projects"), + types.join(", "), + IFindFilter::descriptionForFindFlags(findFlags)); } // #pragma mark -- SymbolsFindFilterConfigWidget |