From ebb877adcc08714a8892bef4f8b510b0da38e45a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Fri, 13 Oct 2023 16:02:04 +0200 Subject: [PATCH] gui/platforms.h: renamed `Platform` to `PlatformData` / Platform: removed unnecessary `cppcheck` namespace (#5545) --- cli/cmdlineparser.cpp | 4 +- gui/mainwindow.cpp | 22 +- gui/platforms.cpp | 20 +- gui/platforms.h | 10 +- gui/projectfiledialog.cpp | 24 +- gui/test/projectfile/testprojectfile.cpp | 2 +- lib/checkcondition.cpp | 4 +- lib/checktype.cpp | 6 +- lib/cppcheck.cpp | 2 +- lib/importproject.cpp | 16 +- lib/importproject.h | 6 +- lib/platform.cpp | 10 +- lib/platform.h | 272 +++++++++++------------ lib/settings.h | 2 +- lib/symboldatabase.cpp | 10 +- lib/symboldatabase.h | 7 +- lib/tokenize.cpp | 2 +- lib/valueflow.cpp | 18 +- test/fixture.cpp | 4 +- test/fixture.h | 4 +- test/testcharvar.cpp | 2 +- test/testclangimport.cpp | 2 +- test/testcmdlineparser.cpp | 40 ++-- test/testcondition.cpp | 2 +- test/testio.cpp | 258 ++++++++++----------- test/testother.cpp | 10 +- test/testplatform.cpp | 56 ++--- test/testpreprocessor.cpp | 4 +- test/testsimplifytemplate.cpp | 2 +- test/testsimplifytokens.cpp | 26 +-- test/testsimplifytypedef.cpp | 46 ++-- test/testsimplifyusing.cpp | 22 +- test/testsymboldatabase.cpp | 8 +- test/testtokenize.cpp | 214 +++++++++--------- test/testtype.cpp | 14 +- test/testunusedfunctions.cpp | 12 +- test/testunusedprivfunc.cpp | 6 +- test/testvalueflow.cpp | 2 +- test/testvarid.cpp | 2 +- 39 files changed, 583 insertions(+), 590 deletions(-) diff --git a/cli/cmdlineparser.cpp b/cli/cmdlineparser.cpp index 1e18eac06c5..70da8b86a89 100644 --- a/cli/cmdlineparser.cpp +++ b/cli/cmdlineparser.cpp @@ -618,9 +618,9 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[]) // these are loaded via external files and thus have Settings::PlatformFile set instead. // override the type so they behave like the regular platforms. if (platform == "unix32-unsigned") - mSettings.platform.type = cppcheck::Platform::Type::Unix32; + mSettings.platform.type = Platform::Type::Unix32; else if (platform == "unix64-unsigned") - mSettings.platform.type = cppcheck::Platform::Type::Unix64; + mSettings.platform.type = Platform::Type::Unix64; } // Write results in results.plist diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 4b027104e82..84efbf66294 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -243,7 +243,7 @@ MainWindow::MainWindow(TranslationHandler* th, QSettings* settings) : mUI->mActionEditProjectFile->setEnabled(mProjectFile != nullptr); for (int i = 0; i < mPlatforms.getCount(); i++) { - Platform platform = mPlatforms.mPlatforms[i]; + PlatformData platform = mPlatforms.mPlatforms[i]; QAction *action = new QAction(this); platform.mActMainWindow = action; mPlatforms.mPlatforms[i] = platform; @@ -274,11 +274,11 @@ MainWindow::MainWindow(TranslationHandler* th, QSettings* settings) : // For other platforms default to unspecified/default which means the // platform Cppcheck GUI was compiled on. #if defined(_WIN32) - const cppcheck::Platform::Type defaultPlatform = cppcheck::Platform::Type::Win32W; + const Platform::Type defaultPlatform = Platform::Type::Win32W; #else - const cppcheck::Platform::Type defaultPlatform = cppcheck::Platform::Type::Unspecified; + const Platform::Type defaultPlatform = Platform::Type::Unspecified; #endif - Platform &platform = mPlatforms.get((cppcheck::Platform::Type)mSettings->value(SETTINGS_CHECKED_PLATFORM, defaultPlatform).toInt()); + PlatformData &platform = mPlatforms.get((Platform::Type)mSettings->value(SETTINGS_CHECKED_PLATFORM, defaultPlatform).toInt()); platform.mActMainWindow->setChecked(true); mNetworkAccessManager = new QNetworkAccessManager(this); @@ -494,7 +494,7 @@ void MainWindow::doAnalyzeProject(ImportProject p, const bool checkLibrary, cons p.ignorePaths(v); if (!mProjectFile->getAnalyzeAllVsConfigs()) { - const cppcheck::Platform::Type platform = (cppcheck::Platform::Type) mSettings->value(SETTINGS_CHECKED_PLATFORM, 0).toInt(); + const Platform::Type platform = (Platform::Type) mSettings->value(SETTINGS_CHECKED_PLATFORM, 0).toInt(); std::vector configurations; const QStringList configs = mProjectFile->getVsConfigurations(); std::transform(configs.cbegin(), configs.cend(), std::back_inserter(configurations), [](const QString& e) { @@ -967,9 +967,9 @@ Settings MainWindow::getCppcheckSettings() const QString applicationFilePath = QCoreApplication::applicationFilePath(); result.platform.loadFromFile(applicationFilePath.toStdString().c_str(), platform.toStdString()); } else { - for (int i = cppcheck::Platform::Type::Native; i <= cppcheck::Platform::Type::Unix64; i++) { - const cppcheck::Platform::Type p = (cppcheck::Platform::Type)i; - if (platform == cppcheck::Platform::toString(p)) { + for (int i = Platform::Type::Native; i <= Platform::Type::Unix64; i++) { + const Platform::Type p = (Platform::Type)i; + if (platform == Platform::toString(p)) { result.platform.set(p); break; } @@ -1060,8 +1060,8 @@ Settings MainWindow::getCppcheckSettings() result.jobs = mSettings->value(SETTINGS_CHECK_THREADS, 1).toInt(); result.inlineSuppressions = mSettings->value(SETTINGS_INLINE_SUPPRESSIONS, false).toBool(); result.certainty.setEnabled(Certainty::inconclusive, mSettings->value(SETTINGS_INCONCLUSIVE_ERRORS, false).toBool()); - if (!mProjectFile || result.platform.type == cppcheck::Platform::Type::Unspecified) - result.platform.set((cppcheck::Platform::Type) mSettings->value(SETTINGS_CHECKED_PLATFORM, 0).toInt()); + if (!mProjectFile || result.platform.type == Platform::Type::Unspecified) + result.platform.set((Platform::Type) mSettings->value(SETTINGS_CHECKED_PLATFORM, 0).toInt()); result.standards.setCPP(mSettings->value(SETTINGS_STD_CPP, QString()).toString().toStdString()); result.standards.setC(mSettings->value(SETTINGS_STD_C, QString()).toString().toStdString()); result.enforcedLang = (Settings::Language)mSettings->value(SETTINGS_ENFORCED_LANGUAGE, 0).toInt(); @@ -1987,7 +1987,7 @@ void MainWindow::selectPlatform() { QAction *action = qobject_cast(sender()); if (action) { - const cppcheck::Platform::Type platform = (cppcheck::Platform::Type) action->data().toInt(); + const Platform::Type platform = (Platform::Type) action->data().toInt(); mSettings->setValue(SETTINGS_CHECKED_PLATFORM, platform); } } diff --git a/gui/platforms.cpp b/gui/platforms.cpp index ce5f1c62ddb..bfaba2ffd33 100644 --- a/gui/platforms.cpp +++ b/gui/platforms.cpp @@ -24,9 +24,9 @@ Platforms::Platforms(QObject *parent) init(); } -void Platforms::add(const QString &title, cppcheck::Platform::Type platform) +void Platforms::add(const QString &title, Platform::Type platform) { - Platform plat; + PlatformData plat; plat.mTitle = title; plat.mType = platform; plat.mActMainWindow = nullptr; @@ -35,12 +35,12 @@ void Platforms::add(const QString &title, cppcheck::Platform::Type platform) void Platforms::init() { - add(tr("Native"), cppcheck::Platform::Type::Native); - add(tr("Unix 32-bit"), cppcheck::Platform::Type::Unix32); - add(tr("Unix 64-bit"), cppcheck::Platform::Type::Unix64); - add(tr("Windows 32-bit ANSI"), cppcheck::Platform::Type::Win32A); - add(tr("Windows 32-bit Unicode"), cppcheck::Platform::Type::Win32W); - add(tr("Windows 64-bit"), cppcheck::Platform::Type::Win64); + add(tr("Native"), Platform::Type::Native); + add(tr("Unix 32-bit"), Platform::Type::Unix32); + add(tr("Unix 64-bit"), Platform::Type::Unix64); + add(tr("Windows 32-bit ANSI"), Platform::Type::Win32A); + add(tr("Windows 32-bit Unicode"), Platform::Type::Win32W); + add(tr("Windows 64-bit"), Platform::Type::Win64); } int Platforms::getCount() const @@ -48,9 +48,9 @@ int Platforms::getCount() const return mPlatforms.count(); } -Platform& Platforms::get(cppcheck::Platform::Type platform) +PlatformData& Platforms::get(Platform::Type platform) { - QList::iterator iter = mPlatforms.begin(); + QList::iterator iter = mPlatforms.begin(); while (iter != mPlatforms.end()) { if ((*iter).mType == platform) { return *iter; diff --git a/gui/platforms.h b/gui/platforms.h index 0693615f5fa..dc941efbc75 100644 --- a/gui/platforms.h +++ b/gui/platforms.h @@ -33,9 +33,9 @@ class QAction; /** * @brief Checked platform GUI-data. */ -struct Platform { +struct PlatformData { QString mTitle; /**< Text visible in the GUI. */ - cppcheck::Platform::Type mType; /**< Type in the core. */ + Platform::Type mType; /**< Type in the core. */ QAction *mActMainWindow; /**< Pointer to main window action item. */ }; @@ -47,12 +47,12 @@ class Platforms : public QObject { public: explicit Platforms(QObject *parent = nullptr); - void add(const QString &title, cppcheck::Platform::Type platform); + void add(const QString &title, Platform::Type platform); int getCount() const; void init(); - Platform& get(cppcheck::Platform::Type platform); + PlatformData& get(Platform::Type platform); - QList mPlatforms; + QList mPlatforms; }; /// @} diff --git a/gui/projectfiledialog.cpp b/gui/projectfiledialog.cpp index 3fc029a955b..5835c4728cc 100644 --- a/gui/projectfiledialog.cpp +++ b/gui/projectfiledialog.cpp @@ -77,13 +77,13 @@ static QStringList getPaths(const QListWidget *list) } /** Platforms shown in the platform combobox */ -static const cppcheck::Platform::Type builtinPlatforms[] = { - cppcheck::Platform::Type::Native, - cppcheck::Platform::Type::Win32A, - cppcheck::Platform::Type::Win32W, - cppcheck::Platform::Type::Win64, - cppcheck::Platform::Type::Unix32, - cppcheck::Platform::Type::Unix64 +static const Platform::Type builtinPlatforms[] = { + Platform::Type::Native, + Platform::Type::Win32A, + Platform::Type::Win32W, + Platform::Type::Win64, + Platform::Type::Unix32, + Platform::Type::Unix64 }; static const int numberOfBuiltinPlatforms = sizeof(builtinPlatforms) / sizeof(builtinPlatforms[0]); @@ -190,7 +190,7 @@ ProjectFileDialog::ProjectFileDialog(ProjectFile *projectFile, bool premium, QWi // Platforms.. Platforms platforms; - for (const cppcheck::Platform::Type builtinPlatform : builtinPlatforms) + for (const Platform::Type builtinPlatform : builtinPlatforms) mUI->mComboBoxPlatform->addItem(platforms.get(builtinPlatform).mTitle); QStringList platformFiles; for (QString sp : searchPaths) { @@ -203,7 +203,7 @@ ProjectFileDialog::ProjectFileDialog(ProjectFile *projectFile, bool premium, QWi for (const QFileInfo& item : dir.entryInfoList()) { const QString platformFile = item.fileName(); - cppcheck::Platform plat2; + Platform plat2; if (!plat2.loadFromFile(applicationFilePath.toStdString().c_str(), platformFile.toStdString())) continue; @@ -336,8 +336,8 @@ void ProjectFileDialog::loadFromProjectFile(const ProjectFile *projectFile) } else { int i; for (i = 0; i < numberOfBuiltinPlatforms; ++i) { - const cppcheck::Platform::Type p = builtinPlatforms[i]; - if (platform == cppcheck::Platform::toString(p)) + const Platform::Type p = builtinPlatforms[i]; + if (platform == Platform::toString(p)) break; } if (i < numberOfBuiltinPlatforms) @@ -445,7 +445,7 @@ void ProjectFileDialog::saveToProjectFile(ProjectFile *projectFile) const else { const int i = mUI->mComboBoxPlatform->currentIndex(); if (i>=0 && i < numberOfBuiltinPlatforms) - projectFile->setPlatform(cppcheck::Platform::toString(builtinPlatforms[i])); + projectFile->setPlatform(Platform::toString(builtinPlatforms[i])); else projectFile->setPlatform(QString()); } diff --git a/gui/test/projectfile/testprojectfile.cpp b/gui/test/projectfile/testprojectfile.cpp index 37624e986d3..6e5e73b0f06 100644 --- a/gui/test/projectfile/testprojectfile.cpp +++ b/gui/test/projectfile/testprojectfile.cpp @@ -37,7 +37,7 @@ const char Settings::SafeChecks::XmlExternalFunctions[] = "external-functions"; const char Settings::SafeChecks::XmlInternalFunctions[] = "internal-functions"; const char Settings::SafeChecks::XmlExternalVariables[] = "external-variables"; Settings::Settings() : maxCtuDepth(10) {} -cppcheck::Platform::Platform() = default; +Platform::Platform() = default; bool ImportProject::sourceFileExists(const std::string & /*file*/) { return true; } diff --git a/lib/checkcondition.cpp b/lib/checkcondition.cpp index 9fa5f797b45..4866b499cd4 100644 --- a/lib/checkcondition.cpp +++ b/lib/checkcondition.cpp @@ -1912,8 +1912,8 @@ void CheckCondition::checkCompareValueOutOfTypeRange() if (!mSettings->severity.isEnabled(Severity::style)) return; - if (mSettings->platform.type == cppcheck::Platform::Type::Native || - mSettings->platform.type == cppcheck::Platform::Type::Unspecified) + if (mSettings->platform.type == Platform::Type::Native || + mSettings->platform.type == Platform::Type::Unspecified) return; logChecker("CheckCondition::checkCompareValueOutOfTypeRange"); // style,platform diff --git a/lib/checktype.cpp b/lib/checktype.cpp index 20338d19dc8..d1c95d20e2c 100644 --- a/lib/checktype.cpp +++ b/lib/checktype.cpp @@ -61,7 +61,7 @@ static const CWE CWE190(190U); // Integer Overflow or Wraparound void CheckType::checkTooBigBitwiseShift() { // unknown sizeof(int) => can't run this checker - if (mSettings->platform.type == cppcheck::Platform::Type::Unspecified) + if (mSettings->platform.type == Platform::Type::Unspecified) return; logChecker("CheckType::checkTooBigBitwiseShift"); // platform @@ -167,7 +167,7 @@ void CheckType::tooBigSignedBitwiseShiftError(const Token *tok, int lhsbits, con void CheckType::checkIntegerOverflow() { // unknown sizeof(int) => can't run this checker - if (mSettings->platform.type == cppcheck::Platform::Type::Unspecified || mSettings->platform.int_bit >= MathLib::bigint_bits) + if (mSettings->platform.type == Platform::Type::Unspecified || mSettings->platform.int_bit >= MathLib::bigint_bits) return; logChecker("CheckType::checkIntegerOverflow"); // platform @@ -476,7 +476,7 @@ void CheckType::checkFloatToIntegerOverflow(const Token *tok, const ValueType *v floatToIntegerOverflowError(tok, f); else if ((-f.floatValue) > std::exp2(mSettings->platform.long_long_bit - 1)) floatToIntegerOverflowError(tok, f); - else if (mSettings->platform.type != cppcheck::Platform::Type::Unspecified) { + else if (mSettings->platform.type != Platform::Type::Unspecified) { int bits = 0; if (vtint->type == ValueType::Type::CHAR) bits = mSettings->platform.char_bit; diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index 5a9e5fe2200..126d9d93682 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -561,7 +561,7 @@ unsigned int CppCheck::check(const ImportProject::FileSettings &fs) temp.mSettings.standards.setCPP(fs.standard); else if (!fs.standard.empty()) temp.mSettings.standards.setC(fs.standard); - if (fs.platformType != cppcheck::Platform::Type::Unspecified) + if (fs.platformType != Platform::Type::Unspecified) temp.mSettings.platform.set(fs.platformType); if (mSettings.clang) { temp.mSettings.includePaths.insert(temp.mSettings.includePaths.end(), fs.systemIncludePaths.cbegin(), fs.systemIncludePaths.cend()); diff --git a/lib/importproject.cpp b/lib/importproject.cpp index 9c4d2783e96..9d42daa325c 100644 --- a/lib/importproject.cpp +++ b/lib/importproject.cpp @@ -756,9 +756,9 @@ bool ImportProject::importVcxproj(const std::string &filename, std::map filenames; for (std::list::iterator it = fileSettings.begin(); it != fileSettings.end();) { @@ -1276,9 +1276,9 @@ void ImportProject::selectOneVsConfig(cppcheck::Platform::Type platform) bool remove = false; if (!startsWith(fs.cfg,"Debug")) remove = true; - if (platform == cppcheck::Platform::Type::Win64 && fs.platformType != platform) + if (platform == Platform::Type::Win64 && fs.platformType != platform) remove = true; - else if ((platform == cppcheck::Platform::Type::Win32A || platform == cppcheck::Platform::Type::Win32W) && fs.platformType == cppcheck::Platform::Type::Win64) + else if ((platform == Platform::Type::Win32A || platform == Platform::Type::Win32W) && fs.platformType == Platform::Type::Win64) remove = true; else if (filenames.find(fs.filename) != filenames.end()) remove = true; @@ -1291,7 +1291,7 @@ void ImportProject::selectOneVsConfig(cppcheck::Platform::Type platform) } } -void ImportProject::selectVsConfigurations(cppcheck::Platform::Type platform, const std::vector &configurations) +void ImportProject::selectVsConfigurations(Platform::Type platform, const std::vector &configurations) { for (std::list::iterator it = fileSettings.begin(); it != fileSettings.end();) { if (it->cfg.empty()) { @@ -1303,9 +1303,9 @@ void ImportProject::selectVsConfigurations(cppcheck::Platform::Type platform, co bool remove = false; if (std::find(configurations.begin(), configurations.end(), config) == configurations.end()) remove = true; - if (platform == cppcheck::Platform::Type::Win64 && fs.platformType != platform) + if (platform == Platform::Type::Win64 && fs.platformType != platform) remove = true; - else if ((platform == cppcheck::Platform::Type::Win32A || platform == cppcheck::Platform::Type::Win32W) && fs.platformType == cppcheck::Platform::Type::Win64) + else if ((platform == Platform::Type::Win32A || platform == Platform::Type::Win32W) && fs.platformType == Platform::Type::Win64) remove = true; if (remove) { it = fileSettings.erase(it); diff --git a/lib/importproject.h b/lib/importproject.h index 46abbda9dda..916dd9167ab 100644 --- a/lib/importproject.h +++ b/lib/importproject.h @@ -74,7 +74,7 @@ class CPPCHECKLIB ImportProject { std::list includePaths; std::list systemIncludePaths; std::string standard; - cppcheck::Platform::Type platformType = cppcheck::Platform::Type::Unspecified; + Platform::Type platformType = Platform::Type::Unspecified; bool msc{}; bool useMfc{}; @@ -90,8 +90,8 @@ class CPPCHECKLIB ImportProject { ImportProject(const ImportProject&) = default; ImportProject& operator=(const ImportProject&) = default; - void selectOneVsConfig(cppcheck::Platform::Type platform); - void selectVsConfigurations(cppcheck::Platform::Type platform, const std::vector &configurations); + void selectOneVsConfig(Platform::Type platform); + void selectVsConfigurations(Platform::Type platform, const std::vector &configurations); std::list getVSConfigs(); diff --git a/lib/platform.cpp b/lib/platform.cpp index f2a04ba80a3..09983751a7e 100644 --- a/lib/platform.cpp +++ b/lib/platform.cpp @@ -27,13 +27,13 @@ #include -cppcheck::Platform::Platform() +Platform::Platform() { set(Type::Native); } -bool cppcheck::Platform::set(Type t) +bool Platform::set(Type t) { switch (t) { case Type::Unspecified: // unknown type sizes (sizes etc are set but are not known) @@ -150,7 +150,7 @@ bool cppcheck::Platform::set(Type t) return false; } -bool cppcheck::Platform::set(const std::string& platformstr, std::string& errstr, const std::vector& paths, bool verbose) +bool Platform::set(const std::string& platformstr, std::string& errstr, const std::vector& paths, bool verbose) { if (platformstr == "win32A") set(Type::Win32A); @@ -189,7 +189,7 @@ bool cppcheck::Platform::set(const std::string& platformstr, std::string& errstr return true; } -bool cppcheck::Platform::loadFromFile(const char exename[], const std::string &filename, bool verbose) +bool Platform::loadFromFile(const char exename[], const std::string &filename, bool verbose) { // TODO: only append .xml if missing // TODO: use native separators @@ -240,7 +240,7 @@ static unsigned int xmlTextAsUInt(const tinyxml2::XMLElement* node, bool& error) return retval; } -bool cppcheck::Platform::loadFromXmlDocument(const tinyxml2::XMLDocument *doc) +bool Platform::loadFromXmlDocument(const tinyxml2::XMLDocument *doc) { const tinyxml2::XMLElement * const rootnode = doc->FirstChildElement(); diff --git a/lib/platform.h b/lib/platform.h index 6d9833240d2..323be855a89 100644 --- a/lib/platform.h +++ b/lib/platform.h @@ -35,154 +35,150 @@ namespace tinyxml2 { class XMLDocument; } -namespace cppcheck { - - /** - * @brief Platform settings - */ - class CPPCHECKLIB Platform { - private: - static long long min_value(int bit) { - if (bit >= 64) - return LLONG_MIN; - return -(1LL << (bit-1)); - } - - static long long max_value(int bit) { - if (bit >= 64) - return (~0ULL) >> 1; - return (1LL << (bit-1)) - 1LL; - } - public: - Platform(); - - bool isIntValue(long long value) const { - return value >= min_value(int_bit) && value <= max_value(int_bit); - } +/** + * @brief Platform settings + */ +class CPPCHECKLIB Platform { +private: + static long long min_value(int bit) { + if (bit >= 64) + return LLONG_MIN; + return -(1LL << (bit-1)); + } + + static long long max_value(int bit) { + if (bit >= 64) + return (~0ULL) >> 1; + return (1LL << (bit-1)) - 1LL; + } +public: + Platform(); + + bool isIntValue(long long value) const { + return value >= min_value(int_bit) && value <= max_value(int_bit); + } + + bool isIntValue(unsigned long long value) const { + const unsigned long long intMax = max_value(int_bit); + return value <= intMax; + } + + bool isLongValue(long long value) const { + return value >= min_value(long_bit) && value <= max_value(long_bit); + } + + bool isLongValue(unsigned long long value) const { + const unsigned long long longMax = max_value(long_bit); + return value <= longMax; + } + + bool isLongLongValue(unsigned long long value) const { + const unsigned long long longLongMax = max_value(long_long_bit); + return value <= longLongMax; + } + + nonneg int char_bit; /// bits in char + nonneg int short_bit; /// bits in short + nonneg int int_bit; /// bits in int + nonneg int long_bit; /// bits in long + nonneg int long_long_bit; /// bits in long long + + /** size of standard types */ + nonneg int sizeof_bool; + nonneg int sizeof_short; + nonneg int sizeof_int; + nonneg int sizeof_long; + nonneg int sizeof_long_long; + nonneg int sizeof_float; + nonneg int sizeof_double; + nonneg int sizeof_long_double; + nonneg int sizeof_wchar_t; + nonneg int sizeof_size_t; + nonneg int sizeof_pointer; + + char defaultSign; // unsigned:'u', signed:'s', unknown:'\0' + + enum Type { + Unspecified, // No platform specified + Native, // whatever system this code was compiled on + Win32A, + Win32W, + Win64, + Unix32, + Unix64, + File + }; - bool isIntValue(unsigned long long value) const { - const unsigned long long intMax = max_value(int_bit); - return value <= intMax; - } + /** platform type */ + Type type; - bool isLongValue(long long value) const { - return value >= min_value(long_bit) && value <= max_value(long_bit); - } + /** set the platform type for predefined platforms - deprecated use set(const std::string&, std::string&) instead */ + bool set(Type t); - bool isLongValue(unsigned long long value) const { - const unsigned long long longMax = max_value(long_bit); - return value <= longMax; - } + /** set the platform type */ + bool set(const std::string& platformstr, std::string& errstr, const std::vector& paths = {}, bool verbose = false); - bool isLongLongValue(unsigned long long value) const { - const unsigned long long longLongMax = max_value(long_long_bit); - return value <= longLongMax; - } - - nonneg int char_bit; /// bits in char - nonneg int short_bit; /// bits in short - nonneg int int_bit; /// bits in int - nonneg int long_bit; /// bits in long - nonneg int long_long_bit; /// bits in long long - - /** size of standard types */ - nonneg int sizeof_bool; - nonneg int sizeof_short; - nonneg int sizeof_int; - nonneg int sizeof_long; - nonneg int sizeof_long_long; - nonneg int sizeof_float; - nonneg int sizeof_double; - nonneg int sizeof_long_double; - nonneg int sizeof_wchar_t; - nonneg int sizeof_size_t; - nonneg int sizeof_pointer; - - char defaultSign; // unsigned:'u', signed:'s', unknown:'\0' - - enum Type { - Unspecified, // No platform specified - Native, // whatever system this code was compiled on - Win32A, - Win32W, - Win64, - Unix32, - Unix64, - File - }; - - /** platform type */ - Type type; - - /** set the platform type for predefined platforms - deprecated use set(const std::string&, std::string&) instead */ - bool set(Type t); - - /** set the platform type */ - bool set(const std::string& platformstr, std::string& errstr, const std::vector& paths = {}, bool verbose = false); - - /** - * load platform file - * @param exename application path - * @param filename platform filename - * @param verbose log verbose information about the lookup - * @return returns true if file was loaded successfully - */ - bool loadFromFile(const char exename[], const std::string &filename, bool verbose = false); - - /** load platform from xml document, primarily for testing */ - bool loadFromXmlDocument(const tinyxml2::XMLDocument *doc); - - /** - * @brief Returns true if platform type is Windows - * @return true if Windows platform type. - */ - bool isWindows() const { - return type == Type::Win32A || - type == Type::Win32W || - type == Type::Win64; - } - - const char *toString() const { - return toString(type); - } + /** + * load platform file + * @param exename application path + * @param filename platform filename + * @param verbose log verbose information about the lookup + * @return returns true if file was loaded successfully + */ + bool loadFromFile(const char exename[], const std::string &filename, bool verbose = false); - static const char *toString(Type pt) { - switch (pt) { - case Type::Unspecified: - return "unspecified"; - case Type::Native: - return "native"; - case Type::Win32A: - return "win32A"; - case Type::Win32W: - return "win32W"; - case Type::Win64: - return "win64"; - case Type::Unix32: - return "unix32"; - case Type::Unix64: - return "unix64"; - case Type::File: - return "platformFile"; - default: - throw std::runtime_error("unknown platform"); - } - } + /** load platform from xml document, primarily for testing */ + bool loadFromXmlDocument(const tinyxml2::XMLDocument *doc); - long long unsignedCharMax() const { - return max_value(char_bit + 1); + /** + * @brief Returns true if platform type is Windows + * @return true if Windows platform type. + */ + bool isWindows() const { + return type == Type::Win32A || + type == Type::Win32W || + type == Type::Win64; + } + + const char *toString() const { + return toString(type); + } + + static const char *toString(Type pt) { + switch (pt) { + case Type::Unspecified: + return "unspecified"; + case Type::Native: + return "native"; + case Type::Win32A: + return "win32A"; + case Type::Win32W: + return "win32W"; + case Type::Win64: + return "win64"; + case Type::Unix32: + return "unix32"; + case Type::Unix64: + return "unix64"; + case Type::File: + return "platformFile"; + default: + throw std::runtime_error("unknown platform"); } + } - long long signedCharMax() const { - return max_value(char_bit); - } + long long unsignedCharMax() const { + return max_value(char_bit + 1); + } - long long signedCharMin() const { - return min_value(char_bit); - } - }; + long long signedCharMax() const { + return max_value(char_bit); + } -} + long long signedCharMin() const { + return min_value(char_bit); + } +}; /// @} //--------------------------------------------------------------------------- diff --git a/lib/settings.h b/lib/settings.h index f5bf7a5d374..bac34334733 100644 --- a/lib/settings.h +++ b/lib/settings.h @@ -245,7 +245,7 @@ class CPPCHECKLIB WARN_UNUSED Settings { /** @brief write results (--output-file=<file>) */ std::string outputFile; - cppcheck::Platform platform; + Platform platform; /** @brief Experimental: --performance-valueflow-max-time=T */ int performanceValueFlowMaxTime = -1; diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 100603dd35d..6dbedeafc61 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -6313,7 +6313,7 @@ void SymbolDatabase::setValueType(Token* tok, const Variable& var, SourceLocatio } } -static ValueType::Type getEnumType(const Scope* scope, const cppcheck::Platform& platform); +static ValueType::Type getEnumType(const Scope* scope, const Platform& platform); void SymbolDatabase::setValueType(Token* tok, const Enumerator& enumerator, SourceLocation loc) { @@ -6830,7 +6830,7 @@ void SymbolDatabase::setValueType(Token* tok, const ValueType& valuetype, Source } } -static ValueType::Type getEnumType(const Scope* scope, const cppcheck::Platform& platform) // TODO: also determine sign? +static ValueType::Type getEnumType(const Scope* scope, const Platform& platform) // TODO: also determine sign? { ValueType::Type type = ValueType::Type::INT; for (const Token* tok = scope->bodyStart; tok && tok != scope->bodyEnd; tok = tok->next()) { @@ -7151,7 +7151,7 @@ void SymbolDatabase::setValueTypeInTokenList(bool reportDebugWarnings, Token *to pos -= 2; } else break; } - if (mSettings.platform.type != cppcheck::Platform::Type::Unspecified) { + if (mSettings.platform.type != Platform::Type::Unspecified) { if (type <= ValueType::Type::INT && mSettings.platform.isIntValue(unsignedSuffix ? (value >> 1) : value)) type = ValueType::Type::INT; else if (type <= ValueType::Type::INT && !MathLib::isDec(tokStr) && mSettings.platform.isIntValue(value >> 2)) { @@ -7242,7 +7242,7 @@ void SymbolDatabase::setValueTypeInTokenList(bool reportDebugWarnings, Token *to else if (Token::simpleMatch(tok->previous(), "sizeof (")) { ValueType valuetype(ValueType::Sign::UNSIGNED, ValueType::Type::LONG, 0U); - if (mSettings.platform.type == cppcheck::Platform::Type::Win64) + if (mSettings.platform.type == Platform::Type::Win64) valuetype.type = ValueType::Type::LONGLONG; valuetype.originalTypeName = "size_t"; @@ -7779,7 +7779,7 @@ bool ValueType::isConst(nonneg int indirect) const return constness & (1 << (pointer - indirect)); } -MathLib::bigint ValueType::typeSize(const cppcheck::Platform &platform, bool p) const +MathLib::bigint ValueType::typeSize(const Platform &platform, bool p) const { if (p && pointer) return platform.sizeof_pointer; diff --git a/lib/symboldatabase.h b/lib/symboldatabase.h index a7dd7d9c7b3..8afe804e801 100644 --- a/lib/symboldatabase.h +++ b/lib/symboldatabase.h @@ -40,10 +40,7 @@ #include #include -namespace cppcheck { - class Platform; -} - +class Platform; class ErrorLogger; class Function; class Scope; @@ -1298,7 +1295,7 @@ class CPPCHECKLIB ValueType { bool isConst(nonneg int indirect = 0) const; - MathLib::bigint typeSize(const cppcheck::Platform &platform, bool p=false) const; + MathLib::bigint typeSize(const Platform &platform, bool p=false) const; /// Check if type is the same ignoring const and references bool isTypeEqual(const ValueType* that) const; diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 4766f4add9f..895af19e63d 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -9766,7 +9766,7 @@ void Tokenizer::simplifyMicrosoftStringFunctions() if (!mSettings->platform.isWindows()) return; - const bool ansi = mSettings->platform.type == cppcheck::Platform::Type::Win32A; + const bool ansi = mSettings->platform.type == Platform::Type::Win32A; for (Token *tok = list.front(); tok; tok = tok->next()) { if (tok->strAt(1) != "(") continue; diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index ecd1bed5c3e..22bf164d4ef 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -1128,7 +1128,7 @@ size_t ValueFlow::getSizeOf(const ValueType &vt, const Settings *settings) } -static bool getMinMaxValues(const ValueType* vt, const cppcheck::Platform& platform, MathLib::bigint& minValue, MathLib::bigint& maxValue); +static bool getMinMaxValues(const ValueType* vt, const Platform& platform, MathLib::bigint& minValue, MathLib::bigint& maxValue); // Handle various constants.. static Token * valueFlowSetConstantValue(Token *tok, const Settings *settings, bool cpp) @@ -1193,7 +1193,7 @@ static Token * valueFlowSetConstantValue(Token *tok, const Settings *settings, b const size_t sz = vt ? ValueFlow::getSizeOf(*vt, settings) : 0; if (sz > 0) { ValueFlow::Value value(sz); - if (!tok2->isTemplateArg() && settings->platform.type != cppcheck::Platform::Type::Unspecified) + if (!tok2->isTemplateArg() && settings->platform.type != Platform::Type::Unspecified) value.setKnown(); setTokenValue(tok->next(), std::move(value), settings); } @@ -1206,7 +1206,7 @@ static Token * valueFlowSetConstantValue(Token *tok, const Settings *settings, b tok->linkAt(1); } ValueFlow::Value value(size); - if (!tok2->isTemplateArg() && settings->platform.type != cppcheck::Platform::Type::Unspecified) + if (!tok2->isTemplateArg() && settings->platform.type != Platform::Type::Unspecified) value.setKnown(); setTokenValue(tok, value, settings); setTokenValue(tok->next(), std::move(value), settings); @@ -1219,7 +1219,7 @@ static Token * valueFlowSetConstantValue(Token *tok, const Settings *settings, b } } ValueFlow::Value value(size); - if (!tok2->isTemplateArg() && settings->platform.type != cppcheck::Platform::Type::Unspecified) + if (!tok2->isTemplateArg() && settings->platform.type != Platform::Type::Unspecified) value.setKnown(); setTokenValue(tok, value, settings); setTokenValue(tok->next(), std::move(value), settings); @@ -1236,7 +1236,7 @@ static Token * valueFlowSetConstantValue(Token *tok, const Settings *settings, b sz1->variable()->dimensionKnown(0) && Token::Match(sz2->astOperand2(), "*|[") && Token::Match(sz2->astOperand2()->astOperand1(), "%varid%", varid1)) { ValueFlow::Value value(sz1->variable()->dimension(0)); - if (!tok2->isTemplateArg() && settings->platform.type != cppcheck::Platform::Type::Unspecified) + if (!tok2->isTemplateArg() && settings->platform.type != Platform::Type::Unspecified) value.setKnown(); setTokenValue(tok->tokAt(4), std::move(value), settings); } @@ -1265,7 +1265,7 @@ static Token * valueFlowSetConstantValue(Token *tok, const Settings *settings, b } if (size && count > 0) { ValueFlow::Value value(count * size); - if (settings->platform.type != cppcheck::Platform::Type::Unspecified) + if (settings->platform.type != Platform::Type::Unspecified) value.setKnown(); setTokenValue(tok, value, settings); setTokenValue(tok->next(), std::move(value), settings); @@ -1320,7 +1320,7 @@ static Token * valueFlowSetConstantValue(Token *tok, const Settings *settings, b } if (sz > 0) { ValueFlow::Value value(sz); - if (!tok2->isTemplateArg() && settings->platform.type != cppcheck::Platform::Type::Unspecified) + if (!tok2->isTemplateArg() && settings->platform.type != Platform::Type::Unspecified) value.setKnown(); setTokenValue(tok->next(), std::move(value), settings); } @@ -8947,7 +8947,7 @@ static void valueFlowDynamicBufferSize(const TokenList& tokenlist, const SymbolD } } -static bool getMinMaxValues(const ValueType *vt, const cppcheck::Platform &platform, MathLib::bigint &minValue, MathLib::bigint &maxValue) +static bool getMinMaxValues(const ValueType *vt, const Platform &platform, MathLib::bigint &minValue, MathLib::bigint &maxValue) { if (!vt || !vt->isIntegral() || vt->pointer) return false; @@ -9024,7 +9024,7 @@ static void valueFlowSafeFunctions(TokenList& tokenlist, const SymbolDatabase& s continue; const bool safe = function->isSafe(settings); - const bool all = safe && settings->platform.type != cppcheck::Platform::Type::Unspecified; + const bool all = safe && settings->platform.type != Platform::Type::Unspecified; for (const Variable &arg : function->argumentList) { if (!arg.nameToken() || !arg.valueType()) diff --git a/test/fixture.cpp b/test/fixture.cpp index 8b714dd5308..ab9679802f2 100644 --- a/test/fixture.cpp +++ b/test/fixture.cpp @@ -421,9 +421,9 @@ TestFixture::SettingsBuilder& TestFixture::SettingsBuilder::library(const char l return *this; } -TestFixture::SettingsBuilder& TestFixture::SettingsBuilder::platform(cppcheck::Platform::Type type) +TestFixture::SettingsBuilder& TestFixture::SettingsBuilder::platform(Platform::Type type) { - const std::string platformStr = cppcheck::Platform::toString(type); + const std::string platformStr = Platform::toString(type); if (REDUNDANT_CHECK && settings.platform.type == type) throw std::runtime_error("redundant setting: platform (" + platformStr + ")"); diff --git a/test/fixture.h b/test/fixture.h index 039a4a2c097..07710b49afa 100644 --- a/test/fixture.h +++ b/test/fixture.h @@ -200,7 +200,7 @@ class TestFixture : public ErrorLogger { SettingsBuilder& libraryxml(const char xmldata[], std::size_t len); - SettingsBuilder& platform(cppcheck::Platform::Type type); + SettingsBuilder& platform(Platform::Type type); SettingsBuilder& checkConfiguration() { if (REDUNDANT_CHECK && settings.checkConfiguration) @@ -274,6 +274,6 @@ extern std::ostringstream output; #define LOAD_LIB_2_EXE( LIB, NAME, EXE ) do { if (((LIB).load((EXE), NAME).errorcode != Library::ErrorCode::OK)) throw std::runtime_error("library '" + std::string(NAME) + "' not found"); } while (false) #define LOAD_LIB_2( LIB, NAME ) LOAD_LIB_2_EXE(LIB, NAME, exename.c_str()) -#define PLATFORM( P, T ) do { std::string errstr; assertEquals(__FILE__, __LINE__, true, P.set(cppcheck::Platform::toString(T), errstr, {exename}), errstr); } while (false) +#define PLATFORM( P, T ) do { std::string errstr; assertEquals(__FILE__, __LINE__, true, P.set(Platform::toString(T), errstr, {exename}), errstr); } while (false) #endif // fixtureH diff --git a/test/testcharvar.cpp b/test/testcharvar.cpp index 5dc35ce55f4..1936720e561 100644 --- a/test/testcharvar.cpp +++ b/test/testcharvar.cpp @@ -31,7 +31,7 @@ class TestCharVar : public TestFixture { TestCharVar() : TestFixture("TestCharVar") {} private: - const Settings settings = settingsBuilder().severity(Severity::warning).severity(Severity::portability).platform(cppcheck::Platform::Type::Unspecified).build(); + const Settings settings = settingsBuilder().severity(Severity::warning).severity(Severity::portability).platform(Platform::Type::Unspecified).build(); void run() override { TEST_CASE(array_index_1); diff --git a/test/testclangimport.cpp b/test/testclangimport.cpp index 38873c756dd..f92b8ef98f4 100644 --- a/test/testclangimport.cpp +++ b/test/testclangimport.cpp @@ -1050,7 +1050,7 @@ class TestClangImport : public TestFixture { #define GET_SYMBOL_DB(AST) \ - const Settings settings = settingsBuilder().clang().platform(cppcheck::Platform::Type::Unix64).build(); \ + const Settings settings = settingsBuilder().clang().platform(Platform::Type::Unix64).build(); \ Tokenizer tokenizer(&settings, this); \ { \ std::istringstream istr(AST); \ diff --git a/test/testcmdlineparser.cpp b/test/testcmdlineparser.cpp index 59fd3776fe2..3bc957d7cf3 100644 --- a/test/testcmdlineparser.cpp +++ b/test/testcmdlineparser.cpp @@ -1190,90 +1190,90 @@ class TestCmdlineParser : public TestFixture { void platformWin64() { REDIRECT; const char * const argv[] = {"cppcheck", "--platform=win64", "file.cpp"}; - ASSERT(settings->platform.set(cppcheck::Platform::Type::Unspecified)); + ASSERT(settings->platform.set(Platform::Type::Unspecified)); ASSERT(parser->parseFromArgs(3, argv)); - ASSERT_EQUALS(cppcheck::Platform::Type::Win64, settings->platform.type); + ASSERT_EQUALS(Platform::Type::Win64, settings->platform.type); ASSERT_EQUALS("", logger->str()); } void platformWin32A() { REDIRECT; const char * const argv[] = {"cppcheck", "--platform=win32A", "file.cpp"}; - ASSERT(settings->platform.set(cppcheck::Platform::Type::Unspecified)); + ASSERT(settings->platform.set(Platform::Type::Unspecified)); ASSERT(parser->parseFromArgs(3, argv)); - ASSERT_EQUALS(cppcheck::Platform::Type::Win32A, settings->platform.type); + ASSERT_EQUALS(Platform::Type::Win32A, settings->platform.type); ASSERT_EQUALS("", logger->str()); } void platformWin32W() { REDIRECT; const char * const argv[] = {"cppcheck", "--platform=win32W", "file.cpp"}; - ASSERT(settings->platform.set(cppcheck::Platform::Type::Unspecified)); + ASSERT(settings->platform.set(Platform::Type::Unspecified)); ASSERT(parser->parseFromArgs(3, argv)); - ASSERT_EQUALS(cppcheck::Platform::Type::Win32W, settings->platform.type); + ASSERT_EQUALS(Platform::Type::Win32W, settings->platform.type); ASSERT_EQUALS("", logger->str()); } void platformUnix32() { REDIRECT; const char * const argv[] = {"cppcheck", "--platform=unix32", "file.cpp"}; - ASSERT(settings->platform.set(cppcheck::Platform::Type::Unspecified)); + ASSERT(settings->platform.set(Platform::Type::Unspecified)); ASSERT(parser->parseFromArgs(3, argv)); - ASSERT_EQUALS(cppcheck::Platform::Type::Unix32, settings->platform.type); + ASSERT_EQUALS(Platform::Type::Unix32, settings->platform.type); ASSERT_EQUALS("", logger->str()); } void platformUnix32Unsigned() { REDIRECT; const char * const argv[] = {"cppcheck", "--platform=unix32-unsigned", "file.cpp"}; - ASSERT(settings->platform.set(cppcheck::Platform::Type::Unspecified)); + ASSERT(settings->platform.set(Platform::Type::Unspecified)); ASSERT(parser->parseFromArgs(3, argv)); - ASSERT_EQUALS(cppcheck::Platform::Type::Unix32, settings->platform.type); + ASSERT_EQUALS(Platform::Type::Unix32, settings->platform.type); ASSERT_EQUALS("", logger->str()); } void platformUnix64() { REDIRECT; const char * const argv[] = {"cppcheck", "--platform=unix64", "file.cpp"}; - ASSERT(settings->platform.set(cppcheck::Platform::Type::Unspecified)); + ASSERT(settings->platform.set(Platform::Type::Unspecified)); ASSERT(parser->parseFromArgs(3, argv)); - ASSERT_EQUALS(cppcheck::Platform::Type::Unix64, settings->platform.type); + ASSERT_EQUALS(Platform::Type::Unix64, settings->platform.type); ASSERT_EQUALS("", logger->str()); } void platformUnix64Unsigned() { REDIRECT; const char * const argv[] = {"cppcheck", "--platform=unix64-unsigned", "file.cpp"}; - ASSERT(settings->platform.set(cppcheck::Platform::Type::Unspecified)); + ASSERT(settings->platform.set(Platform::Type::Unspecified)); ASSERT(parser->parseFromArgs(3, argv)); - ASSERT_EQUALS(cppcheck::Platform::Type::Unix64, settings->platform.type); + ASSERT_EQUALS(Platform::Type::Unix64, settings->platform.type); ASSERT_EQUALS("", logger->str()); } void platformNative() { REDIRECT; const char * const argv[] = {"cppcheck", "--platform=native", "file.cpp"}; - ASSERT(settings->platform.set(cppcheck::Platform::Type::Unspecified)); + ASSERT(settings->platform.set(Platform::Type::Unspecified)); ASSERT(parser->parseFromArgs(3, argv)); - ASSERT_EQUALS(cppcheck::Platform::Type::Native, settings->platform.type); + ASSERT_EQUALS(Platform::Type::Native, settings->platform.type); ASSERT_EQUALS("", logger->str()); } void platformUnspecified() { REDIRECT; const char * const argv[] = {"cppcheck", "--platform=unspecified", "file.cpp"}; - ASSERT(settings->platform.set(cppcheck::Platform::Type::Native)); + ASSERT(settings->platform.set(Platform::Type::Native)); ASSERT(parser->parseFromArgs(3, argv)); - ASSERT_EQUALS(cppcheck::Platform::Type::Unspecified, settings->platform.type); + ASSERT_EQUALS(Platform::Type::Unspecified, settings->platform.type); ASSERT_EQUALS("", logger->str()); } void platformPlatformFile() { REDIRECT; const char * const argv[] = {"cppcheck", "--platform=avr8", "file.cpp"}; - ASSERT(settings->platform.set(cppcheck::Platform::Type::Unspecified)); + ASSERT(settings->platform.set(Platform::Type::Unspecified)); ASSERT_EQUALS(true, parser->parseFromArgs(3, argv)); - ASSERT_EQUALS(cppcheck::Platform::Type::File, settings->platform.type); + ASSERT_EQUALS(Platform::Type::File, settings->platform.type); ASSERT_EQUALS("", logger->str()); } diff --git a/test/testcondition.cpp b/test/testcondition.cpp index 2ca5b71c05b..786ba311cdf 100644 --- a/test/testcondition.cpp +++ b/test/testcondition.cpp @@ -5702,7 +5702,7 @@ class TestCondition : public TestFixture { } void compareOutOfTypeRange() { - const Settings settingsUnix64 = settingsBuilder().severity(Severity::style).platform(cppcheck::Platform::Type::Unix64).build(); + const Settings settingsUnix64 = settingsBuilder().severity(Severity::style).platform(Platform::Type::Unix64).build(); check("void f(unsigned char c) {\n" " if (c == 256) {}\n" diff --git a/test/testio.cpp b/test/testio.cpp index 0cd148edb28..8f89f0a7bd5 100644 --- a/test/testio.cpp +++ b/test/testio.cpp @@ -82,7 +82,7 @@ class TestIO : public TestFixture { } #define check(...) check_(__FILE__, __LINE__, __VA_ARGS__) - void check_(const char* file, int line, const char* code, bool inconclusive = false, bool portability = false, cppcheck::Platform::Type platform = cppcheck::Platform::Type::Unspecified, bool onlyFormatStr = false, bool cpp = true) { + void check_(const char* file, int line, const char* code, bool inconclusive = false, bool portability = false, Platform::Type platform = Platform::Type::Unspecified, bool onlyFormatStr = false, bool cpp = true) { // Clear the error buffer.. errout.str(""); @@ -178,7 +178,7 @@ class TestIO : public TestFixture { " fread(buffer, 5, 6, f);\n" " rewind(f);\n" " fwrite(buffer, 5, 6, f);\n" - "}", false, false, cppcheck::Platform::Type::Win32W); + "}", false, false, Platform::Type::Win32W); ASSERT_EQUALS("[test.cpp:5]: (error) Write operation on a file that was opened only for reading.\n", errout.str()); check("void foo(FILE*& f) {\n" @@ -186,7 +186,7 @@ class TestIO : public TestFixture { " fread(buffer, 5, 6, f);\n" " rewind(f);\n" " fwrite(buffer, 5, 6, f);\n" - "}", false, false, cppcheck::Platform::Type::Win32A); + "}", false, false, Platform::Type::Win32A); ASSERT_EQUALS("[test.cpp:5]: (error) Write operation on a file that was opened only for reading.\n", errout.str()); check("void foo(FILE*& f) {\n" @@ -194,7 +194,7 @@ class TestIO : public TestFixture { " fread(buffer, 5, 6, f);\n" " rewind(f);\n" " fwrite(buffer, 5, 6, f);\n" - "}", false, false, cppcheck::Platform::Type::Win32W); + "}", false, false, Platform::Type::Win32W); ASSERT_EQUALS("[test.cpp:5]: (error) Write operation on a file that was opened only for reading.\n", errout.str()); check("void foo(FILE*& f) {\n" @@ -202,7 +202,7 @@ class TestIO : public TestFixture { " fread(buffer, 5, 6, f);\n" " rewind(f);\n" " fwrite(buffer, 5, 6, f);\n" - "}", false, false, cppcheck::Platform::Type::Win32W); + "}", false, false, Platform::Type::Win32W); ASSERT_EQUALS("[test.cpp:5]: (error) Write operation on a file that was opened only for reading.\n", errout.str()); check("void foo(FILE*& f) {\n" @@ -210,7 +210,7 @@ class TestIO : public TestFixture { " fread(buffer, 5, 6, f);\n" " rewind(f);\n" " fwrite(buffer, 5, 6, f);\n" - "}", false, false, cppcheck::Platform::Type::Win32A); + "}", false, false, Platform::Type::Win32A); ASSERT_EQUALS("[test.cpp:5]: (error) Write operation on a file that was opened only for reading.\n", errout.str()); check("void foo(FILE*& f) {\n" @@ -218,7 +218,7 @@ class TestIO : public TestFixture { " fread(buffer, 5, 6, f);\n" " rewind(f);\n" " fwrite(buffer, 5, 6, f);\n" - "}", false, false, cppcheck::Platform::Type::Win32W); + "}", false, false, Platform::Type::Win32W); ASSERT_EQUALS("[test.cpp:5]: (error) Write operation on a file that was opened only for reading.\n", errout.str()); check("void foo(FILE*& f) {\n" @@ -230,43 +230,43 @@ class TestIO : public TestFixture { check("void foo(FILE*& f) {\n" " f = _wfopen(name, L\"r+\");\n" " fwrite(buffer, 5, 6, f);\n" - "}", false, false, cppcheck::Platform::Type::Win32W); + "}", false, false, Platform::Type::Win32W); ASSERT_EQUALS("", errout.str()); check("void foo(FILE*& f) {\n" " f = _tfopen(name, _T(\"r+\"));\n" " fwrite(buffer, 5, 6, f);\n" - "}", false, false, cppcheck::Platform::Type::Win32A); + "}", false, false, Platform::Type::Win32A); ASSERT_EQUALS("", errout.str()); check("void foo(FILE*& f) {\n" " f = _tfopen(name, _T(\"r+\"));\n" " fwrite(buffer, 5, 6, f);\n" - "}", false, false, cppcheck::Platform::Type::Win32W); + "}", false, false, Platform::Type::Win32W); ASSERT_EQUALS("", errout.str()); check("void foo(FILE*& f) {\n" " _wfopen_s(&f, name, L\"r+\");\n" " fwrite(buffer, 5, 6, f);\n" - "}", false, false, cppcheck::Platform::Type::Win32W); + "}", false, false, Platform::Type::Win32W); ASSERT_EQUALS("", errout.str()); check("void foo(FILE*& f) {\n" " _tfopen_s(&f, name, _T(\"r+\"));\n" " fwrite(buffer, 5, 6, f);\n" - "}", false, false, cppcheck::Platform::Type::Win32A); + "}", false, false, Platform::Type::Win32A); ASSERT_EQUALS("", errout.str()); check("void foo(FILE*& f) {\n" " _tfopen_s(&f, name, _T(\"r+\"));\n" " fwrite(buffer, 5, 6, f);\n" - "}", false, false, cppcheck::Platform::Type::Win32W); + "}", false, false, Platform::Type::Win32W); ASSERT_EQUALS("", errout.str()); check("void foo(FILE*& f) {\n" " f = tmpfile();\n" " fwrite(buffer, 5, 6, f);\n" - "}", false, false, cppcheck::Platform::Type::Win32W); + "}", false, false, Platform::Type::Win32W); ASSERT_EQUALS("", errout.str()); // Write mode @@ -333,37 +333,37 @@ class TestIO : public TestFixture { check("void foo(FILE*& f) {\n" " f = _wfreopen(name, L\"r\", f);\n" " fwrite(buffer, 5, 6, f);\n" - "}", false, false, cppcheck::Platform::Type::Win32W); + "}", false, false, Platform::Type::Win32W); ASSERT_EQUALS("[test.cpp:3]: (error) Write operation on a file that was opened only for reading.\n", errout.str()); check("void foo(FILE*& f) {\n" " f = _tfreopen(name, _T(\"r\"), f);\n" " fwrite(buffer, 5, 6, f);\n" - "}", false, false, cppcheck::Platform::Type::Win32A); + "}", false, false, Platform::Type::Win32A); ASSERT_EQUALS("[test.cpp:3]: (error) Write operation on a file that was opened only for reading.\n", errout.str()); check("void foo(FILE*& f) {\n" " f = _tfreopen(name, _T(\"r\"), f);\n" " fwrite(buffer, 5, 6, f);\n" - "}", false, false, cppcheck::Platform::Type::Win32W); + "}", false, false, Platform::Type::Win32W); ASSERT_EQUALS("[test.cpp:3]: (error) Write operation on a file that was opened only for reading.\n", errout.str()); check("void foo(FILE*& f) {\n" " f = _wfreopen_s(&f, name, L\"r\", f);\n" " fwrite(buffer, 5, 6, f);\n" - "}", false, false, cppcheck::Platform::Type::Win32W); + "}", false, false, Platform::Type::Win32W); ASSERT_EQUALS("[test.cpp:3]: (error) Write operation on a file that was opened only for reading.\n", errout.str()); check("void foo(FILE*& f) {\n" " f = _tfreopen_s(&f, name, _T(\"r\"), f);\n" " fwrite(buffer, 5, 6, f);\n" - "}", false, false, cppcheck::Platform::Type::Win32A); + "}", false, false, Platform::Type::Win32A); ASSERT_EQUALS("[test.cpp:3]: (error) Write operation on a file that was opened only for reading.\n", errout.str()); check("void foo(FILE*& f) {\n" " f = _tfreopen_s(&f, name, _T(\"r\"), f);\n" " fwrite(buffer, 5, 6, f);\n" - "}", false, false, cppcheck::Platform::Type::Win32W); + "}", false, false, Platform::Type::Win32W); ASSERT_EQUALS("[test.cpp:3]: (error) Write operation on a file that was opened only for reading.\n", errout.str()); // Crash tests @@ -821,65 +821,65 @@ class TestIO : public TestFixture { void testFormatStrNoWarn(const char *filename, unsigned int linenr, const char* code, bool cpp = false) { - check(code, true, false, cppcheck::Platform::Type::Unix32, true, cpp); + check(code, true, false, Platform::Type::Unix32, true, cpp); assertEquals(filename, linenr, emptyString, errout.str()); - check(code, true, false, cppcheck::Platform::Type::Unix64, true, cpp); + check(code, true, false, Platform::Type::Unix64, true, cpp); assertEquals(filename, linenr, emptyString, errout.str()); - check(code, true, false, cppcheck::Platform::Type::Win32A, true, cpp); + check(code, true, false, Platform::Type::Win32A, true, cpp); assertEquals(filename, linenr, emptyString, errout.str()); - check(code, true, false, cppcheck::Platform::Type::Win64, true, cpp); + check(code, true, false, Platform::Type::Win64, true, cpp); assertEquals(filename, linenr, emptyString, errout.str()); } void testFormatStrWarn(const char *filename, unsigned int linenr, const char* code, const char* testScanfErrString, bool cpp = false) { - check(code, true, false, cppcheck::Platform::Type::Unix32, true, cpp); + check(code, true, false, Platform::Type::Unix32, true, cpp); assertEquals(filename, linenr, testScanfErrString, errout.str()); - check(code, true, false, cppcheck::Platform::Type::Unix64, true, cpp); + check(code, true, false, Platform::Type::Unix64, true, cpp); assertEquals(filename, linenr, testScanfErrString, errout.str()); - check(code, true, false, cppcheck::Platform::Type::Win32A, true, cpp); + check(code, true, false, Platform::Type::Win32A, true, cpp); assertEquals(filename, linenr, testScanfErrString, errout.str()); - check(code, true, false, cppcheck::Platform::Type::Win64, true, cpp); + check(code, true, false, Platform::Type::Win64, true, cpp); assertEquals(filename, linenr, testScanfErrString, errout.str()); } void testFormatStrWarnAka(const char *filename, unsigned int linenr, const char* code, const char* testScanfErrAkaString, const char* testScanfErrAkaWin64String, bool cpp = false) { - check(code, true, true, cppcheck::Platform::Type::Unix32, true, cpp); + check(code, true, true, Platform::Type::Unix32, true, cpp); assertEquals(filename, linenr, testScanfErrAkaString, errout.str()); - check(code, true, true, cppcheck::Platform::Type::Unix64, true, cpp); + check(code, true, true, Platform::Type::Unix64, true, cpp); assertEquals(filename, linenr, testScanfErrAkaString, errout.str()); - check(code, true, true, cppcheck::Platform::Type::Win32A, true, cpp); + check(code, true, true, Platform::Type::Win32A, true, cpp); assertEquals(filename, linenr, testScanfErrAkaString, errout.str()); - check(code, true, true, cppcheck::Platform::Type::Win64, true, cpp); + check(code, true, true, Platform::Type::Win64, true, cpp); assertEquals(filename, linenr, testScanfErrAkaWin64String, errout.str()); } void testFormatStrWarnAkaWin64(const char *filename, unsigned int linenr, const char* code, const char* testScanfErrAkaWin64String, bool cpp = false) { - check(code, true, true, cppcheck::Platform::Type::Unix32, true, cpp); + check(code, true, true, Platform::Type::Unix32, true, cpp); assertEquals(filename, linenr, emptyString, errout.str()); - check(code, true, true, cppcheck::Platform::Type::Unix64, true, cpp); + check(code, true, true, Platform::Type::Unix64, true, cpp); assertEquals(filename, linenr, emptyString, errout.str()); - check(code, true, true, cppcheck::Platform::Type::Win32A, true, cpp); + check(code, true, true, Platform::Type::Win32A, true, cpp); assertEquals(filename, linenr, emptyString, errout.str()); - check(code, true, true, cppcheck::Platform::Type::Win64, true, cpp); + check(code, true, true, Platform::Type::Win64, true, cpp); assertEquals(filename, linenr, testScanfErrAkaWin64String, errout.str()); } void testFormatStrWarnAkaWin32(const char *filename, unsigned int linenr, const char* code, const char* testScanfErrAkaString, bool cpp = false) { - check(code, true, true, cppcheck::Platform::Type::Unix32, true, cpp); + check(code, true, true, Platform::Type::Unix32, true, cpp); assertEquals(filename, linenr, testScanfErrAkaString, errout.str()); - check(code, true, true, cppcheck::Platform::Type::Unix64, true, cpp); + check(code, true, true, Platform::Type::Unix64, true, cpp); assertEquals(filename, linenr, testScanfErrAkaString, errout.str()); - check(code, true, true, cppcheck::Platform::Type::Win32A, true, cpp); + check(code, true, true, Platform::Type::Win32A, true, cpp); assertEquals(filename, linenr, testScanfErrAkaString, errout.str()); - check(code, true, true, cppcheck::Platform::Type::Win64, true, cpp); + check(code, true, true, Platform::Type::Win64, true, cpp); assertEquals(filename, linenr, emptyString, errout.str()); } @@ -2133,13 +2133,13 @@ class TestIO : public TestFixture { const char* result_win64("[test.cpp:5]: (portability) %zd in format string (no. 1) requires 'ssize_t *' but the argument type is 'size_t * {aka unsigned long long *}'.\n" "[test.cpp:6]: (portability) %zd in format string (no. 1) requires 'ssize_t *' but the argument type is 'ptrdiff_t * {aka signed long long *}'.\n"); - check(code, false, true, cppcheck::Platform::Type::Unix32); + check(code, false, true, Platform::Type::Unix32); ASSERT_EQUALS(result, errout.str()); - check(code, false, true, cppcheck::Platform::Type::Unix64); + check(code, false, true, Platform::Type::Unix64); ASSERT_EQUALS(result, errout.str()); - check(code, false, true, cppcheck::Platform::Type::Win32A); + check(code, false, true, Platform::Type::Win32A); ASSERT_EQUALS(result, errout.str()); - check(code, false, true, cppcheck::Platform::Type::Win64); + check(code, false, true, Platform::Type::Win64); ASSERT_EQUALS(result_win64, errout.str()); } { @@ -2529,56 +2529,56 @@ class TestIO : public TestFixture { check("void foo(size_t s, ptrdiff_t p) {\n" " printf(\"%zd\", s);\n" " printf(\"%tu\", p);\n" - "}", false, true, cppcheck::Platform::Type::Unix32); + "}", false, true, Platform::Type::Unix32); ASSERT_EQUALS("[test.cpp:2]: (portability) %zd in format string (no. 1) requires 'ssize_t' but the argument type is 'size_t {aka unsigned long}'.\n" "[test.cpp:3]: (portability) %tu in format string (no. 1) requires 'unsigned ptrdiff_t' but the argument type is 'ptrdiff_t {aka signed long}'.\n", errout.str()); check("void foo(std::size_t s, std::ptrdiff_t p) {\n" " printf(\"%zd\", s);\n" " printf(\"%tu\", p);\n" - "}", false, true, cppcheck::Platform::Type::Unix32); + "}", false, true, Platform::Type::Unix32); ASSERT_EQUALS("[test.cpp:2]: (portability) %zd in format string (no. 1) requires 'ssize_t' but the argument type is 'std::size_t {aka unsigned long}'.\n" "[test.cpp:3]: (portability) %tu in format string (no. 1) requires 'unsigned ptrdiff_t' but the argument type is 'std::ptrdiff_t {aka signed long}'.\n", errout.str()); check("void foo(size_t s, ptrdiff_t p) {\n" " printf(\"%zd\", s);\n" " printf(\"%tu\", p);\n" - "}", false, true, cppcheck::Platform::Type::Unix64); + "}", false, true, Platform::Type::Unix64); ASSERT_EQUALS("[test.cpp:2]: (portability) %zd in format string (no. 1) requires 'ssize_t' but the argument type is 'size_t {aka unsigned long}'.\n" "[test.cpp:3]: (portability) %tu in format string (no. 1) requires 'unsigned ptrdiff_t' but the argument type is 'ptrdiff_t {aka signed long}'.\n", errout.str()); check("void foo(std::size_t s, std::ptrdiff_t p) {\n" " printf(\"%zd\", s);\n" " printf(\"%tu\", p);\n" - "}", false, true, cppcheck::Platform::Type::Unix64); + "}", false, true, Platform::Type::Unix64); ASSERT_EQUALS("[test.cpp:2]: (portability) %zd in format string (no. 1) requires 'ssize_t' but the argument type is 'std::size_t {aka unsigned long}'.\n" "[test.cpp:3]: (portability) %tu in format string (no. 1) requires 'unsigned ptrdiff_t' but the argument type is 'std::ptrdiff_t {aka signed long}'.\n", errout.str()); check("void foo(size_t s, ptrdiff_t p) {\n" " printf(\"%zd\", s);\n" " printf(\"%tu\", p);\n" - "}", false, true, cppcheck::Platform::Type::Win32A); + "}", false, true, Platform::Type::Win32A); ASSERT_EQUALS("[test.cpp:2]: (portability) %zd in format string (no. 1) requires 'ssize_t' but the argument type is 'size_t {aka unsigned long}'.\n" "[test.cpp:3]: (portability) %tu in format string (no. 1) requires 'unsigned ptrdiff_t' but the argument type is 'ptrdiff_t {aka signed long}'.\n", errout.str()); check("void foo(std::size_t s, std::ptrdiff_t p) {\n" " printf(\"%zd\", s);\n" " printf(\"%tu\", p);\n" - "}", false, true, cppcheck::Platform::Type::Win32A); + "}", false, true, Platform::Type::Win32A); ASSERT_EQUALS("[test.cpp:2]: (portability) %zd in format string (no. 1) requires 'ssize_t' but the argument type is 'std::size_t {aka unsigned long}'.\n" "[test.cpp:3]: (portability) %tu in format string (no. 1) requires 'unsigned ptrdiff_t' but the argument type is 'std::ptrdiff_t {aka signed long}'.\n", errout.str()); check("void foo(size_t s, ptrdiff_t p) {\n" " printf(\"%zd\", s);\n" " printf(\"%tu\", p);\n" - "}", false, true, cppcheck::Platform::Type::Win64); + "}", false, true, Platform::Type::Win64); ASSERT_EQUALS("[test.cpp:2]: (portability) %zd in format string (no. 1) requires 'ssize_t' but the argument type is 'size_t {aka unsigned long long}'.\n" "[test.cpp:3]: (portability) %tu in format string (no. 1) requires 'unsigned ptrdiff_t' but the argument type is 'ptrdiff_t {aka signed long long}'.\n", errout.str()); check("void foo(std::size_t s, std::ptrdiff_t p) {\n" " printf(\"%zd\", s);\n" " printf(\"%tu\", p);\n" - "}", false, true, cppcheck::Platform::Type::Win64); + "}", false, true, Platform::Type::Win64); ASSERT_EQUALS("[test.cpp:2]: (portability) %zd in format string (no. 1) requires 'ssize_t' but the argument type is 'std::size_t {aka unsigned long long}'.\n" "[test.cpp:3]: (portability) %tu in format string (no. 1) requires 'unsigned ptrdiff_t' but the argument type is 'std::ptrdiff_t {aka signed long long}'.\n", errout.str()); @@ -2587,7 +2587,7 @@ class TestIO : public TestFixture { " printf(\"%lu\", um);\n" " printf(\"%llu\", s);\n" " printf(\"%llu\", um);\n" - "}", false, true, cppcheck::Platform::Type::Win64); + "}", false, true, Platform::Type::Win64); ASSERT_EQUALS("[test.cpp:2]: (portability) %lu in format string (no. 1) requires 'unsigned long' but the argument type is 'size_t {aka unsigned long long}'.\n" "[test.cpp:3]: (portability) %lu in format string (no. 1) requires 'unsigned long' but the argument type is 'uintmax_t {aka unsigned long long}'.\n" "[test.cpp:4]: (portability) %llu in format string (no. 1) requires 'unsigned long long' but the argument type is 'size_t {aka unsigned long long}'.\n" @@ -2618,7 +2618,7 @@ class TestIO : public TestFixture { check("void foo(intmax_t im, ptrdiff_t p) {\n" " printf(\"%lld\", im);\n" " printf(\"%lld\", p);\n" - "}", false, true, cppcheck::Platform::Type::Win64); + "}", false, true, Platform::Type::Win64); ASSERT_EQUALS("[test.cpp:2]: (portability) %lld in format string (no. 1) requires 'long long' but the argument type is 'intmax_t {aka signed long long}'.\n" "[test.cpp:3]: (portability) %lld in format string (no. 1) requires 'long long' but the argument type is 'ptrdiff_t {aka signed long long}'.\n", errout.str()); @@ -2927,7 +2927,7 @@ class TestIO : public TestFixture { "void foo() {\n" " printf(\"%zu %Iu %d %f\", v.size(), v.size(), v.size(), v.size());\n" " printf(\"%zu %Iu %d %f\", s.size(), s.size(), s.size(), s.size());\n" - "}\n", false, true, cppcheck::Platform::Type::Win32A); + "}\n", false, true, Platform::Type::Win32A); ASSERT_EQUALS("[test.cpp:4]: (portability) %d in format string (no. 3) requires 'int' but the argument type is 'std::size_t {aka unsigned long}'.\n" "[test.cpp:4]: (portability) %f in format string (no. 4) requires 'double' but the argument type is 'std::size_t {aka unsigned long}'.\n" "[test.cpp:5]: (portability) %d in format string (no. 3) requires 'int' but the argument type is 'std::size_t {aka unsigned long}'.\n" @@ -2938,7 +2938,7 @@ class TestIO : public TestFixture { "void foo() {\n" " printf(\"%zu %Iu %d %f\", v.size(), v.size(), v.size(), v.size());\n" " printf(\"%zu %Iu %d %f\", s.size(), s.size(), s.size(), s.size());\n" - "}\n", false, true, cppcheck::Platform::Type::Win64); + "}\n", false, true, Platform::Type::Win64); ASSERT_EQUALS("[test.cpp:4]: (portability) %d in format string (no. 3) requires 'int' but the argument type is 'std::size_t {aka unsigned long long}'.\n" "[test.cpp:4]: (portability) %f in format string (no. 4) requires 'double' but the argument type is 'std::size_t {aka unsigned long long}'.\n" "[test.cpp:5]: (portability) %d in format string (no. 3) requires 'int' but the argument type is 'std::size_t {aka unsigned long long}'.\n" @@ -2949,7 +2949,7 @@ class TestIO : public TestFixture { "void foo() {\n" " printf(\"%zu %Iu %d %f\", v.size(), v.size(), v.size(), v.size());\n" " printf(\"%zu %Iu %d %f\", s.size(), s.size(), s.size(), s.size());\n" - "}\n", false, true, cppcheck::Platform::Type::Unix32); + "}\n", false, true, Platform::Type::Unix32); ASSERT_EQUALS("[test.cpp:4]: (portability) %d in format string (no. 3) requires 'int' but the argument type is 'std::size_t {aka unsigned long}'.\n" "[test.cpp:4]: (portability) %f in format string (no. 4) requires 'double' but the argument type is 'std::size_t {aka unsigned long}'.\n" "[test.cpp:5]: (portability) %d in format string (no. 3) requires 'int' but the argument type is 'std::size_t {aka unsigned long}'.\n" @@ -2960,7 +2960,7 @@ class TestIO : public TestFixture { "void foo() {\n" " printf(\"%zu %Iu %d %f\", v.size(), v.size(), v.size(), v.size());\n" " printf(\"%zu %Iu %d %f\", s.size(), s.size(), s.size(), s.size());\n" - "}\n", false, true, cppcheck::Platform::Type::Unix64); + "}\n", false, true, Platform::Type::Unix64); ASSERT_EQUALS("[test.cpp:4]: (portability) %d in format string (no. 3) requires 'int' but the argument type is 'std::size_t {aka unsigned long}'.\n" "[test.cpp:4]: (portability) %f in format string (no. 4) requires 'double' but the argument type is 'std::size_t {aka unsigned long}'.\n" "[test.cpp:5]: (portability) %d in format string (no. 3) requires 'int' but the argument type is 'std::size_t {aka unsigned long}'.\n" @@ -2971,7 +2971,7 @@ class TestIO : public TestFixture { "void foo() {\n" " printf(\"%zu %Iu %d %f\", v.size(), v.size(), v.size(), v.size());\n" " printf(\"%zu %Iu %d %f\", s.size(), s.size(), s.size(), s.size());\n" - "}\n", false, true, cppcheck::Platform::Type::Unix64); + "}\n", false, true, Platform::Type::Unix64); ASSERT_EQUALS("[test.cpp:4]: (portability) %d in format string (no. 3) requires 'int' but the argument type is 'size_t {aka unsigned long}'.\n" "[test.cpp:4]: (portability) %f in format string (no. 4) requires 'double' but the argument type is 'size_t {aka unsigned long}'.\n" "[test.cpp:5]: (portability) %d in format string (no. 3) requires 'int' but the argument type is 'std::size_t {aka unsigned long}'.\n" @@ -2980,14 +2980,14 @@ class TestIO : public TestFixture { check("class Fred : public std::vector {} v;\n" "void foo() {\n" " printf(\"%d %u %f\", v[0], v[0], v[0]);\n" - "}\n", false, true, cppcheck::Platform::Type::Unix64); + "}\n", false, true, Platform::Type::Unix64); ASSERT_EQUALS("[test.cpp:3]: (warning) %u in format string (no. 2) requires 'unsigned int' but the argument type is 'int'.\n" "[test.cpp:3]: (warning) %f in format string (no. 3) requires 'double' but the argument type is 'int'.\n", errout.str()); check("std::string s;\n" "void foo() {\n" " printf(\"%s %p %u %d %f\", s.c_str(), s.c_str(), s.c_str(), s.c_str(), s.c_str());\n" - "}\n", false, true, cppcheck::Platform::Type::Unix64); + "}\n", false, true, Platform::Type::Unix64); ASSERT_EQUALS("[test.cpp:3]: (warning) %u in format string (no. 3) requires 'unsigned int' but the argument type is 'const char *'.\n" "[test.cpp:3]: (warning) %d in format string (no. 4) requires 'int' but the argument type is 'const char *'.\n" "[test.cpp:3]: (warning) %f in format string (no. 5) requires 'double' but the argument type is 'const char *'.\n", errout.str()); @@ -3003,7 +3003,7 @@ class TestIO : public TestFixture { " printf(\"%u %u\", array.size(), s);\n" " printf(\"%lu %lu\", array.size(), s);\n" " printf(\"%llu %llu\", array.size(), s);\n" - "}\n", false, true, cppcheck::Platform::Type::Unix64); + "}\n", false, true, Platform::Type::Unix64); ASSERT_EQUALS("[test.cpp:8]: (warning) %u in format string (no. 1) requires 'unsigned int' but the argument type is 'char *'.\n" "[test.cpp:8]: (warning) %u in format string (no. 2) requires 'unsigned int' but the argument type is 'char *'.\n" "[test.cpp:8]: (warning) %u in format string (no. 3) requires 'unsigned int' but the argument type is 'char *'.\n" @@ -3027,7 +3027,7 @@ class TestIO : public TestFixture { "char ca[3];\n" "void foo() {\n" " printf(\"%td %zd %d %d %d %d %d %d %d %d %d %d %d\", pt, pt, b, c, sc, uc, s, us, st, pt, pc, cl, ca);\n" - "}\n", false, true, cppcheck::Platform::Type::Unix64); + "}\n", false, true, Platform::Type::Unix64); ASSERT_EQUALS("[test.cpp:13]: (portability) %zd in format string (no. 2) requires 'ssize_t' but the argument type is 'ptrdiff_t {aka signed long}'.\n" "[test.cpp:13]: (portability) %d in format string (no. 9) requires 'int' but the argument type is 'size_t {aka unsigned long}'.\n" "[test.cpp:13]: (portability) %d in format string (no. 10) requires 'int' but the argument type is 'ptrdiff_t {aka signed long}'.\n" @@ -3048,7 +3048,7 @@ class TestIO : public TestFixture { "char ca[3];\n" "void foo() {\n" " printf(\"%ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld\", b, c, sc, uc, s, us, st, pt, pc, cl, ca);\n" - "}\n", false, true, cppcheck::Platform::Type::Unix64); + "}\n", false, true, Platform::Type::Unix64); ASSERT_EQUALS("[test.cpp:13]: (warning) %ld in format string (no. 1) requires 'long' but the argument type is 'bool'.\n" "[test.cpp:13]: (warning) %ld in format string (no. 2) requires 'long' but the argument type is 'char'.\n" "[test.cpp:13]: (warning) %ld in format string (no. 3) requires 'long' but the argument type is 'signed char'.\n" @@ -3075,7 +3075,7 @@ class TestIO : public TestFixture { "char ca[3];\n" "void foo() {\n" " printf(\"%td %zd %d %d %d %d %d %d %d %d %d\", ptf(), ptf(), bf(), cf(), scf(), ucf(), sf(), usf(), stf(), ptf(), pcf());\n" - "}\n", false, true, cppcheck::Platform::Type::Unix64); + "}\n", false, true, Platform::Type::Unix64); ASSERT_EQUALS("[test.cpp:13]: (portability) %zd in format string (no. 2) requires 'ssize_t' but the argument type is 'ptrdiff_t {aka signed long}'.\n" "[test.cpp:13]: (portability) %d in format string (no. 9) requires 'int' but the argument type is 'size_t {aka unsigned long}'.\n" "[test.cpp:13]: (portability) %d in format string (no. 10) requires 'int' but the argument type is 'ptrdiff_t {aka signed long}'.\n" @@ -3094,7 +3094,7 @@ class TestIO : public TestFixture { "char ca[3];\n" "void foo() {\n" " printf(\"%ld %ld %ld %ld %ld %ld %ld %ld %ld\", bf(), cf(), scf(), ucf(), sf(), usf(), stf(), ptf(), pcf());\n" - "}\n", false, true, cppcheck::Platform::Type::Unix64); + "}\n", false, true, Platform::Type::Unix64); ASSERT_EQUALS("[test.cpp:13]: (warning) %ld in format string (no. 1) requires 'long' but the argument type is 'bool'.\n" "[test.cpp:13]: (warning) %ld in format string (no. 2) requires 'long' but the argument type is 'char'.\n" "[test.cpp:13]: (warning) %ld in format string (no. 3) requires 'long' but the argument type is 'signed char'.\n" @@ -3114,7 +3114,7 @@ class TestIO : public TestFixture { " printf(\"%p %d\", b[0], b[0]);\n" " printf(\"%p %d\", c[0], c[0]);\n" " printf(\"%p %d\", s.c_str(), s.c_str());\n" - "}\n", false, true, cppcheck::Platform::Type::Unix64); + "}\n", false, true, Platform::Type::Unix64); ASSERT_EQUALS("[test.cpp:6]: (portability) %u in format string (no. 2) requires 'unsigned int' but the argument type is 'size_t {aka unsigned long}'.\n" "[test.cpp:7]: (warning) %d in format string (no. 2) requires 'int' but the argument type is 'const int *'.\n" "[test.cpp:8]: (warning) %d in format string (no. 2) requires 'int' but the argument type is 'const struct A *'.\n" @@ -3127,7 +3127,7 @@ class TestIO : public TestFixture { " printf(\"%p %d\", a[0].c_str(), a[0].c_str());\n" " printf(\"%c %p\", b[0], b[0]);\n" " printf(\"%c %p\", s[0], s[0]);\n" - "}\n", false, false, cppcheck::Platform::Type::Unix64); + "}\n", false, false, Platform::Type::Unix64); ASSERT_EQUALS("[test.cpp:5]: (warning) %d in format string (no. 2) requires 'int' but the argument type is 'const char *'.\n" "[test.cpp:6]: (warning) %p in format string (no. 2) requires an address but the argument type is 'char'.\n" "[test.cpp:7]: (warning) %p in format string (no. 2) requires an address but the argument type is 'char'.\n", errout.str()); @@ -3139,28 +3139,28 @@ class TestIO : public TestFixture { "buffer b;\n" "void foo() {\n" " printf(\"%u\", b.size());\n" - "}\n", false, true, cppcheck::Platform::Type::Unix64); + "}\n", false, true, Platform::Type::Unix64); ASSERT_EQUALS("[test.cpp:7]: (portability) %u in format string (no. 1) requires 'unsigned int' but the argument type is 'size_t {aka unsigned long}'.\n", errout.str()); check("DWORD a;\n" "DWORD_PTR b;\n" "void foo() {\n" " printf(\"%u %u\", a, b);\n" - "}\n", false, true, cppcheck::Platform::Type::Win32A); + "}\n", false, true, Platform::Type::Win32A); ASSERT_EQUALS("[test.cpp:4]: (portability) %u in format string (no. 1) requires 'unsigned int' but the argument type is 'DWORD {aka unsigned long}'.\n" "[test.cpp:4]: (portability) %u in format string (no. 2) requires 'unsigned int' but the argument type is 'DWORD_PTR {aka unsigned long}'.\n", errout.str()); check("unsigned long a[] = { 1, 2 };\n" "void foo() {\n" " printf(\"%d %d %x \", a[0], a[0], a[0]);\n" - "}\n", false, false, cppcheck::Platform::Type::Win32A); + "}\n", false, false, Platform::Type::Win32A); ASSERT_EQUALS("[test.cpp:3]: (warning) %d in format string (no. 1) requires 'int' but the argument type is 'unsigned long'.\n" "[test.cpp:3]: (warning) %d in format string (no. 2) requires 'int' but the argument type is 'unsigned long'.\n" "[test.cpp:3]: (warning) %x in format string (no. 3) requires 'unsigned int' but the argument type is 'unsigned long'.\n", errout.str()); check("void foo (wchar_t c) {\n" // ticket #5051 false positive " printf(\"%c\", c);\n" - "}\n", false, false, cppcheck::Platform::Type::Win64); + "}\n", false, false, Platform::Type::Win64); ASSERT_EQUALS("", errout.str()); check("void foo() {\n" @@ -3336,7 +3336,7 @@ class TestIO : public TestFixture { check("void f() {\n" " printf(\"%lu\", sizeof(char));\n" - "}\n", false, true, cppcheck::Platform::Type::Win64); + "}\n", false, true, Platform::Type::Win64); ASSERT_EQUALS("[test.cpp:2]: (portability) %lu in format string (no. 1) requires 'unsigned long' but the argument type is 'size_t {aka unsigned long long}'.\n", errout.str()); } @@ -4124,7 +4124,7 @@ class TestIO : public TestFixture { " printf(\"%I32d %I32u %I32x\", u32, u32, u32);\n" " printf(\"%I64d %I64u %I64x\", i64, i64, i64);\n" " printf(\"%I64d %I64u %I64x\", u64, u64, u64);\n" - "}", false, true, cppcheck::Platform::Type::Win32A); + "}", false, true, Platform::Type::Win32A); ASSERT_EQUALS("[test.cpp:8]: (portability) %Id in format string (no. 1) requires 'ptrdiff_t' but the argument type is 'size_t {aka unsigned long}'.\n" "[test.cpp:9]: (portability) %Iu in format string (no. 2) requires 'size_t' but the argument type is 'ptrdiff_t {aka signed long}'.\n" "[test.cpp:9]: (portability) %Ix in format string (no. 3) requires 'size_t' but the argument type is 'ptrdiff_t {aka signed long}'.\n" @@ -4146,7 +4146,7 @@ class TestIO : public TestFixture { " printf(\"%I32d %I32u %I32x\", u32, u32, u32);\n" " printf(\"%I64d %I64u %I64x\", i64, i64, i64);\n" " printf(\"%I64d %I64u %I64x\", u64, u64, u64);\n" - "}", false, true, cppcheck::Platform::Type::Win64); + "}", false, true, Platform::Type::Win64); ASSERT_EQUALS("[test.cpp:8]: (portability) %Id in format string (no. 1) requires 'ptrdiff_t' but the argument type is 'size_t {aka unsigned long long}'.\n" "[test.cpp:9]: (portability) %Iu in format string (no. 2) requires 'size_t' but the argument type is 'ptrdiff_t {aka signed long long}'.\n" "[test.cpp:9]: (portability) %Ix in format string (no. 3) requires 'size_t' but the argument type is 'ptrdiff_t {aka signed long long}'.\n" @@ -4191,23 +4191,23 @@ class TestIO : public TestFixture { // ticket #5264 check("void foo(LPARAM lp, WPARAM wp, LRESULT lr) {\n" " printf(\"%Ix %Ix %Ix\", lp, wp, lr);\n" - "}\n", false, true, cppcheck::Platform::Type::Win64); + "}\n", false, true, Platform::Type::Win64); ASSERT_EQUALS("", errout.str()); check("void foo(LPARAM lp, WPARAM wp, LRESULT lr) {\n" " printf(\"%Ix %Ix %Ix\", lp, wp, lr);\n" - "}\n", false, true, cppcheck::Platform::Type::Win32A); + "}\n", false, true, Platform::Type::Win32A); ASSERT_EQUALS("", errout.str()); check("void foo(UINT32 a, ::UINT32 b, Fred::UINT32 c) {\n" " printf(\"%d %d %d\", a, b, c);\n" - "};\n", false, true, cppcheck::Platform::Type::Win32A); + "};\n", false, true, Platform::Type::Win32A); ASSERT_EQUALS("[test.cpp:2]: (portability) %d in format string (no. 1) requires 'int' but the argument type is 'UINT32 {aka unsigned int}'.\n" "[test.cpp:2]: (portability) %d in format string (no. 2) requires 'int' but the argument type is 'UINT32 {aka unsigned int}'.\n", errout.str()); check("void foo(LPCVOID a, ::LPCVOID b, Fred::LPCVOID c) {\n" " printf(\"%d %d %d\", a, b, c);\n" - "};\n", false, true, cppcheck::Platform::Type::Win32A); + "};\n", false, true, Platform::Type::Win32A); ASSERT_EQUALS("[test.cpp:2]: (warning) %d in format string (no. 1) requires 'int' but the argument type is 'const void *'.\n" "[test.cpp:2]: (warning) %d in format string (no. 2) requires 'int' but the argument type is 'const void *'.\n", errout.str()); @@ -4217,7 +4217,7 @@ class TestIO : public TestFixture { " printf(\"%zd\", s);\n" " printf(\"%zd%i\", s, i);\n" " printf(\"%zu\", s);\n" - "}", false, true, cppcheck::Platform::Type::Win32A); + "}", false, true, Platform::Type::Win32A); ASSERT_EQUALS("[test.cpp:6]: (portability) %zu in format string (no. 1) requires 'size_t' but the argument type is 'SSIZE_T {aka signed long}'.\n", errout.str()); check("void foo() {\n" @@ -4226,7 +4226,7 @@ class TestIO : public TestFixture { " printf(\"%zd\", s);\n" " printf(\"%zd%i\", s, i);\n" " printf(\"%zu\", s);\n" - "}", false, true, cppcheck::Platform::Type::Win64); + "}", false, true, Platform::Type::Win64); ASSERT_EQUALS("[test.cpp:6]: (portability) %zu in format string (no. 1) requires 'size_t' but the argument type is 'SSIZE_T {aka signed long long}'.\n", errout.str()); check("void foo() {\n" @@ -4235,7 +4235,7 @@ class TestIO : public TestFixture { " printf(\"%zd\", s);\n" " printf(\"%zd%i\", s, i);\n" " printf(\"%zu\", s);\n" - "}", false, true, cppcheck::Platform::Type::Unix64); + "}", false, true, Platform::Type::Unix64); ASSERT_EQUALS("", errout.str()); check("void foo() {\n" @@ -4245,7 +4245,7 @@ class TestIO : public TestFixture { " printf(\"%zd\", s);\n" " printf(\"%zd%i\", s, i);\n" " printf(\"%zu\", s);\n" - "}", false, true, cppcheck::Platform::Type::Win64); + "}", false, true, Platform::Type::Win64); ASSERT_EQUALS("[test.cpp:7]: (portability) %zu in format string (no. 1) requires 'size_t' but the argument type is 'SSIZE_T {aka signed long long}'.\n", errout.str()); } @@ -4264,7 +4264,7 @@ class TestIO : public TestFixture { " scanf(\"%I32d %I32u %I32x\", &u32, &u32, &u32);\n" " scanf(\"%I64d %I64u %I64x\", &i64, &i64, &i64);\n" " scanf(\"%I64d %I64u %I64x\", &u64, &u64, &u64);\n" - "}", false, true, cppcheck::Platform::Type::Win32A); + "}", false, true, Platform::Type::Win32A); ASSERT_EQUALS("[test.cpp:8]: (portability) %Id in format string (no. 1) requires 'ptrdiff_t *' but the argument type is 'size_t * {aka unsigned long *}'.\n" "[test.cpp:9]: (portability) %Iu in format string (no. 2) requires 'size_t *' but the argument type is 'ptrdiff_t * {aka signed long *}'.\n" "[test.cpp:9]: (portability) %Ix in format string (no. 3) requires 'size_t *' but the argument type is 'ptrdiff_t * {aka signed long *}'.\n" @@ -4288,7 +4288,7 @@ class TestIO : public TestFixture { " scanf(\"%I32d %I32u %I32x\", &u32, &u32, &u32);\n" " scanf(\"%I64d %I64u %I64x\", &i64, &i64, &i64);\n" " scanf(\"%I64d %I64u %I64x\", &u64, &u64, &u64);\n" - "}", false, true, cppcheck::Platform::Type::Win64); + "}", false, true, Platform::Type::Win64); ASSERT_EQUALS("[test.cpp:8]: (portability) %Id in format string (no. 1) requires 'ptrdiff_t *' but the argument type is 'size_t * {aka unsigned long long *}'.\n" "[test.cpp:9]: (portability) %Iu in format string (no. 2) requires 'size_t *' but the argument type is 'ptrdiff_t * {aka signed long long *}'.\n" "[test.cpp:9]: (portability) %Ix in format string (no. 3) requires 'size_t *' but the argument type is 'ptrdiff_t * {aka signed long long *}'.\n" @@ -4338,7 +4338,7 @@ class TestIO : public TestFixture { " scanf(\"%zd\", &s);\n" " scanf(\"%zd%i\", &s, &i);\n" " scanf(\"%zu\", &s);\n" - "}", false, true, cppcheck::Platform::Type::Win32A); + "}", false, true, Platform::Type::Win32A); ASSERT_EQUALS("[test.cpp:6]: (portability) %zu in format string (no. 1) requires 'size_t *' but the argument type is 'SSIZE_T * {aka signed long *}'.\n", errout.str()); check("void foo() {\n" @@ -4347,7 +4347,7 @@ class TestIO : public TestFixture { " scanf(\"%zd\", &s);\n" " scanf(\"%zd%i\", &s, &i);\n" " scanf(\"%zu\", &s);\n" - "}", false, true, cppcheck::Platform::Type::Win64); + "}", false, true, Platform::Type::Win64); ASSERT_EQUALS("[test.cpp:6]: (portability) %zu in format string (no. 1) requires 'size_t *' but the argument type is 'SSIZE_T * {aka signed long long *}'.\n", errout.str()); check("void foo() {\n" @@ -4356,7 +4356,7 @@ class TestIO : public TestFixture { " scanf(\"%zd\", &s);\n" " scanf(\"%zd%i\", &s, &i);\n" " scanf(\"%zu\", &s);\n" - "}", false, true, cppcheck::Platform::Type::Unix64); + "}", false, true, Platform::Type::Unix64); ASSERT_EQUALS("", errout.str()); check("void foo() {\n" @@ -4366,7 +4366,7 @@ class TestIO : public TestFixture { " scanf(\"%zd\", &s);\n" " scanf(\"%zd%i\", &s, &i);\n" " scanf(\"%zu\", &s);\n" - "}", false, true, cppcheck::Platform::Type::Win64); + "}", false, true, Platform::Type::Win64); ASSERT_EQUALS("[test.cpp:7]: (portability) %zu in format string (no. 1) requires 'size_t *' but the argument type is 'SSIZE_T * {aka signed long long *}'.\n", errout.str()); } @@ -4377,7 +4377,7 @@ class TestIO : public TestFixture { " String string;\n" " string.Format(\"%I32d\", u32);\n" " string.AppendFormat(\"%I32d\", u32);\n" - "}", false, true, cppcheck::Platform::Type::Win32A); + "}", false, true, Platform::Type::Win32A); ASSERT_EQUALS("", errout.str()); check("void foo() {\n" @@ -4385,7 +4385,7 @@ class TestIO : public TestFixture { " CString string;\n" " string.Format(\"%I32d\", u32);\n" " string.AppendFormat(\"%I32d\", u32);\n" - "}", false, true, cppcheck::Platform::Type::Unix32); + "}", false, true, Platform::Type::Unix32); ASSERT_EQUALS("", errout.str()); check("void foo() {\n" @@ -4394,7 +4394,7 @@ class TestIO : public TestFixture { " string.Format(\"%I32d\", u32);\n" " string.AppendFormat(\"%I32d\", u32);\n" " CString::Format(\"%I32d\", u32);\n" - "}", false, true, cppcheck::Platform::Type::Win32A); + "}", false, true, Platform::Type::Win32A); ASSERT_EQUALS("[test.cpp:4]: (portability) %I32d in format string (no. 1) requires '__int32' but the argument type is 'unsigned __int32 {aka unsigned int}'.\n" "[test.cpp:5]: (portability) %I32d in format string (no. 1) requires '__int32' but the argument type is 'unsigned __int32 {aka unsigned int}'.\n" "[test.cpp:6]: (portability) %I32d in format string (no. 1) requires '__int32' but the argument type is 'unsigned __int32 {aka unsigned int}'.\n", errout.str()); @@ -4405,7 +4405,7 @@ class TestIO : public TestFixture { " int i;\n" " unsigned int u;\n" " _tprintf_s(_T(\"%d %u\"), u, i, 0);\n" - "}\n", false, false, cppcheck::Platform::Type::Win32A); + "}\n", false, false, Platform::Type::Win32A); ASSERT_EQUALS("[test.cpp:4]: (warning) %d in format string (no. 1) requires 'int' but the argument type is 'unsigned int'.\n" "[test.cpp:4]: (warning) %u in format string (no. 2) requires 'unsigned int' but the argument type is 'signed int'.\n" "[test.cpp:4]: (warning) _tprintf_s format string requires 2 parameters but 3 are given.\n", errout.str()); @@ -4414,7 +4414,7 @@ class TestIO : public TestFixture { " int i;\n" " unsigned int u;\n" " _tprintf_s(_T(\"%d %u\"), u, i, 0);\n" - "}\n", false, false, cppcheck::Platform::Type::Win32W); + "}\n", false, false, Platform::Type::Win32W); ASSERT_EQUALS("[test.cpp:4]: (warning) %d in format string (no. 1) requires 'int' but the argument type is 'unsigned int'.\n" "[test.cpp:4]: (warning) %u in format string (no. 2) requires 'unsigned int' but the argument type is 'signed int'.\n" "[test.cpp:4]: (warning) _tprintf_s format string requires 2 parameters but 3 are given.\n", errout.str()); @@ -4423,7 +4423,7 @@ class TestIO : public TestFixture { " int i;\n" " unsigned int u;\n" " printf_s(\"%d %u\", u, i, 0);\n" - "}\n", false, false, cppcheck::Platform::Type::Win32A); + "}\n", false, false, Platform::Type::Win32A); ASSERT_EQUALS("[test.cpp:4]: (warning) %d in format string (no. 1) requires 'int' but the argument type is 'unsigned int'.\n" "[test.cpp:4]: (warning) %u in format string (no. 2) requires 'unsigned int' but the argument type is 'signed int'.\n" "[test.cpp:4]: (warning) printf_s format string requires 2 parameters but 3 are given.\n", errout.str()); @@ -4432,7 +4432,7 @@ class TestIO : public TestFixture { " int i;\n" " unsigned int u;\n" " wprintf_s(L\"%d %u\", u, i, 0);\n" - "}\n", false, false, cppcheck::Platform::Type::Win32W); + "}\n", false, false, Platform::Type::Win32W); ASSERT_EQUALS("[test.cpp:4]: (warning) %d in format string (no. 1) requires 'int' but the argument type is 'unsigned int'.\n" "[test.cpp:4]: (warning) %u in format string (no. 2) requires 'unsigned int' but the argument type is 'signed int'.\n" "[test.cpp:4]: (warning) wprintf_s format string requires 2 parameters but 3 are given.\n", errout.str()); @@ -4442,7 +4442,7 @@ class TestIO : public TestFixture { " int i;\n" " unsigned int u;\n" " _stprintf_s(str, sizeof(str) / sizeof(TCHAR), _T(\"%d %u\"), u, i, 0);\n" - "}\n", false, false, cppcheck::Platform::Type::Win32A); + "}\n", false, false, Platform::Type::Win32A); ASSERT_EQUALS("[test.cpp:5]: (warning) %d in format string (no. 1) requires 'int' but the argument type is 'unsigned int'.\n" "[test.cpp:5]: (warning) %u in format string (no. 2) requires 'unsigned int' but the argument type is 'signed int'.\n" "[test.cpp:5]: (warning) _stprintf_s format string requires 2 parameters but 3 are given.\n", errout.str()); @@ -4452,7 +4452,7 @@ class TestIO : public TestFixture { " int i;\n" " unsigned int u;\n" " _stprintf_s(str, sizeof(str) / sizeof(TCHAR), _T(\"%d %u\"), u, i, 0);\n" - "}\n", false, false, cppcheck::Platform::Type::Win32W); + "}\n", false, false, Platform::Type::Win32W); ASSERT_EQUALS("[test.cpp:5]: (warning) %d in format string (no. 1) requires 'int' but the argument type is 'unsigned int'.\n" "[test.cpp:5]: (warning) %u in format string (no. 2) requires 'unsigned int' but the argument type is 'signed int'.\n" "[test.cpp:5]: (warning) _stprintf_s format string requires 2 parameters but 3 are given.\n", errout.str()); @@ -4462,7 +4462,7 @@ class TestIO : public TestFixture { " int i;\n" " unsigned int u;\n" " sprintf_s(str, sizeof(str), \"%d %u\", u, i, 0);\n" - "}\n", false, false, cppcheck::Platform::Type::Win32A); + "}\n", false, false, Platform::Type::Win32A); ASSERT_EQUALS("[test.cpp:5]: (warning) %d in format string (no. 1) requires 'int' but the argument type is 'unsigned int'.\n" "[test.cpp:5]: (warning) %u in format string (no. 2) requires 'unsigned int' but the argument type is 'signed int'.\n" "[test.cpp:5]: (warning) sprintf_s format string requires 2 parameters but 3 are given.\n", errout.str()); @@ -4472,7 +4472,7 @@ class TestIO : public TestFixture { " int i;\n" " unsigned int u;\n" " sprintf_s(str, \"%d %u\", u, i, 0);\n" - "}\n", false, false, cppcheck::Platform::Type::Win32A); + "}\n", false, false, Platform::Type::Win32A); ASSERT_EQUALS("[test.cpp:5]: (warning) %d in format string (no. 1) requires 'int' but the argument type is 'unsigned int'.\n" "[test.cpp:5]: (warning) %u in format string (no. 2) requires 'unsigned int' but the argument type is 'signed int'.\n" "[test.cpp:5]: (warning) sprintf_s format string requires 2 parameters but 3 are given.\n", errout.str()); @@ -4482,7 +4482,7 @@ class TestIO : public TestFixture { " int i;\n" " unsigned int u;\n" " swprintf_s(str, sizeof(str) / sizeof(wchar_t), L\"%d %u\", u, i, 0);\n" - "}\n", false, false, cppcheck::Platform::Type::Win32W); + "}\n", false, false, Platform::Type::Win32W); ASSERT_EQUALS("[test.cpp:5]: (warning) %d in format string (no. 1) requires 'int' but the argument type is 'unsigned int'.\n" "[test.cpp:5]: (warning) %u in format string (no. 2) requires 'unsigned int' but the argument type is 'signed int'.\n" "[test.cpp:5]: (warning) swprintf_s format string requires 2 parameters but 3 are given.\n", errout.str()); @@ -4492,7 +4492,7 @@ class TestIO : public TestFixture { " int i;\n" " unsigned int u;\n" " swprintf_s(str, L\"%d %u\", u, i, 0);\n" - "}\n", false, false, cppcheck::Platform::Type::Win32W); + "}\n", false, false, Platform::Type::Win32W); ASSERT_EQUALS("[test.cpp:5]: (warning) %d in format string (no. 1) requires 'int' but the argument type is 'unsigned int'.\n" "[test.cpp:5]: (warning) %u in format string (no. 2) requires 'unsigned int' but the argument type is 'signed int'.\n" "[test.cpp:5]: (warning) swprintf_s format string requires 2 parameters but 3 are given.\n", errout.str()); @@ -4502,7 +4502,7 @@ class TestIO : public TestFixture { " int i;\n" " unsigned int u;\n" " _sntprintf_s(str, sizeof(str) / sizeof(TCHAR), _TRUNCATE, _T(\"%d %u\"), u, i, 0);\n" - "}\n", false, false, cppcheck::Platform::Type::Win32A); + "}\n", false, false, Platform::Type::Win32A); ASSERT_EQUALS("[test.cpp:5]: (warning) %d in format string (no. 1) requires 'int' but the argument type is 'unsigned int'.\n" "[test.cpp:5]: (warning) %u in format string (no. 2) requires 'unsigned int' but the argument type is 'signed int'.\n" "[test.cpp:5]: (warning) _sntprintf_s format string requires 2 parameters but 3 are given.\n", errout.str()); @@ -4512,7 +4512,7 @@ class TestIO : public TestFixture { " int i;\n" " unsigned int u;\n" " _sntprintf_s(str, sizeof(str) / sizeof(TCHAR), _TRUNCATE, _T(\"%d %u\"), u, i, 0);\n" - "}\n", false, false, cppcheck::Platform::Type::Win32W); + "}\n", false, false, Platform::Type::Win32W); ASSERT_EQUALS("[test.cpp:5]: (warning) %d in format string (no. 1) requires 'int' but the argument type is 'unsigned int'.\n" "[test.cpp:5]: (warning) %u in format string (no. 2) requires 'unsigned int' but the argument type is 'signed int'.\n" "[test.cpp:5]: (warning) _sntprintf_s format string requires 2 parameters but 3 are given.\n", errout.str()); @@ -4522,7 +4522,7 @@ class TestIO : public TestFixture { " int i;\n" " unsigned int u;\n" " _snprintf_s(str, sizeof(str), _TRUNCATE, \"%d %u\", u, i, 0);\n" - "}\n", false, false, cppcheck::Platform::Type::Win32A); + "}\n", false, false, Platform::Type::Win32A); ASSERT_EQUALS("[test.cpp:5]: (warning) %d in format string (no. 1) requires 'int' but the argument type is 'unsigned int'.\n" "[test.cpp:5]: (warning) %u in format string (no. 2) requires 'unsigned int' but the argument type is 'signed int'.\n" "[test.cpp:5]: (warning) _snprintf_s format string requires 2 parameters but 3 are given.\n", errout.str()); @@ -4532,7 +4532,7 @@ class TestIO : public TestFixture { " int i;\n" " unsigned int u;\n" " _snwprintf_s(str, sizeof(str) / sizeof(wchar_t), _TRUNCATE, L\"%d %u\", u, i, 0);\n" - "}\n", false, false, cppcheck::Platform::Type::Win32W); + "}\n", false, false, Platform::Type::Win32W); ASSERT_EQUALS("[test.cpp:5]: (warning) %d in format string (no. 1) requires 'int' but the argument type is 'unsigned int'.\n" "[test.cpp:5]: (warning) %u in format string (no. 2) requires 'unsigned int' but the argument type is 'signed int'.\n" "[test.cpp:5]: (warning) _snwprintf_s format string requires 2 parameters but 3 are given.\n", errout.str()); @@ -4541,7 +4541,7 @@ class TestIO : public TestFixture { " int i;\n" " unsigned int u;\n" " _ftprintf_s(fp, _T(\"%d %u\"), u, i, 0);\n" - "}\n", false, false, cppcheck::Platform::Type::Win32A); + "}\n", false, false, Platform::Type::Win32A); ASSERT_EQUALS("[test.cpp:4]: (warning) %d in format string (no. 1) requires 'int' but the argument type is 'unsigned int'.\n" "[test.cpp:4]: (warning) %u in format string (no. 2) requires 'unsigned int' but the argument type is 'signed int'.\n" "[test.cpp:4]: (warning) _ftprintf_s format string requires 2 parameters but 3 are given.\n", errout.str()); @@ -4550,7 +4550,7 @@ class TestIO : public TestFixture { " int i;\n" " unsigned int u;\n" " _ftprintf_s(fp, _T(\"%d %u\"), u, i, 0);\n" - "}\n", false, false, cppcheck::Platform::Type::Win32W); + "}\n", false, false, Platform::Type::Win32W); ASSERT_EQUALS("[test.cpp:4]: (warning) %d in format string (no. 1) requires 'int' but the argument type is 'unsigned int'.\n" "[test.cpp:4]: (warning) %u in format string (no. 2) requires 'unsigned int' but the argument type is 'signed int'.\n" "[test.cpp:4]: (warning) _ftprintf_s format string requires 2 parameters but 3 are given.\n", errout.str()); @@ -4559,7 +4559,7 @@ class TestIO : public TestFixture { " int i;\n" " unsigned int u;\n" " fprintf_s(fp, \"%d %u\", u, i, 0);\n" - "}\n", false, false, cppcheck::Platform::Type::Win32A); + "}\n", false, false, Platform::Type::Win32A); ASSERT_EQUALS("[test.cpp:4]: (warning) %d in format string (no. 1) requires 'int' but the argument type is 'unsigned int'.\n" "[test.cpp:4]: (warning) %u in format string (no. 2) requires 'unsigned int' but the argument type is 'signed int'.\n" "[test.cpp:4]: (warning) fprintf_s format string requires 2 parameters but 3 are given.\n", errout.str()); @@ -4568,7 +4568,7 @@ class TestIO : public TestFixture { " int i;\n" " unsigned int u;\n" " fwprintf_s(fp, L\"%d %u\", u, i, 0);\n" - "}\n", false, false, cppcheck::Platform::Type::Win32W); + "}\n", false, false, Platform::Type::Win32W); ASSERT_EQUALS("[test.cpp:4]: (warning) %d in format string (no. 1) requires 'int' but the argument type is 'unsigned int'.\n" "[test.cpp:4]: (warning) %u in format string (no. 2) requires 'unsigned int' but the argument type is 'signed int'.\n" "[test.cpp:4]: (warning) fwprintf_s format string requires 2 parameters but 3 are given.\n", errout.str()); @@ -4578,7 +4578,7 @@ class TestIO : public TestFixture { " const char * const format = \"%15s%17s%17s%17s%17s\";\n" " sprintf_s(lineBuffer, 600, format, \"type\", \"sum\", \"avg\", \"min\", \"max\");\n" " sprintf_s(lineBuffer, format, \"type\", \"sum\", \"avg\", \"min\", \"max\");\n" - "}\n", false, false, cppcheck::Platform::Type::Win32A); + "}\n", false, false, Platform::Type::Win32A); ASSERT_EQUALS("", errout.str()); check("void foo() {\n" @@ -4598,7 +4598,7 @@ class TestIO : public TestFixture { " sprintf_s(lineBuffer, 100, format1, \"type\", \"sum\", \"avg\", \"min\", i, 0);\n" " sprintf_s(lineBuffer, 100, format2, \"type\", \"sum\", \"avg\", \"min\", i, 0);\n" " sprintf_s(lineBuffer, 100, format3, \"type\", \"sum\", \"avg\", \"min\", i, 0);\n" - "}\n", true, false, cppcheck::Platform::Type::Win32A); + "}\n", true, false, Platform::Type::Win32A); ASSERT_EQUALS("[test.cpp:6]: (warning) %s in format string (no. 5) requires 'char *' but the argument type is 'signed int'.\n" "[test.cpp:6]: (warning) sprintf_s format string requires 5 parameters but 6 are given.\n" "[test.cpp:7]: (warning) %s in format string (no. 5) requires 'char *' but the argument type is 'signed int'.\n" @@ -4632,7 +4632,7 @@ class TestIO : public TestFixture { " unsigned int u;\n" " TCHAR str[10];\n" " _tscanf_s(_T(\"%s %d %u %[a-z]\"), str, 10, &u, &i, str, 10, 0)\n" - "}\n", false, false, cppcheck::Platform::Type::Win32A); + "}\n", false, false, Platform::Type::Win32A); ASSERT_EQUALS("[test.cpp:5]: (warning) %d in format string (no. 2) requires 'int *' but the argument type is 'unsigned int *'.\n" "[test.cpp:5]: (warning) %u in format string (no. 3) requires 'unsigned int *' but the argument type is 'signed int *'.\n" "[test.cpp:5]: (warning) _tscanf_s format string requires 6 parameters but 7 are given.\n", errout.str()); @@ -4642,7 +4642,7 @@ class TestIO : public TestFixture { " unsigned int u;\n" " TCHAR str[10];\n" " _tscanf_s(_T(\"%s %d %u %[a-z]\"), str, 10, &u, &i, str, 10, 0)\n" - "}\n", false, false, cppcheck::Platform::Type::Win32W); + "}\n", false, false, Platform::Type::Win32W); ASSERT_EQUALS("[test.cpp:5]: (warning) %d in format string (no. 2) requires 'int *' but the argument type is 'unsigned int *'.\n" "[test.cpp:5]: (warning) %u in format string (no. 3) requires 'unsigned int *' but the argument type is 'signed int *'.\n" "[test.cpp:5]: (warning) _tscanf_s format string requires 6 parameters but 7 are given.\n", errout.str()); @@ -4652,7 +4652,7 @@ class TestIO : public TestFixture { " unsigned int u;\n" " char str[10];\n" " scanf_s(\"%s %d %u %[a-z]\", str, 10, &u, &i, str, 10, 0)\n" - "}\n", false, false, cppcheck::Platform::Type::Win32A); + "}\n", false, false, Platform::Type::Win32A); ASSERT_EQUALS("[test.cpp:5]: (warning) %d in format string (no. 2) requires 'int *' but the argument type is 'unsigned int *'.\n" "[test.cpp:5]: (warning) %u in format string (no. 3) requires 'unsigned int *' but the argument type is 'signed int *'.\n" "[test.cpp:5]: (warning) scanf_s format string requires 6 parameters but 7 are given.\n", errout.str()); @@ -4662,7 +4662,7 @@ class TestIO : public TestFixture { " unsigned int u;\n" " wchar_t str[10];\n" " wscanf_s(L\"%s %d %u %[a-z]\", str, 10, &u, &i, str, 10, 0)\n" - "}\n", false, false, cppcheck::Platform::Type::Win32W); + "}\n", false, false, Platform::Type::Win32W); ASSERT_EQUALS("[test.cpp:5]: (warning) %d in format string (no. 2) requires 'int *' but the argument type is 'unsigned int *'.\n" "[test.cpp:5]: (warning) %u in format string (no. 3) requires 'unsigned int *' but the argument type is 'signed int *'.\n" "[test.cpp:5]: (warning) wscanf_s format string requires 6 parameters but 7 are given.\n", errout.str()); @@ -4674,7 +4674,7 @@ class TestIO : public TestFixture { "}\n", false, false, - cppcheck::Platform::Type::Win32A); + Platform::Type::Win32A); ASSERT_EQUALS("[test.cpp:4]: (error) Width 9 given in format string (no. 1) is larger than destination buffer 'str[8]', use %8c to prevent overflowing it.\n", errout.str()); check("void foo() {\n" @@ -4683,7 +4683,7 @@ class TestIO : public TestFixture { " unsigned int u;\n" " TCHAR str[10];\n" " _stscanf_s(txt, _T(\"%s %d %u %[a-z]\"), str, 10, &u, &i, str, 10, 0)\n" - "}\n", false, false, cppcheck::Platform::Type::Win32A); + "}\n", false, false, Platform::Type::Win32A); ASSERT_EQUALS("[test.cpp:6]: (warning) %d in format string (no. 2) requires 'int *' but the argument type is 'unsigned int *'.\n" "[test.cpp:6]: (warning) %u in format string (no. 3) requires 'unsigned int *' but the argument type is 'signed int *'.\n" "[test.cpp:6]: (warning) _stscanf_s format string requires 6 parameters but 7 are given.\n", errout.str()); @@ -4694,7 +4694,7 @@ class TestIO : public TestFixture { " unsigned int u;\n" " TCHAR str[10];\n" " _stscanf_s(txt, _T(\"%s %d %u %[a-z]\"), str, 10, &u, &i, str, 10, 0)\n" - "}\n", false, false, cppcheck::Platform::Type::Win32W); + "}\n", false, false, Platform::Type::Win32W); ASSERT_EQUALS("[test.cpp:6]: (warning) %d in format string (no. 2) requires 'int *' but the argument type is 'unsigned int *'.\n" "[test.cpp:6]: (warning) %u in format string (no. 3) requires 'unsigned int *' but the argument type is 'signed int *'.\n" "[test.cpp:6]: (warning) _stscanf_s format string requires 6 parameters but 7 are given.\n", errout.str()); @@ -4705,7 +4705,7 @@ class TestIO : public TestFixture { " unsigned int u;\n" " char str[10];\n" " sscanf_s(txt, \"%s %d %u %[a-z]\", str, 10, &u, &i, str, 10, 0)\n" - "}\n", false, false, cppcheck::Platform::Type::Win32A); + "}\n", false, false, Platform::Type::Win32A); ASSERT_EQUALS("[test.cpp:6]: (warning) %d in format string (no. 2) requires 'int *' but the argument type is 'unsigned int *'.\n" "[test.cpp:6]: (warning) %u in format string (no. 3) requires 'unsigned int *' but the argument type is 'signed int *'.\n" "[test.cpp:6]: (warning) sscanf_s format string requires 6 parameters but 7 are given.\n", errout.str()); @@ -4716,7 +4716,7 @@ class TestIO : public TestFixture { " unsigned int u;\n" " wchar_t str[10];\n" " swscanf_s(txt, L\"%s %d %u %[a-z]\", str, 10, &u, &i, str, 10, 0)\n" - "}\n", false, false, cppcheck::Platform::Type::Win32W); + "}\n", false, false, Platform::Type::Win32W); ASSERT_EQUALS("[test.cpp:6]: (warning) %d in format string (no. 2) requires 'int *' but the argument type is 'unsigned int *'.\n" "[test.cpp:6]: (warning) %u in format string (no. 3) requires 'unsigned int *' but the argument type is 'signed int *'.\n" "[test.cpp:6]: (warning) swscanf_s format string requires 6 parameters but 7 are given.\n", errout.str()); @@ -4726,7 +4726,7 @@ class TestIO : public TestFixture { " unsigned int u;\n" " TCHAR str[10];\n" " _ftscanf_s(fp, _T(\"%s %d %u %[a-z]\"), str, 10, &u, &i, str, 10, 0)\n" - "}\n", false, false, cppcheck::Platform::Type::Win32A); + "}\n", false, false, Platform::Type::Win32A); ASSERT_EQUALS("[test.cpp:5]: (warning) %d in format string (no. 2) requires 'int *' but the argument type is 'unsigned int *'.\n" "[test.cpp:5]: (warning) %u in format string (no. 3) requires 'unsigned int *' but the argument type is 'signed int *'.\n" "[test.cpp:5]: (warning) _ftscanf_s format string requires 6 parameters but 7 are given.\n", errout.str()); @@ -4736,7 +4736,7 @@ class TestIO : public TestFixture { " unsigned int u;\n" " TCHAR str[10];\n" " _ftscanf_s(fp, _T(\"%s %d %u %[a-z]\"), str, 10, &u, &i, str, 10, 0)\n" - "}\n", false, false, cppcheck::Platform::Type::Win32W); + "}\n", false, false, Platform::Type::Win32W); ASSERT_EQUALS("[test.cpp:5]: (warning) %d in format string (no. 2) requires 'int *' but the argument type is 'unsigned int *'.\n" "[test.cpp:5]: (warning) %u in format string (no. 3) requires 'unsigned int *' but the argument type is 'signed int *'.\n" "[test.cpp:5]: (warning) _ftscanf_s format string requires 6 parameters but 7 are given.\n", errout.str()); @@ -4746,7 +4746,7 @@ class TestIO : public TestFixture { " unsigned int u;\n" " char str[10];\n" " fscanf_s(fp, \"%s %d %u %[a-z]\", str, 10, &u, &i, str, 10, 0)\n" - "}\n", false, false, cppcheck::Platform::Type::Win32A); + "}\n", false, false, Platform::Type::Win32A); ASSERT_EQUALS("[test.cpp:5]: (warning) %d in format string (no. 2) requires 'int *' but the argument type is 'unsigned int *'.\n" "[test.cpp:5]: (warning) %u in format string (no. 3) requires 'unsigned int *' but the argument type is 'signed int *'.\n" "[test.cpp:5]: (warning) fscanf_s format string requires 6 parameters but 7 are given.\n", errout.str()); @@ -4756,7 +4756,7 @@ class TestIO : public TestFixture { " unsigned int u;\n" " wchar_t str[10];\n" " fwscanf_s(fp, L\"%s %d %u %[a-z]\", str, 10, &u, &i, str, 10, 0)\n" - "}\n", false, false, cppcheck::Platform::Type::Win32W); + "}\n", false, false, Platform::Type::Win32W); ASSERT_EQUALS("[test.cpp:5]: (warning) %d in format string (no. 2) requires 'int *' but the argument type is 'unsigned int *'.\n" "[test.cpp:5]: (warning) %u in format string (no. 3) requires 'unsigned int *' but the argument type is 'signed int *'.\n" "[test.cpp:5]: (warning) fwscanf_s format string requires 6 parameters but 7 are given.\n", errout.str()); @@ -4764,7 +4764,7 @@ class TestIO : public TestFixture { check("void foo() {\n" " WCHAR msStr1[5] = {0};\n" " wscanf_s(L\"%4[^-]\", msStr1, _countof(msStr1));\n" - "}\n", false, false, cppcheck::Platform::Type::Win32W); + "}\n", false, false, Platform::Type::Win32W); ASSERT_EQUALS("", errout.str()); } @@ -4772,13 +4772,13 @@ class TestIO : public TestFixture { check("void foo(float f) {\n" " QString string;\n" " string.sprintf(\"%d\", f);\n" - "}", false, false, cppcheck::Platform::Type::Win32A); + "}", false, false, Platform::Type::Win32A); ASSERT_EQUALS("[test.cpp:3]: (warning) %d in format string (no. 1) requires 'int' but the argument type is 'float'.\n", errout.str()); check("void foo(float f) {\n" " QString string;\n" " string = QString::asprintf(\"%d\", f);\n" - "}", false, false, cppcheck::Platform::Type::Win32A); + "}", false, false, Platform::Type::Win32A); ASSERT_EQUALS("[test.cpp:3]: (warning) %d in format string (no. 1) requires 'int' but the argument type is 'float'.\n", errout.str()); } @@ -4838,7 +4838,7 @@ class TestIO : public TestFixture { // 8141 check("void f(int i) {\n" " printf(\"%f\", imaxabs(i));\n" - "}\n", false, true, cppcheck::Platform::Type::Unix64); + "}\n", false, true, Platform::Type::Unix64); ASSERT_EQUALS("[test.cpp:2]: (portability) %f in format string (no. 1) requires 'double' but the argument type is 'intmax_t {aka signed long}'.\n", errout.str()); } diff --git a/test/testother.cpp b/test/testother.cpp index eede3d6949b..0a2c804cc26 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -353,7 +353,7 @@ class TestOther : public TestFixture { void checkInterlockedDecrement(const char code[]) { Settings settings; - settings.platform.type = cppcheck::Platform::Type::Win32A; + settings.platform.type = Platform::Type::Win32A; check(code, nullptr, false, true, false, &settings); } @@ -2159,7 +2159,7 @@ class TestOther : public TestFixture { "T::T(std::string s) noexcept(true) : m(std::move(s)) {}\n"); ASSERT_EQUALS("", errout.str()); - Settings settings1 = settingsBuilder().platform(cppcheck::Platform::Type::Win64).build(); + Settings settings1 = settingsBuilder().platform(Platform::Type::Win64).build(); check("using ui64 = unsigned __int64;\n" "ui64 Test(ui64 one, ui64 two) { return one + two; }\n", /*filename*/ nullptr, /*inconclusive*/ true, /*runSimpleChecks*/ true, /*verbose*/ false, &settings1); @@ -2304,11 +2304,11 @@ class TestOther : public TestFixture { "};\n" "void f(X x) {}"; - Settings s32 = settingsBuilder(_settings).platform(cppcheck::Platform::Type::Unix32).build(); + Settings s32 = settingsBuilder(_settings).platform(Platform::Type::Unix32).build(); check(code, &s32); ASSERT_EQUALS("[test.cpp:5]: (performance) Function parameter 'x' should be passed by const reference.\n", errout.str()); - Settings s64 = settingsBuilder(_settings).platform(cppcheck::Platform::Type::Unix64).build(); + Settings s64 = settingsBuilder(_settings).platform(Platform::Type::Unix64).build(); check(code, &s64); ASSERT_EQUALS("", errout.str()); } @@ -7926,7 +7926,7 @@ class TestOther : public TestFixture { ASSERT_EQUALS("[test.cpp:3]: (style) Checking if unsigned expression 'value' is less than zero.\n", errout.str()); // #9040 - Settings settings1 = settingsBuilder().platform(cppcheck::Platform::Type::Win64).build(); + Settings settings1 = settingsBuilder().platform(Platform::Type::Win64).build(); check("using BOOL = unsigned;\n" "int i;\n" "bool f() {\n" diff --git a/test/testplatform.cpp b/test/testplatform.cpp index 7dbb24789b6..06bce2138f4 100644 --- a/test/testplatform.cpp +++ b/test/testplatform.cpp @@ -43,7 +43,7 @@ class TestPlatform : public TestFixture { TEST_CASE(default_platform); } - static bool readPlatform(cppcheck::Platform& platform, const char* xmldata) { + static bool readPlatform(Platform& platform, const char* xmldata) { tinyxml2::XMLDocument doc; return (doc.Parse(xmldata) == tinyxml2::XML_SUCCESS) && platform.loadFromXmlDocument(&doc); } @@ -51,16 +51,16 @@ class TestPlatform : public TestFixture { void empty() const { // An empty platform file does not change values, only the type. const char xmldata[] = "\n"; - cppcheck::Platform platform; + Platform platform; // TODO: this should fail - platform files need to be complete TODO_ASSERT(!readPlatform(platform, xmldata)); } void valid_config_win32a() const { // Verify if native Win32A platform is loaded correctly - cppcheck::Platform platform; - PLATFORM(platform, cppcheck::Platform::Type::Win32A); - ASSERT_EQUALS(cppcheck::Platform::Type::Win32A, platform.type); + Platform platform; + PLATFORM(platform, Platform::Type::Win32A); + ASSERT_EQUALS(Platform::Type::Win32A, platform.type); ASSERT(platform.isWindows()); ASSERT_EQUALS(1, platform.sizeof_bool); ASSERT_EQUALS(2, platform.sizeof_short); @@ -83,9 +83,9 @@ class TestPlatform : public TestFixture { void valid_config_unix64() const { // Verify if native Unix64 platform is loaded correctly - cppcheck::Platform platform; - PLATFORM(platform, cppcheck::Platform::Type::Unix64); - ASSERT_EQUALS(cppcheck::Platform::Type::Unix64, platform.type); + Platform platform; + PLATFORM(platform, Platform::Type::Unix64); + ASSERT_EQUALS(Platform::Type::Unix64, platform.type); ASSERT(!platform.isWindows()); ASSERT_EQUALS(1, platform.sizeof_bool); ASSERT_EQUALS(2, platform.sizeof_short); @@ -108,9 +108,9 @@ class TestPlatform : public TestFixture { void valid_config_win32w() const { // Verify if native Win32W platform is loaded correctly - cppcheck::Platform platform; - PLATFORM(platform, cppcheck::Platform::Type::Win32W); - ASSERT_EQUALS(cppcheck::Platform::Type::Win32W, platform.type); + Platform platform; + PLATFORM(platform, Platform::Type::Win32W); + ASSERT_EQUALS(Platform::Type::Win32W, platform.type); ASSERT(platform.isWindows()); ASSERT_EQUALS(1, platform.sizeof_bool); ASSERT_EQUALS(2, platform.sizeof_short); @@ -133,9 +133,9 @@ class TestPlatform : public TestFixture { void valid_config_unix32() const { // Verify if native Unix32 platform is loaded correctly - cppcheck::Platform platform; - PLATFORM(platform, cppcheck::Platform::Type::Unix32); - ASSERT_EQUALS(cppcheck::Platform::Type::Unix32, platform.type); + Platform platform; + PLATFORM(platform, Platform::Type::Unix32); + ASSERT_EQUALS(Platform::Type::Unix32, platform.type); ASSERT(!platform.isWindows()); ASSERT_EQUALS(1, platform.sizeof_bool); ASSERT_EQUALS(2, platform.sizeof_short); @@ -158,9 +158,9 @@ class TestPlatform : public TestFixture { void valid_config_win64() const { // Verify if native Win64 platform is loaded correctly - cppcheck::Platform platform; - PLATFORM(platform, cppcheck::Platform::Type::Win64); - ASSERT_EQUALS(cppcheck::Platform::Type::Win64, platform.type); + Platform platform; + PLATFORM(platform, Platform::Type::Win64); + ASSERT_EQUALS(Platform::Type::Win64, platform.type); ASSERT(platform.isWindows()); ASSERT_EQUALS(1, platform.sizeof_bool); ASSERT_EQUALS(2, platform.sizeof_short); @@ -202,9 +202,9 @@ class TestPlatform : public TestFixture { " 2\n" " \n" " "; - cppcheck::Platform platform; + Platform platform; ASSERT(readPlatform(platform, xmldata)); - ASSERT_EQUALS(cppcheck::Platform::Type::File, platform.type); + ASSERT_EQUALS(Platform::Type::File, platform.type); ASSERT(!platform.isWindows()); ASSERT_EQUALS(8, platform.char_bit); ASSERT_EQUALS('u', platform.defaultSign); @@ -246,9 +246,9 @@ class TestPlatform : public TestFixture { " 11\n" " \n" " "; - cppcheck::Platform platform; + Platform platform; ASSERT(readPlatform(platform, xmldata)); - ASSERT_EQUALS(cppcheck::Platform::Type::File, platform.type); + ASSERT_EQUALS(Platform::Type::File, platform.type); ASSERT(!platform.isWindows()); ASSERT_EQUALS(20, platform.char_bit); ASSERT_EQUALS('s', platform.defaultSign); @@ -290,7 +290,7 @@ class TestPlatform : public TestFixture { " 11\n" " \n" " "; - cppcheck::Platform platform; + Platform platform; // TODO: needs to fail - files need to be complete TODO_ASSERT(!readPlatform(platform, xmldata)); } @@ -316,9 +316,9 @@ class TestPlatform : public TestFixture { " 0\n" " \n" " "; - cppcheck::Platform platform; + Platform platform; ASSERT(readPlatform(platform, xmldata)); - ASSERT_EQUALS(cppcheck::Platform::Type::File, platform.type); + ASSERT_EQUALS(Platform::Type::File, platform.type); ASSERT(!platform.isWindows()); ASSERT_EQUALS(0, platform.char_bit); ASSERT_EQUALS('z', platform.defaultSign); @@ -359,7 +359,7 @@ class TestPlatform : public TestFixture { " 2\n" " \n" " "; - cppcheck::Platform platform; + Platform platform; ASSERT(!readPlatform(platform, xmldata)); } @@ -384,13 +384,13 @@ class TestPlatform : public TestFixture { " \n" " \n" " "; - cppcheck::Platform platform; + Platform platform; ASSERT(!readPlatform(platform, xmldata)); } void default_platform() const { - cppcheck::Platform platform; - ASSERT_EQUALS(cppcheck::Platform::Type::Native, platform.type); + Platform platform; + ASSERT_EQUALS(Platform::Type::Native, platform.type); } }; diff --git a/test/testpreprocessor.cpp b/test/testpreprocessor.cpp index a696d006c8b..86effdcaea6 100644 --- a/test/testpreprocessor.cpp +++ b/test/testpreprocessor.cpp @@ -480,7 +480,7 @@ class TestPreprocessor : public TestFixture { // preprocess code with unix32 platform.. { - const Settings settings = settingsBuilder().platform(cppcheck::Platform::Type::Unix32).build(); + const Settings settings = settingsBuilder().platform(Platform::Type::Unix32).build(); Preprocessor preprocessor(settings, this); preprocessor.setPlatformInfo(&tokens); ASSERT_EQUALS("\n1", preprocessor.getcode(tokens, "", files, false)); @@ -488,7 +488,7 @@ class TestPreprocessor : public TestFixture { // preprocess code with unix64 platform.. { - const Settings settings = settingsBuilder().platform(cppcheck::Platform::Type::Unix64).build(); + const Settings settings = settingsBuilder().platform(Platform::Type::Unix64).build(); Preprocessor preprocessor(settings, this); preprocessor.setPlatformInfo(&tokens); ASSERT_EQUALS("\n\n\n2", preprocessor.getcode(tokens, "", files, false)); diff --git a/test/testsimplifytemplate.cpp b/test/testsimplifytemplate.cpp index f6294b17a4c..752d5d85ec7 100644 --- a/test/testsimplifytemplate.cpp +++ b/test/testsimplifytemplate.cpp @@ -307,7 +307,7 @@ class TestSimplifyTemplate : public TestFixture { } #define tok(...) tok_(__FILE__, __LINE__, __VA_ARGS__) - std::string tok_(const char* file, int line, const char code[], bool debugwarnings = false, cppcheck::Platform::Type type = cppcheck::Platform::Type::Native) { + std::string tok_(const char* file, int line, const char code[], bool debugwarnings = false, Platform::Type type = Platform::Type::Native) { errout.str(""); const Settings settings1 = settingsBuilder(settings).library("std.cfg").debugwarnings(debugwarnings).platform(type).build(); diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index 1e633a0f0b2..184575784b1 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -163,7 +163,7 @@ class TestSimplifyTokens : public TestFixture { } #define tok(...) tok_(__FILE__, __LINE__, __VA_ARGS__) - std::string tok_(const char* file, int line, const char code[], bool simplify = true, cppcheck::Platform::Type type = cppcheck::Platform::Type::Native) { + std::string tok_(const char* file, int line, const char code[], bool simplify = true, Platform::Type type = Platform::Type::Native) { errout.str(""); const Settings settings = settingsBuilder(settings0).platform(type).build(); @@ -189,7 +189,7 @@ class TestSimplifyTokens : public TestFixture { } #define tokenizeAndStringify(...) tokenizeAndStringify_(__FILE__, __LINE__, __VA_ARGS__) - std::string tokenizeAndStringify_(const char* file, int linenr, const char code[], bool simplify = false, bool expand = true, cppcheck::Platform::Type platform = cppcheck::Platform::Type::Native, const char* filename = "test.cpp", bool cpp11 = true) { + std::string tokenizeAndStringify_(const char* file, int linenr, const char code[], bool simplify = false, bool expand = true, Platform::Type platform = Platform::Type::Native, const char* filename = "test.cpp", bool cpp11 = true) { errout.str(""); const Settings settings = settingsBuilder(settings1).debugwarnings().platform(platform).cpp(cpp11 ? Standards::CPP11 : Standards::CPP03).build(); @@ -252,10 +252,10 @@ class TestSimplifyTokens : public TestFixture { ASSERT_EQUALS(tok(code2), tok(code1)); const char code3[] = "x = L\"1\" TEXT(\"2\") L\"3\";"; - ASSERT_EQUALS("x = L\"123\" ;", tok(code3, false, cppcheck::Platform::Type::Win64)); + ASSERT_EQUALS("x = L\"123\" ;", tok(code3, false, Platform::Type::Win64)); const char code4[] = "x = TEXT(\"1\") L\"2\";"; - ASSERT_EQUALS("x = L\"1\" L\"2\" ;", tok(code4, false, cppcheck::Platform::Type::Win64)); + ASSERT_EQUALS("x = L\"1\" L\"2\" ;", tok(code4, false, Platform::Type::Win64)); } void combine_wstrings() { @@ -1300,12 +1300,12 @@ class TestSimplifyTokens : public TestFixture { ASSERT_EQUALS("int f ( ) ;", tok("int __far __syscall f();")); ASSERT_EQUALS("int f ( ) ;", tok("int __far __pascal f();")); ASSERT_EQUALS("int f ( ) ;", tok("int __far __fortran f();")); - ASSERT_EQUALS("int f ( ) ;", tok("int WINAPI f();", true, cppcheck::Platform::Type::Win32A)); - ASSERT_EQUALS("int f ( ) ;", tok("int APIENTRY f();", true, cppcheck::Platform::Type::Win32A)); - ASSERT_EQUALS("int f ( ) ;", tok("int CALLBACK f();", true, cppcheck::Platform::Type::Win32A)); + ASSERT_EQUALS("int f ( ) ;", tok("int WINAPI f();", true, Platform::Type::Win32A)); + ASSERT_EQUALS("int f ( ) ;", tok("int APIENTRY f();", true, Platform::Type::Win32A)); + ASSERT_EQUALS("int f ( ) ;", tok("int CALLBACK f();", true, Platform::Type::Win32A)); // don't simplify Microsoft defines in unix code (#7554) - ASSERT_EQUALS("enum E { CALLBACK } ;", tok("enum E { CALLBACK } ;", true, cppcheck::Platform::Type::Unix32)); + ASSERT_EQUALS("enum E { CALLBACK } ;", tok("enum E { CALLBACK } ;", true, Platform::Type::Unix32)); } void simplifyAttribute() { @@ -2033,7 +2033,7 @@ class TestSimplifyTokens : public TestFixture { "strcpy ( a , \"hello\" ) ;\n" "strcat ( a , \"!\" ) ;\n" "}"; - ASSERT_EQUALS(expected, tokenizeAndStringify(code, true, true, cppcheck::Platform::Type::Native, "test.c")); + ASSERT_EQUALS(expected, tokenizeAndStringify(code, true, true, Platform::Type::Native, "test.c")); } { @@ -2129,7 +2129,7 @@ class TestSimplifyTokens : public TestFixture { "cin >> x ;\n" "return x ;\n" "}"; - ASSERT_EQUALS(expected, tokenizeAndStringify(code, true, true, cppcheck::Platform::Type::Native, "test.cpp")); + ASSERT_EQUALS(expected, tokenizeAndStringify(code, true, true, Platform::Type::Native, "test.cpp")); } } @@ -2143,7 +2143,7 @@ class TestSimplifyTokens : public TestFixture { "int x ; x = 0 ;\n" "cin >> std :: hex >> x ;\n" "}"; - ASSERT_EQUALS(expected, tokenizeAndStringify(code, true, true, cppcheck::Platform::Type::Native, "test.cpp")); + ASSERT_EQUALS(expected, tokenizeAndStringify(code, true, true, Platform::Type::Native, "test.cpp")); } void simplifyKnownVariables48() { @@ -2156,7 +2156,7 @@ class TestSimplifyTokens : public TestFixture { "int i ;\n" "for ( i = 0 ; ( i < sz ) && ( sz > 3 ) ; ++ i ) { }\n" "}"; - ASSERT_EQUALS(expected, tokenizeAndStringify(code, true, true, cppcheck::Platform::Type::Native, "test.c")); + ASSERT_EQUALS(expected, tokenizeAndStringify(code, true, true, Platform::Type::Native, "test.c")); } void simplifyKnownVariables49() { // #3691 @@ -2172,7 +2172,7 @@ class TestSimplifyTokens : public TestFixture { "case 2 : ; x = sz ; break ;\n" "}\n" "}"; - ASSERT_EQUALS(expected, tokenizeAndStringify(code, true, true, cppcheck::Platform::Type::Native, "test.c")); + ASSERT_EQUALS(expected, tokenizeAndStringify(code, true, true, Platform::Type::Native, "test.c")); } void simplifyKnownVariables50() { // #4066 diff --git a/test/testsimplifytypedef.cpp b/test/testsimplifytypedef.cpp index 68468addd46..e845fa7da82 100644 --- a/test/testsimplifytypedef.cpp +++ b/test/testsimplifytypedef.cpp @@ -228,7 +228,7 @@ class TestSimplifyTypedef : public TestFixture { } #define tok(...) tok_(__FILE__, __LINE__, __VA_ARGS__) - std::string tok_(const char* file, int line, const char code[], bool simplify = true, cppcheck::Platform::Type type = cppcheck::Platform::Type::Native, bool debugwarnings = true) { + std::string tok_(const char* file, int line, const char code[], bool simplify = true, Platform::Type type = Platform::Type::Native, bool debugwarnings = true) { errout.str(""); // show warnings about unhandled typedef @@ -788,7 +788,7 @@ class TestSimplifyTypedef : public TestFixture { "};"; // Tokenize and check output.. - TODO_ASSERT_THROW(tok(code, true, cppcheck::Platform::Type::Native, false), InternalError); // TODO: Do not throw exception + TODO_ASSERT_THROW(tok(code, true, Platform::Type::Native, false), InternalError); // TODO: Do not throw exception //ASSERT_EQUALS("", errout.str()); } @@ -1876,7 +1876,7 @@ class TestSimplifyTypedef : public TestFixture { // The expected tokens.. const char expected2[] = "void f ( ) { char a [ 256 ] = { 0 } ; char b [ 256 ] = { 0 } ; }"; - ASSERT_EQUALS(expected2, tok(code2, false, cppcheck::Platform::Type::Native, false)); + ASSERT_EQUALS(expected2, tok(code2, false, Platform::Type::Native, false)); ASSERT_EQUALS("", errout.str()); const char code3[] = "typedef char TString[256];\n" @@ -1887,7 +1887,7 @@ class TestSimplifyTypedef : public TestFixture { // The expected tokens.. const char expected3[] = "void f ( ) { char a [ 256 ] ; a = \"\" ; char b [ 256 ] ; b = \"\" ; }"; - ASSERT_EQUALS(expected3, tok(code3, false, cppcheck::Platform::Type::Native, false)); + ASSERT_EQUALS(expected3, tok(code3, false, Platform::Type::Native, false)); ASSERT_EQUALS("", errout.str()); const char code4[] = "typedef char TString[256];\n" @@ -1898,7 +1898,7 @@ class TestSimplifyTypedef : public TestFixture { // The expected tokens.. const char expected4[] = "void f ( ) { char a [ 256 ] ; a = \"1234\" ; char b [ 256 ] ; b = \"5678\" ; }"; - ASSERT_EQUALS(expected4, tok(code4, false, cppcheck::Platform::Type::Native, false)); + ASSERT_EQUALS(expected4, tok(code4, false, Platform::Type::Native, false)); ASSERT_EQUALS("", errout.str()); } @@ -1924,7 +1924,7 @@ class TestSimplifyTypedef : public TestFixture { " Foo b(0);\n" " return b > Foo(10);\n" "}"; - const std::string actual(tok(code, true, cppcheck::Platform::Type::Native, false)); + const std::string actual(tok(code, true, Platform::Type::Native, false)); ASSERT_EQUALS("int main ( ) { BAR < int > b ( 0 ) ; return b > BAR < int > ( 10 ) ; }", actual); ASSERT_EQUALS("", errout.str()); } @@ -2082,7 +2082,7 @@ class TestSimplifyTypedef : public TestFixture { void simplifyTypedef75() { // ticket #2426 const char code[] = "typedef _Packed struct S { long l; };"; - ASSERT_EQUALS(";", tok(code, true, cppcheck::Platform::Type::Native, false)); + ASSERT_EQUALS(";", tok(code, true, Platform::Type::Native, false)); ASSERT_EQUALS("", errout.str()); } @@ -2404,7 +2404,7 @@ class TestSimplifyTypedef : public TestFixture { "public: " "expression_error :: error_code ( * f ) ( void * , const char * , expression_space ) ; " "} ;"; - ASSERT_EQUALS(expected, tok(code, true, cppcheck::Platform::Type::Native, false)); + ASSERT_EQUALS(expected, tok(code, true, Platform::Type::Native, false)); ASSERT_EQUALS("", errout.str()); } @@ -2568,7 +2568,7 @@ class TestSimplifyTypedef : public TestFixture { "} ; " "} " "}"; - ASSERT_EQUALS(expected, tok(code, true, cppcheck::Platform::Type::Native, false)); + ASSERT_EQUALS(expected, tok(code, true, Platform::Type::Native, false)); ASSERT_EQUALS("", errout.str()); } @@ -3046,7 +3046,7 @@ class TestSimplifyTypedef : public TestFixture { "void A :: f ( external :: ns1 :: B<1> ) { } " "} " "struct external :: ns1 :: B<1> { } ;"; - ASSERT_EQUALS(exp, tok(code, true, cppcheck::Platform::Type::Native, true)); + ASSERT_EQUALS(exp, tok(code, true, Platform::Type::Native, true)); ASSERT_EQUALS("", errout.str()); } { @@ -3079,7 +3079,7 @@ class TestSimplifyTypedef : public TestFixture { "void A :: f ( external :: ns1 :: B<1> ) { } " "} " "struct external :: ns1 :: B<1> { } ;"; - ASSERT_EQUALS(exp, tok(code, true, cppcheck::Platform::Type::Native, true)); + ASSERT_EQUALS(exp, tok(code, true, Platform::Type::Native, true)); ASSERT_EQUALS("", errout.str()); } { @@ -3129,7 +3129,7 @@ class TestSimplifyTypedef : public TestFixture { "void A :: f ( V ) { } " "} " "struct external :: ns1 :: B<1> { } ;"; - TODO_ASSERT_EQUALS(exp, act, tok(code, true, cppcheck::Platform::Type::Native, true)); + TODO_ASSERT_EQUALS(exp, act, tok(code, true, Platform::Type::Native, true)); TODO_ASSERT_EQUALS("", "[test.cpp:14]: (debug) Executable scope 'f' with unknown function.\n", errout.str()); } { @@ -3178,7 +3178,7 @@ class TestSimplifyTypedef : public TestFixture { "namespace ns { " "void A :: f ( V ) { } " "}"; - TODO_ASSERT_EQUALS(exp, act, tok(code, true, cppcheck::Platform::Type::Native, true)); + TODO_ASSERT_EQUALS(exp, act, tok(code, true, Platform::Type::Native, true)); ASSERT_EQUALS("", errout.str()); } { @@ -3208,7 +3208,7 @@ class TestSimplifyTypedef : public TestFixture { "void A :: f ( external :: B<1> ) { } " "} " "struct external :: B<1> { } ;"; - ASSERT_EQUALS(exp, tok(code, true, cppcheck::Platform::Type::Native, true)); + ASSERT_EQUALS(exp, tok(code, true, Platform::Type::Native, true)); ASSERT_EQUALS("", errout.str()); } { @@ -3236,7 +3236,7 @@ class TestSimplifyTypedef : public TestFixture { "void A :: f ( B<1> ) { } " "} " "struct B<1> { } ;"; - ASSERT_EQUALS(exp, tok(code, true, cppcheck::Platform::Type::Native, true)); + ASSERT_EQUALS(exp, tok(code, true, Platform::Type::Native, true)); ASSERT_EQUALS("", errout.str()); } } @@ -3654,7 +3654,7 @@ class TestSimplifyTypedef : public TestFixture { "C ( * f5 ) ( ) ; " "C ( * f6 ) ( ) ; " "C ( * f7 ) ( ) ;"; - ASSERT_EQUALS(expected, tok(code, true, cppcheck::Platform::Type::Native, false)); + ASSERT_EQUALS(expected, tok(code, true, Platform::Type::Native, false)); ASSERT_EQUALS("", errout.str()); } @@ -3683,7 +3683,7 @@ class TestSimplifyTypedef : public TestFixture { "const C ( * f5 ) ( ) ; " "const C ( * f6 ) ( ) ; " "const C ( * f7 ) ( ) ;"; - ASSERT_EQUALS(expected, tok(code, true, cppcheck::Platform::Type::Native, false)); + ASSERT_EQUALS(expected, tok(code, true, Platform::Type::Native, false)); ASSERT_EQUALS("", errout.str()); } @@ -3711,7 +3711,7 @@ class TestSimplifyTypedef : public TestFixture { "const C ( * f5 ) ( ) ; " "const C ( * f6 ) ( ) ; " "const C ( * f7 ) ( ) ;"; - ASSERT_EQUALS(expected, tok(code, true, cppcheck::Platform::Type::Native, false)); + ASSERT_EQUALS(expected, tok(code, true, Platform::Type::Native, false)); ASSERT_EQUALS("", errout.str()); } @@ -3739,7 +3739,7 @@ class TestSimplifyTypedef : public TestFixture { "C * ( * f5 ) ( ) ; " "C * ( * f6 ) ( ) ; " "C * ( * f7 ) ( ) ;"; - ASSERT_EQUALS(expected, tok(code, true, cppcheck::Platform::Type::Native, false)); + ASSERT_EQUALS(expected, tok(code, true, Platform::Type::Native, false)); ASSERT_EQUALS("", errout.str()); } @@ -3767,7 +3767,7 @@ class TestSimplifyTypedef : public TestFixture { "const C * ( * f5 ) ( ) ; " "const C * ( * f6 ) ( ) ; " "const C * ( * f7 ) ( ) ;"; - ASSERT_EQUALS(expected, tok(code, true, cppcheck::Platform::Type::Native, false)); + ASSERT_EQUALS(expected, tok(code, true, Platform::Type::Native, false)); ASSERT_EQUALS("", errout.str()); } @@ -3796,7 +3796,7 @@ class TestSimplifyTypedef : public TestFixture { "const C * ( * f5 ) ( ) ; " "const C * ( * f6 ) ( ) ; " "const C * ( * f7 ) ( ) ;"; - ASSERT_EQUALS(expected, tok(code, true, cppcheck::Platform::Type::Native, false)); + ASSERT_EQUALS(expected, tok(code, true, Platform::Type::Native, false)); ASSERT_EQUALS("", errout.str()); } } @@ -3941,7 +3941,7 @@ class TestSimplifyTypedef : public TestFixture { "B :: C ( * f2 ) ( ) ; " "B :: C ( * f3 ) ( ) ; " "B :: C ( * f4 ) ( ) ;"; - ASSERT_EQUALS(expected, tok(code, true, cppcheck::Platform::Type::Native, false)); + ASSERT_EQUALS(expected, tok(code, true, Platform::Type::Native, false)); ASSERT_EQUALS("", errout.str()); } @@ -3979,7 +3979,7 @@ class TestSimplifyTypedef : public TestFixture { "A :: B :: C ( * f2 ) ( ) ; " "A :: B :: C ( * f3 ) ( ) ; " "A :: B :: C ( * f4 ) ( ) ;"; - ASSERT_EQUALS(expected, tok(code, true, cppcheck::Platform::Type::Native, false)); + ASSERT_EQUALS(expected, tok(code, true, Platform::Type::Native, false)); ASSERT_EQUALS("", errout.str()); } } diff --git a/test/testsimplifyusing.cpp b/test/testsimplifyusing.cpp index 4208b128f29..5e3a5427a57 100644 --- a/test/testsimplifyusing.cpp +++ b/test/testsimplifyusing.cpp @@ -94,7 +94,7 @@ class TestSimplifyUsing : public TestFixture { } #define tok(...) tok_(__FILE__, __LINE__, __VA_ARGS__) - std::string tok_(const char* file, int line, const char code[], cppcheck::Platform::Type type = cppcheck::Platform::Type::Native, bool debugwarnings = true, bool preprocess = false) { + std::string tok_(const char* file, int line, const char code[], Platform::Type type = Platform::Type::Native, bool debugwarnings = true, bool preprocess = false) { errout.str(""); const Settings settings = settingsBuilder(settings0).certainty(Certainty::inconclusive).debugwarnings(debugwarnings).platform(type).build(); @@ -406,7 +406,7 @@ class TestSimplifyUsing : public TestFixture { " FP_M(val);" "};"; - TODO_ASSERT_THROW(tok(code, cppcheck::Platform::Type::Native, false), InternalError); // TODO: Do not throw AST validation exception + TODO_ASSERT_THROW(tok(code, Platform::Type::Native, false), InternalError); // TODO: Do not throw AST validation exception //ASSERT_EQUALS("", errout.str()); } @@ -670,7 +670,7 @@ class TestSimplifyUsing : public TestFixture { " T* p{ new T };\n" "}\n"; const char expected[] = "void f ( ) { int * p { new int } ; }"; - ASSERT_EQUALS(expected, tok(code, cppcheck::Platform::Type::Native, /*debugwarnings*/ true)); + ASSERT_EQUALS(expected, tok(code, Platform::Type::Native, /*debugwarnings*/ true)); ASSERT_EQUALS("", errout.str()); } @@ -678,7 +678,7 @@ class TestSimplifyUsing : public TestFixture { const char code[] = "using T = int*;\n" "void f(T = T()) {}\n"; const char expected[] = "void f ( int * = ( int * ) 0 ) { }"; - ASSERT_EQUALS(expected, tok(code, cppcheck::Platform::Type::Native, /*debugwarnings*/ true)); + ASSERT_EQUALS(expected, tok(code, Platform::Type::Native, /*debugwarnings*/ true)); ASSERT_EQUALS("", errout.str()); } @@ -732,11 +732,11 @@ class TestSimplifyUsing : public TestFixture { const char exp[] = "int i ;"; - ASSERT_EQUALS(exp, tok(code, cppcheck::Platform::Type::Unix32)); - ASSERT_EQUALS(exp, tok(code, cppcheck::Platform::Type::Unix64)); - ASSERT_EQUALS(exp, tok(code, cppcheck::Platform::Type::Win32A)); - ASSERT_EQUALS(exp, tok(code, cppcheck::Platform::Type::Win32W)); - ASSERT_EQUALS(exp, tok(code, cppcheck::Platform::Type::Win64)); + ASSERT_EQUALS(exp, tok(code, Platform::Type::Unix32)); + ASSERT_EQUALS(exp, tok(code, Platform::Type::Unix64)); + ASSERT_EQUALS(exp, tok(code, Platform::Type::Win32A)); + ASSERT_EQUALS(exp, tok(code, Platform::Type::Win32W)); + ASSERT_EQUALS(exp, tok(code, Platform::Type::Win64)); } void simplifyUsing9042() { @@ -756,7 +756,7 @@ class TestSimplifyUsing : public TestFixture { "} ; " "template < class T > class s { } ;"; - ASSERT_EQUALS(exp, tok(code, cppcheck::Platform::Type::Win64)); + ASSERT_EQUALS(exp, tok(code, Platform::Type::Win64)); } void simplifyUsing9191() { @@ -1389,7 +1389,7 @@ class TestSimplifyUsing : public TestFixture { "STAMP(A, int);\n" "STAMP(B, A);\n" "STAMP(C, B);\n"; - tok(code, cppcheck::Platform::Type::Native, /*debugwarnings*/ true, /*preprocess*/ true); + tok(code, Platform::Type::Native, /*debugwarnings*/ true, /*preprocess*/ true); ASSERT(startsWith(errout.str(), "[test.cpp:6]: (debug) Failed to parse 'using C = S < S < S < int")); } diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index 2941fb60cd0..5fffaec3957 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -69,7 +69,7 @@ class TestSymbolDatabase : public TestFixture { const Token* vartok{nullptr}; const Token* typetok{nullptr}; Settings settings1 = settingsBuilder().library("std.cfg").build(); - const Settings settings2 = settingsBuilder().platform(cppcheck::Platform::Type::Unspecified).build(); + const Settings settings2 = settingsBuilder().platform(Platform::Type::Unspecified).build(); void reset() { vartok = nullptr; @@ -8516,7 +8516,7 @@ class TestSymbolDatabase : public TestFixture { } { // PodType - Settings settingsWin64 = settingsBuilder().platform(cppcheck::Platform::Type::Win64).build(); + Settings settingsWin64 = settingsBuilder().platform(Platform::Type::Win64).build(); const Library::PodType u32 = { 4, 'u' }; const Library::PodType podtype2 = { 0, 'u', Library::PodType::Type::INT }; settingsWin64.library.mPodTypes["u32"] = u32; @@ -8537,7 +8537,7 @@ class TestSymbolDatabase : public TestFixture { } { // PlatformType - Settings settingsUnix32 = settingsBuilder().platform(cppcheck::Platform::Type::Unix32).build(); + Settings settingsUnix32 = settingsBuilder().platform(Platform::Type::Unix32).build(); Library::PlatformType s32; s32.mType = "int"; settingsUnix32.library.mPlatforms[settingsUnix32.platform.toString()].mPlatformTypes["s32"] = s32; @@ -8547,7 +8547,7 @@ class TestSymbolDatabase : public TestFixture { } { // PlatformType - wchar_t - Settings settingsWin64 = settingsBuilder().platform(cppcheck::Platform::Type::Win64).build(); + Settings settingsWin64 = settingsBuilder().platform(Platform::Type::Win64).build(); Library::PlatformType lpctstr; lpctstr.mType = "wchar_t"; settingsWin64.library.mPlatforms[settingsWin64.platform.toString()].mPlatformTypes["LPCTSTR"] = lpctstr; diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 3ca170c8e75..d194934b2b6 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -449,7 +449,7 @@ class TestTokenizer : public TestFixture { } #define tokenizeAndStringify(...) tokenizeAndStringify_(__FILE__, __LINE__, __VA_ARGS__) - std::string tokenizeAndStringify_(const char* file, int linenr, const char code[], bool expand = true, cppcheck::Platform::Type platform = cppcheck::Platform::Type::Native, const char* filename = "test.cpp", Standards::cppstd_t std = Standards::CPP11) { + std::string tokenizeAndStringify_(const char* file, int linenr, const char code[], bool expand = true, Platform::Type platform = Platform::Type::Native, const char* filename = "test.cpp", Standards::cppstd_t std = Standards::CPP11) { errout.str(""); const Settings settings = settingsBuilder(settings1).debugwarnings().cpp(std).platform(platform).build(); @@ -475,7 +475,7 @@ class TestTokenizer : public TestFixture { } #define tokenizeAndStringifyWindows(...) tokenizeAndStringifyWindows_(__FILE__, __LINE__, __VA_ARGS__) - std::string tokenizeAndStringifyWindows_(const char* file, int linenr, const char code[], bool expand = true, cppcheck::Platform::Type platform = cppcheck::Platform::Type::Native, const char* filename = "test.cpp", bool cpp11 = true) { + std::string tokenizeAndStringifyWindows_(const char* file, int linenr, const char code[], bool expand = true, Platform::Type platform = Platform::Type::Native, const char* filename = "test.cpp", bool cpp11 = true) { errout.str(""); const Settings settings = settingsBuilder(settings_windows).debugwarnings().cpp(cpp11 ? Standards::CPP11 : Standards::CPP03).platform(platform).build(); @@ -807,11 +807,11 @@ class TestTokenizer : public TestFixture { void validate() { // C++ code in C file - ASSERT_THROW(tokenizeAndStringify(";using namespace std;",false,cppcheck::Platform::Type::Native,"test.c"), InternalError); - ASSERT_THROW(tokenizeAndStringify(";std::map m;",false,cppcheck::Platform::Type::Native,"test.c"), InternalError); - ASSERT_THROW(tokenizeAndStringify(";template class X { };",false,cppcheck::Platform::Type::Native,"test.c"), InternalError); - ASSERT_THROW(tokenizeAndStringify("int X() {};",false,cppcheck::Platform::Type::Native,"test.c"), InternalError); - ASSERT_THROW(tokenizeAndStringify("void foo(int i) { reinterpret_cast(i) };",false,cppcheck::Platform::Type::Native,"test.h"), InternalError); + ASSERT_THROW(tokenizeAndStringify(";using namespace std;",false,Platform::Type::Native,"test.c"), InternalError); + ASSERT_THROW(tokenizeAndStringify(";std::map m;",false,Platform::Type::Native,"test.c"), InternalError); + ASSERT_THROW(tokenizeAndStringify(";template class X { };",false,Platform::Type::Native,"test.c"), InternalError); + ASSERT_THROW(tokenizeAndStringify("int X() {};",false,Platform::Type::Native,"test.c"), InternalError); + ASSERT_THROW(tokenizeAndStringify("void foo(int i) { reinterpret_cast(i) };",false,Platform::Type::Native,"test.h"), InternalError); } void objectiveC() { @@ -1768,7 +1768,7 @@ class TestTokenizer : public TestFixture { const char code[] = "struct foo {\n" " void operator delete(void *obj, size_t sz);\n" "}\n"; - const std::string actual(tokenizeAndStringify(code, true, cppcheck::Platform::Type::Win32A)); + const std::string actual(tokenizeAndStringify(code, true, Platform::Type::Win32A)); const char expected[] = "struct foo {\n" "void operatordelete ( void * obj , unsigned long sz ) ;\n" @@ -2268,7 +2268,7 @@ class TestTokenizer : public TestFixture { void vardecl14() { const char code[] = "::std::tr1::shared_ptr pNum1, pNum2;\n"; - ASSERT_EQUALS(":: std :: tr1 :: shared_ptr < int > pNum1 ; :: std :: tr1 :: shared_ptr < int > pNum2 ;", tokenizeAndStringify(code, false, cppcheck::Platform::Type::Native, "test.cpp", Standards::CPP03)); + ASSERT_EQUALS(":: std :: tr1 :: shared_ptr < int > pNum1 ; :: std :: tr1 :: shared_ptr < int > pNum2 ;", tokenizeAndStringify(code, false, Platform::Type::Native, "test.cpp", Standards::CPP03)); } void vardecl15() { @@ -2473,7 +2473,7 @@ class TestTokenizer : public TestFixture { void vardecl26() { // #5907 const char code[] = "extern int *new, obj, player;"; const char expected[] = "extern int * new ; extern int obj ; extern int player ;"; - ASSERT_EQUALS(expected, tokenizeAndStringify(code, true, cppcheck::Platform::Type::Native, "test.c")); + ASSERT_EQUALS(expected, tokenizeAndStringify(code, true, Platform::Type::Native, "test.c")); ASSERT_EQUALS(expected, tokenizeAndStringify(code)); } @@ -2484,7 +2484,7 @@ class TestTokenizer : public TestFixture { " return 0;\n" " return 0;\n" "}"; - tokenizeAndStringify(code, /*expand=*/ true, cppcheck::Platform::Type::Native, "test.c"); + tokenizeAndStringify(code, /*expand=*/ true, Platform::Type::Native, "test.c"); } void vardecl28() { @@ -2496,7 +2496,7 @@ class TestTokenizer : public TestFixture { "const unsigned short x ; x = 1 ;\n" "return x ;\n" "}", - tokenizeAndStringify(code, /*expand=*/ true, cppcheck::Platform::Type::Native, "test.c")); + tokenizeAndStringify(code, /*expand=*/ true, Platform::Type::Native, "test.c")); } void vardecl29() { // #9282 @@ -2516,9 +2516,9 @@ class TestTokenizer : public TestFixture { void vardecl30() { const char code[] = "struct D {} const d;"; ASSERT_EQUALS("struct D { } ; struct D const d ;", - tokenizeAndStringify(code, true, cppcheck::Platform::Type::Native, "test.cpp")); + tokenizeAndStringify(code, true, Platform::Type::Native, "test.cpp")); ASSERT_EQUALS("struct D { } ; struct D const d ;", - tokenizeAndStringify(code, true, cppcheck::Platform::Type::Native, "test.c")); + tokenizeAndStringify(code, true, Platform::Type::Native, "test.c")); } void vardecl31() { @@ -2589,15 +2589,15 @@ class TestTokenizer : public TestFixture { } void implicitIntConst() { - ASSERT_EQUALS("const int x ;", tokenizeAndStringify("const x;", true, cppcheck::Platform::Type::Native, "test.c")); - ASSERT_EQUALS("const int * x ;", tokenizeAndStringify("const *x;", true, cppcheck::Platform::Type::Native, "test.c")); - ASSERT_EQUALS("const int * f ( ) ;", tokenizeAndStringify("const *f();", true, cppcheck::Platform::Type::Native, "test.c")); + ASSERT_EQUALS("const int x ;", tokenizeAndStringify("const x;", true, Platform::Type::Native, "test.c")); + ASSERT_EQUALS("const int * x ;", tokenizeAndStringify("const *x;", true, Platform::Type::Native, "test.c")); + ASSERT_EQUALS("const int * f ( ) ;", tokenizeAndStringify("const *f();", true, Platform::Type::Native, "test.c")); } void implicitIntExtern() { - ASSERT_EQUALS("extern int x ;", tokenizeAndStringify("extern x;", true, cppcheck::Platform::Type::Native, "test.c")); - ASSERT_EQUALS("extern int * x ;", tokenizeAndStringify("extern *x;", true, cppcheck::Platform::Type::Native, "test.c")); - ASSERT_EQUALS("const int * f ( ) ;", tokenizeAndStringify("const *f();", true, cppcheck::Platform::Type::Native, "test.c")); + ASSERT_EQUALS("extern int x ;", tokenizeAndStringify("extern x;", true, Platform::Type::Native, "test.c")); + ASSERT_EQUALS("extern int * x ;", tokenizeAndStringify("extern *x;", true, Platform::Type::Native, "test.c")); + ASSERT_EQUALS("const int * f ( ) ;", tokenizeAndStringify("const *f();", true, Platform::Type::Native, "test.c")); } /** @@ -3638,15 +3638,15 @@ class TestTokenizer : public TestFixture { // Pointer to standard type ASSERT_EQUALS("char buf [ 100 ] ; readlink ( path , buf , 99 ) ;", tokenizeAndStringify("char buf[100] ; readlink(path, &buf[0], 99);", - true, cppcheck::Platform::Type::Native, "test.c")); + true, Platform::Type::Native, "test.c")); ASSERT_EQUALS("void foo ( char * c ) { if ( 1 == ( 1 & c [ 0 ] ) ) { } }", tokenizeAndStringify("void foo(char *c) { if (1==(1 & c[0])) {} }", - true, cppcheck::Platform::Type::Native, "test.c")); + true, Platform::Type::Native, "test.c")); // Simplification of unknown type - C only ASSERT_EQUALS("foo data [ 100 ] ; something ( foo ) ;", - tokenizeAndStringify("foo data[100]; something(&foo[0]);", true, cppcheck::Platform::Type::Native, "test.c")); + tokenizeAndStringify("foo data[100]; something(&foo[0]);", true, Platform::Type::Native, "test.c")); // C++: No pointer simplification ASSERT_EQUALS("foo data [ 100 ] ; something ( & foo [ 0 ] ) ;", @@ -4399,16 +4399,16 @@ class TestTokenizer : public TestFixture { ASSERT_EQUALS("struct A { long x ; } ;", tokenizeAndStringify(code5)); const char code6[] = "struct A { __int8 x : 3; };"; - ASSERT_EQUALS("struct A { char x ; } ;", tokenizeAndStringifyWindows(code6, true, cppcheck::Platform::Type::Win32A)); + ASSERT_EQUALS("struct A { char x ; } ;", tokenizeAndStringifyWindows(code6, true, Platform::Type::Win32A)); const char code7[] = "struct A { __int16 x : 3; };"; - ASSERT_EQUALS("struct A { short x ; } ;", tokenizeAndStringifyWindows(code7, true, cppcheck::Platform::Type::Win32A)); + ASSERT_EQUALS("struct A { short x ; } ;", tokenizeAndStringifyWindows(code7, true, Platform::Type::Win32A)); const char code8[] = "struct A { __int32 x : 3; };"; - ASSERT_EQUALS("struct A { int x ; } ;", tokenizeAndStringifyWindows(code8, true, cppcheck::Platform::Type::Win32A)); + ASSERT_EQUALS("struct A { int x ; } ;", tokenizeAndStringifyWindows(code8, true, Platform::Type::Win32A)); const char code9[] = "struct A { __int64 x : 3; };"; - ASSERT_EQUALS("struct A { long long x ; } ;", tokenizeAndStringifyWindows(code9, true, cppcheck::Platform::Type::Win32A)); + ASSERT_EQUALS("struct A { long long x ; } ;", tokenizeAndStringifyWindows(code9, true, Platform::Type::Win32A)); const char code10[] = "struct A { unsigned char x : 3; };"; ASSERT_EQUALS("struct A { unsigned char x ; } ;", tokenizeAndStringify(code10)); @@ -4423,16 +4423,16 @@ class TestTokenizer : public TestFixture { ASSERT_EQUALS("struct A { unsigned long x ; } ;", tokenizeAndStringify(code13)); const char code14[] = "struct A { unsigned __int8 x : 3; };"; - ASSERT_EQUALS("struct A { unsigned char x ; } ;", tokenizeAndStringifyWindows(code14, true, cppcheck::Platform::Type::Win32A)); + ASSERT_EQUALS("struct A { unsigned char x ; } ;", tokenizeAndStringifyWindows(code14, true, Platform::Type::Win32A)); const char code15[] = "struct A { unsigned __int16 x : 3; };"; - ASSERT_EQUALS("struct A { unsigned short x ; } ;", tokenizeAndStringifyWindows(code15, true, cppcheck::Platform::Type::Win32A)); + ASSERT_EQUALS("struct A { unsigned short x ; } ;", tokenizeAndStringifyWindows(code15, true, Platform::Type::Win32A)); const char code16[] = "struct A { unsigned __int32 x : 3; };"; - ASSERT_EQUALS("struct A { unsigned int x ; } ;", tokenizeAndStringifyWindows(code16, true, cppcheck::Platform::Type::Win32A)); + ASSERT_EQUALS("struct A { unsigned int x ; } ;", tokenizeAndStringifyWindows(code16, true, Platform::Type::Win32A)); const char code17[] = "struct A { unsigned __int64 x : 3; };"; - ASSERT_EQUALS("struct A { unsigned long long x ; } ;", tokenizeAndStringifyWindows(code17, true, cppcheck::Platform::Type::Win32A)); + ASSERT_EQUALS("struct A { unsigned long long x ; } ;", tokenizeAndStringifyWindows(code17, true, Platform::Type::Win32A)); const char code18[] = "struct A { signed char x : 3; };"; ASSERT_EQUALS("struct A { signed char x ; } ;", tokenizeAndStringify(code18)); @@ -4447,16 +4447,16 @@ class TestTokenizer : public TestFixture { ASSERT_EQUALS("struct A { signed long x ; } ;", tokenizeAndStringifyWindows(code21)); const char code22[] = "struct A { signed __int8 x : 3; };"; - ASSERT_EQUALS("struct A { signed char x ; } ;", tokenizeAndStringifyWindows(code22, true, cppcheck::Platform::Type::Win32A)); + ASSERT_EQUALS("struct A { signed char x ; } ;", tokenizeAndStringifyWindows(code22, true, Platform::Type::Win32A)); const char code23[] = "struct A { signed __int16 x : 3; };"; - ASSERT_EQUALS("struct A { signed short x ; } ;", tokenizeAndStringifyWindows(code23, true, cppcheck::Platform::Type::Win32A)); + ASSERT_EQUALS("struct A { signed short x ; } ;", tokenizeAndStringifyWindows(code23, true, Platform::Type::Win32A)); const char code24[] = "struct A { signed __int32 x : 3; };"; - ASSERT_EQUALS("struct A { signed int x ; } ;", tokenizeAndStringifyWindows(code24, true, cppcheck::Platform::Type::Win32A)); + ASSERT_EQUALS("struct A { signed int x ; } ;", tokenizeAndStringifyWindows(code24, true, Platform::Type::Win32A)); const char code25[] = "struct A { signed __int64 x : 3; };"; - ASSERT_EQUALS("struct A { signed long long x ; } ;", tokenizeAndStringifyWindows(code25, true, cppcheck::Platform::Type::Win32A)); + ASSERT_EQUALS("struct A { signed long long x ; } ;", tokenizeAndStringifyWindows(code25, true, Platform::Type::Win32A)); } void bitfields2() { @@ -4781,72 +4781,72 @@ class TestTokenizer : public TestFixture { void microsoftMemory() { const char code1a[] = "void foo() { int a[10], b[10]; CopyMemory(a, b, sizeof(a)); }"; - ASSERT_EQUALS("void foo ( ) { int a [ 10 ] ; int b [ 10 ] ; memcpy ( a , b , sizeof ( a ) ) ; }", tokenizeAndStringify(code1a,true,cppcheck::Platform::Type::Win32A)); + ASSERT_EQUALS("void foo ( ) { int a [ 10 ] ; int b [ 10 ] ; memcpy ( a , b , sizeof ( a ) ) ; }", tokenizeAndStringify(code1a,true,Platform::Type::Win32A)); const char code1b[] = "void foo() { int a[10], b[10]; RtlCopyMemory(a, b, sizeof(a)); }"; - ASSERT_EQUALS("void foo ( ) { int a [ 10 ] ; int b [ 10 ] ; memcpy ( a , b , sizeof ( a ) ) ; }", tokenizeAndStringify(code1b,true,cppcheck::Platform::Type::Win32A)); + ASSERT_EQUALS("void foo ( ) { int a [ 10 ] ; int b [ 10 ] ; memcpy ( a , b , sizeof ( a ) ) ; }", tokenizeAndStringify(code1b,true,Platform::Type::Win32A)); const char code1c[] = "void foo() { int a[10], b[10]; RtlCopyBytes(a, b, sizeof(a)); }"; - ASSERT_EQUALS("void foo ( ) { int a [ 10 ] ; int b [ 10 ] ; memcpy ( a , b , sizeof ( a ) ) ; }", tokenizeAndStringify(code1c,true,cppcheck::Platform::Type::Win32A)); + ASSERT_EQUALS("void foo ( ) { int a [ 10 ] ; int b [ 10 ] ; memcpy ( a , b , sizeof ( a ) ) ; }", tokenizeAndStringify(code1c,true,Platform::Type::Win32A)); const char code2a[] = "void foo() { int a[10]; FillMemory(a, sizeof(a), 255); }"; - ASSERT_EQUALS("void foo ( ) { int a [ 10 ] ; memset ( a , 255 , sizeof ( a ) ) ; }", tokenizeAndStringify(code2a,true,cppcheck::Platform::Type::Win32A)); + ASSERT_EQUALS("void foo ( ) { int a [ 10 ] ; memset ( a , 255 , sizeof ( a ) ) ; }", tokenizeAndStringify(code2a,true,Platform::Type::Win32A)); const char code2b[] = "void foo() { int a[10]; RtlFillMemory(a, sizeof(a), 255); }"; - ASSERT_EQUALS("void foo ( ) { int a [ 10 ] ; memset ( a , 255 , sizeof ( a ) ) ; }", tokenizeAndStringify(code2b,true,cppcheck::Platform::Type::Win32A)); + ASSERT_EQUALS("void foo ( ) { int a [ 10 ] ; memset ( a , 255 , sizeof ( a ) ) ; }", tokenizeAndStringify(code2b,true,Platform::Type::Win32A)); const char code2c[] = "void foo() { int a[10]; RtlFillBytes(a, sizeof(a), 255); }"; - ASSERT_EQUALS("void foo ( ) { int a [ 10 ] ; memset ( a , 255 , sizeof ( a ) ) ; }", tokenizeAndStringify(code2c,true,cppcheck::Platform::Type::Win32A)); + ASSERT_EQUALS("void foo ( ) { int a [ 10 ] ; memset ( a , 255 , sizeof ( a ) ) ; }", tokenizeAndStringify(code2c,true,Platform::Type::Win32A)); const char code3a[] = "void foo() { int a[10], b[10]; MoveMemory(a, b, sizeof(a)); }"; - ASSERT_EQUALS("void foo ( ) { int a [ 10 ] ; int b [ 10 ] ; memmove ( a , b , sizeof ( a ) ) ; }", tokenizeAndStringify(code3a,true,cppcheck::Platform::Type::Win32A)); + ASSERT_EQUALS("void foo ( ) { int a [ 10 ] ; int b [ 10 ] ; memmove ( a , b , sizeof ( a ) ) ; }", tokenizeAndStringify(code3a,true,Platform::Type::Win32A)); const char code3b[] = "void foo() { int a[10], b[10]; RtlMoveMemory(a, b, sizeof(a)); }"; - ASSERT_EQUALS("void foo ( ) { int a [ 10 ] ; int b [ 10 ] ; memmove ( a , b , sizeof ( a ) ) ; }", tokenizeAndStringify(code3b,true,cppcheck::Platform::Type::Win32A)); + ASSERT_EQUALS("void foo ( ) { int a [ 10 ] ; int b [ 10 ] ; memmove ( a , b , sizeof ( a ) ) ; }", tokenizeAndStringify(code3b,true,Platform::Type::Win32A)); const char code4a[] = "void foo() { int a[10]; ZeroMemory(a, sizeof(a)); }"; - ASSERT_EQUALS("void foo ( ) { int a [ 10 ] ; memset ( a , 0 , sizeof ( a ) ) ; }", tokenizeAndStringify(code4a,true,cppcheck::Platform::Type::Win32A)); + ASSERT_EQUALS("void foo ( ) { int a [ 10 ] ; memset ( a , 0 , sizeof ( a ) ) ; }", tokenizeAndStringify(code4a,true,Platform::Type::Win32A)); const char code4b[] = "void foo() { int a[10]; RtlZeroMemory(a, sizeof(a)); }"; - ASSERT_EQUALS("void foo ( ) { int a [ 10 ] ; memset ( a , 0 , sizeof ( a ) ) ; }", tokenizeAndStringify(code4b,true,cppcheck::Platform::Type::Win32A)); + ASSERT_EQUALS("void foo ( ) { int a [ 10 ] ; memset ( a , 0 , sizeof ( a ) ) ; }", tokenizeAndStringify(code4b,true,Platform::Type::Win32A)); const char code4c[] = "void foo() { int a[10]; RtlZeroBytes(a, sizeof(a)); }"; - ASSERT_EQUALS("void foo ( ) { int a [ 10 ] ; memset ( a , 0 , sizeof ( a ) ) ; }", tokenizeAndStringify(code4c,true,cppcheck::Platform::Type::Win32A)); + ASSERT_EQUALS("void foo ( ) { int a [ 10 ] ; memset ( a , 0 , sizeof ( a ) ) ; }", tokenizeAndStringify(code4c,true,Platform::Type::Win32A)); const char code4d[] = "void foo() { int a[10]; RtlSecureZeroMemory(a, sizeof(a)); }"; - ASSERT_EQUALS("void foo ( ) { int a [ 10 ] ; memset ( a , 0 , sizeof ( a ) ) ; }", tokenizeAndStringify(code4d,true,cppcheck::Platform::Type::Win32A)); + ASSERT_EQUALS("void foo ( ) { int a [ 10 ] ; memset ( a , 0 , sizeof ( a ) ) ; }", tokenizeAndStringify(code4d,true,Platform::Type::Win32A)); const char code5[] = "void foo() { int a[10], b[10]; RtlCompareMemory(a, b, sizeof(a)); }"; - ASSERT_EQUALS("void foo ( ) { int a [ 10 ] ; int b [ 10 ] ; memcmp ( a , b , sizeof ( a ) ) ; }", tokenizeAndStringify(code5,true,cppcheck::Platform::Type::Win32A)); + ASSERT_EQUALS("void foo ( ) { int a [ 10 ] ; int b [ 10 ] ; memcmp ( a , b , sizeof ( a ) ) ; }", tokenizeAndStringify(code5,true,Platform::Type::Win32A)); const char code6[] = "void foo() { ZeroMemory(f(1, g(a, b)), h(i, j(0, 1))); }"; - ASSERT_EQUALS("void foo ( ) { memset ( f ( 1 , g ( a , b ) ) , 0 , h ( i , j ( 0 , 1 ) ) ) ; }", tokenizeAndStringify(code6,true,cppcheck::Platform::Type::Win32A)); + ASSERT_EQUALS("void foo ( ) { memset ( f ( 1 , g ( a , b ) ) , 0 , h ( i , j ( 0 , 1 ) ) ) ; }", tokenizeAndStringify(code6,true,Platform::Type::Win32A)); const char code7[] = "void foo() { FillMemory(f(1, g(a, b)), h(i, j(0, 1)), 255); }"; - ASSERT_EQUALS("void foo ( ) { memset ( f ( 1 , g ( a , b ) ) , 255 , h ( i , j ( 0 , 1 ) ) ) ; }", tokenizeAndStringify(code7,true,cppcheck::Platform::Type::Win32A)); + ASSERT_EQUALS("void foo ( ) { memset ( f ( 1 , g ( a , b ) ) , 255 , h ( i , j ( 0 , 1 ) ) ) ; }", tokenizeAndStringify(code7,true,Platform::Type::Win32A)); } void microsoftString() { const char code1a[] = "void foo() { _tprintf (_T(\"test\") _T(\"1\")); }"; - ASSERT_EQUALS("void foo ( ) { printf ( \"test1\" ) ; }", tokenizeAndStringify(code1a, true, cppcheck::Platform::Type::Win32A)); + ASSERT_EQUALS("void foo ( ) { printf ( \"test1\" ) ; }", tokenizeAndStringify(code1a, true, Platform::Type::Win32A)); const char code1b[] = "void foo() { _tprintf (_TEXT(\"test\") _TEXT(\"2\")); }"; - ASSERT_EQUALS("void foo ( ) { printf ( \"test2\" ) ; }", tokenizeAndStringify(code1b, true, cppcheck::Platform::Type::Win32A)); + ASSERT_EQUALS("void foo ( ) { printf ( \"test2\" ) ; }", tokenizeAndStringify(code1b, true, Platform::Type::Win32A)); const char code1c[] = "void foo() { _tprintf (TEXT(\"test\") TEXT(\"3\")); }"; - ASSERT_EQUALS("void foo ( ) { printf ( \"test3\" ) ; }", tokenizeAndStringify(code1c, true, cppcheck::Platform::Type::Win32A)); + ASSERT_EQUALS("void foo ( ) { printf ( \"test3\" ) ; }", tokenizeAndStringify(code1c, true, Platform::Type::Win32A)); const char code2a[] = "void foo() { _tprintf (_T(\"test\") _T(\"1\")); }"; - ASSERT_EQUALS("void foo ( ) { wprintf ( L\"test1\" ) ; }", tokenizeAndStringify(code2a, true, cppcheck::Platform::Type::Win32W)); - ASSERT_EQUALS("void foo ( ) { wprintf ( L\"test1\" ) ; }", tokenizeAndStringify(code2a, true, cppcheck::Platform::Type::Win64)); + ASSERT_EQUALS("void foo ( ) { wprintf ( L\"test1\" ) ; }", tokenizeAndStringify(code2a, true, Platform::Type::Win32W)); + ASSERT_EQUALS("void foo ( ) { wprintf ( L\"test1\" ) ; }", tokenizeAndStringify(code2a, true, Platform::Type::Win64)); const char code2b[] = "void foo() { _tprintf (_TEXT(\"test\") _TEXT(\"2\")); }"; - ASSERT_EQUALS("void foo ( ) { wprintf ( L\"test2\" ) ; }", tokenizeAndStringify(code2b, true, cppcheck::Platform::Type::Win32W)); - ASSERT_EQUALS("void foo ( ) { wprintf ( L\"test2\" ) ; }", tokenizeAndStringify(code2b, true, cppcheck::Platform::Type::Win64)); + ASSERT_EQUALS("void foo ( ) { wprintf ( L\"test2\" ) ; }", tokenizeAndStringify(code2b, true, Platform::Type::Win32W)); + ASSERT_EQUALS("void foo ( ) { wprintf ( L\"test2\" ) ; }", tokenizeAndStringify(code2b, true, Platform::Type::Win64)); const char code2c[] = "void foo() { _tprintf (TEXT(\"test\") TEXT(\"3\")); }"; - ASSERT_EQUALS("void foo ( ) { wprintf ( L\"test3\" ) ; }", tokenizeAndStringify(code2c, true, cppcheck::Platform::Type::Win32W)); - ASSERT_EQUALS("void foo ( ) { wprintf ( L\"test3\" ) ; }", tokenizeAndStringify(code2c, true, cppcheck::Platform::Type::Win64)); + ASSERT_EQUALS("void foo ( ) { wprintf ( L\"test3\" ) ; }", tokenizeAndStringify(code2c, true, Platform::Type::Win32W)); + ASSERT_EQUALS("void foo ( ) { wprintf ( L\"test3\" ) ; }", tokenizeAndStringify(code2c, true, Platform::Type::Win64)); } void borland() { // __closure ASSERT_EQUALS("int ( * a ) ( ) ;", // TODO VarId - tokenizeAndStringify("int (__closure *a)();", true, cppcheck::Platform::Type::Win32A)); + tokenizeAndStringify("int (__closure *a)();", true, Platform::Type::Win32A)); // __property ASSERT_EQUALS("class Fred { ; __property ; } ;", - tokenizeAndStringify("class Fred { __property int x = { } };", true, cppcheck::Platform::Type::Win32A)); + tokenizeAndStringify("class Fred { __property int x = { } };", true, Platform::Type::Win32A)); } void simplifySQL() { @@ -4869,42 +4869,42 @@ class TestTokenizer : public TestFixture { } void simplifyCAlternativeTokens() { - ASSERT_EQUALS("void or ( ) ;", tokenizeAndStringify("void or(void);", true, cppcheck::Platform::Type::Native, "test.c")); - ASSERT_EQUALS("void f ( ) { if ( a && b ) { ; } }", tokenizeAndStringify("void f() { if (a and b); }", true, cppcheck::Platform::Type::Native, "test.c")); - ASSERT_EQUALS("void f ( ) { if ( a && b ) { ; } }", tokenizeAndStringify("void f() { if (a and b); }", true, cppcheck::Platform::Type::Native, "test.cpp")); - ASSERT_EQUALS("void f ( ) { if ( a || b ) { ; } }", tokenizeAndStringify("void f() { if (a or b); }", true, cppcheck::Platform::Type::Native, "test.c")); - ASSERT_EQUALS("void f ( ) { if ( a || b ) { ; } }", tokenizeAndStringify("void f() { if (a or b); }", true, cppcheck::Platform::Type::Native, "test.cpp")); - ASSERT_EQUALS("void f ( ) { if ( a & b ) { ; } }", tokenizeAndStringify("void f() { if (a bitand b); }", true, cppcheck::Platform::Type::Native, "test.c")); - ASSERT_EQUALS("void f ( ) { if ( a & b ) { ; } }", tokenizeAndStringify("void f() { if (a bitand b); }", true, cppcheck::Platform::Type::Native, "test.cpp")); - ASSERT_EQUALS("void f ( ) { if ( a | b ) { ; } }", tokenizeAndStringify("void f() { if (a bitor b); }", true, cppcheck::Platform::Type::Native, "test.c")); - ASSERT_EQUALS("void f ( ) { if ( a | b ) { ; } }", tokenizeAndStringify("void f() { if (a bitor b); }", true, cppcheck::Platform::Type::Native, "test.cpp")); - ASSERT_EQUALS("void f ( ) { if ( a ^ b ) { ; } }", tokenizeAndStringify("void f() { if (a xor b); }", true, cppcheck::Platform::Type::Native, "test.c")); - ASSERT_EQUALS("void f ( ) { if ( a ^ b ) { ; } }", tokenizeAndStringify("void f() { if (a xor b); }", true, cppcheck::Platform::Type::Native, "test.cpp")); - ASSERT_EQUALS("void f ( ) { if ( ~ b ) { ; } }", tokenizeAndStringify("void f() { if (compl b); }", true, cppcheck::Platform::Type::Native, "test.c")); - ASSERT_EQUALS("void f ( ) { if ( ~ b ) { ; } }", tokenizeAndStringify("void f() { if (compl b); }", true, cppcheck::Platform::Type::Native, "test.cpp")); - ASSERT_EQUALS("void f ( ) { if ( ! b ) { ; } }", tokenizeAndStringify("void f() { if (not b); }", true, cppcheck::Platform::Type::Native, "test.c")); - ASSERT_EQUALS("void f ( ) { if ( ! b ) { ; } }", tokenizeAndStringify("void f() { if (not b); }", true, cppcheck::Platform::Type::Native, "test.cpp")); - ASSERT_EQUALS("void f ( ) const { if ( ! b ) { ; } }", tokenizeAndStringify("void f() const { if (not b); }", true, cppcheck::Platform::Type::Native, "test.cpp")); - ASSERT_EQUALS("void f ( ) { if ( a != b ) { ; } }", tokenizeAndStringify("void f() { if (a not_eq b); }", true, cppcheck::Platform::Type::Native, "test.c")); - ASSERT_EQUALS("void f ( ) { if ( a != b ) { ; } }", tokenizeAndStringify("void f() { if (a not_eq b); }", true, cppcheck::Platform::Type::Native, "test.cpp")); + ASSERT_EQUALS("void or ( ) ;", tokenizeAndStringify("void or(void);", true, Platform::Type::Native, "test.c")); + ASSERT_EQUALS("void f ( ) { if ( a && b ) { ; } }", tokenizeAndStringify("void f() { if (a and b); }", true, Platform::Type::Native, "test.c")); + ASSERT_EQUALS("void f ( ) { if ( a && b ) { ; } }", tokenizeAndStringify("void f() { if (a and b); }", true, Platform::Type::Native, "test.cpp")); + ASSERT_EQUALS("void f ( ) { if ( a || b ) { ; } }", tokenizeAndStringify("void f() { if (a or b); }", true, Platform::Type::Native, "test.c")); + ASSERT_EQUALS("void f ( ) { if ( a || b ) { ; } }", tokenizeAndStringify("void f() { if (a or b); }", true, Platform::Type::Native, "test.cpp")); + ASSERT_EQUALS("void f ( ) { if ( a & b ) { ; } }", tokenizeAndStringify("void f() { if (a bitand b); }", true, Platform::Type::Native, "test.c")); + ASSERT_EQUALS("void f ( ) { if ( a & b ) { ; } }", tokenizeAndStringify("void f() { if (a bitand b); }", true, Platform::Type::Native, "test.cpp")); + ASSERT_EQUALS("void f ( ) { if ( a | b ) { ; } }", tokenizeAndStringify("void f() { if (a bitor b); }", true, Platform::Type::Native, "test.c")); + ASSERT_EQUALS("void f ( ) { if ( a | b ) { ; } }", tokenizeAndStringify("void f() { if (a bitor b); }", true, Platform::Type::Native, "test.cpp")); + ASSERT_EQUALS("void f ( ) { if ( a ^ b ) { ; } }", tokenizeAndStringify("void f() { if (a xor b); }", true, Platform::Type::Native, "test.c")); + ASSERT_EQUALS("void f ( ) { if ( a ^ b ) { ; } }", tokenizeAndStringify("void f() { if (a xor b); }", true, Platform::Type::Native, "test.cpp")); + ASSERT_EQUALS("void f ( ) { if ( ~ b ) { ; } }", tokenizeAndStringify("void f() { if (compl b); }", true, Platform::Type::Native, "test.c")); + ASSERT_EQUALS("void f ( ) { if ( ~ b ) { ; } }", tokenizeAndStringify("void f() { if (compl b); }", true, Platform::Type::Native, "test.cpp")); + ASSERT_EQUALS("void f ( ) { if ( ! b ) { ; } }", tokenizeAndStringify("void f() { if (not b); }", true, Platform::Type::Native, "test.c")); + ASSERT_EQUALS("void f ( ) { if ( ! b ) { ; } }", tokenizeAndStringify("void f() { if (not b); }", true, Platform::Type::Native, "test.cpp")); + ASSERT_EQUALS("void f ( ) const { if ( ! b ) { ; } }", tokenizeAndStringify("void f() const { if (not b); }", true, Platform::Type::Native, "test.cpp")); + ASSERT_EQUALS("void f ( ) { if ( a != b ) { ; } }", tokenizeAndStringify("void f() { if (a not_eq b); }", true, Platform::Type::Native, "test.c")); + ASSERT_EQUALS("void f ( ) { if ( a != b ) { ; } }", tokenizeAndStringify("void f() { if (a not_eq b); }", true, Platform::Type::Native, "test.cpp")); // #6201 - ASSERT_EQUALS("void f ( ) { if ( ! c || ! memcmp ( a , b , s ) ) { ; } }", tokenizeAndStringify("void f() { if (!c or !memcmp(a, b, s)); }", true, cppcheck::Platform::Type::Native, "test.c")); - ASSERT_EQUALS("void f ( ) { if ( ! c || ! memcmp ( a , b , s ) ) { ; } }", tokenizeAndStringify("void f() { if (!c or !memcmp(a, b, s)); }", true, cppcheck::Platform::Type::Native, "test.cpp")); + ASSERT_EQUALS("void f ( ) { if ( ! c || ! memcmp ( a , b , s ) ) { ; } }", tokenizeAndStringify("void f() { if (!c or !memcmp(a, b, s)); }", true, Platform::Type::Native, "test.c")); + ASSERT_EQUALS("void f ( ) { if ( ! c || ! memcmp ( a , b , s ) ) { ; } }", tokenizeAndStringify("void f() { if (!c or !memcmp(a, b, s)); }", true, Platform::Type::Native, "test.cpp")); // #6029 - ASSERT_EQUALS("void f ( ) { if ( ! b ) { } }", tokenizeAndStringify("void f() { if (not b){} }", true, cppcheck::Platform::Type::Native, "test.c")); - ASSERT_EQUALS("void f ( ) { if ( ! b ) { } }", tokenizeAndStringify("void f() { if (not b){} }", true, cppcheck::Platform::Type::Native, "test.cpp")); + ASSERT_EQUALS("void f ( ) { if ( ! b ) { } }", tokenizeAndStringify("void f() { if (not b){} }", true, Platform::Type::Native, "test.c")); + ASSERT_EQUALS("void f ( ) { if ( ! b ) { } }", tokenizeAndStringify("void f() { if (not b){} }", true, Platform::Type::Native, "test.cpp")); // #6207 - ASSERT_EQUALS("void f ( ) { if ( not = x ) { } }", tokenizeAndStringify("void f() { if (not=x){} }", true, cppcheck::Platform::Type::Native, "test.c")); - ASSERT_EQUALS("void f ( ) { if ( not = x ) { } }", tokenizeAndStringify("void f() { if (not=x){} }", true, cppcheck::Platform::Type::Native, "test.cpp")); + ASSERT_EQUALS("void f ( ) { if ( not = x ) { } }", tokenizeAndStringify("void f() { if (not=x){} }", true, Platform::Type::Native, "test.c")); + ASSERT_EQUALS("void f ( ) { if ( not = x ) { } }", tokenizeAndStringify("void f() { if (not=x){} }", true, Platform::Type::Native, "test.cpp")); // #8029 - ASSERT_EQUALS("void f ( struct S * s ) { x = s . and + 1 ; }", tokenizeAndStringify("void f(struct S *s) { x = s->and + 1; }", true, cppcheck::Platform::Type::Native, "test.c")); + ASSERT_EQUALS("void f ( struct S * s ) { x = s . and + 1 ; }", tokenizeAndStringify("void f(struct S *s) { x = s->and + 1; }", true, Platform::Type::Native, "test.c")); // #8745 ASSERT_EQUALS("void f ( ) { if ( x ) { or = 0 ; } }", tokenizeAndStringify("void f() { if (x) or = 0; }")); // #9324 ASSERT_EQUALS("void f ( const char * str ) { while ( * str == '!' || * str == '[' ) { } }", tokenizeAndStringify("void f(const char *str) { while (*str=='!' or *str=='['){} }")); // #9920 - ASSERT_EQUALS("result = ch != s . end ( ) && * ch == ':' ;", tokenizeAndStringify("result = ch != s.end() and *ch == ':';", true, cppcheck::Platform::Type::Native, "test.c")); + ASSERT_EQUALS("result = ch != s . end ( ) && * ch == ':' ;", tokenizeAndStringify("result = ch != s.end() and *ch == ':';", true, Platform::Type::Native, "test.c")); // #8975 ASSERT_EQUALS("void foo ( ) {\n" @@ -4915,9 +4915,9 @@ class TestTokenizer : public TestFixture { "void foo() {\n" " char *or;\n" " while ((*or != 0) && (*or != '|')) or++;\n" - "}", true, cppcheck::Platform::Type::Native, "test.c")); + "}", true, Platform::Type::Native, "test.c")); // #10013 - ASSERT_EQUALS("void f ( ) { x = ! 123 ; }", tokenizeAndStringify("void f() { x = not 123; }", true, cppcheck::Platform::Type::Native, "test.cpp")); + ASSERT_EQUALS("void f ( ) { x = ! 123 ; }", tokenizeAndStringify("void f() { x = not 123; }", true, Platform::Type::Native, "test.cpp")); } void simplifyRoundCurlyParentheses() { @@ -4939,7 +4939,7 @@ class TestTokenizer : public TestFixture { "operator ( ) ; " "}"; - ASSERT_EQUALS(result, tokenizeAndStringify(code, /*expand=*/ true, /*platform=*/ cppcheck::Platform::Type::Native, "test.c")); + ASSERT_EQUALS(result, tokenizeAndStringify(code, /*expand=*/ true, /*platform=*/ Platform::Type::Native, "test.c")); } void simplifyOperatorName2() { @@ -5588,10 +5588,10 @@ class TestTokenizer : public TestFixture { "float * ptrToFloat ;"; // These types should be defined the same on all Windows platforms - const std::string win32A = tokenizeAndStringifyWindows(code, true, cppcheck::Platform::Type::Win32A); + const std::string win32A = tokenizeAndStringifyWindows(code, true, Platform::Type::Win32A); ASSERT_EQUALS(expected, win32A); - ASSERT_EQUALS(win32A, tokenizeAndStringifyWindows(code, true, cppcheck::Platform::Type::Win32W)); - ASSERT_EQUALS(win32A, tokenizeAndStringifyWindows(code, true, cppcheck::Platform::Type::Win64)); + ASSERT_EQUALS(win32A, tokenizeAndStringifyWindows(code, true, Platform::Type::Win32W)); + ASSERT_EQUALS(win32A, tokenizeAndStringifyWindows(code, true, Platform::Type::Win64)); } void platformWin32A() { @@ -5637,7 +5637,7 @@ class TestTokenizer : public TestFixture { "sscanf ( dst , \"%s\" , dst ) ; " "} " "unsigned char tbyte ;"; - ASSERT_EQUALS(expected, tokenizeAndStringifyWindows(code, true, cppcheck::Platform::Type::Win32A)); + ASSERT_EQUALS(expected, tokenizeAndStringifyWindows(code, true, Platform::Type::Win32A)); } void platformWin32W() { @@ -5683,29 +5683,29 @@ class TestTokenizer : public TestFixture { "wscanf ( L\"%s\" , dst ) ; " "swscanf ( dst , L\"%s\" , dst ) ; " "}"; - ASSERT_EQUALS(expected, tokenizeAndStringifyWindows(code, true, cppcheck::Platform::Type::Win32W)); + ASSERT_EQUALS(expected, tokenizeAndStringifyWindows(code, true, Platform::Type::Win32W)); } void platformWin32AStringCat() { //#5150 const char code[] = "TCHAR text[] = _T(\"123\") _T(\"456\") _T(\"789\");"; const char expected[] = "char text [ 10 ] = \"123456789\" ;"; - ASSERT_EQUALS(expected, tokenizeAndStringifyWindows(code, true, cppcheck::Platform::Type::Win32A)); + ASSERT_EQUALS(expected, tokenizeAndStringifyWindows(code, true, Platform::Type::Win32A)); } void platformWin32WStringCat() { //#5150 const char code[] = "TCHAR text[] = _T(\"123\") _T(\"456\") _T(\"789\");"; const char expected[] = "wchar_t text [ 10 ] = L\"123456789\" ;"; - ASSERT_EQUALS(expected, tokenizeAndStringifyWindows(code, true, cppcheck::Platform::Type::Win32W)); + ASSERT_EQUALS(expected, tokenizeAndStringifyWindows(code, true, Platform::Type::Win32W)); } void platformWinWithNamespace() { const char code1[] = "UINT32 a; ::UINT32 b; foo::UINT32 c;"; const char expected1[] = "unsigned int a ; unsigned int b ; foo :: UINT32 c ;"; - ASSERT_EQUALS(expected1, tokenizeAndStringifyWindows(code1, true, cppcheck::Platform::Type::Win32A)); + ASSERT_EQUALS(expected1, tokenizeAndStringifyWindows(code1, true, Platform::Type::Win32A)); const char code2[] = "LPCVOID a; ::LPCVOID b; foo::LPCVOID c;"; const char expected2[] = "const void * a ; const void * b ; foo :: LPCVOID c ;"; - ASSERT_EQUALS(expected2, tokenizeAndStringifyWindows(code2, true, cppcheck::Platform::Type::Win32A)); + ASSERT_EQUALS(expected2, tokenizeAndStringifyWindows(code2, true, Platform::Type::Win32A)); } void isOneNumber() const { @@ -5789,10 +5789,10 @@ class TestTokenizer : public TestFixture { tokenizeAndStringify("[[deprecated]] int f();")); ASSERT_EQUALS("[ [ deprecated ] ] int f ( ) ;", - tokenizeAndStringify("[[deprecated]] int f();", true, cppcheck::Platform::Type::Native, "test.cpp", Standards::CPP03)); + tokenizeAndStringify("[[deprecated]] int f();", true, Platform::Type::Native, "test.cpp", Standards::CPP03)); ASSERT_EQUALS("[ [ deprecated ] ] int f ( ) ;", - tokenizeAndStringify("[[deprecated]] int f();", true, cppcheck::Platform::Type::Native, "test.c")); + tokenizeAndStringify("[[deprecated]] int f();", true, Platform::Type::Native, "test.c")); ASSERT_EQUALS("template < class T > int f ( ) { }", tokenizeAndStringify("template [[noreturn]] int f(){}")); @@ -5801,7 +5801,7 @@ class TestTokenizer : public TestFixture { tokenizeAndStringify("[[maybe_unused]] int f([[maybe_unused]] int i);")); ASSERT_EQUALS("[ [ maybe_unused ] ] int f ( [ [ maybe_unused ] ] int i ) ;", - tokenizeAndStringify("[[maybe_unused]] int f([[maybe_unused]] int i);", true, cppcheck::Platform::Type::Native, "test.cpp", Standards::CPP03)); + tokenizeAndStringify("[[maybe_unused]] int f([[maybe_unused]] int i);", true, Platform::Type::Native, "test.cpp", Standards::CPP03)); ASSERT_EQUALS("struct a ;", tokenizeAndStringify("struct [[]] a;")); @@ -6684,7 +6684,7 @@ class TestTokenizer : public TestFixture { " return y;\n" " else\n" " return z;\n" - "}\n", true, cppcheck::Platform::Type::Native, "test.cpp", Standards::CPP17)); + "}\n", true, Platform::Type::Native, "test.cpp", Standards::CPP17)); // #10079 - createInnerAST bug.. ASSERT_EQUALS("x{([= yz= switchy(", @@ -6834,7 +6834,7 @@ class TestTokenizer : public TestFixture { ASSERT_EQUALS("class Fred : Base { } ;", tokenizeAndStringify("class Fred FINAL : Base { } ;")); ASSERT_EQUALS("class Fred : Base { } ;", tokenizeAndStringify("class DLLEXPORT Fred final : Base { } ;")); // #11422 // Regression for C code: - ASSERT_EQUALS("struct Fred { } ;", tokenizeAndStringify("struct DLLEXPORT Fred { } ;", true, cppcheck::Platform::Type::Native, "test.c")); + ASSERT_EQUALS("struct Fred { } ;", tokenizeAndStringify("struct DLLEXPORT Fred { } ;", true, Platform::Type::Native, "test.c")); } void sizeofAddParentheses() { @@ -6892,12 +6892,12 @@ class TestTokenizer : public TestFixture { ASSERT_NO_THROW(tokenizeAndStringify("void f(void* q) {\n" " g(&(S) { .p = (int*)q });\n" - "}\n", /*expand*/ true, cppcheck::Platform::Type::Native, "test.c")); + "}\n", /*expand*/ true, Platform::Type::Native, "test.c")); ASSERT_NO_THROW(tokenizeAndStringify("typedef struct { int i; } S;\n" "void f(float a) {\n" "S s = (S){ .i = (int)a };\n" - "}\n", /*expand*/ true, cppcheck::Platform::Type::Native, "test.c")); + "}\n", /*expand*/ true, Platform::Type::Native, "test.c")); } void findGarbageCode() { // Test Tokenizer::findGarbageCode() @@ -6985,7 +6985,7 @@ class TestTokenizer : public TestFixture { ASSERT_THROW_EQUALS(tokenizeAndStringify("void f() { assert(a+()); }"), InternalError, "syntax error: +()"); // #9445 - typeof is not a keyword in C - ASSERT_NO_THROW(tokenizeAndStringify("void foo() { char *typeof, *value; }", false, cppcheck::Platform::Type::Native, "test.c")); + ASSERT_NO_THROW(tokenizeAndStringify("void foo() { char *typeof, *value; }", false, Platform::Type::Native, "test.c")); ASSERT_THROW_EQUALS(tokenizeAndStringify("enum : { };"), InternalError, "syntax error: Unexpected token '{'"); ASSERT_THROW_EQUALS(tokenizeAndStringify("enum : 3 { };"), InternalError, "syntax error: Unexpected token '3'"); diff --git a/test/testtype.cpp b/test/testtype.cpp index 65f26d5c9f1..1007e2b30fb 100644 --- a/test/testtype.cpp +++ b/test/testtype.cpp @@ -61,7 +61,7 @@ class TestType : public TestFixture { void checkTooBigShift_Unix32() { const Settings settings0; - const Settings settings = settingsBuilder().platform(cppcheck::Platform::Type::Unix32).build(); + const Settings settings = settingsBuilder().platform(Platform::Type::Unix32).build(); // unsigned types getting promoted to int sizeof(int) = 4 bytes // and unsigned types having already a size of 4 bytes @@ -234,7 +234,7 @@ class TestType : public TestFixture { } void checkIntegerOverflow() { - const Settings settings = settingsBuilder().severity(Severity::warning).platform(cppcheck::Platform::Type::Unix32).build(); + const Settings settings = settingsBuilder().severity(Severity::warning).platform(Platform::Type::Unix32).build(); check("x = (int)0x10000 * (int)0x10000;", settings); ASSERT_EQUALS("[test.cpp:1]: (error) Signed integer overflow for expression '(int)0x10000*(int)0x10000'.\n", errout.str()); @@ -275,7 +275,7 @@ class TestType : public TestFixture { void signConversion() { const Settings settings0; - const Settings settings = settingsBuilder().platform(cppcheck::Platform::Type::Unix64).build(); + const Settings settings = settingsBuilder().platform(Platform::Type::Unix64).build(); check("x = -4 * (unsigned)y;", settings0); ASSERT_EQUALS("[test.cpp:1]: (warning) Expression '-4' has a negative value. That is converted to an unsigned value and used in an unsigned calculation.\n", errout.str()); @@ -324,8 +324,8 @@ class TestType : public TestFixture { } void longCastAssign() { - const Settings settings = settingsBuilder().severity(Severity::style).platform(cppcheck::Platform::Type::Unix64).build(); - const Settings settingsWin = settingsBuilder().severity(Severity::style).platform(cppcheck::Platform::Type::Win64).build(); + const Settings settings = settingsBuilder().severity(Severity::style).platform(Platform::Type::Unix64).build(); + const Settings settingsWin = settingsBuilder().severity(Severity::style).platform(Platform::Type::Win64).build(); const char code[] = "long f(int x, int y) {\n" " const long ret = x * y;\n" @@ -375,8 +375,8 @@ class TestType : public TestFixture { } void longCastReturn() { - const Settings settings = settingsBuilder().severity(Severity::style).platform(cppcheck::Platform::Type::Unix64).build(); - const Settings settingsWin = settingsBuilder().severity(Severity::style).platform(cppcheck::Platform::Type::Win64).build(); + const Settings settings = settingsBuilder().severity(Severity::style).platform(Platform::Type::Unix64).build(); + const Settings settingsWin = settingsBuilder().severity(Severity::style).platform(Platform::Type::Win64).build(); const char code[] = "long f(int x, int y) {\n" " return x * y;\n" diff --git a/test/testunusedfunctions.cpp b/test/testunusedfunctions.cpp index c38c453b17b..d51ec6c6f0e 100644 --- a/test/testunusedfunctions.cpp +++ b/test/testunusedfunctions.cpp @@ -83,7 +83,7 @@ class TestUnusedFunctions : public TestFixture { } #define check(...) check_(__FILE__, __LINE__, __VA_ARGS__) - void check_(const char* file, int line, const char code[], cppcheck::Platform::Type platform = cppcheck::Platform::Type::Native, const Settings *s = nullptr) { + void check_(const char* file, int line, const char code[], Platform::Type platform = Platform::Type::Native, const Settings *s = nullptr) { // Clear the error buffer.. errout.str(""); @@ -653,10 +653,10 @@ class TestUnusedFunctions : public TestFixture { const Settings s = settingsBuilder(settings).library("windows.cfg").build(); - check("int WinMain() { }", cppcheck::Platform::Type::Native, &s); + check("int WinMain() { }", Platform::Type::Native, &s); ASSERT_EQUALS("", errout.str()); - check("int _tmain() { }", cppcheck::Platform::Type::Native, &s); + check("int _tmain() { }", Platform::Type::Native, &s); ASSERT_EQUALS("", errout.str()); } @@ -669,10 +669,10 @@ class TestUnusedFunctions : public TestFixture { const Settings s = settingsBuilder(settings).library("windows.cfg").build(); - check("int wWinMain() { }", cppcheck::Platform::Type::Native, &s); + check("int wWinMain() { }", Platform::Type::Native, &s); ASSERT_EQUALS("", errout.str()); - check("int _tmain() { }", cppcheck::Platform::Type::Native, &s); + check("int _tmain() { }", Platform::Type::Native, &s); ASSERT_EQUALS("", errout.str()); } @@ -685,7 +685,7 @@ class TestUnusedFunctions : public TestFixture { const Settings s = settingsBuilder(settings).library("gnu.cfg").build(); check("int _init() { }\n" - "int _fini() { }\n", cppcheck::Platform::Type::Native, &s); + "int _fini() { }\n", Platform::Type::Native, &s); ASSERT_EQUALS("", errout.str()); } diff --git a/test/testunusedprivfunc.cpp b/test/testunusedprivfunc.cpp index 81936efc55b..a0842a8526a 100644 --- a/test/testunusedprivfunc.cpp +++ b/test/testunusedprivfunc.cpp @@ -87,7 +87,7 @@ class TestUnusedPrivateFunction : public TestFixture { } #define check(...) check_(__FILE__, __LINE__, __VA_ARGS__) - void check_(const char* file, int line, const char code[], cppcheck::Platform::Type platform = cppcheck::Platform::Type::Native) { + void check_(const char* file, int line, const char code[], Platform::Type platform = Platform::Type::Native) { // Clear the error buffer.. errout.str(""); @@ -606,7 +606,7 @@ class TestUnusedPrivateFunction : public TestFixture { "public:\n" " Foo() { }\n" " __property int x = {read=getx}\n" - "};", cppcheck::Platform::Type::Win32A); + "};", Platform::Type::Win32A); ASSERT_EQUALS("", errout.str()); } @@ -619,7 +619,7 @@ class TestUnusedPrivateFunction : public TestFixture { " }\n" "public:\n" " Foo() { }\n" - "};", cppcheck::Platform::Type::Win32A); + "};", Platform::Type::Win32A); ASSERT_EQUALS("", errout.str()); } diff --git a/test/testvalueflow.cpp b/test/testvalueflow.cpp index 9e0937b2a47..78d33a551d6 100644 --- a/test/testvalueflow.cpp +++ b/test/testvalueflow.cpp @@ -992,7 +992,7 @@ class TestValueFlow : public TestFixture { // ~ code = "x = ~0U;"; - PLATFORM(settings.platform, cppcheck::Platform::Type::Native); // ensure platform is native + PLATFORM(settings.platform, Platform::Type::Native); // ensure platform is native values = tokenValues(code,"~"); ASSERT_EQUALS(1U, values.size()); ASSERT_EQUALS(~0U, values.back().intvalue); diff --git a/test/testvarid.cpp b/test/testvarid.cpp index dd30bf3fe2d..fd8050a4d4b 100644 --- a/test/testvarid.cpp +++ b/test/testvarid.cpp @@ -32,7 +32,7 @@ class TestVarID : public TestFixture { TestVarID() : TestFixture("TestVarID") {} private: - const Settings settings = settingsBuilder().c(Standards::C89).cpp(Standards::CPPLatest).platform(cppcheck::Platform::Type::Unix64).build(); + const Settings settings = settingsBuilder().c(Standards::C89).cpp(Standards::CPPLatest).platform(Platform::Type::Unix64).build(); void run() override { TEST_CASE(varid1); TEST_CASE(varid2);