CheckInternal: Check that emplace is not used
This commit is contained in:
parent
e95ff8c7b6
commit
0a83c6b173
|
@ -347,6 +347,19 @@ void CheckInternal::checkExtraWhitespace()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CheckInternal::checkStlUsage()
|
||||||
|
{
|
||||||
|
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||||
|
for (const Scope *scope : symbolDatabase->functionScopes) {
|
||||||
|
for (const Token* tok = scope->classStart->next(); tok != scope->classEnd; tok = tok->next()) {
|
||||||
|
if (Token::simpleMatch(tok, ". emplace ("))
|
||||||
|
reportError(tok, Severity::error, "internalStlUsage", "The 'emplace' function shall be avoided for now. 'emplace_back' is fine");
|
||||||
|
//if (Token::simpleMatch(tok, ". back ( )") && tok->astOperand1() && tok->astOperand1()->valueType() && tok->astOperand1()->valueType()->container && Token::simpleMatch(tok->astOperand1()->valueType()->container, "std :: string"))
|
||||||
|
// reportError(tok, Severity::error, "internalStlUsage", "The 'std::string::back()' function shall be avoided for now.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CheckInternal::multiComparePatternError(const Token* tok, const std::string& pattern, const std::string &funcname)
|
void CheckInternal::multiComparePatternError(const Token* tok, const std::string& pattern, const std::string &funcname)
|
||||||
{
|
{
|
||||||
reportError(tok, Severity::error, "multiComparePatternError",
|
reportError(tok, Severity::error, "multiComparePatternError",
|
||||||
|
|
|
@ -57,6 +57,7 @@ public:
|
||||||
checkInternal.checkRedundantNextPrevious();
|
checkInternal.checkRedundantNextPrevious();
|
||||||
checkInternal.checkExtraWhitespace();
|
checkInternal.checkExtraWhitespace();
|
||||||
checkInternal.checkRedundantTokCheck();
|
checkInternal.checkRedundantTokCheck();
|
||||||
|
checkInternal.checkStlUsage();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @brief %Check if a simple pattern is used inside Token::Match or Token::findmatch */
|
/** @brief %Check if a simple pattern is used inside Token::Match or Token::findmatch */
|
||||||
|
@ -79,6 +80,9 @@ public:
|
||||||
|
|
||||||
/** @brief %Check if there is a redundant check for none-nullness of parameter before Match functions, such as (tok && Token::Match(tok, "foo")) */
|
/** @brief %Check if there is a redundant check for none-nullness of parameter before Match functions, such as (tok && Token::Match(tok, "foo")) */
|
||||||
void checkRedundantTokCheck();
|
void checkRedundantTokCheck();
|
||||||
|
|
||||||
|
/** @brief Try to avoid some new functions that are not fully supported in Linux */
|
||||||
|
void checkStlUsage();
|
||||||
private:
|
private:
|
||||||
void multiComparePatternError(const Token *tok, const std::string &pattern, const std::string &funcname);
|
void multiComparePatternError(const Token *tok, const std::string &pattern, const std::string &funcname);
|
||||||
void simplePatternError(const Token *tok, const std::string &pattern, const std::string &funcname);
|
void simplePatternError(const Token *tok, const std::string &pattern, const std::string &funcname);
|
||||||
|
|
Loading…
Reference in New Issue