diff --git a/cli/cppcheckexecutor.cpp b/cli/cppcheckexecutor.cpp index e99555a2599..b7fbf5c4915 100644 --- a/cli/cppcheckexecutor.cpp +++ b/cli/cppcheckexecutor.cpp @@ -465,7 +465,7 @@ int CppCheckExecutor::check_internal(const Settings& settings) const } if (!settings.checkConfiguration) { - cppcheck.tooManyConfigsError(emptyString,0U); + cppcheck.tooManyConfigsError("",0U); } stdLogger.writeCheckersReport(); diff --git a/cli/processexecutor.cpp b/cli/processexecutor.cpp index d60638f447f..6e347568c21 100644 --- a/cli/processexecutor.cpp +++ b/cli/processexecutor.cpp @@ -24,7 +24,6 @@ #if !defined(WIN32) && !defined(__MINGW32__) -#include "config.h" #include "cppcheck.h" #include "errorlogger.h" #include "errortypes.h" @@ -404,7 +403,7 @@ void ProcessExecutor::reportInternalChildErr(const std::string &childname, const std::list locations; locations.emplace_back(childname, 0, 0); const ErrorMessage errmsg(std::move(locations), - emptyString, + "", Severity::error, "Internal error: " + msg, "cppcheckError", diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index 5fca5e89817..f00da25b34a 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -3794,7 +3794,7 @@ void CheckClass::getErrorMessages(ErrorLogger *errorLogger, const Settings *sett c.uninitVarError(nullptr, false, Function::eConstructor, "classname", "varname", true, false); c.uninitVarError(nullptr, true, Function::eConstructor, "classname", "varnamepriv", true, false); c.missingMemberCopyError(nullptr, Function::eConstructor, "classname", "varnamepriv"); - c.operatorEqVarError(nullptr, "classname", emptyString, false); + c.operatorEqVarError(nullptr, "classname", "", false); c.unusedPrivateFunctionError(nullptr, "classname", "funcname"); c.memsetError(nullptr, "memfunc", "classname", "class"); c.memsetErrorReference(nullptr, "memfunc", "class"); diff --git a/lib/checkcondition.cpp b/lib/checkcondition.cpp index 4f5d3a6ff1e..6fc8ccf46b2 100644 --- a/lib/checkcondition.cpp +++ b/lib/checkcondition.cpp @@ -2072,7 +2072,7 @@ void CheckCondition::getErrorMessages(ErrorLogger *errorLogger, const Settings * { CheckCondition c(nullptr, settings, errorLogger); - c.assignIfError(nullptr, nullptr, emptyString, false); + c.assignIfError(nullptr, nullptr, "", false); c.badBitmaskCheckError(nullptr); c.comparisonError(nullptr, "&", 6, "==", 1, false); c.duplicateConditionError(nullptr, nullptr, ErrorPath{}); diff --git a/lib/checknullpointer.h b/lib/checknullpointer.h index 0c9b2d990c2..aa2970bf731 100644 --- a/lib/checknullpointer.h +++ b/lib/checknullpointer.h @@ -88,7 +88,7 @@ class CPPCHECKLIB CheckNullPointer : public Check { void nullPointerError(const Token *tok) { ValueFlow::Value v(0); v.setKnown(); - nullPointerError(tok, emptyString, &v, false); + nullPointerError(tok, "", &v, false); } void nullPointerError(const Token *tok, const std::string &varname, const ValueFlow::Value* value, bool inconclusive); diff --git a/lib/checkstl.cpp b/lib/checkstl.cpp index 647c8338b24..809d6366cb6 100644 --- a/lib/checkstl.cpp +++ b/lib/checkstl.cpp @@ -3376,8 +3376,8 @@ void CheckStl::getErrorMessages(ErrorLogger* errorLogger, const Settings* settin c.uselessCallsRemoveError(nullptr, "remove"); c.dereferenceInvalidIteratorError(nullptr, "i"); c.eraseIteratorOutOfBoundsError(nullptr, nullptr); - c.useStlAlgorithmError(nullptr, emptyString); - c.knownEmptyContainerError(nullptr, emptyString); + c.useStlAlgorithmError(nullptr, ""); + c.knownEmptyContainerError(nullptr, ""); c.globalLockGuardError(nullptr); c.localMutexError(nullptr); } diff --git a/lib/checkunusedfunctions.cpp b/lib/checkunusedfunctions.cpp index 9d128055a35..25fbd9a63aa 100644 --- a/lib/checkunusedfunctions.cpp +++ b/lib/checkunusedfunctions.cpp @@ -351,7 +351,7 @@ static void staticFunctionError(ErrorLogger& errorLogger, locationList.back().fileIndex = fileIndex; } - const ErrorMessage errmsg(std::move(locationList), emptyString, Severity::style, "$symbol:" + funcname + "\nThe function '$symbol' should have static linkage since it is not used outside of its translation unit.", "staticFunction", Certainty::normal); + const ErrorMessage errmsg(std::move(locationList), "", Severity::style, "$symbol:" + funcname + "\nThe function '$symbol' should have static linkage since it is not used outside of its translation unit.", "staticFunction", Certainty::normal); errorLogger.reportErr(errmsg); } @@ -412,7 +412,7 @@ void CheckUnusedFunctions::unusedFunctionError(ErrorLogger& errorLogger, locationList.back().fileIndex = fileIndex; } - const ErrorMessage errmsg(std::move(locationList), emptyString, Severity::style, "$symbol:" + funcname + "\nThe function '$symbol' is never used.", "unusedFunction", CWE561, Certainty::normal); + const ErrorMessage errmsg(std::move(locationList), "", Severity::style, "$symbol:" + funcname + "\nThe function '$symbol' is never used.", "unusedFunction", CWE561, Certainty::normal); errorLogger.reportErr(errmsg); } diff --git a/lib/checkunusedfunctions.h b/lib/checkunusedfunctions.h index 6e8e1f71da8..562f724cb51 100644 --- a/lib/checkunusedfunctions.h +++ b/lib/checkunusedfunctions.h @@ -57,7 +57,7 @@ class CPPCHECKLIB CheckUnusedFunctions { static void analyseWholeProgram(const Settings &settings, ErrorLogger& errorLogger, const std::string &buildDir); static void getErrorMessages(ErrorLogger &errorLogger) { - unusedFunctionError(errorLogger, emptyString, 0, 0, "funcName"); + unusedFunctionError(errorLogger, "", 0, 0, "funcName"); } // Return true if an error is reported. diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index a20c62303c7..56014f18390 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -339,7 +339,7 @@ static std::string getDumpFileName(const Settings& settings, const std::string& extension = "." + std::to_string(settings.pid) + ".dump"; if (!settings.dump && !settings.buildDir.empty()) - return AnalyzerInformation::getAnalyzerInfoFile(settings.buildDir, filename, emptyString) + extension; + return AnalyzerInformation::getAnalyzerInfoFile(settings.buildDir, filename, "") + extension; return filename + extension; } @@ -658,7 +658,7 @@ unsigned int CppCheck::checkClang(const FileWithDetails &file) mErrorLogger.reportOut(std::string("Checking ") + file.spath() + " ...", Color::FgGreen); // TODO: get language from FileWithDetails object - const std::string analyzerInfo = mSettings.buildDir.empty() ? std::string() : AnalyzerInformation::getAnalyzerInfoFile(mSettings.buildDir, file.spath(), emptyString); + const std::string analyzerInfo = mSettings.buildDir.empty() ? std::string() : AnalyzerInformation::getAnalyzerInfoFile(mSettings.buildDir, file.spath(), ""); const std::string clangcmd = analyzerInfo + ".clang-cmd"; const std::string clangStderr = analyzerInfo + ".clang-stderr"; const std::string clangAst = analyzerInfo + ".clang-ast"; @@ -773,13 +773,13 @@ unsigned int CppCheck::check(const FileWithDetails &file) if (mSettings.clang) return checkClang(file); - return checkFile(file, emptyString); + return checkFile(file, ""); } unsigned int CppCheck::check(const FileWithDetails &file, const std::string &content) { std::istringstream iss(content); - return checkFile(file, emptyString, &iss); + return checkFile(file, "", &iss); } unsigned int CppCheck::check(const FileSettings &fs) @@ -1298,7 +1298,7 @@ void CppCheck::internalError(const std::string &filename, const std::string &msg ErrorMessage::FileLocation loc1(filename, 0, 0); ErrorMessage errmsg({std::move(loc1)}, - emptyString, + "", Severity::error, fullmsg, "internalError", @@ -1333,7 +1333,7 @@ void CppCheck::checkNormalTokens(const Tokenizer &tokenizer, AnalyzerInformation if (mSettings.debugwarnings) { ErrorMessage::FileLocation loc(tokenizer.list.getFiles()[0], 0, 0); ErrorMessage errmsg({std::move(loc)}, - emptyString, + "", Severity::debug, "Checks maximum time exceeded", "checksMaxTime", @@ -1564,7 +1564,7 @@ void CppCheck::executeRules(const std::string &tokenlist, const TokenList &list) if (pcreCompileErrorStr) { const std::string msg = "pcre_compile failed: " + std::string(pcreCompileErrorStr); const ErrorMessage errmsg(std::list(), - emptyString, + "", Severity::error, msg, "pcre_compile", @@ -1585,7 +1585,7 @@ void CppCheck::executeRules(const std::string &tokenlist, const TokenList &list) if (pcreStudyErrorStr) { const std::string msg = "pcre_study failed: " + std::string(pcreStudyErrorStr); const ErrorMessage errmsg(std::list(), - emptyString, + "", Severity::error, msg, "pcre_study", @@ -1608,7 +1608,7 @@ void CppCheck::executeRules(const std::string &tokenlist, const TokenList &list) const std::string errorMessage = pcreErrorCodeToString(pcreExecRet); if (!errorMessage.empty()) { const ErrorMessage errmsg(std::list(), - emptyString, + "", Severity::error, std::string("pcre_exec failed: ") + errorMessage, "pcre_exec", @@ -1843,7 +1843,7 @@ void CppCheck::tooManyConfigsError(const std::string &file, const int numberOfCo ErrorMessage errmsg(std::move(loclist), - emptyString, + "", Severity::information, msg.str(), "toomanyconfigs", CWE398, @@ -1865,7 +1865,7 @@ void CppCheck::purgedConfigurationMessage(const std::string &file, const std::st } ErrorMessage errmsg(std::move(loclist), - emptyString, + "", Severity::information, "The configuration '" + configuration + "' was not checked because its code equals another one.", "purgedConfiguration", @@ -1882,9 +1882,9 @@ void CppCheck::getErrorMessages(ErrorLogger &errorlogger) s.addEnabled("all"); CppCheck cppcheck(errorlogger, true, nullptr); - cppcheck.purgedConfigurationMessage(emptyString,emptyString); + cppcheck.purgedConfigurationMessage("",""); cppcheck.mTooManyConfigs = true; - cppcheck.tooManyConfigsError(emptyString,0U); + cppcheck.tooManyConfigsError("",0U); // TODO: add functions to get remaining error messages // call all "getErrorMessages" in all registered Check classes @@ -1913,7 +1913,7 @@ void CppCheck::analyseClangTidy(const FileSettings &fileSettings) const std::string args = "-quiet -checks=*,-clang-analyzer-*,-llvm* \"" + fileSettings.filename() + "\" -- " + allIncludes + allDefines; std::string output; - if (const int exitcode = mExecuteCommand(exe, split(args), emptyString, output)) { + if (const int exitcode = mExecuteCommand(exe, split(args), "", output)) { std::cerr << "Failed to execute '" << exe << "' (exitcode: " << std::to_string(exitcode) << ")" << std::endl; return; } @@ -1923,7 +1923,7 @@ void CppCheck::analyseClangTidy(const FileSettings &fileSettings) std::string line; if (!mSettings.buildDir.empty()) { - const std::string analyzerInfoFile = AnalyzerInformation::getAnalyzerInfoFile(mSettings.buildDir, fileSettings.filename(), emptyString); + const std::string analyzerInfoFile = AnalyzerInformation::getAnalyzerInfoFile(mSettings.buildDir, fileSettings.filename(), ""); std::ofstream fcmd(analyzerInfoFile + ".clang-tidy-cmd"); fcmd << istr.str(); } diff --git a/lib/importproject.cpp b/lib/importproject.cpp index e4bfc8b42cd..498eb22456a 100644 --- a/lib/importproject.cpp +++ b/lib/importproject.cpp @@ -204,7 +204,7 @@ ImportProject::Type ImportProject::import(const std::string &filename, Settings } else if (endsWith(filename, ".vcxproj")) { std::map variables; std::vector sharedItemsProjects; - if (importVcxproj(filename, variables, emptyString, fileFilters, sharedItemsProjects)) { + if (importVcxproj(filename, variables, "", fileFilters, sharedItemsProjects)) { setRelativePaths(filename); return ImportProject::Type::VS_VCXPROJ; } @@ -462,7 +462,7 @@ bool ImportProject::importSln(std::istream &istr, const std::string &path, const if (!Path::isAbsolute(vcxproj)) vcxproj = path + vcxproj; vcxproj = Path::fromNativeSeparators(std::move(vcxproj)); - if (!importVcxproj(vcxproj, variables, emptyString, fileFilters, sharedItemsProjects)) { + if (!importVcxproj(vcxproj, variables, "", fileFilters, sharedItemsProjects)) { printError("failed to load '" + vcxproj + "' from Visual Studio solution"); return false; } @@ -1311,7 +1311,7 @@ bool ImportProject::importCppcheckGuiProject(std::istream &istr, Settings *setti suppressions.push_back(std::move(s)); } } else if (strcmp(name, CppcheckXml::VSConfigurationElementName) == 0) - guiProject.checkVsConfigs = readXmlStringList(node, emptyString, CppcheckXml::VSConfigurationName, nullptr); + guiProject.checkVsConfigs = readXmlStringList(node, "", CppcheckXml::VSConfigurationName, nullptr); else if (strcmp(name, CppcheckXml::PlatformElementName) == 0) guiProject.platform = empty_if_null(node->GetText()); else if (strcmp(name, CppcheckXml::AnalyzeAllVsConfigsElementName) == 0) @@ -1319,13 +1319,13 @@ bool ImportProject::importCppcheckGuiProject(std::istream &istr, Settings *setti else if (strcmp(name, CppcheckXml::Parser) == 0) temp.clang = true; else if (strcmp(name, CppcheckXml::AddonsElementName) == 0) { - const auto& addons = readXmlStringList(node, emptyString, CppcheckXml::AddonElementName, nullptr); + const auto& addons = readXmlStringList(node, "", CppcheckXml::AddonElementName, nullptr); temp.addons.insert(addons.cbegin(), addons.cend()); } else if (strcmp(name, CppcheckXml::TagsElementName) == 0) node->Attribute(CppcheckXml::TagElementName); // FIXME: Write some warning else if (strcmp(name, CppcheckXml::ToolsElementName) == 0) { - const std::list toolList = readXmlStringList(node, emptyString, CppcheckXml::ToolElementName, nullptr); + const std::list toolList = readXmlStringList(node, "", CppcheckXml::ToolElementName, nullptr); for (const std::string &toolName : toolList) { if (toolName == CppcheckXml::ClangTidy) temp.clangTidy = true; diff --git a/lib/preprocessor.cpp b/lib/preprocessor.cpp index 6c5eb9df1db..e5802de35c3 100644 --- a/lib/preprocessor.cpp +++ b/lib/preprocessor.cpp @@ -340,7 +340,7 @@ std::list Preprocessor::createDirectives(const simplecpp::TokenList & continue; if (tok->next && tok->next->str() == "endfile") continue; - Directive directive(tok->location, emptyString); + Directive directive(tok->location, ""); for (const simplecpp::Token *tok2 = tok; tok2 && tok2->location.line == directive.linenr; tok2 = tok2->next) { if (tok2->comment) continue; @@ -691,7 +691,7 @@ static simplecpp::DUI createDUI(const Settings &mSettings, const std::string &cf splitcfg(mSettings.userDefines, dui.defines, "1"); if (!cfg.empty()) - splitcfg(cfg, dui.defines, emptyString); + splitcfg(cfg, dui.defines, ""); for (const std::string &def : mSettings.library.defines()) { const std::string::size_type pos = def.find_first_of(" ("); @@ -769,7 +769,7 @@ void Preprocessor::handleErrors(const simplecpp::OutputList& outputList, bool th bool Preprocessor::loadFiles(const simplecpp::TokenList &rawtokens, std::vector &files) { - const simplecpp::DUI dui = createDUI(mSettings, emptyString, files[0]); + const simplecpp::DUI dui = createDUI(mSettings, "", files[0]); simplecpp::OutputList outputList; mTokenLists = simplecpp::load(rawtokens, files, dui, &outputList); @@ -924,9 +924,9 @@ void Preprocessor::missingInclude(const std::string &filename, unsigned int line void Preprocessor::getErrorMessages(ErrorLogger &errorLogger, const Settings &settings) { Preprocessor preprocessor(settings, errorLogger); - preprocessor.missingInclude(emptyString, 1, emptyString, UserHeader); - preprocessor.missingInclude(emptyString, 1, emptyString, SystemHeader); - preprocessor.error(emptyString, 1, "#error message"); // #error .. + preprocessor.missingInclude("", 1, "", UserHeader); + preprocessor.missingInclude("", 1, "", SystemHeader); + preprocessor.error("", 1, "#error message"); // #error .. } void Preprocessor::dump(std::ostream &out) const diff --git a/lib/suppressions.cpp b/lib/suppressions.cpp index 341d7012342..d5a10d8176e 100644 --- a/lib/suppressions.cpp +++ b/lib/suppressions.cpp @@ -592,7 +592,7 @@ bool SuppressionList::reportUnmatchedSuppressions(const std::list callStack; if (!s.fileName.empty()) callStack.emplace_back(s.fileName, s.lineNumber, 0); - errorLogger.reportErr(::ErrorMessage(std::move(callStack), emptyString, Severity::information, "Unmatched suppression: " + s.errorId, "unmatchedSuppression", Certainty::normal)); + errorLogger.reportErr(::ErrorMessage(std::move(callStack), "", Severity::information, "Unmatched suppression: " + s.errorId, "unmatchedSuppression", Certainty::normal)); err = true; } return err; diff --git a/lib/templatesimplifier.cpp b/lib/templatesimplifier.cpp index 3c8078bdce2..59987a68b7c 100644 --- a/lib/templatesimplifier.cpp +++ b/lib/templatesimplifier.cpp @@ -3175,7 +3175,7 @@ bool TemplateSimplifier::simplifyTemplateInstantiations( if (mSettings.debugwarnings) { ErrorMessage::FileLocation loc(mTokenList.getFiles()[0], 0, 0); ErrorMessage errmsg({std::move(loc)}, - emptyString, + "", Severity::debug, "Template instantiation maximum time exceeded", "templateMaxTime", @@ -3251,7 +3251,7 @@ bool TemplateSimplifier::simplifyTemplateInstantiations( if (mSettings.debugwarnings) { ErrorMessage::FileLocation loc(mTokenList.getFiles()[0], 0, 0); ErrorMessage errmsg({std::move(loc)}, - emptyString, + "", Severity::debug, "Template instantiation maximum time exceeded", "templateMaxTime", diff --git a/lib/templatesimplifier.h b/lib/templatesimplifier.h index 6cbfd40a8ea..693de8c0165 100644 --- a/lib/templatesimplifier.h +++ b/lib/templatesimplifier.h @@ -490,7 +490,7 @@ class CPPCHECKLIB TemplateSimplifier { void printOut( const TokenAndName &tokenAndName, const std::string &indent = " ") const; - void printOut(const std::string &text = emptyString) const; + void printOut(const std::string &text = "") const; Tokenizer &mTokenizer; TokenList &mTokenList; diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index fea21bc61ce..2aa6a8b8afa 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -1225,7 +1225,7 @@ void Tokenizer::simplifyTypedefCpp() if (mSettings.debugwarnings) { ErrorMessage::FileLocation loc(list.getFiles()[0], 0, 0); ErrorMessage errmsg({std::move(loc)}, - emptyString, + "", Severity::debug, "Typedef simplification instantiation maximum time exceeded", "typedefMaxTime", @@ -10926,7 +10926,7 @@ void Tokenizer::getErrorMessages(ErrorLogger& errorLogger, const Settings& setti Tokenizer tokenizer(settings, errorLogger); tokenizer.invalidConstFunctionTypeError(nullptr); // checkLibraryNoReturn - tokenizer.unhandled_macro_class_x_y(nullptr, emptyString, emptyString, emptyString, emptyString); - tokenizer.macroWithSemicolonError(nullptr, emptyString); - tokenizer.unhandledCharLiteral(nullptr, emptyString); + tokenizer.unhandled_macro_class_x_y(nullptr, "", "", "", ""); + tokenizer.macroWithSemicolonError(nullptr, ""); + tokenizer.unhandledCharLiteral(nullptr, ""); } diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 69afe396a12..9f5254b02c7 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -7098,7 +7098,7 @@ struct ValueFlowPassRunner { if (n == 0 && values != getTotalValues()) { ErrorMessage::FileLocation loc(state.tokenlist.getFiles()[0], 0, 0); ErrorMessage errmsg({std::move(loc)}, - emptyString, + "", Severity::debug, "ValueFlow maximum iterations exceeded", "valueFlowMaxIterations", diff --git a/test/fixture.h b/test/fixture.h index a2f315aeaae..0a440dc1185 100644 --- a/test/fixture.h +++ b/test/fixture.h @@ -22,7 +22,6 @@ #include "check.h" #include "color.h" -#include "config.h" #include "errorlogger.h" #include "platform.h" #include "settings.h" @@ -72,7 +71,7 @@ class TestFixture : public ErrorLogger { void assert_(const char * filename, unsigned int linenr, bool condition) const; template - void assertEquals(const char* const filename, const unsigned int linenr, const T& expected, const T& actual, const std::string& msg = emptyString) const { + void assertEquals(const char* const filename, const unsigned int linenr, const T& expected, const T& actual, const std::string& msg = "") const { if (expected != actual) { std::ostringstream expectedStr; expectedStr << expected; @@ -84,7 +83,7 @@ class TestFixture : public ErrorLogger { } template - void assertEqualsEnum(const char* const filename, const unsigned int linenr, const T& expected, const T& actual, const std::string& msg = emptyString) const { + void assertEqualsEnum(const char* const filename, const unsigned int linenr, const T& expected, const T& actual, const std::string& msg = "") const { if (std::is_unsigned()) assertEquals(filename, linenr, static_cast(expected), static_cast(actual), msg); else @@ -99,13 +98,13 @@ class TestFixture : public ErrorLogger { todoAssertEquals(filename, linenr, static_cast(wanted), static_cast(current), static_cast(actual)); } - void assertEquals(const char * filename, unsigned int linenr, const std::string &expected, const std::string &actual, const std::string &msg = emptyString) const; - void assertEqualsWithoutLineNumbers(const char * filename, unsigned int linenr, const std::string &expected, const std::string &actual, const std::string &msg = emptyString) const; - void assertEquals(const char * filename, unsigned int linenr, const char expected[], const std::string& actual, const std::string &msg = emptyString) const; - void assertEquals(const char * filename, unsigned int linenr, const char expected[], const char actual[], const std::string &msg = emptyString) const; - void assertEquals(const char * filename, unsigned int linenr, const std::string& expected, const char actual[], const std::string &msg = emptyString) const; - void assertEquals(const char * filename, unsigned int linenr, long long expected, long long actual, const std::string &msg = emptyString) const; - void assertEqualsDouble(const char * filename, unsigned int linenr, double expected, double actual, double tolerance, const std::string &msg = emptyString) const; + void assertEquals(const char * filename, unsigned int linenr, const std::string &expected, const std::string &actual, const std::string &msg = "") const; + void assertEqualsWithoutLineNumbers(const char * filename, unsigned int linenr, const std::string &expected, const std::string &actual, const std::string &msg = "") const; + void assertEquals(const char * filename, unsigned int linenr, const char expected[], const std::string& actual, const std::string &msg = "") const; + void assertEquals(const char * filename, unsigned int linenr, const char expected[], const char actual[], const std::string &msg = "") const; + void assertEquals(const char * filename, unsigned int linenr, const std::string& expected, const char actual[], const std::string &msg = "") const; + void assertEquals(const char * filename, unsigned int linenr, long long expected, long long actual, const std::string &msg = "") const; + void assertEqualsDouble(const char * filename, unsigned int linenr, double expected, double actual, double tolerance, const std::string &msg = "") const; void todoAssertEquals(const char * filename, unsigned int linenr, const std::string &wanted, const std::string ¤t, const std::string &actual) const; diff --git a/test/helpers.h b/test/helpers.h index f85f5a01fe7..acb81c8d46a 100644 --- a/test/helpers.h +++ b/test/helpers.h @@ -19,7 +19,6 @@ #ifndef helpersH #define helpersH -#include "config.h" #include "library.h" #include "preprocessor.h" #include "settings.h" @@ -80,7 +79,7 @@ class SimpleTokenizer : public Tokenizer { template bool tokenize(const char (&code)[size], bool cpp = true, - const std::string &configuration = emptyString) + const std::string &configuration = "") { std::istringstream istr(code); if (!list.createTokens(istr, cpp ? "test.cpp" : "test.c")) @@ -92,7 +91,7 @@ class SimpleTokenizer : public Tokenizer { // TODO: get rid of this bool tokenize(const std::string& code, bool cpp = true, - const std::string &configuration = emptyString) + const std::string &configuration = "") { std::istringstream istr(code); if (!list.createTokens(istr, cpp ? "test.cpp" : "test.c")) diff --git a/test/testerrorlogger.cpp b/test/testerrorlogger.cpp index 39c219c1d9b..e6b841594bc 100644 --- a/test/testerrorlogger.cpp +++ b/test/testerrorlogger.cpp @@ -16,7 +16,6 @@ * along with this program. If not, see . */ -#include "config.h" #include "cppcheck.h" #include "errorlogger.h" #include "errortypes.h" @@ -126,7 +125,7 @@ class TestErrorLogger : public TestFixture { void ErrorMessageConstruct() const { std::list locs(1, fooCpp5); - ErrorMessage msg(std::move(locs), emptyString, Severity::error, "Programming error.", "errorId", Certainty::normal); + ErrorMessage msg(std::move(locs), "", Severity::error, "Programming error.", "errorId", Certainty::normal); ASSERT_EQUALS(1, msg.callStack.size()); ASSERT_EQUALS("Programming error.", msg.shortMessage()); ASSERT_EQUALS("Programming error.", msg.verboseMessage()); @@ -136,7 +135,7 @@ class TestErrorLogger : public TestFixture { void ErrorMessageConstructLocations() const { std::list locs = { fooCpp5, barCpp8 }; - ErrorMessage msg(std::move(locs), emptyString, Severity::error, "Programming error.", "errorId", Certainty::normal); + ErrorMessage msg(std::move(locs), "", Severity::error, "Programming error.", "errorId", Certainty::normal); ASSERT_EQUALS(2, msg.callStack.size()); ASSERT_EQUALS("Programming error.", msg.shortMessage()); ASSERT_EQUALS("Programming error.", msg.verboseMessage()); @@ -146,7 +145,7 @@ class TestErrorLogger : public TestFixture { void ErrorMessageVerbose() const { std::list locs(1, fooCpp5); - ErrorMessage msg(std::move(locs), emptyString, Severity::error, "Programming error.\nVerbose error", "errorId", Certainty::normal); + ErrorMessage msg(std::move(locs), "", Severity::error, "Programming error.\nVerbose error", "errorId", Certainty::normal); ASSERT_EQUALS(1, msg.callStack.size()); ASSERT_EQUALS("Programming error.", msg.shortMessage()); ASSERT_EQUALS("Verbose error", msg.verboseMessage()); @@ -156,7 +155,7 @@ class TestErrorLogger : public TestFixture { void ErrorMessageVerboseLocations() const { std::list locs = { fooCpp5, barCpp8 }; - ErrorMessage msg(std::move(locs), emptyString, Severity::error, "Programming error.\nVerbose error", "errorId", Certainty::normal); + ErrorMessage msg(std::move(locs), "", Severity::error, "Programming error.\nVerbose error", "errorId", Certainty::normal); ASSERT_EQUALS(2, msg.callStack.size()); ASSERT_EQUALS("Programming error.", msg.shortMessage()); ASSERT_EQUALS("Verbose error", msg.verboseMessage()); @@ -196,7 +195,7 @@ class TestErrorLogger : public TestFixture { void CustomFormat() const { std::list locs(1, fooCpp5); - ErrorMessage msg(std::move(locs), emptyString, Severity::error, "Programming error.\nVerbose error", "errorId", Certainty::normal); + ErrorMessage msg(std::move(locs), "", Severity::error, "Programming error.\nVerbose error", "errorId", Certainty::normal); ASSERT_EQUALS(1, msg.callStack.size()); ASSERT_EQUALS("Programming error.", msg.shortMessage()); ASSERT_EQUALS("Verbose error", msg.verboseMessage()); @@ -206,7 +205,7 @@ class TestErrorLogger : public TestFixture { void CustomFormat2() const { std::list locs(1, fooCpp5); - ErrorMessage msg(std::move(locs), emptyString, Severity::error, "Programming error.\nVerbose error", "errorId", Certainty::normal); + ErrorMessage msg(std::move(locs), "", Severity::error, "Programming error.\nVerbose error", "errorId", Certainty::normal); ASSERT_EQUALS(1, msg.callStack.size()); ASSERT_EQUALS("Programming error.", msg.shortMessage()); ASSERT_EQUALS("Verbose error", msg.verboseMessage()); @@ -217,7 +216,7 @@ class TestErrorLogger : public TestFixture { void CustomFormatLocations() const { // Check that first location from location stack is used in template std::list locs = { fooCpp5, barCpp8 }; - ErrorMessage msg(std::move(locs), emptyString, Severity::error, "Programming error.\nVerbose error", "errorId", Certainty::normal); + ErrorMessage msg(std::move(locs), "", Severity::error, "Programming error.\nVerbose error", "errorId", Certainty::normal); ASSERT_EQUALS(2, msg.callStack.size()); ASSERT_EQUALS("Programming error.", msg.shortMessage()); ASSERT_EQUALS("Verbose error", msg.verboseMessage()); @@ -227,7 +226,7 @@ class TestErrorLogger : public TestFixture { void ToXmlV2() const { std::list locs(1, fooCpp5); - ErrorMessage msg(std::move(locs), emptyString, Severity::error, "Programming error.\nVerbose error", "errorId", Certainty::normal); + ErrorMessage msg(std::move(locs), "", Severity::error, "Programming error.\nVerbose error", "errorId", Certainty::normal); std::string header("\n\n"); header += " ", msg.toXML()); } void ToXmlV2Locations() const { std::list locs = { fooCpp5, barCpp8_i }; - ErrorMessage msg(std::move(locs), emptyString, Severity::error, "Programming error.\nVerbose error", "errorId", Certainty::normal); + ErrorMessage msg(std::move(locs), "", Severity::error, "Programming error.\nVerbose error", "errorId", Certainty::normal); std::string header("\n\n"); header += " locs; - ErrorMessage msg(std::move(locs), emptyString, Severity::error, "Programming error.\nComparing \"\203\" with \"\003\"", "errorId", Certainty::normal); + ErrorMessage msg(std::move(locs), "", Severity::error, "Programming error.\nComparing \"\203\" with \"\003\"", "errorId", Certainty::normal); const std::string expected(" "); ASSERT_EQUALS(expected, msg.toXML()); } { const char code1[]="äöü"; const char code2[]="\x12\x00\x00\x01"; - ErrorMessage msg1({}, emptyString, Severity::error, std::string("Programming error.\nReading \"")+code1+"\"", "errorId", Certainty::normal); + ErrorMessage msg1({}, "", Severity::error, std::string("Programming error.\nReading \"")+code1+"\"", "errorId", Certainty::normal); ASSERT_EQUALS(" ", msg1.toXML()); - ErrorMessage msg2({}, emptyString, Severity::error, std::string("Programming error.\nReading \"")+code2+"\"", "errorId", Certainty::normal); + ErrorMessage msg2({}, "", Severity::error, std::string("Programming error.\nReading \"")+code2+"\"", "errorId", Certainty::normal); ASSERT_EQUALS(" ", msg2.toXML()); } } @@ -328,7 +327,7 @@ class TestErrorLogger : public TestFixture { std::list locs(1, fooCpp5); // Inconclusive error message - ErrorMessage msg(std::move(locs), emptyString, Severity::error, "Programming error", "errorId", Certainty::inconclusive); + ErrorMessage msg(std::move(locs), "", Severity::error, "Programming error", "errorId", Certainty::inconclusive); // xml version 2 error message ASSERT_EQUALS(" \n" @@ -340,7 +339,7 @@ class TestErrorLogger : public TestFixture { void SerializeInconclusiveMessage() const { // Inconclusive error message std::list locs; - ErrorMessage msg(std::move(locs), emptyString, Severity::error, "Programming error", "errorId", Certainty::inconclusive); + ErrorMessage msg(std::move(locs), "", Severity::error, "Programming error", "errorId", Certainty::inconclusive); msg.file0 = "test.cpp"; const std::string msg_str = msg.serialize(); @@ -439,7 +438,7 @@ class TestErrorLogger : public TestFixture { void SerializeSanitize() const { std::list locs; - ErrorMessage msg(std::move(locs), emptyString, Severity::error, std::string("Illegal character in \"foo\001bar\""), "errorId", Certainty::normal); + ErrorMessage msg(std::move(locs), "", Severity::error, std::string("Illegal character in \"foo\001bar\""), "errorId", Certainty::normal); msg.file0 = "1.c"; const std::string msg_str = msg.serialize(); @@ -468,7 +467,7 @@ class TestErrorLogger : public TestFixture { ErrorMessage::FileLocation loc1(":/,;", "abcd:/,", 654, 33); loc1.setfile("[]:;,()"); - ErrorMessage msg({std::move(loc1)}, emptyString, Severity::error, "Programming error", "errorId", Certainty::inconclusive); + ErrorMessage msg({std::move(loc1)}, "", Severity::error, "Programming error", "errorId", Certainty::inconclusive); const std::string msg_str = msg.serialize(); ASSERT_EQUALS("7 errorId" @@ -494,7 +493,7 @@ class TestErrorLogger : public TestFixture { } void SerializeAndDeserialize() const { - ErrorMessage msg({}, emptyString, Severity::warning, "$symbol:var\nmessage $symbol", "id", Certainty::normal); + ErrorMessage msg({}, "", Severity::warning, "$symbol:var\nmessage $symbol", "id", Certainty::normal); msg.remark = "some remark"; ErrorMessage msg2; diff --git a/test/testio.cpp b/test/testio.cpp index 7314e3eec04..3ccf07858ad 100644 --- a/test/testio.cpp +++ b/test/testio.cpp @@ -17,7 +17,6 @@ */ #include "checkio.h" -#include "config.h" #include "errortypes.h" #include "fixture.h" #include "helpers.h" @@ -835,15 +834,15 @@ class TestIO : public TestFixture { void testFormatStrNoWarn(const char *filename, unsigned int linenr, const char (&code)[size], bool cpp = false) { check(code, dinit(CheckOptions, $.inconclusive = true, $.platform = Platform::Type::Unix32, $.onlyFormatStr = true, $.cpp = cpp)); - assertEquals(filename, linenr, emptyString, errout_str()); + assertEquals(filename, linenr, "", errout_str()); check(code, dinit(CheckOptions, $.inconclusive = true, $.platform = Platform::Type::Unix64, $.onlyFormatStr = true, $.cpp = cpp)); - assertEquals(filename, linenr, emptyString, errout_str()); + assertEquals(filename, linenr, "", errout_str()); check(code, dinit(CheckOptions, $.inconclusive = true, $.platform = Platform::Type::Win32A, $.onlyFormatStr = true, $.cpp = cpp)); - assertEquals(filename, linenr, emptyString, errout_str()); + assertEquals(filename, linenr, "", errout_str()); check(code, dinit(CheckOptions, $.inconclusive = true, $.platform = Platform::Type::Win32W, $.onlyFormatStr = true, $.cpp = cpp)); - assertEquals(filename, linenr, emptyString, errout_str()); + assertEquals(filename, linenr, "", errout_str()); check(code, dinit(CheckOptions, $.inconclusive = true, $.platform = Platform::Type::Win64, $.onlyFormatStr = true, $.cpp = cpp)); - assertEquals(filename, linenr, emptyString, errout_str()); + assertEquals(filename, linenr, "", errout_str()); } template @@ -883,13 +882,13 @@ class TestIO : public TestFixture { const char (&code)[size], const char* testScanfErrAkaWin64String, bool cpp = false) { check(code, dinit(CheckOptions, $.inconclusive = true, $.portability = true, $.platform = Platform::Type::Unix32, $.onlyFormatStr = true, $.cpp = cpp)); - assertEquals(filename, linenr, emptyString, errout_str()); + assertEquals(filename, linenr, "", errout_str()); check(code, dinit(CheckOptions, $.inconclusive = true, $.portability = true, $.platform = Platform::Type::Unix64, $.onlyFormatStr = true, $.cpp = cpp)); - assertEquals(filename, linenr, emptyString, errout_str()); + assertEquals(filename, linenr, "", errout_str()); check(code, dinit(CheckOptions, $.inconclusive = true, $.portability = true, $.platform = Platform::Type::Win32A, $.onlyFormatStr = true, $.cpp = cpp)); - assertEquals(filename, linenr, emptyString, errout_str()); + assertEquals(filename, linenr, "", errout_str()); check(code, dinit(CheckOptions, $.inconclusive = true, $.portability = true, $.platform = Platform::Type::Win32W, $.onlyFormatStr = true, $.cpp = cpp)); - assertEquals(filename, linenr, emptyString, errout_str()); + assertEquals(filename, linenr, "", errout_str()); check(code, dinit(CheckOptions, $.inconclusive = true, $.portability = true, $.platform = Platform::Type::Win64, $.onlyFormatStr = true, $.cpp = cpp)); assertEquals(filename, linenr, testScanfErrAkaWin64String, errout_str()); } @@ -907,7 +906,7 @@ class TestIO : public TestFixture { check(code, dinit(CheckOptions, $.inconclusive = true, $.portability = true, $.platform = Platform::Type::Win32W, $.onlyFormatStr = true, $.cpp = cpp)); assertEquals(filename, linenr, testScanfErrAkaString, errout_str()); check(code, dinit(CheckOptions, $.inconclusive = true, $.portability = true, $.platform = Platform::Type::Win64, $.onlyFormatStr = true, $.cpp = cpp)); - assertEquals(filename, linenr, emptyString, errout_str()); + assertEquals(filename, linenr, "", errout_str()); } #define TEST_SCANF_NOWARN(FORMAT, FORMATSTR, TYPE) \ diff --git a/test/testsuppressions.cpp b/test/testsuppressions.cpp index 166092af2d7..6ff39aaf295 100644 --- a/test/testsuppressions.cpp +++ b/test/testsuppressions.cpp @@ -16,7 +16,6 @@ * along with this program. If not, see . */ -#include "config.h" #include "cppcheck.h" #include "cppcheckexecutor.h" #include "errortypes.h" @@ -205,32 +204,32 @@ class TestSuppressions : public TestFixture { ASSERT_EQUALS(true, suppressions.isSuppressed(errorMessage("errorid", "x/../a.c", 123))); } - unsigned int checkSuppressionFiles(const char code[], const std::string &suppression = emptyString) { + unsigned int checkSuppressionFiles(const char code[], const std::string &suppression = "") { return _checkSuppression(code, false, suppression); } - unsigned int checkSuppressionFS(const char code[], const std::string &suppression = emptyString) { + unsigned int checkSuppressionFS(const char code[], const std::string &suppression = "") { return _checkSuppression(code, true, suppression); } // Check the suppression - unsigned int _checkSuppression(const char code[], bool useFS, const std::string &suppression = emptyString) { + unsigned int _checkSuppression(const char code[], bool useFS, const std::string &suppression = "") { std::map files; files["test.cpp"] = code; return _checkSuppression(files, useFS, suppression); } - unsigned int checkSuppressionFiles(std::map &f, const std::string &suppression = emptyString) { + unsigned int checkSuppressionFiles(std::map &f, const std::string &suppression = "") { return _checkSuppression(f, false, suppression); } - unsigned int checkSuppressionFS(std::map &f, const std::string &suppression = emptyString) { + unsigned int checkSuppressionFS(std::map &f, const std::string &suppression = "") { return _checkSuppression(f, true, suppression); } // Check the suppression for multiple files - unsigned int _checkSuppression(std::map &f, bool useFS, const std::string &suppression = emptyString) { + unsigned int _checkSuppression(std::map &f, bool useFS, const std::string &suppression = "") { std::list fileSettings; std::list filelist; @@ -270,15 +269,15 @@ class TestSuppressions : public TestFixture { return exitCode; } - unsigned int checkSuppressionThreadsFiles(const char code[], const std::string &suppression = emptyString) { + unsigned int checkSuppressionThreadsFiles(const char code[], const std::string &suppression = "") { return _checkSuppressionThreads(code, false, suppression); } - unsigned int checkSuppressionThreadsFS(const char code[], const std::string &suppression = emptyString) { + unsigned int checkSuppressionThreadsFS(const char code[], const std::string &suppression = "") { return _checkSuppressionThreads(code, true, suppression); } - unsigned int _checkSuppressionThreads(const char code[], bool useFS, const std::string &suppression = emptyString) { + unsigned int _checkSuppressionThreads(const char code[], bool useFS, const std::string &suppression = "") { std::list fileSettings; std::list filelist; @@ -314,15 +313,15 @@ class TestSuppressions : public TestFixture { } #if !defined(WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__) - unsigned int checkSuppressionProcessesFiles(const char code[], const std::string &suppression = emptyString) { + unsigned int checkSuppressionProcessesFiles(const char code[], const std::string &suppression = "") { return _checkSuppressionProcesses(code, false, suppression); } - unsigned int checkSuppressionProcessesFS(const char code[], const std::string &suppression = emptyString) { + unsigned int checkSuppressionProcessesFS(const char code[], const std::string &suppression = "") { return _checkSuppressionProcesses(code, true, suppression); } - unsigned int _checkSuppressionProcesses(const char code[], bool useFS, const std::string &suppression = emptyString) { + unsigned int _checkSuppressionProcesses(const char code[], bool useFS, const std::string &suppression = "") { std::list fileSettings; std::list filelist; diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 7e049fc4f68..df267630459 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -16,7 +16,6 @@ * along with this program. If not, see . */ -#include "config.h" #include "errortypes.h" #include "fixture.h" #include "helpers.h" @@ -8389,10 +8388,10 @@ class TestTokenizerCompileLimits : public TestFixture std::istringstream fin(raw_code); simplecpp::OutputList outputList; std::vector files; - const simplecpp::TokenList tokens1(fin, files, emptyString, &outputList); + const simplecpp::TokenList tokens1(fin, files, "", &outputList); const std::string filedata = tokens1.stringify(); const Settings settings; - const std::string code = PreprocessorHelper::getcode(settings, *this, filedata, emptyString, emptyString); + const std::string code = PreprocessorHelper::getcode(settings, *this, filedata, "", ""); ASSERT_THROW_INTERNAL_EQUALS(tokenizeAndStringify(code), AST, "maximum AST depth exceeded"); } diff --git a/tools/dmake/dmake.cpp b/tools/dmake/dmake.cpp index 3e32e788183..f85f65ae0d4 100644 --- a/tools/dmake/dmake.cpp +++ b/tools/dmake/dmake.cpp @@ -31,8 +31,6 @@ #include #include -#include "config.h" - #include "../cli/filelister.h" #include "../lib/filesettings.h" #include "../lib/pathmatch.h" @@ -570,7 +568,7 @@ int main(int argc, char **argv) fout << "# To compile with rules, use 'make HAVE_RULES=yes'\n"; makeConditionalVariable(fout, "HAVE_RULES", ""); - makeMatchcompiler(fout, emptyString, emptyString); + makeMatchcompiler(fout, "", ""); // avoid undefined variable fout << "ifndef CPPFLAGS\n" @@ -839,7 +837,7 @@ int main(int argc, char **argv) compilefiles(fout, libfiles_prio, "${INCLUDE_FOR_LIB}"); compilefiles(fout, clifiles, "${INCLUDE_FOR_CLI}"); compilefiles(fout, testfiles, "${INCLUDE_FOR_TEST}"); - compilefiles(fout, extfiles, emptyString); + compilefiles(fout, extfiles, ""); compilefiles(fout, toolsfiles, "${INCLUDE_FOR_LIB}"); write_ossfuzz_makefile(libfiles_prio, extfiles);