Skip to content

Commit 0636202

Browse files
committed
removed usage of emptyString from some cold paths
1 parent a8c0c0a commit 0636202

10 files changed

+29
-29
lines changed

cli/cppcheckexecutor.cpp

+1-1
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

+1-1
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ void ProcessExecutor::reportInternalChildErr(const std::string &childname, const
404404
std::list<ErrorMessage::FileLocation> locations;
405405
locations.emplace_back(childname, 0, 0);
406406
const ErrorMessage errmsg(std::move(locations),
407-
emptyString,
407+
"",
408408
Severity::error,
409409
"Internal error: " + msg,
410410
"cppcheckError",

lib/checkclass.cpp

+1-1
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

+1-1
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

+1-1
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

+2-2
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.h

+1-1
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

+11-11
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)
@@ -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",
@@ -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

+5-5
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;

lib/preprocessor.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ static simplecpp::DUI createDUI(const Settings &mSettings, const std::string &cf
691691

692692
splitcfg(mSettings.userDefines, dui.defines, "1");
693693
if (!cfg.empty())
694-
splitcfg(cfg, dui.defines, emptyString);
694+
splitcfg(cfg, dui.defines, "");
695695

696696
for (const std::string &def : mSettings.library.defines()) {
697697
const std::string::size_type pos = def.find_first_of(" (");
@@ -769,7 +769,7 @@ void Preprocessor::handleErrors(const simplecpp::OutputList& outputList, bool th
769769

770770
bool Preprocessor::loadFiles(const simplecpp::TokenList &rawtokens, std::vector<std::string> &files)
771771
{
772-
const simplecpp::DUI dui = createDUI(mSettings, emptyString, files[0]);
772+
const simplecpp::DUI dui = createDUI(mSettings, "", files[0]);
773773

774774
simplecpp::OutputList outputList;
775775
mTokenLists = simplecpp::load(rawtokens, files, dui, &outputList);
@@ -924,9 +924,9 @@ void Preprocessor::missingInclude(const std::string &filename, unsigned int line
924924
void Preprocessor::getErrorMessages(ErrorLogger &errorLogger, const Settings &settings)
925925
{
926926
Preprocessor preprocessor(settings, errorLogger);
927-
preprocessor.missingInclude(emptyString, 1, emptyString, UserHeader);
928-
preprocessor.missingInclude(emptyString, 1, emptyString, SystemHeader);
929-
preprocessor.error(emptyString, 1, "#error message"); // #error ..
927+
preprocessor.missingInclude("", 1, "", UserHeader);
928+
preprocessor.missingInclude("", 1, "", SystemHeader);
929+
preprocessor.error("", 1, "#error message"); // #error ..
930930
}
931931

932932
void Preprocessor::dump(std::ostream &out) const

0 commit comments

Comments
 (0)