Skip to content

Commit ebb877a

Browse files
authored
gui/platforms.h: renamed Platform to PlatformData / Platform: removed unnecessary cppcheck namespace (danmar#5545)
1 parent 579938a commit ebb877a

39 files changed

Lines changed: 583 additions & 590 deletions

cli/cmdlineparser.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -618,9 +618,9 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
618618
// these are loaded via external files and thus have Settings::PlatformFile set instead.
619619
// override the type so they behave like the regular platforms.
620620
if (platform == "unix32-unsigned")
621-
mSettings.platform.type = cppcheck::Platform::Type::Unix32;
621+
mSettings.platform.type = Platform::Type::Unix32;
622622
else if (platform == "unix64-unsigned")
623-
mSettings.platform.type = cppcheck::Platform::Type::Unix64;
623+
mSettings.platform.type = Platform::Type::Unix64;
624624
}
625625

626626
// Write results in results.plist

gui/mainwindow.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ MainWindow::MainWindow(TranslationHandler* th, QSettings* settings) :
243243
mUI->mActionEditProjectFile->setEnabled(mProjectFile != nullptr);
244244

245245
for (int i = 0; i < mPlatforms.getCount(); i++) {
246-
Platform platform = mPlatforms.mPlatforms[i];
246+
PlatformData platform = mPlatforms.mPlatforms[i];
247247
QAction *action = new QAction(this);
248248
platform.mActMainWindow = action;
249249
mPlatforms.mPlatforms[i] = platform;
@@ -274,11 +274,11 @@ MainWindow::MainWindow(TranslationHandler* th, QSettings* settings) :
274274
// For other platforms default to unspecified/default which means the
275275
// platform Cppcheck GUI was compiled on.
276276
#if defined(_WIN32)
277-
const cppcheck::Platform::Type defaultPlatform = cppcheck::Platform::Type::Win32W;
277+
const Platform::Type defaultPlatform = Platform::Type::Win32W;
278278
#else
279-
const cppcheck::Platform::Type defaultPlatform = cppcheck::Platform::Type::Unspecified;
279+
const Platform::Type defaultPlatform = Platform::Type::Unspecified;
280280
#endif
281-
Platform &platform = mPlatforms.get((cppcheck::Platform::Type)mSettings->value(SETTINGS_CHECKED_PLATFORM, defaultPlatform).toInt());
281+
PlatformData &platform = mPlatforms.get((Platform::Type)mSettings->value(SETTINGS_CHECKED_PLATFORM, defaultPlatform).toInt());
282282
platform.mActMainWindow->setChecked(true);
283283

284284
mNetworkAccessManager = new QNetworkAccessManager(this);
@@ -494,7 +494,7 @@ void MainWindow::doAnalyzeProject(ImportProject p, const bool checkLibrary, cons
494494
p.ignorePaths(v);
495495

496496
if (!mProjectFile->getAnalyzeAllVsConfigs()) {
497-
const cppcheck::Platform::Type platform = (cppcheck::Platform::Type) mSettings->value(SETTINGS_CHECKED_PLATFORM, 0).toInt();
497+
const Platform::Type platform = (Platform::Type) mSettings->value(SETTINGS_CHECKED_PLATFORM, 0).toInt();
498498
std::vector<std::string> configurations;
499499
const QStringList configs = mProjectFile->getVsConfigurations();
500500
std::transform(configs.cbegin(), configs.cend(), std::back_inserter(configurations), [](const QString& e) {
@@ -967,9 +967,9 @@ Settings MainWindow::getCppcheckSettings()
967967
const QString applicationFilePath = QCoreApplication::applicationFilePath();
968968
result.platform.loadFromFile(applicationFilePath.toStdString().c_str(), platform.toStdString());
969969
} else {
970-
for (int i = cppcheck::Platform::Type::Native; i <= cppcheck::Platform::Type::Unix64; i++) {
971-
const cppcheck::Platform::Type p = (cppcheck::Platform::Type)i;
972-
if (platform == cppcheck::Platform::toString(p)) {
970+
for (int i = Platform::Type::Native; i <= Platform::Type::Unix64; i++) {
971+
const Platform::Type p = (Platform::Type)i;
972+
if (platform == Platform::toString(p)) {
973973
result.platform.set(p);
974974
break;
975975
}
@@ -1060,8 +1060,8 @@ Settings MainWindow::getCppcheckSettings()
10601060
result.jobs = mSettings->value(SETTINGS_CHECK_THREADS, 1).toInt();
10611061
result.inlineSuppressions = mSettings->value(SETTINGS_INLINE_SUPPRESSIONS, false).toBool();
10621062
result.certainty.setEnabled(Certainty::inconclusive, mSettings->value(SETTINGS_INCONCLUSIVE_ERRORS, false).toBool());
1063-
if (!mProjectFile || result.platform.type == cppcheck::Platform::Type::Unspecified)
1064-
result.platform.set((cppcheck::Platform::Type) mSettings->value(SETTINGS_CHECKED_PLATFORM, 0).toInt());
1063+
if (!mProjectFile || result.platform.type == Platform::Type::Unspecified)
1064+
result.platform.set((Platform::Type) mSettings->value(SETTINGS_CHECKED_PLATFORM, 0).toInt());
10651065
result.standards.setCPP(mSettings->value(SETTINGS_STD_CPP, QString()).toString().toStdString());
10661066
result.standards.setC(mSettings->value(SETTINGS_STD_C, QString()).toString().toStdString());
10671067
result.enforcedLang = (Settings::Language)mSettings->value(SETTINGS_ENFORCED_LANGUAGE, 0).toInt();
@@ -1987,7 +1987,7 @@ void MainWindow::selectPlatform()
19871987
{
19881988
QAction *action = qobject_cast<QAction *>(sender());
19891989
if (action) {
1990-
const cppcheck::Platform::Type platform = (cppcheck::Platform::Type) action->data().toInt();
1990+
const Platform::Type platform = (Platform::Type) action->data().toInt();
19911991
mSettings->setValue(SETTINGS_CHECKED_PLATFORM, platform);
19921992
}
19931993
}

gui/platforms.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ Platforms::Platforms(QObject *parent)
2424
init();
2525
}
2626

27-
void Platforms::add(const QString &title, cppcheck::Platform::Type platform)
27+
void Platforms::add(const QString &title, Platform::Type platform)
2828
{
29-
Platform plat;
29+
PlatformData plat;
3030
plat.mTitle = title;
3131
plat.mType = platform;
3232
plat.mActMainWindow = nullptr;
@@ -35,22 +35,22 @@ void Platforms::add(const QString &title, cppcheck::Platform::Type platform)
3535

3636
void Platforms::init()
3737
{
38-
add(tr("Native"), cppcheck::Platform::Type::Native);
39-
add(tr("Unix 32-bit"), cppcheck::Platform::Type::Unix32);
40-
add(tr("Unix 64-bit"), cppcheck::Platform::Type::Unix64);
41-
add(tr("Windows 32-bit ANSI"), cppcheck::Platform::Type::Win32A);
42-
add(tr("Windows 32-bit Unicode"), cppcheck::Platform::Type::Win32W);
43-
add(tr("Windows 64-bit"), cppcheck::Platform::Type::Win64);
38+
add(tr("Native"), Platform::Type::Native);
39+
add(tr("Unix 32-bit"), Platform::Type::Unix32);
40+
add(tr("Unix 64-bit"), Platform::Type::Unix64);
41+
add(tr("Windows 32-bit ANSI"), Platform::Type::Win32A);
42+
add(tr("Windows 32-bit Unicode"), Platform::Type::Win32W);
43+
add(tr("Windows 64-bit"), Platform::Type::Win64);
4444
}
4545

4646
int Platforms::getCount() const
4747
{
4848
return mPlatforms.count();
4949
}
5050

51-
Platform& Platforms::get(cppcheck::Platform::Type platform)
51+
PlatformData& Platforms::get(Platform::Type platform)
5252
{
53-
QList<Platform>::iterator iter = mPlatforms.begin();
53+
QList<PlatformData>::iterator iter = mPlatforms.begin();
5454
while (iter != mPlatforms.end()) {
5555
if ((*iter).mType == platform) {
5656
return *iter;

gui/platforms.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ class QAction;
3333
/**
3434
* @brief Checked platform GUI-data.
3535
*/
36-
struct Platform {
36+
struct PlatformData {
3737
QString mTitle; /**< Text visible in the GUI. */
38-
cppcheck::Platform::Type mType; /**< Type in the core. */
38+
Platform::Type mType; /**< Type in the core. */
3939
QAction *mActMainWindow; /**< Pointer to main window action item. */
4040
};
4141

@@ -47,12 +47,12 @@ class Platforms : public QObject {
4747

4848
public:
4949
explicit Platforms(QObject *parent = nullptr);
50-
void add(const QString &title, cppcheck::Platform::Type platform);
50+
void add(const QString &title, Platform::Type platform);
5151
int getCount() const;
5252
void init();
53-
Platform& get(cppcheck::Platform::Type platform);
53+
PlatformData& get(Platform::Type platform);
5454

55-
QList<Platform> mPlatforms;
55+
QList<PlatformData> mPlatforms;
5656
};
5757

5858
/// @}

gui/projectfiledialog.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,13 @@ static QStringList getPaths(const QListWidget *list)
7777
}
7878

7979
/** Platforms shown in the platform combobox */
80-
static const cppcheck::Platform::Type builtinPlatforms[] = {
81-
cppcheck::Platform::Type::Native,
82-
cppcheck::Platform::Type::Win32A,
83-
cppcheck::Platform::Type::Win32W,
84-
cppcheck::Platform::Type::Win64,
85-
cppcheck::Platform::Type::Unix32,
86-
cppcheck::Platform::Type::Unix64
80+
static const Platform::Type builtinPlatforms[] = {
81+
Platform::Type::Native,
82+
Platform::Type::Win32A,
83+
Platform::Type::Win32W,
84+
Platform::Type::Win64,
85+
Platform::Type::Unix32,
86+
Platform::Type::Unix64
8787
};
8888

8989
static const int numberOfBuiltinPlatforms = sizeof(builtinPlatforms) / sizeof(builtinPlatforms[0]);
@@ -190,7 +190,7 @@ ProjectFileDialog::ProjectFileDialog(ProjectFile *projectFile, bool premium, QWi
190190

191191
// Platforms..
192192
Platforms platforms;
193-
for (const cppcheck::Platform::Type builtinPlatform : builtinPlatforms)
193+
for (const Platform::Type builtinPlatform : builtinPlatforms)
194194
mUI->mComboBoxPlatform->addItem(platforms.get(builtinPlatform).mTitle);
195195
QStringList platformFiles;
196196
for (QString sp : searchPaths) {
@@ -203,7 +203,7 @@ ProjectFileDialog::ProjectFileDialog(ProjectFile *projectFile, bool premium, QWi
203203
for (const QFileInfo& item : dir.entryInfoList()) {
204204
const QString platformFile = item.fileName();
205205

206-
cppcheck::Platform plat2;
206+
Platform plat2;
207207
if (!plat2.loadFromFile(applicationFilePath.toStdString().c_str(), platformFile.toStdString()))
208208
continue;
209209

@@ -336,8 +336,8 @@ void ProjectFileDialog::loadFromProjectFile(const ProjectFile *projectFile)
336336
} else {
337337
int i;
338338
for (i = 0; i < numberOfBuiltinPlatforms; ++i) {
339-
const cppcheck::Platform::Type p = builtinPlatforms[i];
340-
if (platform == cppcheck::Platform::toString(p))
339+
const Platform::Type p = builtinPlatforms[i];
340+
if (platform == Platform::toString(p))
341341
break;
342342
}
343343
if (i < numberOfBuiltinPlatforms)
@@ -445,7 +445,7 @@ void ProjectFileDialog::saveToProjectFile(ProjectFile *projectFile) const
445445
else {
446446
const int i = mUI->mComboBoxPlatform->currentIndex();
447447
if (i>=0 && i < numberOfBuiltinPlatforms)
448-
projectFile->setPlatform(cppcheck::Platform::toString(builtinPlatforms[i]));
448+
projectFile->setPlatform(Platform::toString(builtinPlatforms[i]));
449449
else
450450
projectFile->setPlatform(QString());
451451
}

gui/test/projectfile/testprojectfile.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const char Settings::SafeChecks::XmlExternalFunctions[] = "external-functions";
3737
const char Settings::SafeChecks::XmlInternalFunctions[] = "internal-functions";
3838
const char Settings::SafeChecks::XmlExternalVariables[] = "external-variables";
3939
Settings::Settings() : maxCtuDepth(10) {}
40-
cppcheck::Platform::Platform() = default;
40+
Platform::Platform() = default;
4141
bool ImportProject::sourceFileExists(const std::string & /*file*/) {
4242
return true;
4343
}

lib/checkcondition.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1912,8 +1912,8 @@ void CheckCondition::checkCompareValueOutOfTypeRange()
19121912
if (!mSettings->severity.isEnabled(Severity::style))
19131913
return;
19141914

1915-
if (mSettings->platform.type == cppcheck::Platform::Type::Native ||
1916-
mSettings->platform.type == cppcheck::Platform::Type::Unspecified)
1915+
if (mSettings->platform.type == Platform::Type::Native ||
1916+
mSettings->platform.type == Platform::Type::Unspecified)
19171917
return;
19181918

19191919
logChecker("CheckCondition::checkCompareValueOutOfTypeRange"); // style,platform

lib/checktype.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ static const CWE CWE190(190U); // Integer Overflow or Wraparound
6161
void CheckType::checkTooBigBitwiseShift()
6262
{
6363
// unknown sizeof(int) => can't run this checker
64-
if (mSettings->platform.type == cppcheck::Platform::Type::Unspecified)
64+
if (mSettings->platform.type == Platform::Type::Unspecified)
6565
return;
6666

6767
logChecker("CheckType::checkTooBigBitwiseShift"); // platform
@@ -167,7 +167,7 @@ void CheckType::tooBigSignedBitwiseShiftError(const Token *tok, int lhsbits, con
167167
void CheckType::checkIntegerOverflow()
168168
{
169169
// unknown sizeof(int) => can't run this checker
170-
if (mSettings->platform.type == cppcheck::Platform::Type::Unspecified || mSettings->platform.int_bit >= MathLib::bigint_bits)
170+
if (mSettings->platform.type == Platform::Type::Unspecified || mSettings->platform.int_bit >= MathLib::bigint_bits)
171171
return;
172172

173173
logChecker("CheckType::checkIntegerOverflow"); // platform
@@ -476,7 +476,7 @@ void CheckType::checkFloatToIntegerOverflow(const Token *tok, const ValueType *v
476476
floatToIntegerOverflowError(tok, f);
477477
else if ((-f.floatValue) > std::exp2(mSettings->platform.long_long_bit - 1))
478478
floatToIntegerOverflowError(tok, f);
479-
else if (mSettings->platform.type != cppcheck::Platform::Type::Unspecified) {
479+
else if (mSettings->platform.type != Platform::Type::Unspecified) {
480480
int bits = 0;
481481
if (vtint->type == ValueType::Type::CHAR)
482482
bits = mSettings->platform.char_bit;

lib/cppcheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ unsigned int CppCheck::check(const ImportProject::FileSettings &fs)
561561
temp.mSettings.standards.setCPP(fs.standard);
562562
else if (!fs.standard.empty())
563563
temp.mSettings.standards.setC(fs.standard);
564-
if (fs.platformType != cppcheck::Platform::Type::Unspecified)
564+
if (fs.platformType != Platform::Type::Unspecified)
565565
temp.mSettings.platform.set(fs.platformType);
566566
if (mSettings.clang) {
567567
temp.mSettings.includePaths.insert(temp.mSettings.includePaths.end(), fs.systemIncludePaths.cbegin(), fs.systemIncludePaths.cend());

lib/importproject.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -756,9 +756,9 @@ bool ImportProject::importVcxproj(const std::string &filename, std::map<std::str
756756
fs.useMfc = useOfMfc;
757757
fs.defines = "_WIN32=1";
758758
if (p.platform == ProjectConfiguration::Win32)
759-
fs.platformType = cppcheck::Platform::Type::Win32W;
759+
fs.platformType = Platform::Type::Win32W;
760760
else if (p.platform == ProjectConfiguration::x64) {
761-
fs.platformType = cppcheck::Platform::Type::Win64;
761+
fs.platformType = Platform::Type::Win64;
762762
fs.defines += ";_WIN64=1";
763763
}
764764
std::string additionalIncludePaths;
@@ -1264,7 +1264,7 @@ bool ImportProject::importCppcheckGuiProject(std::istream &istr, Settings *setti
12641264
return true;
12651265
}
12661266

1267-
void ImportProject::selectOneVsConfig(cppcheck::Platform::Type platform)
1267+
void ImportProject::selectOneVsConfig(Platform::Type platform)
12681268
{
12691269
std::set<std::string> filenames;
12701270
for (std::list<ImportProject::FileSettings>::iterator it = fileSettings.begin(); it != fileSettings.end();) {
@@ -1276,9 +1276,9 @@ void ImportProject::selectOneVsConfig(cppcheck::Platform::Type platform)
12761276
bool remove = false;
12771277
if (!startsWith(fs.cfg,"Debug"))
12781278
remove = true;
1279-
if (platform == cppcheck::Platform::Type::Win64 && fs.platformType != platform)
1279+
if (platform == Platform::Type::Win64 && fs.platformType != platform)
12801280
remove = true;
1281-
else if ((platform == cppcheck::Platform::Type::Win32A || platform == cppcheck::Platform::Type::Win32W) && fs.platformType == cppcheck::Platform::Type::Win64)
1281+
else if ((platform == Platform::Type::Win32A || platform == Platform::Type::Win32W) && fs.platformType == Platform::Type::Win64)
12821282
remove = true;
12831283
else if (filenames.find(fs.filename) != filenames.end())
12841284
remove = true;
@@ -1291,7 +1291,7 @@ void ImportProject::selectOneVsConfig(cppcheck::Platform::Type platform)
12911291
}
12921292
}
12931293

1294-
void ImportProject::selectVsConfigurations(cppcheck::Platform::Type platform, const std::vector<std::string> &configurations)
1294+
void ImportProject::selectVsConfigurations(Platform::Type platform, const std::vector<std::string> &configurations)
12951295
{
12961296
for (std::list<ImportProject::FileSettings>::iterator it = fileSettings.begin(); it != fileSettings.end();) {
12971297
if (it->cfg.empty()) {
@@ -1303,9 +1303,9 @@ void ImportProject::selectVsConfigurations(cppcheck::Platform::Type platform, co
13031303
bool remove = false;
13041304
if (std::find(configurations.begin(), configurations.end(), config) == configurations.end())
13051305
remove = true;
1306-
if (platform == cppcheck::Platform::Type::Win64 && fs.platformType != platform)
1306+
if (platform == Platform::Type::Win64 && fs.platformType != platform)
13071307
remove = true;
1308-
else if ((platform == cppcheck::Platform::Type::Win32A || platform == cppcheck::Platform::Type::Win32W) && fs.platformType == cppcheck::Platform::Type::Win64)
1308+
else if ((platform == Platform::Type::Win32A || platform == Platform::Type::Win32W) && fs.platformType == Platform::Type::Win64)
13091309
remove = true;
13101310
if (remove) {
13111311
it = fileSettings.erase(it);

0 commit comments

Comments
 (0)