forked from qt-creator/qt-creator
Clang: Limit the usage of qMakePair and std::make_pair
Change-Id: Ida094760023047ecb8ba29e60d5e81f766981b65 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -212,7 +212,7 @@ template<typename DocType, typename DataType> class VersionedDataCache
|
||||
public:
|
||||
void insert(const DocType &doc, const DataType &data)
|
||||
{
|
||||
m_data.emplace(std::make_pair(doc, VersionedDocData(doc, data)));
|
||||
m_data.emplace(doc, VersionedDocData(doc, data));
|
||||
}
|
||||
void remove(const DocType &doc) { m_data.erase(doc); }
|
||||
std::optional<VersionedDocData<DocType, DataType>> take(const DocType &doc)
|
||||
@@ -531,7 +531,7 @@ QTextCursor ClangdClient::adjustedCursorForHighlighting(const QTextCursor &curso
|
||||
|
||||
const LanguageClient::Client::CustomInspectorTabs ClangdClient::createCustomInspectorTabs()
|
||||
{
|
||||
return {std::make_pair(new ClangdMemoryUsageWidget(this), tr("Memory Usage"))};
|
||||
return {{new ClangdMemoryUsageWidget(this), tr("Memory Usage")}};
|
||||
}
|
||||
|
||||
class ClangdDiagnosticManager : public LanguageClient::DiagnosticManager
|
||||
@@ -1332,9 +1332,7 @@ void ClangdClient::Private::handleSemanticTokens(TextDocument *doc,
|
||||
data->previousTokens.first = tokens;
|
||||
data->previousTokens.second = version;
|
||||
} else {
|
||||
HighlightingData data;
|
||||
data.previousTokens = qMakePair(tokens, version);
|
||||
highlightingData.insert(doc, data);
|
||||
highlightingData.insert(doc, {{tokens, version}, {}});
|
||||
}
|
||||
for (const ExpandedSemanticToken &t : tokens)
|
||||
qCDebug(clangdLogHighlight()) << '\t' << t.line << t.column << t.length << t.type
|
||||
|
@@ -493,7 +493,7 @@ QList<AssistProposalItemInterface *> CustomAssistProcessor::completeInclude(
|
||||
for (AssistProposalItemInterface * const item : qAsConst(completions)) {
|
||||
QString s = item->text();
|
||||
s.replace('/', QChar(0)); // The dir separator should compare less than anything else.
|
||||
completionsForSorting << qMakePair(item, s);
|
||||
completionsForSorting.push_back({item, s});
|
||||
}
|
||||
Utils::sort(completionsForSorting, [](const auto &left, const auto &right) {
|
||||
return left.second < right.second;
|
||||
|
@@ -200,7 +200,7 @@ void ClangdFindReferences::Private::handleFindUsagesResult(const QList<Location>
|
||||
});
|
||||
|
||||
for (const Location &loc : locations)
|
||||
fileData[loc.uri()].rangesAndLineText << qMakePair(loc.range(), QString());
|
||||
fileData[loc.uri()].rangesAndLineText.push_back({loc.range(), {}});
|
||||
for (auto it = fileData.begin(); it != fileData.end();) {
|
||||
const Utils::FilePath filePath = it.key().toFilePath();
|
||||
if (!filePath.exists()) { // https://github.com/clangd/clangd/issues/935
|
||||
|
@@ -454,7 +454,7 @@ void ClangdFollowSymbol::Private::handleGotoImplementationResult(
|
||||
if (!sentinel)
|
||||
return;
|
||||
if (!name.isEmpty())
|
||||
symbolsToDisplay << qMakePair(prefix + name, link);
|
||||
symbolsToDisplay.push_back({prefix + name, link});
|
||||
pendingSymbolInfoRequests.removeOne(reqId);
|
||||
virtualFuncAssistProcessor->update();
|
||||
if (pendingSymbolInfoRequests.isEmpty() && pendingGotoDefRequests.isEmpty()
|
||||
|
@@ -39,7 +39,7 @@ public:
|
||||
for (auto it = obj.begin(); it != obj.end(); ++it) {
|
||||
if (it.key() == totalKey() || it.key() == selfKey())
|
||||
continue;
|
||||
components << std::make_pair(MemoryTree(it.value()), it.key());
|
||||
components.push_back({MemoryTree(it.value()), it.key()});
|
||||
}
|
||||
return components;
|
||||
}
|
||||
@@ -81,11 +81,9 @@ private:
|
||||
|
||||
QString memString() const
|
||||
{
|
||||
static const QList<std::pair<int, QString>> factors{
|
||||
std::make_pair(1000000000, QString("GB")),
|
||||
std::make_pair(1000000, QString("MB")),
|
||||
std::make_pair(1000, QString("KB")),
|
||||
};
|
||||
static const QList<std::pair<int, QString>> factors{{1000000000, "GB"},
|
||||
{1000000, "MB"},
|
||||
{1000, "KB"}};
|
||||
for (const auto &factor : factors) {
|
||||
if (m_bytesUsed > factor.first)
|
||||
return QString::number(qint64(std::round(double(m_bytesUsed) / factor.first)))
|
||||
|
@@ -190,14 +190,12 @@ static QString createExplainingStepToolTipString(const ExplainingStep &step)
|
||||
QList<StringPair> lines;
|
||||
|
||||
if (!step.message.isEmpty()) {
|
||||
lines << qMakePair(
|
||||
QCoreApplication::translate("ClangTools::ExplainingStep", "Message:"),
|
||||
step.message.toHtmlEscaped());
|
||||
lines.push_back({QCoreApplication::translate("ClangTools::ExplainingStep", "Message:"),
|
||||
step.message.toHtmlEscaped()});
|
||||
}
|
||||
|
||||
lines << qMakePair(
|
||||
QCoreApplication::translate("ClangTools::ExplainingStep", "Location:"),
|
||||
createFullLocationString(step.location));
|
||||
lines.push_back({QCoreApplication::translate("ClangTools::ExplainingStep", "Location:"),
|
||||
createFullLocationString(step.location)});
|
||||
|
||||
QString html = QLatin1String("<html>"
|
||||
"<head>"
|
||||
|
@@ -61,30 +61,26 @@ QString createDiagnosticToolTipString(
|
||||
QList<StringPair> lines;
|
||||
|
||||
if (!diagnostic.category.isEmpty()) {
|
||||
lines << qMakePair(
|
||||
QCoreApplication::translate("ClangTools::Diagnostic", "Category:"),
|
||||
diagnostic.category.toHtmlEscaped());
|
||||
lines.push_back({QCoreApplication::translate("ClangTools::Diagnostic", "Category:"),
|
||||
diagnostic.category.toHtmlEscaped()});
|
||||
}
|
||||
|
||||
if (!diagnostic.type.isEmpty()) {
|
||||
lines << qMakePair(
|
||||
QCoreApplication::translate("ClangTools::Diagnostic", "Type:"),
|
||||
diagnostic.type.toHtmlEscaped());
|
||||
lines.push_back({QCoreApplication::translate("ClangTools::Diagnostic", "Type:"),
|
||||
diagnostic.type.toHtmlEscaped()});
|
||||
}
|
||||
|
||||
if (!diagnostic.description.isEmpty()) {
|
||||
lines << qMakePair(
|
||||
QCoreApplication::translate("ClangTools::Diagnostic", "Description:"),
|
||||
diagnostic.description.toHtmlEscaped());
|
||||
lines.push_back({QCoreApplication::translate("ClangTools::Diagnostic", "Description:"),
|
||||
diagnostic.description.toHtmlEscaped()});
|
||||
}
|
||||
|
||||
lines << qMakePair(
|
||||
QCoreApplication::translate("ClangTools::Diagnostic", "Location:"),
|
||||
createFullLocationString(diagnostic.location));
|
||||
lines.push_back({QCoreApplication::translate("ClangTools::Diagnostic", "Location:"),
|
||||
createFullLocationString(diagnostic.location)});
|
||||
|
||||
if (status) {
|
||||
lines << qMakePair(QCoreApplication::translate("ClangTools::Diagnostic", "Fixit status:"),
|
||||
fixitStatus(*status));
|
||||
lines.push_back({QCoreApplication::translate("ClangTools::Diagnostic", "Fixit status:"),
|
||||
fixitStatus(*status)});
|
||||
}
|
||||
|
||||
if (showSteps && !diagnostic.explainingSteps.isEmpty()) {
|
||||
@@ -103,8 +99,8 @@ QString createDiagnosticToolTipString(
|
||||
|
||||
const QString url = documentationUrl(diagnostic.name);
|
||||
if (!url.isEmpty()) {
|
||||
lines << qMakePair(QCoreApplication::translate("ClangTools::Diagnostic", "Documentation:"),
|
||||
QString("<a href=\"%1\">%1</a>").arg(url));
|
||||
lines.push_back({QCoreApplication::translate("ClangTools::Diagnostic", "Documentation:"),
|
||||
QString("<a href=\"%1\">%1</a>").arg(url)});
|
||||
}
|
||||
|
||||
QString html = QLatin1String("<html>"
|
||||
|
@@ -147,7 +147,7 @@ ClazyStandaloneInfo ClazyStandaloneInfo::getInfo(const FilePath &executablePath)
|
||||
const auto it = cache.find(executablePath);
|
||||
if (it == cache.end()) {
|
||||
const ClazyStandaloneInfo info(executablePath);
|
||||
cache.insert(executablePath, qMakePair(timeStamp, info));
|
||||
cache.insert(executablePath, {timeStamp, info});
|
||||
return info;
|
||||
}
|
||||
if (it->first != timeStamp) {
|
||||
@@ -219,8 +219,8 @@ QPair<FilePath, QString> getClangIncludeDirAndVersion(const FilePath &clangToolP
|
||||
const FilePath dynamicResourceDir = queryResourceDir(clangToolPath);
|
||||
const QString dynamicVersion = queryVersion(clangToolPath, QueryFailMode::Noisy);
|
||||
if (dynamicResourceDir.isEmpty() || dynamicVersion.isEmpty())
|
||||
return qMakePair(FilePath::fromString(CLANG_INCLUDE_DIR), QString(CLANG_VERSION));
|
||||
return qMakePair(dynamicResourceDir + "/include", dynamicVersion);
|
||||
return {FilePath::fromString(CLANG_INCLUDE_DIR), QString(CLANG_VERSION)};
|
||||
return {dynamicResourceDir + "/include", dynamicVersion};
|
||||
}
|
||||
|
||||
QHash<Utils::FilePath, QPair<QDateTime, ClazyStandaloneInfo>> ClazyStandaloneInfo::cache;
|
||||
|
Reference in New Issue
Block a user