Skip to content

Commit 25ef9ee

Browse files
authored
use std::string::empty() (cppcheck-opensource#3910)
1 parent 0636018 commit 25ef9ee

7 files changed

Lines changed: 8 additions & 8 deletions

File tree

cli/cmdlineparser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
637637
mSettings->platform(Settings::Unix64);
638638
else if (platform == "native")
639639
mSettings->platform(Settings::Native);
640-
else if (platform == "unspecified" || platform == "Unspecified" || platform == "")
640+
else if (platform == "unspecified" || platform == "Unspecified" || platform.empty())
641641
;
642642
else if (!mSettings->loadPlatformFile(projectFile.c_str(), platform) && !mSettings->loadPlatformFile(argv[0], platform)) {
643643
std::string message("unrecognized platform: \"");

lib/checkleakautovar.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ const Token * CheckLeakAutoVar::checkTokenInsideExpression(const Token * const t
755755
if (rhs->varId() == tok->varId()) {
756756
// simple assignment
757757
varInfo->erase(tok->varId());
758-
} else if (rhs->str() == "(" && mSettings->library.returnValue(rhs->astOperand1()) != emptyString) {
758+
} else if (rhs->str() == "(" && !mSettings->library.returnValue(rhs->astOperand1()).empty()) {
759759
// #9298, assignment through return value of a function
760760
const std::string &returnValue = mSettings->library.returnValue(rhs->astOperand1());
761761
if (returnValue.compare(0, 3, "arg") == 0) {

lib/suppressions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ std::string Suppressions::addSuppressions(const std::list<Suppression> &suppress
258258
{
259259
for (const auto &newSuppression : suppressions) {
260260
auto errmsg = addSuppression(newSuppression);
261-
if (errmsg != "")
261+
if (!errmsg.empty())
262262
return errmsg;
263263
}
264264
return "";

lib/tokenize.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3439,7 +3439,7 @@ void Tokenizer::calculateScopes()
34393439
// New scope is opening, record it here
34403440
std::shared_ptr<ScopeInfo2> newScopeInfo = std::make_shared<ScopeInfo2>(tok->scopeInfo()->name, tok->link(), tok->scopeInfo()->usingNamespaces);
34413441

3442-
if (newScopeInfo->name != "" && nextScopeNameAddition != "")
3442+
if (!newScopeInfo->name.empty() && !nextScopeNameAddition.empty())
34433443
newScopeInfo->name.append(" :: ");
34443444
newScopeInfo->name.append(nextScopeNameAddition);
34453445
nextScopeNameAddition = "";

lib/valueflow.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4564,7 +4564,7 @@ static bool isOpenParenthesisMemberFunctionCallOfVarId(const Token * openParenth
45644564
{
45654565
const Token * varTok = openParenthesisToken->tokAt(-3);
45664566
return Token::Match(varTok, "%varid% . %name% (", varId) &&
4567-
varTok->next()->originalName() == emptyString;
4567+
varTok->next()->originalName().empty();
45684568
}
45694569

45704570
static const Token * findOpenParentesisOfMove(const Token * moveVarTok)
@@ -4603,7 +4603,7 @@ static void valueFlowAfterMove(TokenList* tokenlist, SymbolDatabase* symboldatab
46034603

46044604
for (Token* tok = const_cast<Token*>(start); tok != scope->bodyEnd; tok = tok->next()) {
46054605
Token * varTok;
4606-
if (Token::Match(tok, "%var% . reset|clear (") && tok->next()->originalName() == emptyString) {
4606+
if (Token::Match(tok, "%var% . reset|clear (") && tok->next()->originalName().empty()) {
46074607
varTok = tok;
46084608
ValueFlow::Value value;
46094609
value.valueType = ValueFlow::Value::ValueType::MOVED;

test/testsymboldatabase.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2220,7 +2220,7 @@ class TestSymbolDatabase : public TestFixture {
22202220
const Scope* f = db->findScopeByName("f");
22212221
ASSERT(f && f->type == Scope::eFunction && f->function);
22222222

2223-
ASSERT(f->function->argumentList.size() == 2 && f->function->argumentList.front().index() == 0 && f->function->argumentList.front().name() == "" && f->function->argumentList.back().index() == 1);
2223+
ASSERT(f->function->argumentList.size() == 2 && f->function->argumentList.front().index() == 0 && f->function->argumentList.front().name().empty() && f->function->argumentList.back().index() == 1);
22242224
ASSERT_EQUALS("", errout.str());
22252225
}
22262226
{

test/testunusedfunctions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class TestUnusedFunctions : public TestFixture {
8888
checkUnusedFunctions.parseTokens(tokenizer, "someFile.c", &settings);
8989
// check() returns error if and only if errout is not empty.
9090
if ((checkUnusedFunctions.check)(this, settings)) {
91-
ASSERT(errout.str() != "");
91+
ASSERT(!errout.str().empty());
9292
} else {
9393
ASSERT_EQUALS("", errout.str());
9494
}

0 commit comments

Comments
 (0)