use std::string::empty() (#3910)

This commit is contained in:
Oliver Stöneberg 2022-04-09 19:02:37 +02:00 committed by GitHub
parent 0636018df3
commit 25ef9eeb26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 8 additions and 8 deletions

View File

@ -637,7 +637,7 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
mSettings->platform(Settings::Unix64);
else if (platform == "native")
mSettings->platform(Settings::Native);
else if (platform == "unspecified" || platform == "Unspecified" || platform == "")
else if (platform == "unspecified" || platform == "Unspecified" || platform.empty())
;
else if (!mSettings->loadPlatformFile(projectFile.c_str(), platform) && !mSettings->loadPlatformFile(argv[0], platform)) {
std::string message("unrecognized platform: \"");

View File

@ -755,7 +755,7 @@ const Token * CheckLeakAutoVar::checkTokenInsideExpression(const Token * const t
if (rhs->varId() == tok->varId()) {
// simple assignment
varInfo->erase(tok->varId());
} else if (rhs->str() == "(" && mSettings->library.returnValue(rhs->astOperand1()) != emptyString) {
} else if (rhs->str() == "(" && !mSettings->library.returnValue(rhs->astOperand1()).empty()) {
// #9298, assignment through return value of a function
const std::string &returnValue = mSettings->library.returnValue(rhs->astOperand1());
if (returnValue.compare(0, 3, "arg") == 0) {

View File

@ -258,7 +258,7 @@ std::string Suppressions::addSuppressions(const std::list<Suppression> &suppress
{
for (const auto &newSuppression : suppressions) {
auto errmsg = addSuppression(newSuppression);
if (errmsg != "")
if (!errmsg.empty())
return errmsg;
}
return "";

View File

@ -3439,7 +3439,7 @@ void Tokenizer::calculateScopes()
// New scope is opening, record it here
std::shared_ptr<ScopeInfo2> newScopeInfo = std::make_shared<ScopeInfo2>(tok->scopeInfo()->name, tok->link(), tok->scopeInfo()->usingNamespaces);
if (newScopeInfo->name != "" && nextScopeNameAddition != "")
if (!newScopeInfo->name.empty() && !nextScopeNameAddition.empty())
newScopeInfo->name.append(" :: ");
newScopeInfo->name.append(nextScopeNameAddition);
nextScopeNameAddition = "";

View File

@ -4564,7 +4564,7 @@ static bool isOpenParenthesisMemberFunctionCallOfVarId(const Token * openParenth
{
const Token * varTok = openParenthesisToken->tokAt(-3);
return Token::Match(varTok, "%varid% . %name% (", varId) &&
varTok->next()->originalName() == emptyString;
varTok->next()->originalName().empty();
}
static const Token * findOpenParentesisOfMove(const Token * moveVarTok)
@ -4603,7 +4603,7 @@ static void valueFlowAfterMove(TokenList* tokenlist, SymbolDatabase* symboldatab
for (Token* tok = const_cast<Token*>(start); tok != scope->bodyEnd; tok = tok->next()) {
Token * varTok;
if (Token::Match(tok, "%var% . reset|clear (") && tok->next()->originalName() == emptyString) {
if (Token::Match(tok, "%var% . reset|clear (") && tok->next()->originalName().empty()) {
varTok = tok;
ValueFlow::Value value;
value.valueType = ValueFlow::Value::ValueType::MOVED;

View File

@ -2220,7 +2220,7 @@ private:
const Scope* f = db->findScopeByName("f");
ASSERT(f && f->type == Scope::eFunction && f->function);
ASSERT(f->function->argumentList.size() == 2 && f->function->argumentList.front().index() == 0 && f->function->argumentList.front().name() == "" && f->function->argumentList.back().index() == 1);
ASSERT(f->function->argumentList.size() == 2 && f->function->argumentList.front().index() == 0 && f->function->argumentList.front().name().empty() && f->function->argumentList.back().index() == 1);
ASSERT_EQUALS("", errout.str());
}
{

View File

@ -88,7 +88,7 @@ private:
checkUnusedFunctions.parseTokens(tokenizer, "someFile.c", &settings);
// check() returns error if and only if errout is not empty.
if ((checkUnusedFunctions.check)(this, settings)) {
ASSERT(errout.str() != "");
ASSERT(!errout.str().empty());
} else {
ASSERT_EQUALS("", errout.str());
}