forked from qt-creator/qt-creator
ClangTools: Use qAsConst with non-const Qt containers in range-loops
Change-Id: Id9df0a27c4bcba57ee76574e32ca53cb6c28a43d Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -270,7 +270,7 @@ public:
|
||||
QVector<DiagnosticItem *> itemsSchedulable;
|
||||
|
||||
// Construct refactoring operations
|
||||
for (DiagnosticItem *diagnosticItem : fileInfo.diagnosticItems) {
|
||||
for (DiagnosticItem *diagnosticItem : qAsConst(fileInfo.diagnosticItems)) {
|
||||
const FixitStatus fixItStatus = diagnosticItem->fixItStatus();
|
||||
|
||||
const bool isScheduled = fixItStatus == FixitStatus::Scheduled;
|
||||
@@ -289,7 +289,7 @@ public:
|
||||
|
||||
// Collect replacements
|
||||
ReplacementOperations ops;
|
||||
for (DiagnosticItem *item : itemsScheduledOrSchedulable)
|
||||
for (DiagnosticItem *item : qAsConst(itemsScheduledOrSchedulable))
|
||||
ops += item->fixitOperations();
|
||||
|
||||
if (ops.empty())
|
||||
@@ -311,11 +311,11 @@ public:
|
||||
model->addWatchedPath(ops.first()->fileName);
|
||||
|
||||
// Update DiagnosticItem state
|
||||
for (DiagnosticItem *diagnosticItem : itemsScheduled)
|
||||
for (DiagnosticItem *diagnosticItem : qAsConst(itemsScheduled))
|
||||
diagnosticItem->setFixItStatus(FixitStatus::Applied);
|
||||
for (DiagnosticItem *diagnosticItem : itemsFailedToApply)
|
||||
for (DiagnosticItem *diagnosticItem : qAsConst(itemsFailedToApply))
|
||||
diagnosticItem->setFixItStatus(FixitStatus::FailedToApply);
|
||||
for (DiagnosticItem *diagnosticItem : itemsInvalidated)
|
||||
for (DiagnosticItem *diagnosticItem : qAsConst(itemsInvalidated))
|
||||
diagnosticItem->setFixItStatus(FixitStatus::Invalidated);
|
||||
}
|
||||
}
|
||||
@@ -333,7 +333,7 @@ static FileInfos sortedFileInfos(const QVector<CppTools::ProjectPart::Ptr> &proj
|
||||
if (!projectPart->selectedForBuilding)
|
||||
continue;
|
||||
|
||||
for (const CppTools::ProjectFile &file : projectPart->files) {
|
||||
for (const CppTools::ProjectFile &file : qAsConst(projectPart->files)) {
|
||||
QTC_ASSERT(file.kind != CppTools::ProjectFile::Unclassified, continue);
|
||||
QTC_ASSERT(file.kind != CppTools::ProjectFile::Unsupported, continue);
|
||||
if (file.path == CppTools::CppModelManager::configurationFileName())
|
||||
|
@@ -296,7 +296,7 @@ void ClangToolRunWorker::start()
|
||||
|
||||
void ClangToolRunWorker::stop()
|
||||
{
|
||||
for (ClangToolRunner *runner : m_runners) {
|
||||
for (ClangToolRunner *runner : qAsConst(m_runners)) {
|
||||
QObject::disconnect(runner, nullptr, this, nullptr);
|
||||
delete runner;
|
||||
}
|
||||
|
@@ -160,7 +160,7 @@ void ClangToolsDiagnosticModel::clear()
|
||||
|
||||
void ClangToolsDiagnosticModel::updateItems(const DiagnosticItem *changedItem)
|
||||
{
|
||||
for (auto item : stepsToItemsCache[changedItem->diagnostic().explainingSteps]) {
|
||||
for (auto item : qAsConst(stepsToItemsCache[changedItem->diagnostic().explainingSteps])) {
|
||||
if (item != changedItem)
|
||||
item->setFixItStatus(changedItem->fixItStatus());
|
||||
}
|
||||
|
@@ -91,7 +91,7 @@ public:
|
||||
|
||||
DocumentClangToolRunner *runnerForFilePath(const Utils::FilePath &filePath)
|
||||
{
|
||||
for (DocumentClangToolRunner *runner : documentRunners) {
|
||||
for (DocumentClangToolRunner *runner : qAsConst(documentRunners)) {
|
||||
if (runner->filePath() == filePath)
|
||||
return runner;
|
||||
}
|
||||
|
@@ -204,7 +204,7 @@ void ClangToolsProjectSettings::store()
|
||||
map.insert(SETTINGS_KEY_SELECTED_FILES, files);
|
||||
|
||||
QVariantList list;
|
||||
for (const SuppressedDiagnostic &diag : m_suppressedDiagnostics) {
|
||||
for (const SuppressedDiagnostic &diag : qAsConst(m_suppressedDiagnostics)) {
|
||||
QVariantMap diagMap;
|
||||
diagMap.insert(SETTINGS_KEY_SUPPRESSED_DIAGS_FILEPATH, diag.filePath.toString());
|
||||
diagMap.insert(SETTINGS_KEY_SUPPRESSED_DIAGS_MESSAGE, diag.description);
|
||||
|
@@ -116,9 +116,9 @@ static void removeClangToolRefactorMarkers(TextEditor::TextEditorWidget *editor)
|
||||
|
||||
void DocumentClangToolRunner::scheduleRun()
|
||||
{
|
||||
for (DiagnosticMark *mark : m_marks)
|
||||
for (DiagnosticMark *mark : qAsConst(m_marks))
|
||||
mark->disable();
|
||||
for (TextEditor::TextEditorWidget *editor : m_editorsWithMarkers)
|
||||
for (TextEditor::TextEditorWidget *editor : qAsConst(m_editorsWithMarkers))
|
||||
removeClangToolRefactorMarkers(editor);
|
||||
m_runTimer.start();
|
||||
}
|
||||
|
@@ -74,7 +74,7 @@ public:
|
||||
|
||||
setHeader({tr("Check"), "#"});
|
||||
setRootItem(new Utils::StaticTreeItem(QString()));
|
||||
for (const Check &check : sortedChecks)
|
||||
for (const Check &check : qAsConst(sortedChecks))
|
||||
m_root->appendChild(new CheckItem(check));
|
||||
}
|
||||
};
|
||||
|
@@ -103,7 +103,7 @@ void VirtualFileSystemOverlay::update()
|
||||
jsonRoot["type"] = "directory";
|
||||
jsonRoot["name"] = root.toUserOutput();
|
||||
QJsonArray contents;
|
||||
for (auto doc : documents)
|
||||
for (auto doc : qAsConst(documents))
|
||||
contents << toContent(doc);
|
||||
jsonRoot["contents"] = contents;
|
||||
jsonRoots << jsonRoot;
|
||||
|
Reference in New Issue
Block a user