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