forked from qt-creator/qt-creator
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:
@@ -312,7 +312,7 @@ QVersionNumber ClangdSettings::clangdVersion(const FilePath &clangdFilePath)
|
||||
const auto it = versionCache.find(clangdFilePath);
|
||||
if (it == versionCache.end()) {
|
||||
const QVersionNumber version = getClangdVersion(clangdFilePath);
|
||||
versionCache.insert(clangdFilePath, qMakePair(timeStamp, version));
|
||||
versionCache.insert(clangdFilePath, {timeStamp, version});
|
||||
return version;
|
||||
}
|
||||
if (it->first != timeStamp) {
|
||||
|
@@ -154,7 +154,7 @@ void CppClass::lookupBases(QFutureInterfaceBase &futureInterface,
|
||||
QSet<ClassOrNamespace *> visited;
|
||||
|
||||
QQueue<Data> q;
|
||||
q.enqueue(qMakePair(clazz, this));
|
||||
q.enqueue({clazz, this});
|
||||
while (!q.isEmpty()) {
|
||||
if (futureInterface.isCanceled())
|
||||
return;
|
||||
@@ -171,7 +171,7 @@ void CppClass::lookupBases(QFutureInterfaceBase &futureInterface,
|
||||
CppClass baseCppClass(symbol);
|
||||
CppClass *cppClass = current.second;
|
||||
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);
|
||||
|
||||
QQueue<Data> q;
|
||||
q.enqueue(qMakePair(this, completeHierarchy));
|
||||
q.enqueue({this, completeHierarchy});
|
||||
while (!q.isEmpty()) {
|
||||
if (futureInterface.isCanceled())
|
||||
return;
|
||||
@@ -201,7 +201,7 @@ void CppClass::lookupDerived(QFutureInterfaceBase &futureInterface,
|
||||
const QList<TypeHierarchy> hierarchy = classHierarchy.hierarchy();
|
||||
for (const TypeHierarchy &derivedHierarchy : hierarchy) {
|
||||
clazz->derived.append(CppClass(derivedHierarchy.symbol()));
|
||||
q.enqueue(qMakePair(&clazz->derived.last(), derivedHierarchy));
|
||||
q.enqueue({&clazz->derived.last(), derivedHierarchy});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -234,7 +234,7 @@ Utils::LineColumn OutlineModel::lineColumnFromIndex(const QModelIndex &sourceInd
|
||||
OutlineModel::Range OutlineModel::rangeFromIndex(const QModelIndex &sourceIndex) const
|
||||
{
|
||||
Utils::LineColumn lineColumn = lineColumnFromIndex(sourceIndex);
|
||||
return std::make_pair(lineColumn, lineColumn);
|
||||
return {lineColumn, lineColumn};
|
||||
}
|
||||
|
||||
void OutlineModel::buildTree(SymbolItem *root, bool isRoot)
|
||||
|
@@ -5037,7 +5037,7 @@ QPair<QString, QString> assembleDeclarationData(const QString &specifiers, Decla
|
||||
completeDecl.append(QLatin1Char(' ') + decltrText);
|
||||
else
|
||||
completeDecl.append(decltrText);
|
||||
return qMakePair(name, completeDecl);
|
||||
return {name, completeDecl};
|
||||
}
|
||||
}
|
||||
return QPair<QString, QString>();
|
||||
@@ -5329,7 +5329,7 @@ void ExtractFunction::match(const CppQuickFixInterface &interface, QuickFixOpera
|
||||
if ((usedBeforeExtraction && usedInsideExtraction)
|
||||
|| (usedInsideExtraction && refFuncParams.contains(name))) {
|
||||
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.
|
||||
@@ -5337,7 +5337,7 @@ void ExtractFunction::match(const CppQuickFixInterface &interface, QuickFixOpera
|
||||
if (!funcReturn) {
|
||||
QTC_ASSERT(analyser.m_knownDecls.contains(name), return);
|
||||
// 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();
|
||||
} else {
|
||||
// Would require multiple returns. (Unless we do fancy things, as pointed below.)
|
||||
|
@@ -22,7 +22,7 @@ public:
|
||||
{ insert(Utils::FilePath::fromString(fileName), source, revision); }
|
||||
|
||||
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
|
||||
{ return contains(Utils::FilePath::fromString(fileName)); }
|
||||
|
@@ -256,13 +256,13 @@ Symbol *SymbolFinder::findMatchingVarDefinition(Symbol *declaration, const Snaps
|
||||
for (const LookupItem &item : items) {
|
||||
if (item.declaration() == symbol)
|
||||
addFallback = false;
|
||||
candidates << qMakePair(item.declaration(),
|
||||
context.lookupType(item.declaration()) == enclosingType);
|
||||
candidates.push_back({item.declaration(),
|
||||
context.lookupType(item.declaration()) == enclosingType});
|
||||
}
|
||||
// TODO: This is a workaround for static member definitions not being found by
|
||||
// the lookup() function.
|
||||
if (addFallback)
|
||||
fallbacks << qMakePair(symbol, context.lookupType(symbol) == enclosingType);
|
||||
fallbacks.push_back({symbol, context.lookupType(symbol) == enclosingType});
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user