Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/analyzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ struct Analyzer {
/// Update the state of the program at the token
virtual void updateState(const Token* tok) = 0;
/// Return analyzer for expression at token
virtual ValuePtr<Analyzer> reanalyze(Token* tok, const std::string& msg = emptyString) const = 0;
virtual ValuePtr<Analyzer> reanalyze(Token* tok, const std::string& msg = "") const = 0;
virtual bool invalid() const {
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/checkclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2221,7 +2221,7 @@ void CheckClass::checkConst()
return false;
if (!ovl->functionScope)
return true;
return func.argCount() == ovl->argCount() && func.argsMatch(ovl->functionScope, ovl->argDef, func.argDef, emptyString, 0);
return func.argCount() == ovl->argCount() && func.argsMatch(ovl->functionScope, ovl->argDef, func.argDef, "", 0);
}))
continue;
}
Expand Down Expand Up @@ -3120,7 +3120,7 @@ static std::vector<DuplMemberFuncInfo> getDuplInheritedMemberFunctionsRecursive(
if (classFuncIt.name() == parentClassFuncIt.name() &&
(parentClassFuncIt.access != AccessControl::Private || !skipPrivate) &&
!classFuncIt.isConstructor() && !classFuncIt.isDestructor() &&
classFuncIt.argsMatch(parentClassIt.type->classScope, parentClassFuncIt.argDef, classFuncIt.argDef, emptyString, 0) &&
classFuncIt.argsMatch(parentClassIt.type->classScope, parentClassFuncIt.argDef, classFuncIt.argDef, "", 0) &&
(classFuncIt.isConst() == parentClassFuncIt.isConst() || Function::returnsConst(&classFuncIt) == Function::returnsConst(&parentClassFuncIt)) &&
!(classFuncIt.isDelete() || parentClassFuncIt.isDelete()))
results.emplace_back(&classFuncIt, &parentClassFuncIt, &parentClassIt);
Expand Down
2 changes: 1 addition & 1 deletion lib/checkstl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ void CheckStl::outOfBounds()
}
}

static std::string indexValueString(const ValueFlow::Value& indexValue, const std::string& containerName = emptyString)
static std::string indexValueString(const ValueFlow::Value& indexValue, const std::string& containerName = "")
{
if (indexValue.isIteratorStartValue())
return "at position " + MathLib::toString(indexValue.intvalue) + " from the beginning";
Expand Down
12 changes: 6 additions & 6 deletions lib/checkuninitvar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,11 @@ void CheckUninitVar::checkScope(const Scope* scope, const std::set<std::string>
continue;

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

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

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

if (var.isArray()) {
Expand All @@ -196,14 +196,14 @@ void CheckUninitVar::checkScope(const Scope* scope, const std::set<std::string>
if (!init) {
Alloc alloc = ARRAY;
std::map<nonneg int, VariableValue> variableValue = getVariableValues(var.typeStartToken());
checkScopeForVariable(tok, var, nullptr, nullptr, &alloc, emptyString, variableValue);
checkScopeForVariable(tok, var, nullptr, nullptr, &alloc, "", variableValue);
}
continue;
}
if (stdtype || var.isPointer()) {
Alloc alloc = NO_ALLOC;
std::map<nonneg int, VariableValue> variableValue = getVariableValues(var.typeStartToken());
checkScopeForVariable(tok, var, nullptr, nullptr, &alloc, emptyString, variableValue);
checkScopeForVariable(tok, var, nullptr, nullptr, &alloc, "", variableValue);
}
if (var.type())
checkStruct(tok, var);
Expand All @@ -228,7 +228,7 @@ void CheckUninitVar::checkScope(const Scope* scope, const std::set<std::string>
else if (arg.typeStartToken()->isStandardType() || arg.typeStartToken()->isEnumType()) {
Alloc alloc = NO_ALLOC;
std::map<nonneg int, VariableValue> variableValue;
checkScopeForVariable(tok->next(), arg, nullptr, nullptr, &alloc, emptyString, variableValue);
checkScopeForVariable(tok->next(), arg, nullptr, nullptr, &alloc, "", variableValue);
}
}
}
Expand Down
3 changes: 0 additions & 3 deletions lib/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,6 @@

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

#include <string>
static const std::string emptyString;

// Use the nonneg macro when you want to assert that a variable/argument is not negative
#ifdef __CPPCHECK__
#define nonneg __cppcheck_low__(0)
Expand Down
2 changes: 1 addition & 1 deletion lib/cppcheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1489,7 +1489,7 @@ void CppCheck::executeRules(const std::string &tokenlist, const TokenList &list)
const std::string err = rule.regex->match(str, f);
if (!err.empty()) {
const ErrorMessage errmsg(std::list<ErrorMessage::FileLocation>(),
emptyString,
"",
Severity::error,
err,
"pcre_exec",
Expand Down
2 changes: 1 addition & 1 deletion lib/library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,7 @@ Library::Error Library::load(const tinyxml2::XMLDocument &doc)
unknown_elements.insert(typenodename);
}
if (platform.empty()) {
const PlatformType * const type_ptr = platform_type(type_name, emptyString);
const PlatformType * const type_ptr = platform_type(type_name, "");
if (type_ptr) {
if (*type_ptr == type)
return Error(ErrorCode::DUPLICATE_PLATFORM_TYPE, type_name);
Expand Down
2 changes: 1 addition & 1 deletion lib/library.h
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ class CPPCHECKLIB Library {
const Token* getContainerFromYield(const Token* tok, Container::Yield yield) const;
const Token* getContainerFromAction(const Token* tok, Container::Action action) const;

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

bool isreflection(const std::string &token) const;
Expand Down
2 changes: 1 addition & 1 deletion lib/preprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ static void getConfigs(const simplecpp::TokenList &tokens, std::set<std::string>
} else if (cmdtok->str() == "error") {
if (!configs_ifndef.empty() && !configs_ifndef.back().empty()) {
if (configs_ifndef.size() == 1U)
ret.erase(emptyString);
ret.erase("");
std::vector<std::string> configs(configs_if);
configs.push_back(configs_ifndef.back());
ret.erase(cfg(configs, userDefines));
Expand Down
12 changes: 6 additions & 6 deletions lib/symboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
bool newFunc = true; // Is this function already in the database?
auto range = scope->functionMap.equal_range(tok->str());
for (std::multimap<std::string, const Function*>::const_iterator it = range.first; it != range.second; ++it) {
if (it->second->argsMatch(scope, it->second->argDef, argStart, emptyString, 0)) {
if (it->second->argsMatch(scope, it->second->argDef, argStart, "", 0)) {
newFunc = false;
break;
}
Expand Down Expand Up @@ -806,7 +806,7 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
bool newFunc = true; // Is this function already in the database?
auto range = scope->functionMap.equal_range(ftok->str());
for (std::multimap<std::string, const Function*>::const_iterator it = range.first; it != range.second; ++it) {
if (it->second->argsMatch(scope, it->second->argDef, argStart, emptyString, 0)) {
if (it->second->argsMatch(scope, it->second->argDef, argStart, "", 0)) {
newFunc = false;
break;
}
Expand Down Expand Up @@ -3444,7 +3444,7 @@ Function* SymbolDatabase::addGlobalFunction(Scope*& scope, const Token*& tok, co
const Function *f = it->second;
if (f->hasBody())
continue;
if (f->argsMatch(scope, f->argDef, argStart, emptyString, 0)) {
if (f->argsMatch(scope, f->argDef, argStart, "", 0)) {
function = const_cast<Function *>(it->second);
break;
}
Expand Down Expand Up @@ -3802,7 +3802,7 @@ std::string Type::name() const
else if (start->str() == "class")
start = start->tokAt(1);
else if (!start->isName())
return emptyString;
return "";
const Token* next = start;
while (Token::Match(next, "::|<|>|(|)|[|]|*|&|&&|%name%")) {
if (Token::Match(next, "<|(|[") && next->link())
Expand Down Expand Up @@ -4894,7 +4894,7 @@ const Function * Function::getOverriddenFunctionRecursive(const ::Type* baseType
}

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

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

// is type defined in anonymous namespace..
it = thisScope.definedTypesMap.find(emptyString);
it = thisScope.definedTypesMap.find("");
if (it != thisScope.definedTypesMap.end()) {
for (S *scope : thisScope.nestedList) {
if (scope->className.empty() && (scope->type == ScopeType::eNamespace || scope->isClassOrStructOrUnion())) {
Expand Down
6 changes: 3 additions & 3 deletions lib/token.h
Original file line number Diff line number Diff line change
Expand Up @@ -805,12 +805,12 @@ class CPPCHECKLIB Token {
}

bool isCChar() const {
return (((mTokType == eString) && isPrefixStringCharLiteral(mStr, '"', emptyString)) ||
((mTokType == eChar) && isPrefixStringCharLiteral(mStr, '\'', emptyString) && (replaceEscapeSequences(getCharLiteral(mStr)).size() == 1)));
return (((mTokType == eString) && isPrefixStringCharLiteral(mStr, '"', "")) ||
((mTokType == eChar) && isPrefixStringCharLiteral(mStr, '\'', "") && (replaceEscapeSequences(getCharLiteral(mStr)).size() == 1)));
}

bool isCMultiChar() const {
return (mTokType == eChar) && isPrefixStringCharLiteral(mStr, '\'', emptyString) && (replaceEscapeSequences(getCharLiteral(mStr)).size() > 1);
return (mTokType == eChar) && isPrefixStringCharLiteral(mStr, '\'', "") && (replaceEscapeSequences(getCharLiteral(mStr)).size() > 1);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion test/testerrorlogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ class TestErrorLogger : public TestFixture {
std::list<ErrorMessage::FileLocation> locs = { fooCpp5 };
const auto mapping = createGuidelineMapping(reportType);

ErrorMessage msg(std::move(locs), emptyString, severity, "", errorId, Certainty::normal);
ErrorMessage msg(std::move(locs), "", severity, "", errorId, Certainty::normal);
msg.guideline = getGuideline(msg.id, reportType, mapping, msg.severity);
msg.classification = getClassification(msg.guideline, reportType);

Expand Down