Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removed usage of emptyString from error messages #7251

Merged
merged 1 commit into from
Jan 29, 2025
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/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
11 changes: 5 additions & 6 deletions 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 Expand Up @@ -4325,7 +4325,7 @@ void CheckOther::checkOverlappingWrite()
constexpr bool follow = true;
if (!isSameExpression(macro, ptr1, ptr2, *mSettings, pure, follow, &errorPath))
continue;
overlappingWriteFunction(tok);
overlappingWriteFunction(tok, tok->str());
}
continue;
}
Expand All @@ -4351,7 +4351,7 @@ void CheckOther::checkOverlappingWrite()
constexpr bool follow = true;
if (!isSameExpression(macro, buf1, buf2, *mSettings, pure, follow, &errorPath))
continue;
overlappingWriteFunction(tok);
overlappingWriteFunction(tok, tok->str());
}
}
}
Expand All @@ -4362,9 +4362,8 @@ void CheckOther::overlappingWriteUnion(const Token *tok)
reportError(tok, Severity::error, "overlappingWriteUnion", "Overlapping read/write of union is undefined behavior");
}

void CheckOther::overlappingWriteFunction(const Token *tok)
void CheckOther::overlappingWriteFunction(const Token *tok, const std::string& funcname)
{
const std::string &funcname = tok ? tok->str() : emptyString;
reportError(tok, Severity::error, "overlappingWriteFunction", "Overlapping read/write in " + funcname + "() is undefined behavior");
}

Expand Down Expand Up @@ -4430,7 +4429,7 @@ void CheckOther::getErrorMessages(ErrorLogger *errorLogger, const Settings *sett
c.raceAfterInterlockedDecrementError(nullptr);
c.invalidFreeError(nullptr, "malloc", false);
c.overlappingWriteUnion(nullptr);
c.overlappingWriteFunction(nullptr);
c.overlappingWriteFunction(nullptr, "funcname");

//performance
c.redundantCopyError(nullptr, "varname");
Expand Down
2 changes: 1 addition & 1 deletion lib/checkother.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ class CPPCHECKLIB CheckOther : public Check {

void checkOverlappingWrite();
void overlappingWriteUnion(const Token *tok);
void overlappingWriteFunction(const Token *tok);
void overlappingWriteFunction(const Token *tok, const std::string& funcname);

// Error messages..
void checkComparisonFunctionIsAlwaysTrueOrFalseError(const Token* tok, const std::string &functionName, const std::string &varName, bool result);
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
Loading