Skip to content

Commit

Permalink
Address various deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
mortbopet committed Sep 26, 2023
1 parent 1530917 commit 98ea1b2
Show file tree
Hide file tree
Showing 13 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/assembler/assembler.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ class Assembler : public AssemblerBase {
// Join tokens
QString joinedLine;
const auto tokens = std::get<LineTokens>(tokensVar);
for (const auto &token : qAsConst(tokens)) {
for (const auto &token : std::as_const(tokens)) {
joinedLine += token + " ";
}
joinedLine.chop(1); // remove trailing ' '
Expand Down
2 changes: 1 addition & 1 deletion src/assembler/gnudirectives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ static QString numTokensError(unsigned expected, const TokenizedSrcLine &line) {
std::to_string(line.tokens.size()) + "[");
for (auto t : llvm::enumerate(line.tokens)) {
err += t.value();
if (t.index() < (line.tokens.size() - 1))
if (static_cast<int64_t>(t.index()) < (line.tokens.size() - 1))
err += ", ";
};
err += "].";
Expand Down
4 changes: 2 additions & 2 deletions src/cachesim/cacheplotview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,14 @@ QPixmap CachePlotView::getPlotPixmap() {
itemsToHide << marker->marker;
}

for (const auto &i : qAsConst(itemsToHide)) {
for (const auto &i : std::as_const(itemsToHide)) {
if (i)
i->hide();
}

QPixmap p = grab();

for (const auto &i : qAsConst(itemsToHide)) {
for (const auto &i : std::as_const(itemsToHide)) {
if (i)
i->show();
}
Expand Down
10 changes: 5 additions & 5 deletions src/cachesim/cacheplotwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ CachePlotWidget::gatherData(unsigned fromCycle) const {

void resample(QLineSeries *series, unsigned target, double &step) {
QVector<QPointF> newPoints;
const auto &oldPoints = series->pointsVector();
const auto &oldPoints = series->points();
step = (oldPoints.last().x() / static_cast<double>(target)) *
2; // *2 to account for steps
newPoints.reserve(target);
Expand All @@ -356,7 +356,7 @@ void resample(QLineSeries *series, unsigned target, double &step) {
// sanity check
QPointF plast = QPointF(0, 0);
bool first = true;
for (const auto &p : qAsConst(newPoints)) {
for (const auto &p : std::as_const(newPoints)) {
if (!first) {
Q_ASSERT(p.x() - plast.x() < step * 1.1);
first = false;
Expand Down Expand Up @@ -426,8 +426,8 @@ void CachePlotWidget::updateRatioPlot() {
QList<QPointF> newPoints;
QList<QPointF> newWindowPoints;
QPointF lastPoint;
if (m_series->pointsVector().size() > 0) {
lastPoint = m_series->pointsVector().constLast();
if (m_series->points().size() > 0) {
lastPoint = m_series->points().constLast();
} else {
lastPoint = QPointF(-1, 0);
}
Expand Down Expand Up @@ -489,7 +489,7 @@ void CachePlotWidget::updateRatioPlot() {
// points, and we resample at a 2x ratio
const int maxPoints =
RipesSettings::value(RIPES_SETTING_CACHE_MAXPOINTS).toInt() * 2 * 2;
if (m_series->pointsVector().size() >= maxPoints) {
if (m_series->points().size() >= maxPoints) {
resample(m_series, maxPoints / 2, m_xStep);
}

Expand Down
2 changes: 1 addition & 1 deletion src/cachesim/cacheview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void CacheView::mousePressEvent(QMouseEvent *event) {
// and emit a signal indicating that the address was selected through the
// cache
const auto viewItems = items(event->pos());
for (const auto &item : qAsConst(viewItems)) {
for (const auto &item : std::as_const(viewItems)) {
if (auto *textItem = dynamic_cast<QGraphicsSimpleTextItem *>(item)) {
const QVariant userData = textItem->data(Qt::UserRole);
if (userData.isValid()) {
Expand Down
2 changes: 1 addition & 1 deletion src/ccmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const static QString s_testprogram = "int main() { return 0; }";
QString indentString(const QString &string, int indent) {
auto subStrings = string.split("\n");
auto indentedStrings = QStringList();
for (const auto &str : qAsConst(subStrings)) {
for (const auto &str : std::as_const(subStrings)) {
indentedStrings << QString(" ").repeated(indent) + str;
}
return indentedStrings.join("\n");
Expand Down
2 changes: 1 addition & 1 deletion src/cli/clioptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ bool parseCLIOptions(QCommandLineParser &parser, QString &errorMessage,
.isaInfo()
.supportedExtensions;

for (auto &ext : qAsConst(options.isaExtensions)) {
for (auto &ext : std::as_const(options.isaExtensions)) {
if (!exts.contains(ext)) {
errorMessage =
"Invalid ISA extension '" + ext + "' specified (--isaexts).";
Expand Down
2 changes: 1 addition & 1 deletion src/editor/csyntaxhighlighter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ CSyntaxHighlighter::CSyntaxHighlighter(
} // namespace Ripes

void CSyntaxHighlighter::syntaxHighlightBlock(const QString &text) {
for (const HighlightingRule &rule : qAsConst(highlightingRules)) {
for (const HighlightingRule &rule : std::as_const(highlightingRules)) {
QRegularExpressionMatchIterator matchIterator =
rule.pattern.globalMatch(text);
while (matchIterator.hasNext()) {
Expand Down
4 changes: 2 additions & 2 deletions src/editor/rvsyntaxhighlighter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ RVSyntaxHighlighter::RVSyntaxHighlighter(
<< "\\bgp\\b"
<< "\\btp\\b"
<< "\\bfp\\b";
for (const auto &pattern : qAsConst(registerPatterns)) {
for (const auto &pattern : std::as_const(registerPatterns)) {
rule.pattern = QRegularExpression(pattern);
rule.format = registerFormat;
m_highlightingRules.append(rule);
Expand Down Expand Up @@ -70,7 +70,7 @@ RVSyntaxHighlighter::RVSyntaxHighlighter(
}

void RVSyntaxHighlighter::syntaxHighlightBlock(const QString &text) {
for (const HighlightingRule &rule : qAsConst(m_highlightingRules)) {
for (const HighlightingRule &rule : std::as_const(m_highlightingRules)) {
QRegularExpressionMatchIterator matchIterator =
rule.pattern.globalMatch(text);
while (matchIterator.hasNext()) {
Expand Down
4 changes: 2 additions & 2 deletions src/flowlayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ QSize FlowLayout::sizeHint() const { return minimumSize(); }

QSize FlowLayout::minimumSize() const {
QSize size;
for (const QLayoutItem *item : qAsConst(itemList))
for (const QLayoutItem *item : std::as_const(itemList))
size = size.expandedTo(item->minimumSize());

const QMargins margins = contentsMargins();
Expand All @@ -153,7 +153,7 @@ int FlowLayout::doLayout(const QRect &rect, bool testOnly) const {
//! [9]

//! [10]
for (QLayoutItem *item : qAsConst(itemList)) {
for (QLayoutItem *item : std::as_const(itemList)) {
int spaceX = horizontalSpacing();
int spaceY = verticalSpacing();
if (spaceX == -1)
Expand Down
6 changes: 3 additions & 3 deletions src/processmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ class ProcessManager {
static bool hasValidProgram() { return false; }
static const QString &program() { return get().m_programPath; }
static QString getError() { return QString(); }
static ProcessResult run(const QStringList &args,
bool showProgressDialog = false) {
static ProcessResult run(const QStringList &,
bool = false) {
return ProcessResult();
}

Expand All @@ -165,7 +165,7 @@ class ProcessManager {
}
signals:

bool trySetProgram(const QString &path) { return false; }
bool trySetProgram(const QString &) { return false; }

private:
QString m_programPath;
Expand Down
2 changes: 1 addition & 1 deletion src/processorselectiondialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ void ProcessorSelectionDialog::selectionChanged(QTreeWidgetItem *current,
delete item;
}

for (const auto &ext : qAsConst(isaInfo.supportedExtensions)) {
for (const auto &ext : std::as_const(isaInfo.supportedExtensions)) {
auto chkbox = new QCheckBox(ext);
chkbox->setToolTip(isaInfo.isa->extensionDescription(ext));
m_ui->extensions->addWidget(chkbox);
Expand Down
2 changes: 1 addition & 1 deletion src/savedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void SaveDialog::accept() {

void SaveDialog::pathChanged() {
bool okEnabled = !QFileInfo(m_ui->filePath->text()).fileName().isEmpty();
okEnabled &= m_ui->saveSource->isChecked() | m_ui->saveBinary->isChecked();
okEnabled &= m_ui->saveSource->isChecked() || m_ui->saveBinary->isChecked();

m_ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(okEnabled);

Expand Down

0 comments on commit 98ea1b2

Please sign in to comment.