Skip to content

Commit 06e7663

Browse files
authored
reduced unnecessary usage of emptyString (danmar#7229)
1 parent 853b0c5 commit 06e7663

23 files changed

+100
-109
lines changed

cli/cppcheckexecutor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ int CppCheckExecutor::check_internal(const Settings& settings) const
465465
}
466466

467467
if (!settings.checkConfiguration) {
468-
cppcheck.tooManyConfigsError(emptyString,0U);
468+
cppcheck.tooManyConfigsError("",0U);
469469
}
470470

471471
stdLogger.writeCheckersReport();

cli/processexecutor.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
#if !defined(WIN32) && !defined(__MINGW32__)
2626

27-
#include "config.h"
2827
#include "cppcheck.h"
2928
#include "errorlogger.h"
3029
#include "errortypes.h"
@@ -404,7 +403,7 @@ void ProcessExecutor::reportInternalChildErr(const std::string &childname, const
404403
std::list<ErrorMessage::FileLocation> locations;
405404
locations.emplace_back(childname, 0, 0);
406405
const ErrorMessage errmsg(std::move(locations),
407-
emptyString,
406+
"",
408407
Severity::error,
409408
"Internal error: " + msg,
410409
"cppcheckError",

lib/checkclass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3794,7 +3794,7 @@ void CheckClass::getErrorMessages(ErrorLogger *errorLogger, const Settings *sett
37943794
c.uninitVarError(nullptr, false, Function::eConstructor, "classname", "varname", true, false);
37953795
c.uninitVarError(nullptr, true, Function::eConstructor, "classname", "varnamepriv", true, false);
37963796
c.missingMemberCopyError(nullptr, Function::eConstructor, "classname", "varnamepriv");
3797-
c.operatorEqVarError(nullptr, "classname", emptyString, false);
3797+
c.operatorEqVarError(nullptr, "classname", "", false);
37983798
c.unusedPrivateFunctionError(nullptr, "classname", "funcname");
37993799
c.memsetError(nullptr, "memfunc", "classname", "class");
38003800
c.memsetErrorReference(nullptr, "memfunc", "class");

lib/checkcondition.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2072,7 +2072,7 @@ void CheckCondition::getErrorMessages(ErrorLogger *errorLogger, const Settings *
20722072
{
20732073
CheckCondition c(nullptr, settings, errorLogger);
20742074

2075-
c.assignIfError(nullptr, nullptr, emptyString, false);
2075+
c.assignIfError(nullptr, nullptr, "", false);
20762076
c.badBitmaskCheckError(nullptr);
20772077
c.comparisonError(nullptr, "&", 6, "==", 1, false);
20782078
c.duplicateConditionError(nullptr, nullptr, ErrorPath{});

lib/checknullpointer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class CPPCHECKLIB CheckNullPointer : public Check {
8888
void nullPointerError(const Token *tok) {
8989
ValueFlow::Value v(0);
9090
v.setKnown();
91-
nullPointerError(tok, emptyString, &v, false);
91+
nullPointerError(tok, "", &v, false);
9292
}
9393
void nullPointerError(const Token *tok, const std::string &varname, const ValueFlow::Value* value, bool inconclusive);
9494

lib/checkstl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3376,8 +3376,8 @@ void CheckStl::getErrorMessages(ErrorLogger* errorLogger, const Settings* settin
33763376
c.uselessCallsRemoveError(nullptr, "remove");
33773377
c.dereferenceInvalidIteratorError(nullptr, "i");
33783378
c.eraseIteratorOutOfBoundsError(nullptr, nullptr);
3379-
c.useStlAlgorithmError(nullptr, emptyString);
3380-
c.knownEmptyContainerError(nullptr, emptyString);
3379+
c.useStlAlgorithmError(nullptr, "");
3380+
c.knownEmptyContainerError(nullptr, "");
33813381
c.globalLockGuardError(nullptr);
33823382
c.localMutexError(nullptr);
33833383
}

lib/checkunusedfunctions.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ static void staticFunctionError(ErrorLogger& errorLogger,
351351
locationList.back().fileIndex = fileIndex;
352352
}
353353

354-
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);
354+
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);
355355
errorLogger.reportErr(errmsg);
356356
}
357357

@@ -412,7 +412,7 @@ void CheckUnusedFunctions::unusedFunctionError(ErrorLogger& errorLogger,
412412
locationList.back().fileIndex = fileIndex;
413413
}
414414

415-
const ErrorMessage errmsg(std::move(locationList), emptyString, Severity::style, "$symbol:" + funcname + "\nThe function '$symbol' is never used.", "unusedFunction", CWE561, Certainty::normal);
415+
const ErrorMessage errmsg(std::move(locationList), "", Severity::style, "$symbol:" + funcname + "\nThe function '$symbol' is never used.", "unusedFunction", CWE561, Certainty::normal);
416416
errorLogger.reportErr(errmsg);
417417
}
418418

lib/checkunusedfunctions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class CPPCHECKLIB CheckUnusedFunctions {
5757
static void analyseWholeProgram(const Settings &settings, ErrorLogger& errorLogger, const std::string &buildDir);
5858

5959
static void getErrorMessages(ErrorLogger &errorLogger) {
60-
unusedFunctionError(errorLogger, emptyString, 0, 0, "funcName");
60+
unusedFunctionError(errorLogger, "", 0, 0, "funcName");
6161
}
6262

6363
// Return true if an error is reported.

lib/cppcheck.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ static std::string getDumpFileName(const Settings& settings, const std::string&
339339
extension = "." + std::to_string(settings.pid) + ".dump";
340340

341341
if (!settings.dump && !settings.buildDir.empty())
342-
return AnalyzerInformation::getAnalyzerInfoFile(settings.buildDir, filename, emptyString) + extension;
342+
return AnalyzerInformation::getAnalyzerInfoFile(settings.buildDir, filename, "") + extension;
343343
return filename + extension;
344344
}
345345

@@ -658,7 +658,7 @@ unsigned int CppCheck::checkClang(const FileWithDetails &file)
658658
mErrorLogger.reportOut(std::string("Checking ") + file.spath() + " ...", Color::FgGreen);
659659

660660
// TODO: get language from FileWithDetails object
661-
const std::string analyzerInfo = mSettings.buildDir.empty() ? std::string() : AnalyzerInformation::getAnalyzerInfoFile(mSettings.buildDir, file.spath(), emptyString);
661+
const std::string analyzerInfo = mSettings.buildDir.empty() ? std::string() : AnalyzerInformation::getAnalyzerInfoFile(mSettings.buildDir, file.spath(), "");
662662
const std::string clangcmd = analyzerInfo + ".clang-cmd";
663663
const std::string clangStderr = analyzerInfo + ".clang-stderr";
664664
const std::string clangAst = analyzerInfo + ".clang-ast";
@@ -773,13 +773,13 @@ unsigned int CppCheck::check(const FileWithDetails &file)
773773
if (mSettings.clang)
774774
return checkClang(file);
775775

776-
return checkFile(file, emptyString);
776+
return checkFile(file, "");
777777
}
778778

779779
unsigned int CppCheck::check(const FileWithDetails &file, const std::string &content)
780780
{
781781
std::istringstream iss(content);
782-
return checkFile(file, emptyString, &iss);
782+
return checkFile(file, "", &iss);
783783
}
784784

785785
unsigned int CppCheck::check(const FileSettings &fs)
@@ -1298,7 +1298,7 @@ void CppCheck::internalError(const std::string &filename, const std::string &msg
12981298
ErrorMessage::FileLocation loc1(filename, 0, 0);
12991299

13001300
ErrorMessage errmsg({std::move(loc1)},
1301-
emptyString,
1301+
"",
13021302
Severity::error,
13031303
fullmsg,
13041304
"internalError",
@@ -1333,7 +1333,7 @@ void CppCheck::checkNormalTokens(const Tokenizer &tokenizer, AnalyzerInformation
13331333
if (mSettings.debugwarnings) {
13341334
ErrorMessage::FileLocation loc(tokenizer.list.getFiles()[0], 0, 0);
13351335
ErrorMessage errmsg({std::move(loc)},
1336-
emptyString,
1336+
"",
13371337
Severity::debug,
13381338
"Checks maximum time exceeded",
13391339
"checksMaxTime",
@@ -1564,7 +1564,7 @@ void CppCheck::executeRules(const std::string &tokenlist, const TokenList &list)
15641564
if (pcreCompileErrorStr) {
15651565
const std::string msg = "pcre_compile failed: " + std::string(pcreCompileErrorStr);
15661566
const ErrorMessage errmsg(std::list<ErrorMessage::FileLocation>(),
1567-
emptyString,
1567+
"",
15681568
Severity::error,
15691569
msg,
15701570
"pcre_compile",
@@ -1585,7 +1585,7 @@ void CppCheck::executeRules(const std::string &tokenlist, const TokenList &list)
15851585
if (pcreStudyErrorStr) {
15861586
const std::string msg = "pcre_study failed: " + std::string(pcreStudyErrorStr);
15871587
const ErrorMessage errmsg(std::list<ErrorMessage::FileLocation>(),
1588-
emptyString,
1588+
"",
15891589
Severity::error,
15901590
msg,
15911591
"pcre_study",
@@ -1608,7 +1608,7 @@ void CppCheck::executeRules(const std::string &tokenlist, const TokenList &list)
16081608
const std::string errorMessage = pcreErrorCodeToString(pcreExecRet);
16091609
if (!errorMessage.empty()) {
16101610
const ErrorMessage errmsg(std::list<ErrorMessage::FileLocation>(),
1611-
emptyString,
1611+
"",
16121612
Severity::error,
16131613
std::string("pcre_exec failed: ") + errorMessage,
16141614
"pcre_exec",
@@ -1843,7 +1843,7 @@ void CppCheck::tooManyConfigsError(const std::string &file, const int numberOfCo
18431843

18441844

18451845
ErrorMessage errmsg(std::move(loclist),
1846-
emptyString,
1846+
"",
18471847
Severity::information,
18481848
msg.str(),
18491849
"toomanyconfigs", CWE398,
@@ -1865,7 +1865,7 @@ void CppCheck::purgedConfigurationMessage(const std::string &file, const std::st
18651865
}
18661866

18671867
ErrorMessage errmsg(std::move(loclist),
1868-
emptyString,
1868+
"",
18691869
Severity::information,
18701870
"The configuration '" + configuration + "' was not checked because its code equals another one.",
18711871
"purgedConfiguration",
@@ -1882,9 +1882,9 @@ void CppCheck::getErrorMessages(ErrorLogger &errorlogger)
18821882
s.addEnabled("all");
18831883

18841884
CppCheck cppcheck(errorlogger, true, nullptr);
1885-
cppcheck.purgedConfigurationMessage(emptyString,emptyString);
1885+
cppcheck.purgedConfigurationMessage("","");
18861886
cppcheck.mTooManyConfigs = true;
1887-
cppcheck.tooManyConfigsError(emptyString,0U);
1887+
cppcheck.tooManyConfigsError("",0U);
18881888
// TODO: add functions to get remaining error messages
18891889

18901890
// call all "getErrorMessages" in all registered Check classes
@@ -1913,7 +1913,7 @@ void CppCheck::analyseClangTidy(const FileSettings &fileSettings)
19131913

19141914
const std::string args = "-quiet -checks=*,-clang-analyzer-*,-llvm* \"" + fileSettings.filename() + "\" -- " + allIncludes + allDefines;
19151915
std::string output;
1916-
if (const int exitcode = mExecuteCommand(exe, split(args), emptyString, output)) {
1916+
if (const int exitcode = mExecuteCommand(exe, split(args), "", output)) {
19171917
std::cerr << "Failed to execute '" << exe << "' (exitcode: " << std::to_string(exitcode) << ")" << std::endl;
19181918
return;
19191919
}
@@ -1923,7 +1923,7 @@ void CppCheck::analyseClangTidy(const FileSettings &fileSettings)
19231923
std::string line;
19241924

19251925
if (!mSettings.buildDir.empty()) {
1926-
const std::string analyzerInfoFile = AnalyzerInformation::getAnalyzerInfoFile(mSettings.buildDir, fileSettings.filename(), emptyString);
1926+
const std::string analyzerInfoFile = AnalyzerInformation::getAnalyzerInfoFile(mSettings.buildDir, fileSettings.filename(), "");
19271927
std::ofstream fcmd(analyzerInfoFile + ".clang-tidy-cmd");
19281928
fcmd << istr.str();
19291929
}

lib/importproject.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ ImportProject::Type ImportProject::import(const std::string &filename, Settings
204204
} else if (endsWith(filename, ".vcxproj")) {
205205
std::map<std::string, std::string, cppcheck::stricmp> variables;
206206
std::vector<SharedItemsProject> sharedItemsProjects;
207-
if (importVcxproj(filename, variables, emptyString, fileFilters, sharedItemsProjects)) {
207+
if (importVcxproj(filename, variables, "", fileFilters, sharedItemsProjects)) {
208208
setRelativePaths(filename);
209209
return ImportProject::Type::VS_VCXPROJ;
210210
}
@@ -462,7 +462,7 @@ bool ImportProject::importSln(std::istream &istr, const std::string &path, const
462462
if (!Path::isAbsolute(vcxproj))
463463
vcxproj = path + vcxproj;
464464
vcxproj = Path::fromNativeSeparators(std::move(vcxproj));
465-
if (!importVcxproj(vcxproj, variables, emptyString, fileFilters, sharedItemsProjects)) {
465+
if (!importVcxproj(vcxproj, variables, "", fileFilters, sharedItemsProjects)) {
466466
printError("failed to load '" + vcxproj + "' from Visual Studio solution");
467467
return false;
468468
}
@@ -1311,21 +1311,21 @@ bool ImportProject::importCppcheckGuiProject(std::istream &istr, Settings *setti
13111311
suppressions.push_back(std::move(s));
13121312
}
13131313
} else if (strcmp(name, CppcheckXml::VSConfigurationElementName) == 0)
1314-
guiProject.checkVsConfigs = readXmlStringList(node, emptyString, CppcheckXml::VSConfigurationName, nullptr);
1314+
guiProject.checkVsConfigs = readXmlStringList(node, "", CppcheckXml::VSConfigurationName, nullptr);
13151315
else if (strcmp(name, CppcheckXml::PlatformElementName) == 0)
13161316
guiProject.platform = empty_if_null(node->GetText());
13171317
else if (strcmp(name, CppcheckXml::AnalyzeAllVsConfigsElementName) == 0)
13181318
guiProject.analyzeAllVsConfigs = empty_if_null(node->GetText());
13191319
else if (strcmp(name, CppcheckXml::Parser) == 0)
13201320
temp.clang = true;
13211321
else if (strcmp(name, CppcheckXml::AddonsElementName) == 0) {
1322-
const auto& addons = readXmlStringList(node, emptyString, CppcheckXml::AddonElementName, nullptr);
1322+
const auto& addons = readXmlStringList(node, "", CppcheckXml::AddonElementName, nullptr);
13231323
temp.addons.insert(addons.cbegin(), addons.cend());
13241324
}
13251325
else if (strcmp(name, CppcheckXml::TagsElementName) == 0)
13261326
node->Attribute(CppcheckXml::TagElementName); // FIXME: Write some warning
13271327
else if (strcmp(name, CppcheckXml::ToolsElementName) == 0) {
1328-
const std::list<std::string> toolList = readXmlStringList(node, emptyString, CppcheckXml::ToolElementName, nullptr);
1328+
const std::list<std::string> toolList = readXmlStringList(node, "", CppcheckXml::ToolElementName, nullptr);
13291329
for (const std::string &toolName : toolList) {
13301330
if (toolName == CppcheckXml::ClangTidy)
13311331
temp.clangTidy = true;

0 commit comments

Comments
 (0)