MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / strPlusCharError

Method strPlusCharError

lib/checkstring.cpp:239–247  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

237}
238
239void CheckStringImpl::strPlusCharError(const Token *tok)
240{
241 std::string charType = "char";
242 if (tok && tok->astOperand2() && tok->astOperand2()->variable())
243 charType = tok->astOperand2()->variable()->typeStartToken()->str();
244 else if (tok && tok->astOperand2() && tok->astOperand2()->tokType() == Token::eChar && tok->astOperand2()->isLong())
245 charType = "wchar_t";
246 reportError(tok, Severity::error, "strPlusChar", "Unusual pointer arithmetic. A value of type '" + charType +"' is added to a string literal.", CWE665, Certainty::normal);
247}
248
249static bool isMacroUsage(const Token* tok)
250{

Callers 1

getErrorMessagesMethod · 0.80

Calls 4

astOperand2Method · 0.80
variableMethod · 0.80
reportErrorFunction · 0.70
strMethod · 0.45

Tested by

no test coverage detected