Skip to content

Commit

Permalink
removed usage of emptyString from error messages
Browse files Browse the repository at this point in the history
these can be considered cold paths in the optimal case i.e. no errors
  • Loading branch information
firewave committed Jan 24, 2025
1 parent a1a415d commit a6cdb03
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/checkclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2038,7 +2038,7 @@ void CheckClass::virtualDestructor()
}

for (const Function *func : inconclusiveErrors)
virtualDestructorError(func->tokenDef, func->name(), emptyString, true);
virtualDestructorError(func->tokenDef, func->name(), "", true);
}

void CheckClass::virtualDestructorError(const Token *tok, const std::string &Base, const std::string &Derived, bool inconclusive)
Expand Down
2 changes: 1 addition & 1 deletion lib/checkinternal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ void CheckInternal::checkRedundantTokCheck()
void CheckInternal::checkRedundantTokCheckError(const Token* tok)
{
reportError(tok, Severity::style, "redundantTokCheck",
"Unnecessary check of \"" + (tok? tok->expressionString(): emptyString) + "\", match-function already checks if it is null.");
"Unnecessary check of \"" + (tok? tok->expressionString(): "") + "\", match-function already checks if it is null.");
}

void CheckInternal::checkTokenSimpleMatchPatterns()
Expand Down
2 changes: 1 addition & 1 deletion lib/checkother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3512,7 +3512,7 @@ void CheckOther::unusedLabelError(const Token* tok, bool inSwitch, bool hasIfdef
if (hasIfdef)
id += "Configuration";

std::string msg = "$symbol:" + (tok ? tok->str() : emptyString) + "\nLabel '$symbol' is not used.";
std::string msg = "$symbol:" + (tok ? tok->str() : "") + "\nLabel '$symbol' is not used.";
if (hasIfdef)
msg += " There is #if in function body so the label might be used in code that is removed by the preprocessor.";
if (inSwitch)
Expand Down
4 changes: 2 additions & 2 deletions lib/checkstl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2514,7 +2514,7 @@ void CheckStl::checkDereferenceInvalidIterator2()
outOfBoundsError(emptyAdvance,
lValue.tokvalue->expressionString(),
cValue,
advanceIndex ? advanceIndex->expressionString() : emptyString,
advanceIndex ? advanceIndex->expressionString() : "",
nullptr);
else
outOfBoundsError(tok, lValue.tokvalue->expressionString(), cValue, tok->expressionString(), &value);
Expand Down Expand Up @@ -3148,7 +3148,7 @@ void CheckStl::knownEmptyContainer()
const Token* contTok = splitTok->astOperand2();
if (!isKnownEmptyContainer(contTok))
continue;
knownEmptyContainerError(contTok, emptyString);
knownEmptyContainerError(contTok, "");
} else {
const std::vector<const Token *> args = getArguments(tok);
if (args.empty())
Expand Down
2 changes: 1 addition & 1 deletion lib/checkuninitvar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ bool CheckUninitVar::checkScopeForVariable(const Token *tok, const Variable& var
// Assert that the tokens are '} while ('
if (!Token::simpleMatch(tok, "} while (")) {
if (printDebug)
reportError(tok,Severity::debug,emptyString,"assertion failed '} while ('");
reportError(tok,Severity::debug,"","assertion failed '} while ('");
break;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/errorlogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ class CPPCHECKLIB ErrorMessage {
return mSymbolNames;
}

static ErrorMessage fromInternalError(const InternalError &internalError, const TokenList *tokenList, const std::string &filename, const std::string& msg = emptyString);
static ErrorMessage fromInternalError(const InternalError &internalError, const TokenList *tokenList, const std::string &filename, const std::string& msg = "");

private:
static std::string fixInvalidChars(const std::string& raw);
Expand Down
2 changes: 1 addition & 1 deletion lib/preprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ void Preprocessor::reportOutput(const simplecpp::OutputList &outputList, bool sh
case simplecpp::Output::EXPLICIT_INCLUDE_NOT_FOUND:
case simplecpp::Output::FILE_NOT_FOUND:
case simplecpp::Output::DUI_ERROR:
error(emptyString, 0, out.msg);
error("", 0, out.msg);
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/tokenize.h
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ class CPPCHECKLIB Tokenizer {
public:

/** Syntax error */
NORETURN void syntaxError(const Token *tok, const std::string &code = emptyString) const;
NORETURN void syntaxError(const Token *tok, const std::string &code = "") const;

/** Syntax error. Unmatched character. */
NORETURN void unmatchedToken(const Token *tok) const;
Expand Down

0 comments on commit a6cdb03

Please sign in to comment.