Skip to content

Commit 36dbff5

Browse files
authored
removed emptyString and its remaining usage (danmar#7296)
1 parent 3547499 commit 36dbff5

File tree

12 files changed

+24
-27
lines changed

12 files changed

+24
-27
lines changed

lib/analyzer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ struct Analyzer {
186186
/// Update the state of the program at the token
187187
virtual void updateState(const Token* tok) = 0;
188188
/// Return analyzer for expression at token
189-
virtual ValuePtr<Analyzer> reanalyze(Token* tok, const std::string& msg = emptyString) const = 0;
189+
virtual ValuePtr<Analyzer> reanalyze(Token* tok, const std::string& msg = "") const = 0;
190190
virtual bool invalid() const {
191191
return false;
192192
}

lib/checkclass.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2229,7 +2229,7 @@ void CheckClass::checkConst()
22292229
return false;
22302230
if (!ovl->functionScope)
22312231
return true;
2232-
return func.argCount() == ovl->argCount() && func.argsMatch(ovl->functionScope, ovl->argDef, func.argDef, emptyString, 0);
2232+
return func.argCount() == ovl->argCount() && func.argsMatch(ovl->functionScope, ovl->argDef, func.argDef, "", 0);
22332233
}))
22342234
continue;
22352235
}
@@ -3128,7 +3128,7 @@ static std::vector<DuplMemberFuncInfo> getDuplInheritedMemberFunctionsRecursive(
31283128
if (classFuncIt.name() == parentClassFuncIt.name() &&
31293129
(parentClassFuncIt.access != AccessControl::Private || !skipPrivate) &&
31303130
!classFuncIt.isConstructor() && !classFuncIt.isDestructor() &&
3131-
classFuncIt.argsMatch(parentClassIt.type->classScope, parentClassFuncIt.argDef, classFuncIt.argDef, emptyString, 0) &&
3131+
classFuncIt.argsMatch(parentClassIt.type->classScope, parentClassFuncIt.argDef, classFuncIt.argDef, "", 0) &&
31323132
(classFuncIt.isConst() == parentClassFuncIt.isConst() || Function::returnsConst(&classFuncIt) == Function::returnsConst(&parentClassFuncIt)) &&
31333133
!(classFuncIt.isDelete() || parentClassFuncIt.isDelete()))
31343134
results.emplace_back(&classFuncIt, &parentClassFuncIt, &parentClassIt);

lib/checkstl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ void CheckStl::outOfBounds()
203203
}
204204
}
205205

206-
static std::string indexValueString(const ValueFlow::Value& indexValue, const std::string& containerName = emptyString)
206+
static std::string indexValueString(const ValueFlow::Value& indexValue, const std::string& containerName = "")
207207
{
208208
if (indexValue.isIteratorStartValue())
209209
return "at position " + MathLib::toString(indexValue.intvalue) + " from the beginning";

lib/checkuninitvar.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,11 @@ void CheckUninitVar::checkScope(const Scope* scope, const std::set<std::string>
146146
continue;
147147

148148
if (Token::Match(var.nameToken(), "%name% =")) { // Variable is initialized, but Rhs might be not
149-
checkRhs(var.nameToken(), var, NO_ALLOC, 0U, emptyString);
149+
checkRhs(var.nameToken(), var, NO_ALLOC, 0U, "");
150150
continue;
151151
}
152152
if (Token::Match(var.nameToken(), "%name% ) (") && Token::simpleMatch(var.nameToken()->linkAt(2), ") =")) { // Function pointer is initialized, but Rhs might be not
153-
checkRhs(var.nameToken()->linkAt(2)->next(), var, NO_ALLOC, 0U, emptyString);
153+
checkRhs(var.nameToken()->linkAt(2)->next(), var, NO_ALLOC, 0U, "");
154154
continue;
155155
}
156156

@@ -182,7 +182,7 @@ void CheckUninitVar::checkScope(const Scope* scope, const std::set<std::string>
182182
continue;
183183

184184
if (tok->astParent() && Token::simpleMatch(tok->astParent()->previous(), "for (") && Token::simpleMatch(tok->astParent()->link()->next(), "{") &&
185-
checkLoopBody(tok->astParent()->link()->next(), var, var.isArray() ? ARRAY : NO_ALLOC, emptyString, true))
185+
checkLoopBody(tok->astParent()->link()->next(), var, var.isArray() ? ARRAY : NO_ALLOC, "", true))
186186
continue;
187187

188188
if (var.isArray()) {
@@ -196,14 +196,14 @@ void CheckUninitVar::checkScope(const Scope* scope, const std::set<std::string>
196196
if (!init) {
197197
Alloc alloc = ARRAY;
198198
std::map<nonneg int, VariableValue> variableValue = getVariableValues(var.typeStartToken());
199-
checkScopeForVariable(tok, var, nullptr, nullptr, &alloc, emptyString, variableValue);
199+
checkScopeForVariable(tok, var, nullptr, nullptr, &alloc, "", variableValue);
200200
}
201201
continue;
202202
}
203203
if (stdtype || var.isPointer()) {
204204
Alloc alloc = NO_ALLOC;
205205
std::map<nonneg int, VariableValue> variableValue = getVariableValues(var.typeStartToken());
206-
checkScopeForVariable(tok, var, nullptr, nullptr, &alloc, emptyString, variableValue);
206+
checkScopeForVariable(tok, var, nullptr, nullptr, &alloc, "", variableValue);
207207
}
208208
if (var.type())
209209
checkStruct(tok, var);
@@ -228,7 +228,7 @@ void CheckUninitVar::checkScope(const Scope* scope, const std::set<std::string>
228228
else if (arg.typeStartToken()->isStandardType() || arg.typeStartToken()->isEnumType()) {
229229
Alloc alloc = NO_ALLOC;
230230
std::map<nonneg int, VariableValue> variableValue;
231-
checkScopeForVariable(tok->next(), arg, nullptr, nullptr, &alloc, emptyString, variableValue);
231+
checkScopeForVariable(tok->next(), arg, nullptr, nullptr, &alloc, "", variableValue);
232232
}
233233
}
234234
}

lib/config.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,6 @@
133133

134134
#define REQUIRES(msg, ...) class=typename std::enable_if<__VA_ARGS__::value>::type
135135

136-
#include <string>
137-
static const std::string emptyString;
138-
139136
// Use the nonneg macro when you want to assert that a variable/argument is not negative
140137
#ifdef __CPPCHECK__
141138
#define nonneg __cppcheck_low__(0)

lib/cppcheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1489,7 +1489,7 @@ void CppCheck::executeRules(const std::string &tokenlist, const TokenList &list)
14891489
const std::string err = rule.regex->match(str, f);
14901490
if (!err.empty()) {
14911491
const ErrorMessage errmsg(std::list<ErrorMessage::FileLocation>(),
1492-
emptyString,
1492+
"",
14931493
Severity::error,
14941494
err,
14951495
"pcre_exec",

lib/library.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,7 @@ Library::Error Library::load(const tinyxml2::XMLDocument &doc)
813813
unknown_elements.insert(typenodename);
814814
}
815815
if (platform.empty()) {
816-
const PlatformType * const type_ptr = platform_type(type_name, emptyString);
816+
const PlatformType * const type_ptr = platform_type(type_name, "");
817817
if (type_ptr) {
818818
if (*type_ptr == type)
819819
return Error(ErrorCode::DUPLICATE_PLATFORM_TYPE, type_name);

lib/library.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ class CPPCHECKLIB Library {
401401
const Token* getContainerFromYield(const Token* tok, Container::Yield yield) const;
402402
const Token* getContainerFromAction(const Token* tok, Container::Action action) const;
403403

404-
static bool isContainerYield(const Token* cond, Library::Container::Yield y, const std::string& fallback = emptyString);
404+
static bool isContainerYield(const Token* cond, Library::Container::Yield y, const std::string& fallback = "");
405405
static Library::Container::Yield getContainerYield(const Token* cond);
406406

407407
bool isreflection(const std::string &token) const;

lib/preprocessor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ static void getConfigs(const simplecpp::TokenList &tokens, std::set<std::string>
617617
} else if (cmdtok->str() == "error") {
618618
if (!configs_ifndef.empty() && !configs_ifndef.back().empty()) {
619619
if (configs_ifndef.size() == 1U)
620-
ret.erase(emptyString);
620+
ret.erase("");
621621
std::vector<std::string> configs(configs_if);
622622
configs.push_back(configs_ifndef.back());
623623
ret.erase(cfg(configs, userDefines));

lib/symboldatabase.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
722722
bool newFunc = true; // Is this function already in the database?
723723
auto range = scope->functionMap.equal_range(tok->str());
724724
for (std::multimap<std::string, const Function*>::const_iterator it = range.first; it != range.second; ++it) {
725-
if (it->second->argsMatch(scope, it->second->argDef, argStart, emptyString, 0)) {
725+
if (it->second->argsMatch(scope, it->second->argDef, argStart, "", 0)) {
726726
newFunc = false;
727727
break;
728728
}
@@ -806,7 +806,7 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
806806
bool newFunc = true; // Is this function already in the database?
807807
auto range = scope->functionMap.equal_range(ftok->str());
808808
for (std::multimap<std::string, const Function*>::const_iterator it = range.first; it != range.second; ++it) {
809-
if (it->second->argsMatch(scope, it->second->argDef, argStart, emptyString, 0)) {
809+
if (it->second->argsMatch(scope, it->second->argDef, argStart, "", 0)) {
810810
newFunc = false;
811811
break;
812812
}
@@ -3444,7 +3444,7 @@ Function* SymbolDatabase::addGlobalFunction(Scope*& scope, const Token*& tok, co
34443444
const Function *f = it->second;
34453445
if (f->hasBody())
34463446
continue;
3447-
if (f->argsMatch(scope, f->argDef, argStart, emptyString, 0)) {
3447+
if (f->argsMatch(scope, f->argDef, argStart, "", 0)) {
34483448
function = const_cast<Function *>(it->second);
34493449
break;
34503450
}
@@ -3802,7 +3802,7 @@ std::string Type::name() const
38023802
else if (start->str() == "class")
38033803
start = start->tokAt(1);
38043804
else if (!start->isName())
3805-
return emptyString;
3805+
return "";
38063806
const Token* next = start;
38073807
while (Token::Match(next, "::|<|>|(|)|[|]|*|&|&&|%name%")) {
38083808
if (Token::Match(next, "<|(|[") && next->link())
@@ -4894,7 +4894,7 @@ const Function * Function::getOverriddenFunctionRecursive(const ::Type* baseType
48944894
}
48954895

48964896
// check for matching function parameters
4897-
match = match && argsMatch(baseType->classScope, func->argDef, argDef, emptyString, 0);
4897+
match = match && argsMatch(baseType->classScope, func->argDef, argDef, "", 0);
48984898

48994899
// check for matching cv-ref qualifiers
49004900
match = match
@@ -6473,7 +6473,7 @@ static T* findTypeImpl(S& thisScope, const std::string & name)
64736473
return it->second;
64746474

64756475
// is type defined in anonymous namespace..
6476-
it = thisScope.definedTypesMap.find(emptyString);
6476+
it = thisScope.definedTypesMap.find("");
64776477
if (it != thisScope.definedTypesMap.end()) {
64786478
for (S *scope : thisScope.nestedList) {
64796479
if (scope->className.empty() && (scope->type == ScopeType::eNamespace || scope->isClassOrStructOrUnion())) {

0 commit comments

Comments
 (0)