CppEditor: Limit the usage of qMakePair and std::make_pair

Change-Id: I4c85edbaccb553320b5488d3dd2c2595fc2bd825
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Jarek Kobus
2022-09-30 13:47:00 +02:00
parent afd1742f9f
commit cd582faa7e
6 changed files with 13 additions and 13 deletions

View File

@@ -312,7 +312,7 @@ QVersionNumber ClangdSettings::clangdVersion(const FilePath &clangdFilePath)
const auto it = versionCache.find(clangdFilePath); const auto it = versionCache.find(clangdFilePath);
if (it == versionCache.end()) { if (it == versionCache.end()) {
const QVersionNumber version = getClangdVersion(clangdFilePath); const QVersionNumber version = getClangdVersion(clangdFilePath);
versionCache.insert(clangdFilePath, qMakePair(timeStamp, version)); versionCache.insert(clangdFilePath, {timeStamp, version});
return version; return version;
} }
if (it->first != timeStamp) { if (it->first != timeStamp) {

View File

@@ -154,7 +154,7 @@ void CppClass::lookupBases(QFutureInterfaceBase &futureInterface,
QSet<ClassOrNamespace *> visited; QSet<ClassOrNamespace *> visited;
QQueue<Data> q; QQueue<Data> q;
q.enqueue(qMakePair(clazz, this)); q.enqueue({clazz, this});
while (!q.isEmpty()) { while (!q.isEmpty()) {
if (futureInterface.isCanceled()) if (futureInterface.isCanceled())
return; return;
@@ -171,7 +171,7 @@ void CppClass::lookupBases(QFutureInterfaceBase &futureInterface,
CppClass baseCppClass(symbol); CppClass baseCppClass(symbol);
CppClass *cppClass = current.second; CppClass *cppClass = current.second;
cppClass->bases.append(baseCppClass); cppClass->bases.append(baseCppClass);
q.enqueue(qMakePair(clazz, &cppClass->bases.last())); q.enqueue({clazz, &cppClass->bases.last()});
} }
} }
} }
@@ -191,7 +191,7 @@ void CppClass::lookupDerived(QFutureInterfaceBase &futureInterface,
= TypeHierarchyBuilder::buildDerivedTypeHierarchy(futureInterface, declaration, snapshot); = TypeHierarchyBuilder::buildDerivedTypeHierarchy(futureInterface, declaration, snapshot);
QQueue<Data> q; QQueue<Data> q;
q.enqueue(qMakePair(this, completeHierarchy)); q.enqueue({this, completeHierarchy});
while (!q.isEmpty()) { while (!q.isEmpty()) {
if (futureInterface.isCanceled()) if (futureInterface.isCanceled())
return; return;
@@ -201,7 +201,7 @@ void CppClass::lookupDerived(QFutureInterfaceBase &futureInterface,
const QList<TypeHierarchy> hierarchy = classHierarchy.hierarchy(); const QList<TypeHierarchy> hierarchy = classHierarchy.hierarchy();
for (const TypeHierarchy &derivedHierarchy : hierarchy) { for (const TypeHierarchy &derivedHierarchy : hierarchy) {
clazz->derived.append(CppClass(derivedHierarchy.symbol())); clazz->derived.append(CppClass(derivedHierarchy.symbol()));
q.enqueue(qMakePair(&clazz->derived.last(), derivedHierarchy)); q.enqueue({&clazz->derived.last(), derivedHierarchy});
} }
} }
} }

View File

@@ -234,7 +234,7 @@ Utils::LineColumn OutlineModel::lineColumnFromIndex(const QModelIndex &sourceInd
OutlineModel::Range OutlineModel::rangeFromIndex(const QModelIndex &sourceIndex) const OutlineModel::Range OutlineModel::rangeFromIndex(const QModelIndex &sourceIndex) const
{ {
Utils::LineColumn lineColumn = lineColumnFromIndex(sourceIndex); Utils::LineColumn lineColumn = lineColumnFromIndex(sourceIndex);
return std::make_pair(lineColumn, lineColumn); return {lineColumn, lineColumn};
} }
void OutlineModel::buildTree(SymbolItem *root, bool isRoot) void OutlineModel::buildTree(SymbolItem *root, bool isRoot)

View File

@@ -5037,7 +5037,7 @@ QPair<QString, QString> assembleDeclarationData(const QString &specifiers, Decla
completeDecl.append(QLatin1Char(' ') + decltrText); completeDecl.append(QLatin1Char(' ') + decltrText);
else else
completeDecl.append(decltrText); completeDecl.append(decltrText);
return qMakePair(name, completeDecl); return {name, completeDecl};
} }
} }
return QPair<QString, QString>(); return QPair<QString, QString>();
@@ -5329,7 +5329,7 @@ void ExtractFunction::match(const CppQuickFixInterface &interface, QuickFixOpera
if ((usedBeforeExtraction && usedInsideExtraction) if ((usedBeforeExtraction && usedInsideExtraction)
|| (usedInsideExtraction && refFuncParams.contains(name))) { || (usedInsideExtraction && refFuncParams.contains(name))) {
QTC_ASSERT(analyser.m_knownDecls.contains(name), return); QTC_ASSERT(analyser.m_knownDecls.contains(name), return);
relevantDecls.append(qMakePair(name, analyser.m_knownDecls.value(name))); relevantDecls.push_back({name, analyser.m_knownDecls.value(name)});
} }
// We assume that the first use of a local corresponds to its declaration. // We assume that the first use of a local corresponds to its declaration.
@@ -5337,7 +5337,7 @@ void ExtractFunction::match(const CppQuickFixInterface &interface, QuickFixOpera
if (!funcReturn) { if (!funcReturn) {
QTC_ASSERT(analyser.m_knownDecls.contains(name), return); QTC_ASSERT(analyser.m_knownDecls.contains(name), return);
// The return, if any, is stored as the first item in the list. // The return, if any, is stored as the first item in the list.
relevantDecls.prepend(qMakePair(name, analyser.m_knownDecls.value(name))); relevantDecls.push_front({name, analyser.m_knownDecls.value(name)});
funcReturn = it.key(); funcReturn = it.key();
} else { } else {
// Would require multiple returns. (Unless we do fancy things, as pointed below.) // Would require multiple returns. (Unless we do fancy things, as pointed below.)

View File

@@ -22,7 +22,7 @@ public:
{ insert(Utils::FilePath::fromString(fileName), source, revision); } { insert(Utils::FilePath::fromString(fileName), source, revision); }
void insert(const Utils::FilePath &fileName, const QByteArray &source, unsigned revision = 0) void insert(const Utils::FilePath &fileName, const QByteArray &source, unsigned revision = 0)
{ _elements.insert(fileName, qMakePair(source, revision)); } { _elements.insert(fileName, {source, revision}); }
bool contains(const QString &fileName) const bool contains(const QString &fileName) const
{ return contains(Utils::FilePath::fromString(fileName)); } { return contains(Utils::FilePath::fromString(fileName)); }

View File

@@ -256,13 +256,13 @@ Symbol *SymbolFinder::findMatchingVarDefinition(Symbol *declaration, const Snaps
for (const LookupItem &item : items) { for (const LookupItem &item : items) {
if (item.declaration() == symbol) if (item.declaration() == symbol)
addFallback = false; addFallback = false;
candidates << qMakePair(item.declaration(), candidates.push_back({item.declaration(),
context.lookupType(item.declaration()) == enclosingType); context.lookupType(item.declaration()) == enclosingType});
} }
// TODO: This is a workaround for static member definitions not being found by // TODO: This is a workaround for static member definitions not being found by
// the lookup() function. // the lookup() function.
if (addFallback) if (addFallback)
fallbacks << qMakePair(symbol, context.lookupType(symbol) == enclosingType); fallbacks.push_back({symbol, context.lookupType(symbol) == enclosingType});
} }
} }