fixed some `modernize-use-auto` clean-tidy warnings (#4663)

This commit is contained in:
Oliver Stöneberg 2024-01-05 13:22:37 +01:00 committed by GitHub
parent 3241cf5966
commit 957096417e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 99 additions and 99 deletions

View File

@ -109,7 +109,7 @@ static void CppcheckSignalHandler(int signo, siginfo_t * info, void * context)
pid_t killid; pid_t killid;
// TODO: separate these two defines // TODO: separate these two defines
#if defined(__linux__) && defined(REG_ERR) #if defined(__linux__) && defined(REG_ERR)
const ucontext_t* const uc = reinterpret_cast<const ucontext_t*>(context); const auto* const uc = reinterpret_cast<const ucontext_t*>(context);
killid = (pid_t) syscall(SYS_gettid); killid = (pid_t) syscall(SYS_gettid);
if (uc) { if (uc) {
type = (int)uc->uc_mcontext.gregs[REG_ERR] & 2; type = (int)uc->uc_mcontext.gregs[REG_ERR] & 2;

View File

@ -107,11 +107,11 @@ namespace {
void writeToPipe(PipeSignal type, const std::string &data) const void writeToPipe(PipeSignal type, const std::string &data) const
{ {
{ {
const char t = static_cast<char>(type); const auto t = static_cast<char>(type);
writeToPipeInternal(type, &t, 1); writeToPipeInternal(type, &t, 1);
} }
const unsigned int len = static_cast<unsigned int>(data.length()); const auto len = static_cast<unsigned int>(data.length());
{ {
static constexpr std::size_t l_size = sizeof(unsigned int); static constexpr std::size_t l_size = sizeof(unsigned int);
writeToPipeInternal(type, &len, l_size); writeToPipeInternal(type, &len, l_size);

View File

@ -287,11 +287,11 @@ CodeEditor::CodeEditor(QWidget *parent) :
setStyleSheet(generateStyleString()); setStyleSheet(generateStyleString());
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
QShortcut *copyText = new QShortcut(QKeySequence(Qt::CTRL | Qt::Key_C),this); auto *copyText = new QShortcut(QKeySequence(Qt::CTRL | Qt::Key_C),this);
QShortcut *allText = new QShortcut(QKeySequence(Qt::CTRL | Qt::Key_A),this); auto *allText = new QShortcut(QKeySequence(Qt::CTRL | Qt::Key_A),this);
#else #else
const QShortcut *copyText = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_C),this); const auto *copyText = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_C),this);
const QShortcut *allText = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_A),this); const auto *allText = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_A),this);
#endif #endif
connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberAreaWidth(int))); connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberAreaWidth(int)));

View File

@ -72,10 +72,10 @@ StyleEditDialog::StyleEditDialog(const CodeEditorStyle& newStyle,
mStyleIncoming(newStyle), mStyleIncoming(newStyle),
mStyleOutgoing(newStyle) mStyleOutgoing(newStyle)
{ {
QVBoxLayout *vboxMain = new QVBoxLayout(this); auto *vboxMain = new QVBoxLayout(this);
QHBoxLayout *hboxEdit = new QHBoxLayout(); auto *hboxEdit = new QHBoxLayout();
// Color/Weight controls // Color/Weight controls
QFormLayout *flEditControls = new QFormLayout(); auto *flEditControls = new QFormLayout();
mBtnWidgetColorFG = new SelectColorButton(this); mBtnWidgetColorFG = new SelectColorButton(this);
flEditControls->addRow(QObject::tr("Editor Foreground Color"), flEditControls->addRow(QObject::tr("Editor Foreground Color"),
mBtnWidgetColorFG); mBtnWidgetColorFG);
@ -141,7 +141,7 @@ StyleEditDialog::StyleEditDialog(const CodeEditorStyle& newStyle,
vboxMain->addLayout(hboxEdit); vboxMain->addLayout(hboxEdit);
// Default Controls // Default Controls
QHBoxLayout *hboxDefaultControls = new QHBoxLayout(); auto *hboxDefaultControls = new QHBoxLayout();
mBtnDefaultLight = new QPushButton(QObject::tr("Set to Default Light"), mBtnDefaultLight = new QPushButton(QObject::tr("Set to Default Light"),
this); this);
mBtnDefaultDark = new QPushButton(QObject::tr("Set to Default Dark"), mBtnDefaultDark = new QPushButton(QObject::tr("Set to Default Dark"),
@ -153,7 +153,7 @@ StyleEditDialog::StyleEditDialog(const CodeEditorStyle& newStyle,
vboxMain->addLayout(hboxDefaultControls); vboxMain->addLayout(hboxDefaultControls);
vboxMain->addStretch(2); vboxMain->addStretch(2);
// dialog controls // dialog controls
QDialogButtonBox *dBtnBox = new QDialogButtonBox( auto *dBtnBox = new QDialogButtonBox(
QDialogButtonBox::Cancel | QDialogButtonBox::Cancel |
QDialogButtonBox::Ok | QDialogButtonBox::Ok |
QDialogButtonBox::Reset); QDialogButtonBox::Reset);

View File

@ -185,7 +185,7 @@ void LibraryDialog::saveCfgAs()
void LibraryDialog::addFunction() void LibraryDialog::addFunction()
{ {
LibraryAddFunctionDialog *d = new LibraryAddFunctionDialog; auto *d = new LibraryAddFunctionDialog;
if (d->exec() == QDialog::Accepted && !d->functionName().isEmpty()) { if (d->exec() == QDialog::Accepted && !d->functionName().isEmpty()) {
CppcheckLibraryData::Function f; CppcheckLibraryData::Function f;

View File

@ -58,7 +58,7 @@ int main(int argc, char *argv[])
QCoreApplication::setOrganizationName("Cppcheck"); QCoreApplication::setOrganizationName("Cppcheck");
QCoreApplication::setApplicationName("Cppcheck-GUI"); QCoreApplication::setApplicationName("Cppcheck-GUI");
QSettings* settings = new QSettings("Cppcheck", "Cppcheck-GUI", &app); auto* settings = new QSettings("Cppcheck", "Cppcheck-GUI", &app);
// Set data dir.. // Set data dir..
const QStringList args = QApplication::arguments(); const QStringList args = QApplication::arguments();
@ -70,7 +70,7 @@ int main(int argc, char *argv[])
return 0; return 0;
} }
TranslationHandler* th = new TranslationHandler(&app); auto* th = new TranslationHandler(&app);
th->setLanguage(settings->value(SETTINGS_LANGUAGE, th->suggestLanguage()).toString()); th->setLanguage(settings->value(SETTINGS_LANGUAGE, th->suggestLanguage()).toString());
if (!CheckArgs(QApplication::arguments())) if (!CheckArgs(QApplication::arguments()))

View File

@ -247,7 +247,7 @@ MainWindow::MainWindow(TranslationHandler* th, QSettings* settings) :
for (int i = 0; i < mPlatforms.getCount(); i++) { for (int i = 0; i < mPlatforms.getCount(); i++) {
PlatformData platform = mPlatforms.mPlatforms[i]; PlatformData platform = mPlatforms.mPlatforms[i];
QAction *action = new QAction(this); auto *action = new QAction(this);
platform.mActMainWindow = action; platform.mActMainWindow = action;
mPlatforms.mPlatforms[i] = platform; mPlatforms.mPlatforms[i] = platform;
action->setText(platform.mTitle); action->setText(platform.mTitle);
@ -1021,7 +1021,7 @@ Settings MainWindow::getCppcheckSettings()
result.platform.loadFromFile(applicationFilePath.toStdString().c_str(), platform.toStdString()); result.platform.loadFromFile(applicationFilePath.toStdString().c_str(), platform.toStdString());
} else { } else {
for (int i = Platform::Type::Native; i <= Platform::Type::Unix64; i++) { for (int i = Platform::Type::Native; i <= Platform::Type::Unix64; i++) {
const Platform::Type p = (Platform::Type)i; const auto p = (Platform::Type)i;
if (platform == Platform::toString(p)) { if (platform == Platform::toString(p)) {
result.platform.set(p); result.platform.set(p);
break; break;
@ -1468,21 +1468,21 @@ void MainWindow::about()
msg.exec(); msg.exec();
} }
else { else {
AboutDialog *dlg = new AboutDialog(CppCheck::version(), CppCheck::extraVersion(), this); auto *dlg = new AboutDialog(CppCheck::version(), CppCheck::extraVersion(), this);
dlg->exec(); dlg->exec();
} }
} }
void MainWindow::showLicense() void MainWindow::showLicense()
{ {
FileViewDialog *dlg = new FileViewDialog(":COPYING", tr("License"), this); auto *dlg = new FileViewDialog(":COPYING", tr("License"), this);
dlg->resize(570, 400); dlg->resize(570, 400);
dlg->exec(); dlg->exec();
} }
void MainWindow::showAuthors() void MainWindow::showAuthors()
{ {
FileViewDialog *dlg = new FileViewDialog(":AUTHORS", tr("Authors"), this); auto *dlg = new FileViewDialog(":AUTHORS", tr("Authors"), this);
dlg->resize(350, 400); dlg->resize(350, 400);
dlg->exec(); dlg->exec();
} }
@ -1634,7 +1634,7 @@ void MainWindow::openHelpContents()
void MainWindow::openOnlineHelp() void MainWindow::openOnlineHelp()
{ {
HelpDialog *helpDialog = new HelpDialog; auto *helpDialog = new HelpDialog;
helpDialog->showMaximized(); helpDialog->showMaximized();
} }
@ -1923,7 +1923,7 @@ void MainWindow::enableProjectOpenActions(bool enable)
void MainWindow::openRecentProject() void MainWindow::openRecentProject()
{ {
QAction *action = qobject_cast<QAction *>(sender()); auto *action = qobject_cast<QAction *>(sender());
if (!action) if (!action)
return; return;
const QString project = action->data().toString(); const QString project = action->data().toString();
@ -2012,7 +2012,7 @@ void MainWindow::removeProjectMRU(const QString &project)
void MainWindow::selectPlatform() void MainWindow::selectPlatform()
{ {
QAction *action = qobject_cast<QAction *>(sender()); auto *action = qobject_cast<QAction *>(sender());
if (action) { if (action) {
const Platform::Type platform = (Platform::Type) action->data().toInt(); const Platform::Type platform = (Platform::Type) action->data().toInt();
mSettings->setValue(SETTINGS_CHECKED_PLATFORM, platform); mSettings->setValue(SETTINGS_CHECKED_PLATFORM, platform);

View File

@ -182,7 +182,7 @@ ProjectFileDialog::ProjectFileDialog(ProjectFile *projectFile, bool premium, QWi
libs.sort(); libs.sort();
mUI->mLibraries->clear(); mUI->mLibraries->clear();
for (const QString &lib : libs) { for (const QString &lib : libs) {
QListWidgetItem* item = new QListWidgetItem(lib, mUI->mLibraries); auto* item = new QListWidgetItem(lib, mUI->mLibraries);
item->setFlags(item->flags() | Qt::ItemIsUserCheckable); // set checkable flag item->setFlags(item->flags() | Qt::ItemIsUserCheckable); // set checkable flag
item->setCheckState(Qt::Unchecked); // AND initialize check state item->setCheckState(Qt::Unchecked); // AND initialize check state
} }
@ -604,7 +604,7 @@ void ProjectFileDialog::setProjectConfigurations(const QStringList &configs)
mUI->mListVsConfigs->clear(); mUI->mListVsConfigs->clear();
mUI->mListVsConfigs->setEnabled(!configs.isEmpty() && !mUI->mChkAllVsConfigs->isChecked()); mUI->mListVsConfigs->setEnabled(!configs.isEmpty() && !mUI->mChkAllVsConfigs->isChecked());
for (const QString &cfg : configs) { for (const QString &cfg : configs) {
QListWidgetItem* item = new QListWidgetItem(cfg, mUI->mListVsConfigs); auto* item = new QListWidgetItem(cfg, mUI->mListVsConfigs);
item->setFlags(item->flags() | Qt::ItemIsUserCheckable); // set checkable flag item->setFlags(item->flags() | Qt::ItemIsUserCheckable); // set checkable flag
item->setCheckState(Qt::Unchecked); item->setCheckState(Qt::Unchecked);
} }
@ -621,7 +621,7 @@ void ProjectFileDialog::addIncludeDir(const QString &dir)
return; return;
const QString newdir = QDir::toNativeSeparators(dir); const QString newdir = QDir::toNativeSeparators(dir);
QListWidgetItem *item = new QListWidgetItem(newdir); auto *item = new QListWidgetItem(newdir);
item->setFlags(item->flags() | Qt::ItemIsEditable); item->setFlags(item->flags() | Qt::ItemIsEditable);
mUI->mListIncludeDirs->addItem(item); mUI->mListIncludeDirs->addItem(item);
} }
@ -632,7 +632,7 @@ void ProjectFileDialog::addCheckPath(const QString &path)
return; return;
const QString newpath = QDir::toNativeSeparators(path); const QString newpath = QDir::toNativeSeparators(path);
QListWidgetItem *item = new QListWidgetItem(newpath); auto *item = new QListWidgetItem(newpath);
item->setFlags(item->flags() | Qt::ItemIsEditable); item->setFlags(item->flags() | Qt::ItemIsEditable);
mUI->mListCheckPaths->addItem(item); mUI->mListCheckPaths->addItem(item);
} }
@ -643,7 +643,7 @@ void ProjectFileDialog::addExcludePath(const QString &path)
return; return;
const QString newpath = QDir::toNativeSeparators(path); const QString newpath = QDir::toNativeSeparators(path);
QListWidgetItem *item = new QListWidgetItem(newpath); auto *item = new QListWidgetItem(newpath);
item->setFlags(item->flags() | Qt::ItemIsEditable); item->setFlags(item->flags() | Qt::ItemIsEditable);
mUI->mListExcludedPaths->addItem(item); mUI->mListExcludedPaths->addItem(item);
} }

View File

@ -110,7 +110,7 @@ void ResultsTree::initialize(QSettings *settings, ApplicationList *list, ThreadH
QStandardItem *ResultsTree::createNormalItem(const QString &name) QStandardItem *ResultsTree::createNormalItem(const QString &name)
{ {
QStandardItem *item = new QStandardItem(name); auto *item = new QStandardItem(name);
item->setData(name, Qt::ToolTipRole); item->setData(name, Qt::ToolTipRole);
item->setEditable(false); item->setEditable(false);
return item; return item;
@ -118,7 +118,7 @@ QStandardItem *ResultsTree::createNormalItem(const QString &name)
QStandardItem *ResultsTree::createCheckboxItem(bool checked) QStandardItem *ResultsTree::createCheckboxItem(bool checked)
{ {
QStandardItem *item = new QStandardItem; auto *item = new QStandardItem;
item->setCheckable(true); item->setCheckable(true);
item->setCheckState(checked ? Qt::Checked : Qt::Unchecked); item->setCheckState(checked ? Qt::Checked : Qt::Unchecked);
item->setEnabled(false); item->setEnabled(false);
@ -127,7 +127,7 @@ QStandardItem *ResultsTree::createCheckboxItem(bool checked)
QStandardItem *ResultsTree::createLineNumberItem(const QString &linenumber) QStandardItem *ResultsTree::createLineNumberItem(const QString &linenumber)
{ {
QStandardItem *item = new QStandardItem(); auto *item = new QStandardItem();
item->setData(QVariant(linenumber.toInt()), Qt::DisplayRole); item->setData(QVariant(linenumber.toInt()), Qt::DisplayRole);
item->setToolTip(linenumber); item->setToolTip(linenumber);
item->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter); item->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
@ -611,7 +611,7 @@ void ResultsTree::contextMenuEvent(QContextMenuEvent * e)
//Create a signal mapper so we don't have to store data to class //Create a signal mapper so we don't have to store data to class
//member variables //member variables
QSignalMapper *signalMapper = new QSignalMapper(this); auto *signalMapper = new QSignalMapper(this);
if (mContextItem && mApplications->getApplicationCount() > 0 && mContextItem->parent()) { if (mContextItem && mApplications->getApplicationCount() > 0 && mContextItem->parent()) {
//Create an action for the application //Create an action for the application
@ -619,7 +619,7 @@ void ResultsTree::contextMenuEvent(QContextMenuEvent * e)
if (defaultApplicationIndex < 0) if (defaultApplicationIndex < 0)
defaultApplicationIndex = 0; defaultApplicationIndex = 0;
const Application& app = mApplications->getApplication(defaultApplicationIndex); const Application& app = mApplications->getApplication(defaultApplicationIndex);
QAction *start = new QAction(app.getName(), &menu); auto *start = new QAction(app.getName(), &menu);
if (multipleSelection) if (multipleSelection)
start->setDisabled(true); start->setDisabled(true);
@ -646,11 +646,11 @@ void ResultsTree::contextMenuEvent(QContextMenuEvent * e)
} }
//Create an action for the application //Create an action for the application
QAction *recheckAction = new QAction(tr("Recheck"), &menu); auto *recheckAction = new QAction(tr("Recheck"), &menu);
QAction *copyAction = new QAction(tr("Copy"), &menu); auto *copyAction = new QAction(tr("Copy"), &menu);
QAction *hide = new QAction(tr("Hide"), &menu); auto *hide = new QAction(tr("Hide"), &menu);
QAction *hideallid = new QAction(tr("Hide all with id"), &menu); auto *hideallid = new QAction(tr("Hide all with id"), &menu);
QAction *opencontainingfolder = new QAction(tr("Open containing folder"), &menu); auto *opencontainingfolder = new QAction(tr("Open containing folder"), &menu);
if (multipleSelection) { if (multipleSelection) {
hideallid->setDisabled(true); hideallid->setDisabled(true);
@ -668,7 +668,7 @@ void ResultsTree::contextMenuEvent(QContextMenuEvent * e)
menu.addAction(hide); menu.addAction(hide);
menu.addAction(hideallid); menu.addAction(hideallid);
QAction *suppress = new QAction(tr("Suppress selected id(s)"), &menu); auto *suppress = new QAction(tr("Suppress selected id(s)"), &menu);
{ {
QVariantMap data = mContextItem->data().toMap(); QVariantMap data = mContextItem->data().toMap();
const QString messageId = data[ERRORID].toString(); const QString messageId = data[ERRORID].toString();
@ -691,7 +691,7 @@ void ResultsTree::contextMenuEvent(QContextMenuEvent * e)
menu.addSeparator(); menu.addSeparator();
QMenu *tagMenu = menu.addMenu(tr("Tag")); QMenu *tagMenu = menu.addMenu(tr("Tag"));
{ {
QAction *action = new QAction(tr("No tag"), tagMenu); auto *action = new QAction(tr("No tag"), tagMenu);
tagMenu->addAction(action); tagMenu->addAction(action);
connect(action, &QAction::triggered, [=]() { connect(action, &QAction::triggered, [=]() {
tagSelectedItems(QString()); tagSelectedItems(QString());
@ -699,7 +699,7 @@ void ResultsTree::contextMenuEvent(QContextMenuEvent * e)
} }
for (const QString& tagstr : currentProject->getTags()) { for (const QString& tagstr : currentProject->getTags()) {
QAction *action = new QAction(tagstr, tagMenu); auto *action = new QAction(tagstr, tagMenu);
tagMenu->addAction(action); tagMenu->addAction(action);
connect(action, &QAction::triggered, [=]() { connect(action, &QAction::triggered, [=]() {
tagSelectedItems(tagstr); tagSelectedItems(tagstr);

View File

@ -436,7 +436,7 @@ void ResultsView::readErrorsXml(const QString &filename)
void ResultsView::updateDetails(const QModelIndex &index) void ResultsView::updateDetails(const QModelIndex &index)
{ {
const QStandardItemModel *model = qobject_cast<const QStandardItemModel*>(mUI->mTree->model()); const auto *model = qobject_cast<const QStandardItemModel*>(mUI->mTree->model());
QStandardItem *item = model->itemFromIndex(index); QStandardItem *item = model->itemFromIndex(index);
if (!item) { if (!item) {

View File

@ -140,7 +140,7 @@ void SettingsDialog::initTranslationsList()
{ {
const QString current = mTranslator->getCurrentLanguage(); const QString current = mTranslator->getCurrentLanguage();
for (const TranslationInfo& translation : mTranslator->getTranslations()) { for (const TranslationInfo& translation : mTranslator->getTranslations()) {
QListWidgetItem *item = new QListWidgetItem; auto *item = new QListWidgetItem;
item->setText(translation.mName); item->setText(translation.mName);
item->setData(mLangCodeRole, QVariant(translation.mCode)); item->setData(mLangCodeRole, QVariant(translation.mCode));
mUI->mListLanguages->addItem(item); mUI->mListLanguages->addItem(item);

View File

@ -362,7 +362,7 @@ void StatsDialog::copyToClipboard()
const QString htmlSummary = htmlSettings + htmlPrevious + htmlStatistics; const QString htmlSummary = htmlSettings + htmlPrevious + htmlStatistics;
QMimeData *mimeData = new QMimeData(); auto *mimeData = new QMimeData();
mimeData->setText(textSummary); mimeData->setText(textSummary);
mimeData->setHtml(htmlSummary); mimeData->setHtml(htmlSummary);
clipboard->setMimeData(mimeData); clipboard->setMimeData(mimeData);
@ -384,14 +384,14 @@ void StatsDialog::setStatistics(const CheckStatistics *stats)
#ifdef QT_CHARTS_LIB #ifdef QT_CHARTS_LIB
QChartView *createChart(const QString &statsFile, const QString &tool) QChartView *createChart(const QString &statsFile, const QString &tool)
{ {
QChart *chart = new QChart; auto *chart = new QChart;
chart->addSeries(numberOfReports(statsFile, tool + "-error")); chart->addSeries(numberOfReports(statsFile, tool + "-error"));
chart->addSeries(numberOfReports(statsFile, tool + "-warning")); chart->addSeries(numberOfReports(statsFile, tool + "-warning"));
chart->addSeries(numberOfReports(statsFile, tool + "-style")); chart->addSeries(numberOfReports(statsFile, tool + "-style"));
chart->addSeries(numberOfReports(statsFile, tool + "-performance")); chart->addSeries(numberOfReports(statsFile, tool + "-performance"));
chart->addSeries(numberOfReports(statsFile, tool + "-portability")); chart->addSeries(numberOfReports(statsFile, tool + "-portability"));
QDateTimeAxis *axisX = new QDateTimeAxis; auto *axisX = new QDateTimeAxis;
axisX->setTitleText("Date"); axisX->setTitleText("Date");
chart->addAxis(axisX, Qt::AlignBottom); chart->addAxis(axisX, Qt::AlignBottom);
@ -399,7 +399,7 @@ QChartView *createChart(const QString &statsFile, const QString &tool)
s->attachAxis(axisX); s->attachAxis(axisX);
} }
QValueAxis *axisY = new QValueAxis; auto *axisY = new QValueAxis;
axisY->setLabelFormat("%i"); axisY->setLabelFormat("%i");
axisY->setTitleText("Count"); axisY->setTitleText("Count");
chart->addAxis(axisY, Qt::AlignLeft); chart->addAxis(axisY, Qt::AlignLeft);
@ -407,7 +407,7 @@ QChartView *createChart(const QString &statsFile, const QString &tool)
qreal maxY = 0; qreal maxY = 0;
for (QAbstractSeries *s : chart->series()) { for (QAbstractSeries *s : chart->series()) {
s->attachAxis(axisY); s->attachAxis(axisY);
if (const QLineSeries *ls = dynamic_cast<const QLineSeries*>(s)) { if (const auto *ls = dynamic_cast<const QLineSeries*>(s)) {
for (QPointF p : ls->points()) { for (QPointF p : ls->points()) {
if (p.y() > maxY) if (p.y() > maxY)
maxY = p.y(); maxY = p.y();
@ -419,14 +419,14 @@ QChartView *createChart(const QString &statsFile, const QString &tool)
//chart->createDefaultAxes(); //chart->createDefaultAxes();
chart->setTitle(tool); chart->setTitle(tool);
QChartView *chartView = new QChartView(chart); auto *chartView = new QChartView(chart);
chartView->setRenderHint(QPainter::Antialiasing); chartView->setRenderHint(QPainter::Antialiasing);
return chartView; return chartView;
} }
QLineSeries *numberOfReports(const QString &fileName, const QString &severity) QLineSeries *numberOfReports(const QString &fileName, const QString &severity)
{ {
QLineSeries *series = new QLineSeries(); auto *series = new QLineSeries();
series->setName(severity); series->setName(severity);
QFile f(fileName); QFile f(fileName);
if (f.open(QIODevice::ReadOnly | QIODevice::Text)) { if (f.open(QIODevice::ReadOnly | QIODevice::Text)) {

View File

@ -948,7 +948,7 @@ bool CheckBufferOverrun::isCtuUnsafePointerArith(const Settings *settings, const
/** @brief Parse current TU and extract file info */ /** @brief Parse current TU and extract file info */
Check::FileInfo *CheckBufferOverrun::getFileInfo(const Tokenizer *tokenizer, const Settings *settings) const Check::FileInfo *CheckBufferOverrun::getFileInfo(const Tokenizer *tokenizer, const Settings *settings) const
{ {
MyFileInfo *fileInfo = new MyFileInfo; auto *fileInfo = new MyFileInfo;
fileInfo->unsafeArrayIndex = CTU::getUnsafeUsage(tokenizer, settings, isCtuUnsafeArrayIndex); fileInfo->unsafeArrayIndex = CTU::getUnsafeUsage(tokenizer, settings, isCtuUnsafeArrayIndex);
fileInfo->unsafePointerArith = CTU::getUnsafeUsage(tokenizer, settings, isCtuUnsafePointerArith); fileInfo->unsafePointerArith = CTU::getUnsafeUsage(tokenizer, settings, isCtuUnsafePointerArith);
if (fileInfo->unsafeArrayIndex.empty() && fileInfo->unsafePointerArith.empty()) { if (fileInfo->unsafeArrayIndex.empty() && fileInfo->unsafePointerArith.empty()) {
@ -964,7 +964,7 @@ Check::FileInfo * CheckBufferOverrun::loadFileInfoFromXml(const tinyxml2::XMLEle
const std::string arrayIndex("array-index"); const std::string arrayIndex("array-index");
const std::string pointerArith("pointer-arith"); const std::string pointerArith("pointer-arith");
MyFileInfo *fileInfo = new MyFileInfo; auto *fileInfo = new MyFileInfo;
for (const tinyxml2::XMLElement *e = xmlElement->FirstChildElement(); e; e = e->NextSiblingElement()) { for (const tinyxml2::XMLElement *e = xmlElement->FirstChildElement(); e; e = e->NextSiblingElement()) {
if (e->Name() == arrayIndex) if (e->Name() == arrayIndex)
fileInfo->unsafeArrayIndex = CTU::loadUnsafeUsageListFromXml(e); fileInfo->unsafeArrayIndex = CTU::loadUnsafeUsageListFromXml(e);

View File

@ -3510,14 +3510,14 @@ Check::FileInfo *CheckClass::getFileInfo(const Tokenizer *tokenizer, const Setti
if (classDefinitions.empty()) if (classDefinitions.empty())
return nullptr; return nullptr;
MyFileInfo *fileInfo = new MyFileInfo; auto *fileInfo = new MyFileInfo;
fileInfo->classDefinitions.swap(classDefinitions); fileInfo->classDefinitions.swap(classDefinitions);
return fileInfo; return fileInfo;
} }
Check::FileInfo * CheckClass::loadFileInfoFromXml(const tinyxml2::XMLElement *xmlElement) const Check::FileInfo * CheckClass::loadFileInfoFromXml(const tinyxml2::XMLElement *xmlElement) const
{ {
MyFileInfo *fileInfo = new MyFileInfo; auto *fileInfo = new MyFileInfo;
for (const tinyxml2::XMLElement *e = xmlElement->FirstChildElement(); e; e = e->NextSiblingElement()) { for (const tinyxml2::XMLElement *e = xmlElement->FirstChildElement(); e; e = e->NextSiblingElement()) {
if (std::strcmp(e->Name(), "class") != 0) if (std::strcmp(e->Name(), "class") != 0)
continue; continue;

View File

@ -1285,15 +1285,15 @@ void CheckCondition::checkIncorrectLogicOperator()
// 5 => testvalue is larger than both value1 and value2 // 5 => testvalue is larger than both value1 and value2
bool result1, result2; bool result1, result2;
if (isfloat) { if (isfloat) {
const double testvalue = getvalue<double>(test, d1, d2); const auto testvalue = getvalue<double>(test, d1, d2);
result1 = checkFloatRelation(op1, testvalue, d1); result1 = checkFloatRelation(op1, testvalue, d1);
result2 = checkFloatRelation(op2, testvalue, d2); result2 = checkFloatRelation(op2, testvalue, d2);
} else if (useUnsignedInt) { } else if (useUnsignedInt) {
const MathLib::biguint testvalue = getvalue<MathLib::biguint>(test, u1, u2); const auto testvalue = getvalue<MathLib::biguint>(test, u1, u2);
result1 = checkIntRelation(op1, testvalue, u1); result1 = checkIntRelation(op1, testvalue, u1);
result2 = checkIntRelation(op2, testvalue, u2); result2 = checkIntRelation(op2, testvalue, u2);
} else { } else {
const MathLib::bigint testvalue = getvalue<MathLib::bigint>(test, i1, i2); const auto testvalue = getvalue<MathLib::bigint>(test, i1, i2);
result1 = checkIntRelation(op1, testvalue, i1); result1 = checkIntRelation(op1, testvalue, i1);
result2 = checkIntRelation(op2, testvalue, i2); result2 = checkIntRelation(op2, testvalue, i2);
} }

View File

@ -586,7 +586,7 @@ Check::FileInfo *CheckNullPointer::getFileInfo(const Tokenizer *tokenizer, const
if (unsafeUsage.empty()) if (unsafeUsage.empty())
return nullptr; return nullptr;
MyFileInfo *fileInfo = new MyFileInfo; auto *fileInfo = new MyFileInfo;
fileInfo->unsafeUsage = unsafeUsage; fileInfo->unsafeUsage = unsafeUsage;
return fileInfo; return fileInfo;
} }
@ -597,7 +597,7 @@ Check::FileInfo * CheckNullPointer::loadFileInfoFromXml(const tinyxml2::XMLEleme
if (unsafeUsage.empty()) if (unsafeUsage.empty())
return nullptr; return nullptr;
MyFileInfo *fileInfo = new MyFileInfo; auto *fileInfo = new MyFileInfo;
fileInfo->unsafeUsage = unsafeUsage; fileInfo->unsafeUsage = unsafeUsage;
return fileInfo; return fileInfo;
} }

View File

@ -1705,7 +1705,7 @@ Check::FileInfo *CheckUninitVar::getFileInfo(const Tokenizer *tokenizer, const S
if (unsafeUsage.empty()) if (unsafeUsage.empty())
return nullptr; return nullptr;
MyFileInfo *fileInfo = new MyFileInfo; auto *fileInfo = new MyFileInfo;
fileInfo->unsafeUsage = unsafeUsage; fileInfo->unsafeUsage = unsafeUsage;
return fileInfo; return fileInfo;
} }
@ -1716,7 +1716,7 @@ Check::FileInfo * CheckUninitVar::loadFileInfoFromXml(const tinyxml2::XMLElement
if (unsafeUsage.empty()) if (unsafeUsage.empty())
return nullptr; return nullptr;
MyFileInfo *fileInfo = new MyFileInfo; auto *fileInfo = new MyFileInfo;
fileInfo->unsafeUsage = unsafeUsage; fileInfo->unsafeUsage = unsafeUsage;
return fileInfo; return fileInfo;
} }

View File

@ -648,7 +648,7 @@ Scope *clangimport::AstNode::createScope(TokenList *tokenList, Scope::ScopeType
{ {
SymbolDatabase *symbolDatabase = mData->mSymbolDatabase; SymbolDatabase *symbolDatabase = mData->mSymbolDatabase;
Scope *nestedIn = const_cast<Scope *>(getNestedInScope(tokenList)); auto *nestedIn = const_cast<Scope *>(getNestedInScope(tokenList));
symbolDatabase->scopeList.emplace_back(nullptr, nullptr, nestedIn); symbolDatabase->scopeList.emplace_back(nullptr, nullptr, nestedIn);
Scope *scope = &symbolDatabase->scopeList.back(); Scope *scope = &symbolDatabase->scopeList.back();
@ -974,7 +974,7 @@ Token *clangimport::AstNode::createTokens(TokenList *tokenList)
} }
if (nodeType == EnumConstantDecl) { if (nodeType == EnumConstantDecl) {
Token *nameToken = addtoken(tokenList, getSpelling()); Token *nameToken = addtoken(tokenList, getSpelling());
Scope *scope = const_cast<Scope *>(nameToken->scope()); auto *scope = const_cast<Scope *>(nameToken->scope());
scope->enumeratorList.emplace_back(nameToken->scope()); scope->enumeratorList.emplace_back(nameToken->scope());
Enumerator *e = &scope->enumeratorList.back(); Enumerator *e = &scope->enumeratorList.back();
e->name = nameToken; e->name = nameToken;
@ -1326,7 +1326,7 @@ void clangimport::AstNode::createTokensFunctionDecl(TokenList *tokenList)
addFullScopeNameTokens(tokenList, mData->getScope(mExtTokens[2])); addFullScopeNameTokens(tokenList, mData->getScope(mExtTokens[2]));
Token *nameToken = addtoken(tokenList, getSpelling() + getTemplateParameters()); Token *nameToken = addtoken(tokenList, getSpelling() + getTemplateParameters());
Scope *nestedIn = const_cast<Scope *>(nameToken->scope()); auto *nestedIn = const_cast<Scope *>(nameToken->scope());
if (prev) { if (prev) {
const std::string addr = *(std::find(mExtTokens.cbegin(), mExtTokens.cend(), "prev") + 1); const std::string addr = *(std::find(mExtTokens.cbegin(), mExtTokens.cend(), "prev") + 1);
@ -1343,7 +1343,7 @@ void clangimport::AstNode::createTokensFunctionDecl(TokenList *tokenList)
nestedIn->functionList.back().retDef = startToken; nestedIn->functionList.back().retDef = startToken;
} }
Function * const function = const_cast<Function*>(nameToken->function()); auto * const function = const_cast<Function*>(nameToken->function());
if (!prev) { if (!prev) {
auto accessControl = mData->scopeAccessControl.find(tokenList->back()->scope()); auto accessControl = mData->scopeAccessControl.find(tokenList->back()->scope());
@ -1486,7 +1486,7 @@ Token * clangimport::AstNode::createTokensVarDecl(TokenList *tokenList)
else if (startToken->str() != "static") else if (startToken->str() != "static")
startToken = startToken->next(); startToken = startToken->next();
Token *vartok1 = addtoken(tokenList, name); Token *vartok1 = addtoken(tokenList, name);
Scope *scope = const_cast<Scope *>(tokenList->back()->scope()); auto *scope = const_cast<Scope *>(tokenList->back()->scope());
scope->varlist.emplace_back(vartok1, unquote(type), startToken, vartok1->previous(), 0, scope->defaultAccess(), recordType, scope); scope->varlist.emplace_back(vartok1, unquote(type), startToken, vartok1->previous(), 0, scope->defaultAccess(), recordType, scope);
mData->varDecl(addr, vartok1, &scope->varlist.back()); mData->varDecl(addr, vartok1, &scope->varlist.back());
if (mExtTokens.back() == "cinit" && !children.empty()) { if (mExtTokens.back() == "cinit" && !children.empty()) {
@ -1542,7 +1542,7 @@ static void setValues(const Tokenizer *tokenizer, const SymbolDatabase *symbolDa
scope.definedType->sizeOf = typeSize; scope.definedType->sizeOf = typeSize;
} }
for (Token *tok = const_cast<Token*>(tokenizer->tokens()); tok; tok = tok->next()) { for (auto *tok = const_cast<Token*>(tokenizer->tokens()); tok; tok = tok->next()) {
if (Token::simpleMatch(tok, "sizeof (")) { if (Token::simpleMatch(tok, "sizeof (")) {
ValueType vt = ValueType::parseDecl(tok->tokAt(2), *settings); ValueType vt = ValueType::parseDecl(tok->tokAt(2), *settings);
const int sz = vt.typeSize(settings->platform, true); const int sz = vt.typeSize(settings->platform, true);
@ -1568,7 +1568,7 @@ void clangimport::parseClangAstDump(Tokenizer *tokenizer, std::istream &f)
TokenList *tokenList = &tokenizer->list; TokenList *tokenList = &tokenizer->list;
tokenizer->createSymbolDatabase(); tokenizer->createSymbolDatabase();
SymbolDatabase *symbolDatabase = const_cast<SymbolDatabase *>(tokenizer->getSymbolDatabase()); auto *symbolDatabase = const_cast<SymbolDatabase *>(tokenizer->getSymbolDatabase());
symbolDatabase->scopeList.emplace_back(nullptr, nullptr, nullptr); symbolDatabase->scopeList.emplace_back(nullptr, nullptr, nullptr);
symbolDatabase->scopeList.back().type = Scope::ScopeType::eGlobal; symbolDatabase->scopeList.back().type = Scope::ScopeType::eGlobal;
symbolDatabase->scopeList.back().check = symbolDatabase; symbolDatabase->scopeList.back().check = symbolDatabase;

View File

@ -1347,8 +1347,8 @@ void CppCheck::executeRules(const std::string &tokenlist, const Tokenizer &token
} }
break; break;
} }
const unsigned int pos1 = (unsigned int)ovector[0]; const auto pos1 = (unsigned int)ovector[0];
const unsigned int pos2 = (unsigned int)ovector[1]; const auto pos2 = (unsigned int)ovector[1];
// jump to the end of the match for the next pcre_exec // jump to the end of the match for the next pcre_exec
pos = (int)pos2; pos = (int)pos2;
@ -1751,7 +1751,7 @@ bool CppCheck::analyseWholeProgram()
// Analyse the tokens // Analyse the tokens
CTU::FileInfo ctu; CTU::FileInfo ctu;
for (const Check::FileInfo *fi : mFileInfo) { for (const Check::FileInfo *fi : mFileInfo) {
const CTU::FileInfo *fi2 = dynamic_cast<const CTU::FileInfo *>(fi); const auto *fi2 = dynamic_cast<const CTU::FileInfo *>(fi);
if (fi2) { if (fi2) {
ctu.functionCalls.insert(ctu.functionCalls.end(), fi2->functionCalls.cbegin(), fi2->functionCalls.cend()); ctu.functionCalls.insert(ctu.functionCalls.end(), fi2->functionCalls.cbegin(), fi2->functionCalls.cend());
ctu.nestedCalls.insert(ctu.nestedCalls.end(), fi2->nestedCalls.cbegin(), fi2->nestedCalls.cend()); ctu.nestedCalls.insert(ctu.nestedCalls.end(), fi2->nestedCalls.cbegin(), fi2->nestedCalls.cend());

View File

@ -309,7 +309,7 @@ CTU::FileInfo *CTU::getFileInfo(const Tokenizer *tokenizer)
{ {
const SymbolDatabase * const symbolDatabase = tokenizer->getSymbolDatabase(); const SymbolDatabase * const symbolDatabase = tokenizer->getSymbolDatabase();
FileInfo *fileInfo = new FileInfo; auto *fileInfo = new FileInfo;
// Parse all functions in TU // Parse all functions in TU
for (const Scope &scope : symbolDatabase->scopeList) { for (const Scope &scope : symbolDatabase->scopeList) {
@ -513,7 +513,7 @@ static bool findPath(const std::string &callId,
if (c->callArgNr != callArgNr) if (c->callArgNr != callArgNr)
continue; continue;
const CTU::FileInfo::FunctionCall *functionCall = dynamic_cast<const CTU::FileInfo::FunctionCall *>(c); const auto *functionCall = dynamic_cast<const CTU::FileInfo::FunctionCall *>(c);
if (functionCall) { if (functionCall) {
if (!warning && functionCall->warning) if (!warning && functionCall->warning)
continue; continue;
@ -537,7 +537,7 @@ static bool findPath(const std::string &callId,
return true; return true;
} }
const CTU::FileInfo::NestedCall *nestedCall = dynamic_cast<const CTU::FileInfo::NestedCall *>(c); const auto *nestedCall = dynamic_cast<const CTU::FileInfo::NestedCall *>(c);
if (!nestedCall) if (!nestedCall)
continue; continue;
@ -570,7 +570,7 @@ std::list<ErrorMessage::FileLocation> CTU::FileInfo::getErrorPath(InvalidValueTy
if (!path[index]) if (!path[index])
continue; continue;
const CTU::FileInfo::FunctionCall *functionCall = dynamic_cast<const CTU::FileInfo::FunctionCall *>(path[index]); const auto *functionCall = dynamic_cast<const CTU::FileInfo::FunctionCall *>(path[index]);
if (functionCall) { if (functionCall) {
if (functionCallPtr) if (functionCallPtr)

View File

@ -1052,7 +1052,7 @@ void SymbolDatabase::createSymbolDatabaseSetScopePointers()
const_cast<Token *>(bodyEnd)->scope(&scope); const_cast<Token *>(bodyEnd)->scope(&scope);
for (Token* tok = const_cast<Token *>(bodyStart); tok != bodyEnd; tok = tok->next()) { for (auto* tok = const_cast<Token *>(bodyStart); tok != bodyEnd; tok = tok->next()) {
if (bodyStart != bodyEnd && tok->str() == "{") { if (bodyStart != bodyEnd && tok->str() == "{") {
bool isEndOfScope = false; bool isEndOfScope = false;
for (Scope* innerScope: scope.nestedList) { for (Scope* innerScope: scope.nestedList) {
@ -1702,7 +1702,7 @@ void SymbolDatabase::createSymbolDatabaseExprIds()
std::unordered_map<std::string, nonneg int> unknownIds; std::unordered_map<std::string, nonneg int> unknownIds;
// Assign IDs to incomplete vars which are part of an expression // Assign IDs to incomplete vars which are part of an expression
// Such variables should be assumed global // Such variables should be assumed global
for (Token* tok = const_cast<Token*>(scope->bodyStart); tok != scope->bodyEnd; tok = tok->next()) { for (auto* tok = const_cast<Token*>(scope->bodyStart); tok != scope->bodyEnd; tok = tok->next()) {
if (!tok->isIncompleteVar()) if (!tok->isIncompleteVar())
continue; continue;
if (!isExpression(tok->astParent())) if (!isExpression(tok->astParent()))
@ -1725,7 +1725,7 @@ void SymbolDatabase::createSymbolDatabaseExprIds()
// Assign IDs // Assign IDs
ExprIdMap exprIdMap; ExprIdMap exprIdMap;
std::map<std::string, nonneg int> baseIds; std::map<std::string, nonneg int> baseIds;
for (Token* tok = const_cast<Token*>(scope->bodyStart); tok != scope->bodyEnd; tok = tok->next()) { for (auto* tok = const_cast<Token*>(scope->bodyStart); tok != scope->bodyEnd; tok = tok->next()) {
if (tok->varId() > 0) { if (tok->varId() > 0) {
tok->exprId(tok->varId()); tok->exprId(tok->varId());
if (tok->astParent() && tok->astParent()->exprId() == 0) if (tok->astParent() && tok->astParent()->exprId() == 0)
@ -1794,7 +1794,7 @@ void SymbolDatabase::setArrayDimensionsUsingValueFlow()
continue; continue;
// check each array dimension // check each array dimension
for (const Dimension &const_dimension : var->dimensions()) { for (const Dimension &const_dimension : var->dimensions()) {
Dimension &dimension = const_cast<Dimension &>(const_dimension); auto &dimension = const_cast<Dimension &>(const_dimension);
if (dimension.num != 0 || !dimension.tok) if (dimension.num != 0 || !dimension.tok)
continue; continue;
@ -3383,7 +3383,7 @@ void SymbolDatabase::addClassFunction(Scope **scope, const Token **tok, const To
if (match) { if (match) {
auto range = scope1->functionMap.equal_range((*tok)->str()); auto range = scope1->functionMap.equal_range((*tok)->str());
for (std::multimap<std::string, const Function*>::const_iterator it = range.first; it != range.second; ++it) { for (std::multimap<std::string, const Function*>::const_iterator it = range.first; it != range.second; ++it) {
Function * func = const_cast<Function *>(it->second); auto * func = const_cast<Function *>(it->second);
if (!func->hasBody()) { if (!func->hasBody()) {
if (func->argsMatch(scope1, func->argDef, (*tok)->next(), path, path_length)) { if (func->argsMatch(scope1, func->argDef, (*tok)->next(), path, path_length)) {
const Token *closeParen = (*tok)->next()->link(); const Token *closeParen = (*tok)->next()->link();
@ -6502,7 +6502,7 @@ static bool isContainerYieldPointer(Library::Container::Yield yield)
void SymbolDatabase::setValueType(Token* tok, const ValueType& valuetype, SourceLocation loc) void SymbolDatabase::setValueType(Token* tok, const ValueType& valuetype, SourceLocation loc)
{ {
ValueType* valuetypePtr = new ValueType(valuetype); auto* valuetypePtr = new ValueType(valuetype);
if (mSettings.debugnormal || mSettings.debugwarnings) if (mSettings.debugnormal || mSettings.debugwarnings)
valuetypePtr->setDebugPath(tok, loc); valuetypePtr->setDebugPath(tok, loc);
tok->setValueType(valuetypePtr); tok->setValueType(valuetypePtr);
@ -6584,7 +6584,7 @@ void SymbolDatabase::setValueType(Token* tok, const ValueType& valuetype, Source
setValueType(var1Tok, vt); setValueType(var1Tok, vt);
if (var1Tok != parent->previous()) if (var1Tok != parent->previous())
setValueType(parent->previous(), vt); setValueType(parent->previous(), vt);
Variable *var = const_cast<Variable *>(parent->previous()->variable()); auto *var = const_cast<Variable *>(parent->previous()->variable());
if (var) { if (var) {
ValueType vt2_(*vt2); ValueType vt2_(*vt2);
if (vt2_.pointer == 0 && autoTok->strAt(1) == "*") if (vt2_.pointer == 0 && autoTok->strAt(1) == "*")
@ -6737,7 +6737,7 @@ void SymbolDatabase::setValueType(Token* tok, const ValueType& valuetype, Source
varvt.constness |= 1; varvt.constness |= 1;
} }
setValueType(parent->previous(), varvt); setValueType(parent->previous(), varvt);
Variable *var = const_cast<Variable *>(parent->previous()->variable()); auto *var = const_cast<Variable *>(parent->previous()->variable());
if (var) { if (var) {
var->setValueType(varvt); var->setValueType(varvt);
if (vt2->typeScope && vt2->typeScope->definedType) { if (vt2->typeScope && vt2->typeScope->definedType) {
@ -6803,7 +6803,7 @@ void SymbolDatabase::setValueType(Token* tok, const ValueType& valuetype, Source
if (isconst) if (isconst)
varvt.constness |= (1 << autovt.pointer); varvt.constness |= (1 << autovt.pointer);
setValueType(parent->previous(), varvt); setValueType(parent->previous(), varvt);
Variable * var = const_cast<Variable *>(parent->previous()->variable()); auto * var = const_cast<Variable *>(parent->previous()->variable());
if (var) { if (var) {
var->setValueType(varvt); var->setValueType(varvt);
if (templateArgType && templateArgType->classScope && templateArgType->classScope->definedType) { if (templateArgType && templateArgType->classScope && templateArgType->classScope->definedType) {

View File

@ -1376,7 +1376,7 @@ void TemplateSimplifier::simplifyTemplateAliases()
} }
if (found) { if (found) {
Token *end = const_cast<Token *>(aliasDeclaration.aliasEndToken()); auto *end = const_cast<Token *>(aliasDeclaration.aliasEndToken());
// remove declaration tokens // remove declaration tokens
if (aliasDeclaration.token()->previous()) if (aliasDeclaration.token()->previous())
@ -3227,7 +3227,7 @@ bool TemplateSimplifier::simplifyTemplateInstantiations(
// process uninstantiated templates // process uninstantiated templates
// TODO: remove the specialized check and handle all uninstantiated templates someday. // TODO: remove the specialized check and handle all uninstantiated templates someday.
if (!instantiated && specialized) { if (!instantiated && specialized) {
Token * tok2 = const_cast<Token *>(templateDeclaration.nameToken()); auto * tok2 = const_cast<Token *>(templateDeclaration.nameToken());
if (mErrorLogger && !mTokenList.getFiles().empty()) if (mErrorLogger && !mTokenList.getFiles().empty())
mErrorLogger->reportProgress(mTokenList.getFiles()[0], "TemplateSimplifier::simplifyTemplateInstantiations()", tok2->progressValue()); mErrorLogger->reportProgress(mTokenList.getFiles()[0], "TemplateSimplifier::simplifyTemplateInstantiations()", tok2->progressValue());

View File

@ -3915,7 +3915,7 @@ void Tokenizer::simplifyLabelsCaseDefault()
int indentLevel = 0; int indentLevel = 0;
for (Token *tok = list.front(); tok; tok = tok->next()) { for (Token *tok = list.front(); tok; tok = tok->next()) {
// Simplify labels in the executable scope.. // Simplify labels in the executable scope..
Token *start = const_cast<Token *>(startOfExecutableScope(tok)); auto *start = const_cast<Token *>(startOfExecutableScope(tok));
if (start) { if (start) {
tok = start; tok = start;
executablescope = true; executablescope = true;

View File

@ -5120,7 +5120,7 @@ static void valueFlowAfterMove(TokenList& tokenlist, const SymbolDatabase& symbo
start = memberInitializationTok; start = memberInitializationTok;
} }
for (Token* tok = const_cast<Token*>(start); tok != scope->bodyEnd; tok = tok->next()) { for (auto* tok = const_cast<Token*>(start); tok != scope->bodyEnd; tok = tok->next()) {
Token * varTok; Token * varTok;
if (Token::Match(tok, "%var% . reset|clear (") && tok->next()->originalName().empty()) { if (Token::Match(tok, "%var% . reset|clear (") && tok->next()->originalName().empty()) {
varTok = tok; varTok = tok;
@ -5376,7 +5376,7 @@ static std::set<nonneg int> getVarIds(const Token* tok)
static void valueFlowSymbolic(const TokenList& tokenlist, const SymbolDatabase& symboldatabase, const Settings* settings) static void valueFlowSymbolic(const TokenList& tokenlist, const SymbolDatabase& symboldatabase, const Settings* settings)
{ {
for (const Scope* scope : symboldatabase.functionScopes) { for (const Scope* scope : symboldatabase.functionScopes) {
for (Token* tok = const_cast<Token*>(scope->bodyStart); tok != scope->bodyEnd; tok = tok->next()) { for (auto* tok = const_cast<Token*>(scope->bodyStart); tok != scope->bodyEnd; tok = tok->next()) {
if (!Token::simpleMatch(tok, "=")) if (!Token::simpleMatch(tok, "="))
continue; continue;
if (tok->astParent()) if (tok->astParent())
@ -5469,7 +5469,7 @@ static ValueFlow::Value inferCondition(const std::string& op, const Token* varTo
static void valueFlowSymbolicOperators(const SymbolDatabase& symboldatabase, const Settings* settings) static void valueFlowSymbolicOperators(const SymbolDatabase& symboldatabase, const Settings* settings)
{ {
for (const Scope* scope : symboldatabase.functionScopes) { for (const Scope* scope : symboldatabase.functionScopes) {
for (Token* tok = const_cast<Token*>(scope->bodyStart); tok != scope->bodyEnd; tok = tok->next()) { for (auto* tok = const_cast<Token*>(scope->bodyStart); tok != scope->bodyEnd; tok = tok->next()) {
if (tok->hasKnownIntValue()) if (tok->hasKnownIntValue())
continue; continue;
@ -5582,7 +5582,7 @@ struct SymbolicInferModel : InferModel {
static void valueFlowSymbolicInfer(const SymbolDatabase& symboldatabase, const Settings* settings) static void valueFlowSymbolicInfer(const SymbolDatabase& symboldatabase, const Settings* settings)
{ {
for (const Scope* scope : symboldatabase.functionScopes) { for (const Scope* scope : symboldatabase.functionScopes) {
for (Token* tok = const_cast<Token*>(scope->bodyStart); tok != scope->bodyEnd; tok = tok->next()) { for (auto* tok = const_cast<Token*>(scope->bodyStart); tok != scope->bodyEnd; tok = tok->next()) {
if (!Token::Match(tok, "-|%comp%")) if (!Token::Match(tok, "-|%comp%"))
continue; continue;
if (tok->hasKnownIntValue()) if (tok->hasKnownIntValue())
@ -5930,7 +5930,7 @@ static void valueFlowAfterAssign(TokenList &tokenlist,
if (skippedFunctions.count(scope)) if (skippedFunctions.count(scope))
continue; continue;
std::unordered_map<nonneg int, std::unordered_set<nonneg int>> backAssigns; std::unordered_map<nonneg int, std::unordered_set<nonneg int>> backAssigns;
for (Token* tok = const_cast<Token*>(scope->bodyStart); tok != scope->bodyEnd; tok = tok->next()) { for (auto* tok = const_cast<Token*>(scope->bodyStart); tok != scope->bodyEnd; tok = tok->next()) {
// Assignment // Assignment
bool isInit = false; bool isInit = false;
if (tok->str() != "=" && !(isInit = isVariableInit(tok))) if (tok->str() != "=" && !(isInit = isVariableInit(tok)))
@ -6063,7 +6063,7 @@ static void valueFlowAfterSwap(TokenList& tokenlist,
const Settings* settings) const Settings* settings)
{ {
for (const Scope* scope : symboldatabase.functionScopes) { for (const Scope* scope : symboldatabase.functionScopes) {
for (Token* tok = const_cast<Token*>(scope->bodyStart); tok != scope->bodyEnd; tok = tok->next()) { for (auto* tok = const_cast<Token*>(scope->bodyStart); tok != scope->bodyEnd; tok = tok->next()) {
if (!Token::simpleMatch(tok, "swap (")) if (!Token::simpleMatch(tok, "swap ("))
continue; continue;
if (!Token::simpleMatch(tok->next()->astOperand2(), ",")) if (!Token::simpleMatch(tok->next()->astOperand2(), ","))
@ -6238,7 +6238,7 @@ struct ConditionHandler {
for (const Scope *scope : symboldatabase.functionScopes) { for (const Scope *scope : symboldatabase.functionScopes) {
if (skippedFunctions.count(scope)) if (skippedFunctions.count(scope))
continue; continue;
for (Token *tok = const_cast<Token *>(scope->bodyStart); tok != scope->bodyEnd; tok = tok->next()) { for (auto *tok = const_cast<Token *>(scope->bodyStart); tok != scope->bodyEnd; tok = tok->next()) {
if (Token::Match(tok, "if|while|for (")) if (Token::Match(tok, "if|while|for ("))
continue; continue;
if (Token::Match(tok, ":|;|,")) if (Token::Match(tok, ":|;|,"))
@ -6727,7 +6727,7 @@ struct ConditionHandler {
return; return;
if (r.action.isModified()) if (r.action.isModified())
return; return;
Token* start = const_cast<Token*>(loopScope->bodyEnd); auto* start = const_cast<Token*>(loopScope->bodyEnd);
if (Token::simpleMatch(start, "} while (")) { if (Token::simpleMatch(start, "} while (")) {
start = start->tokAt(2); start = start->tokAt(2);
forward(start, start->link(), cond.vartok, values, tokenlist, settings); forward(start, start->link(), cond.vartok, values, tokenlist, settings);
@ -7180,8 +7180,8 @@ static void valueFlowForLoop(TokenList &tokenlist, const SymbolDatabase& symbold
if (scope.type != Scope::eFor) if (scope.type != Scope::eFor)
continue; continue;
Token* tok = const_cast<Token*>(scope.classDef); auto* tok = const_cast<Token*>(scope.classDef);
Token* const bodyStart = const_cast<Token*>(scope.bodyStart); auto* const bodyStart = const_cast<Token*>(scope.bodyStart);
if (!Token::simpleMatch(tok->next()->astOperand2(), ";") || if (!Token::simpleMatch(tok->next()->astOperand2(), ";") ||
!Token::simpleMatch(tok->next()->astOperand2()->astOperand2(), ";")) !Token::simpleMatch(tok->next()->astOperand2()->astOperand2(), ";"))
@ -8779,7 +8779,7 @@ static void valueFlowContainerSize(TokenList& tokenlist,
// after assignment // after assignment
for (const Scope *functionScope : symboldatabase.functionScopes) { for (const Scope *functionScope : symboldatabase.functionScopes) {
for (Token* tok = const_cast<Token*>(functionScope->bodyStart); tok != functionScope->bodyEnd; tok = tok->next()) { for (auto* tok = const_cast<Token*>(functionScope->bodyStart); tok != functionScope->bodyEnd; tok = tok->next()) {
if (Token::Match(tok, "%name%|;|{|} %var% = %str% ;")) { if (Token::Match(tok, "%name%|;|{|} %var% = %str% ;")) {
Token* containerTok = tok->next(); Token* containerTok = tok->next();
if (containerTok->exprId() == 0) if (containerTok->exprId() == 0)

View File

@ -114,7 +114,7 @@ private:
} }
void nextprevious() const { void nextprevious() const {
Token *token = new Token(); auto *token = new Token();
token->str("1"); token->str("1");
token->insertToken("2"); token->insertToken("2");
token->next()->insertToken("3"); token->next()->insertToken("3");