Skip to content

Commit d06efe0

Browse files
committed
removed emptyString and its remaining usage
1 parent b81083f commit d06efe0

14 files changed

Lines changed: 34 additions & 37 deletions

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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3066,7 +3066,7 @@ static std::vector<DuplMemberFuncInfo> getDuplInheritedMemberFunctionsRecursive(
30663066
if (classFuncIt.name() == parentClassFuncIt.name() &&
30673067
(parentClassFuncIt.access != AccessControl::Private || !skipPrivate) &&
30683068
!classFuncIt.isConstructor() && !classFuncIt.isDestructor() &&
3069-
classFuncIt.argsMatch(parentClassIt.type->classScope, parentClassFuncIt.argDef, classFuncIt.argDef, emptyString, 0) &&
3069+
classFuncIt.argsMatch(parentClassIt.type->classScope, parentClassFuncIt.argDef, classFuncIt.argDef, "", 0) &&
30703070
(classFuncIt.isConst() == parentClassFuncIt.isConst() || Function::returnsConst(&classFuncIt) == Function::returnsConst(&parentClassFuncIt)) &&
30713071
!(classFuncIt.isDelete() || parentClassFuncIt.isDelete()))
30723072
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
@@ -145,11 +145,11 @@ void CheckUninitVar::checkScope(const Scope* scope, const std::set<std::string>
145145
continue;
146146

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

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

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

187187
if (var.isArray()) {
@@ -195,14 +195,14 @@ void CheckUninitVar::checkScope(const Scope* scope, const std::set<std::string>
195195
if (!init) {
196196
Alloc alloc = ARRAY;
197197
std::map<nonneg int, VariableValue> variableValue = getVariableValues(var.typeStartToken());
198-
checkScopeForVariable(tok, var, nullptr, nullptr, &alloc, emptyString, variableValue);
198+
checkScopeForVariable(tok, var, nullptr, nullptr, &alloc, "", variableValue);
199199
}
200200
continue;
201201
}
202202
if (stdtype || var.isPointer()) {
203203
Alloc alloc = NO_ALLOC;
204204
std::map<nonneg int, VariableValue> variableValue = getVariableValues(var.typeStartToken());
205-
checkScopeForVariable(tok, var, nullptr, nullptr, &alloc, emptyString, variableValue);
205+
checkScopeForVariable(tok, var, nullptr, nullptr, &alloc, "", variableValue);
206206
}
207207
if (var.type())
208208
checkStruct(tok, var);
@@ -227,7 +227,7 @@ void CheckUninitVar::checkScope(const Scope* scope, const std::set<std::string>
227227
else if (arg.typeStartToken()->isStandardType() || arg.typeStartToken()->isEnumType()) {
228228
Alloc alloc = NO_ALLOC;
229229
std::map<nonneg int, VariableValue> variableValue;
230-
checkScopeForVariable(tok->next(), arg, nullptr, nullptr, &alloc, emptyString, variableValue);
230+
checkScopeForVariable(tok->next(), arg, nullptr, nullptr, &alloc, "", variableValue);
231231
}
232232
}
233233
}

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/errorlogger.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ class CPPCHECKLIB ErrorMessage {
158158
* @return formatted string
159159
*/
160160
std::string toString(bool verbose,
161-
const std::string &templateFormat = emptyString,
162-
const std::string &templateLocation = emptyString) const;
161+
const std::string &templateFormat = "",
162+
const std::string &templateLocation = "") const;
163163

164164
std::string serialize() const;
165165
void deserialize(const std::string &data);

lib/library.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ Library::Error Library::load(const tinyxml2::XMLDocument &doc)
753753
unknown_elements.insert(typenodename);
754754
}
755755
if (platform.empty()) {
756-
const PlatformType * const type_ptr = platform_type(type_name, emptyString);
756+
const PlatformType * const type_ptr = platform_type(type_name, "");
757757
if (type_ptr) {
758758
if (*type_ptr == type)
759759
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
@@ -397,7 +397,7 @@ class CPPCHECKLIB Library {
397397
const Token* getContainerFromYield(const Token* tok, Container::Yield yield) const;
398398
const Token* getContainerFromAction(const Token* tok, Container::Action action) const;
399399

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

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

lib/preprocessor.cpp

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

lib/symboldatabase.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
686686
bool newFunc = true; // Is this function already in the database?
687687
auto range = scope->functionMap.equal_range(tok->str());
688688
for (std::multimap<std::string, const Function*>::const_iterator it = range.first; it != range.second; ++it) {
689-
if (it->second->argsMatch(scope, it->second->argDef, argStart, emptyString, 0)) {
689+
if (it->second->argsMatch(scope, it->second->argDef, argStart, "", 0)) {
690690
newFunc = false;
691691
break;
692692
}
@@ -770,7 +770,7 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
770770
bool newFunc = true; // Is this function already in the database?
771771
auto range = scope->functionMap.equal_range(ftok->str());
772772
for (std::multimap<std::string, const Function*>::const_iterator it = range.first; it != range.second; ++it) {
773-
if (it->second->argsMatch(scope, it->second->argDef, argStart, emptyString, 0)) {
773+
if (it->second->argsMatch(scope, it->second->argDef, argStart, "", 0)) {
774774
newFunc = false;
775775
break;
776776
}
@@ -3234,7 +3234,7 @@ Function* SymbolDatabase::addGlobalFunction(Scope*& scope, const Token*& tok, co
32343234
const Function *f = it->second;
32353235
if (f->hasBody())
32363236
continue;
3237-
if (f->argsMatch(scope, f->argDef, argStart, emptyString, 0)) {
3237+
if (f->argsMatch(scope, f->argDef, argStart, "", 0)) {
32383238
function = const_cast<Function *>(it->second);
32393239
break;
32403240
}
@@ -3592,7 +3592,7 @@ std::string Type::name() const
35923592
else if (start->str() == "class")
35933593
start = start->tokAt(1);
35943594
else if (!start->isName())
3595-
return emptyString;
3595+
return "";
35963596
const Token* next = start;
35973597
while (Token::Match(next, "::|<|>|(|)|[|]|*|&|&&|%name%")) {
35983598
if (Token::Match(next, "<|(|[") && next->link())
@@ -4676,7 +4676,7 @@ const Function * Function::getOverriddenFunctionRecursive(const ::Type* baseType
46764676
}
46774677

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

46814681
// check for matching cv-ref qualifiers
46824682
match = match
@@ -6248,7 +6248,7 @@ static T* findTypeImpl(S& thisScope, const std::string & name)
62486248
return it->second;
62496249

62506250
// is type defined in anonymous namespace..
6251-
it = thisScope.definedTypesMap.find(emptyString);
6251+
it = thisScope.definedTypesMap.find("");
62526252
if (it != thisScope.definedTypesMap.end()) {
62536253
for (S *scope : thisScope.nestedList) {
62546254
if (scope->className.empty() && (scope->type == ScopeType::eNamespace || scope->isClassOrStructOrUnion())) {

0 commit comments

Comments
 (0)