#7883 hang: CheckOther::checkFuncArgNamesDifferent() template code in .h. Activate language check for header files + Small refactoring
This commit is contained in:
parent
1ec9b8c5b4
commit
f54a6f085b
|
@ -7289,8 +7289,7 @@ bool Tokenizer::duplicateDefinition(Token ** tokPtr)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
static const std::set<std::string> stdFunctionsPresentInC = make_container< std::set<std::string> > () <<
|
||||||
const std::set<std::string> stdFunctionsPresentInC = make_container< std::set<std::string> > () <<
|
|
||||||
"strcat" <<
|
"strcat" <<
|
||||||
"strcpy" <<
|
"strcpy" <<
|
||||||
"strncat" <<
|
"strncat" <<
|
||||||
|
@ -7298,7 +7297,6 @@ namespace {
|
||||||
"free" <<
|
"free" <<
|
||||||
"malloc" <<
|
"malloc" <<
|
||||||
"strdup";
|
"strdup";
|
||||||
}
|
|
||||||
|
|
||||||
void Tokenizer::simplifyStd()
|
void Tokenizer::simplifyStd()
|
||||||
{
|
{
|
||||||
|
@ -8053,11 +8051,11 @@ void Tokenizer::checkConfiguration() const
|
||||||
|
|
||||||
void Tokenizer::validateC() const
|
void Tokenizer::validateC() const
|
||||||
{
|
{
|
||||||
if (!isC())
|
if (isCPP())
|
||||||
return;
|
return;
|
||||||
for (const Token *tok = tokens(); tok; tok = tok->next()) {
|
for (const Token *tok = tokens(); tok; tok = tok->next()) {
|
||||||
// That might trigger false positives, but it's much faster to have this truncated pattern
|
// That might trigger false positives, but it's much faster to have this truncated pattern
|
||||||
if (Token::simpleMatch(tok, "const_cast|dynamic_cast|reinterpret_cast|static_cast <"))
|
if (Token::Match(tok, "const_cast|dynamic_cast|reinterpret_cast|static_cast <"))
|
||||||
syntaxErrorC(tok, "C++ cast <...");
|
syntaxErrorC(tok, "C++ cast <...");
|
||||||
// Template function..
|
// Template function..
|
||||||
if (Token::Match(tok, "%name% < %name% > (")) {
|
if (Token::Match(tok, "%name% < %name% > (")) {
|
||||||
|
@ -8175,19 +8173,20 @@ const Token * Tokenizer::findGarbageCode() const
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const std::set<std::string> controlFlowKeywords = make_container< std::set<std::string> > () <<
|
||||||
|
"goto" <<
|
||||||
|
"do" <<
|
||||||
|
"if" <<
|
||||||
|
"else" <<
|
||||||
|
"for" <<
|
||||||
|
"while" <<
|
||||||
|
"switch" <<
|
||||||
|
"break" <<
|
||||||
|
"continue" <<
|
||||||
|
"return";
|
||||||
|
|
||||||
bool Tokenizer::isGarbageExpr(const Token *start, const Token *end)
|
bool Tokenizer::isGarbageExpr(const Token *start, const Token *end)
|
||||||
{
|
{
|
||||||
std::set<std::string> controlFlowKeywords;
|
|
||||||
controlFlowKeywords.insert("goto");
|
|
||||||
controlFlowKeywords.insert("do");
|
|
||||||
controlFlowKeywords.insert("if");
|
|
||||||
controlFlowKeywords.insert("else");
|
|
||||||
controlFlowKeywords.insert("for");
|
|
||||||
controlFlowKeywords.insert("while");
|
|
||||||
controlFlowKeywords.insert("switch");
|
|
||||||
controlFlowKeywords.insert("break");
|
|
||||||
controlFlowKeywords.insert("continue");
|
|
||||||
controlFlowKeywords.insert("return");
|
|
||||||
for (const Token *tok = start; tok != end; tok = tok->next()) {
|
for (const Token *tok = start; tok != end; tok = tok->next()) {
|
||||||
if (controlFlowKeywords.find(tok->str()) != controlFlowKeywords.end())
|
if (controlFlowKeywords.find(tok->str()) != controlFlowKeywords.end())
|
||||||
return true;
|
return true;
|
||||||
|
@ -8647,8 +8646,7 @@ void Tokenizer::simplifyAttribute()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
static const std::set<std::string> keywords = make_container< std::set<std::string> >()
|
||||||
const std::set<std::string> keywords = make_container< std::set<std::string> >()
|
|
||||||
<< "volatile"
|
<< "volatile"
|
||||||
<< "inline"
|
<< "inline"
|
||||||
<< "_inline"
|
<< "_inline"
|
||||||
|
@ -8657,7 +8655,6 @@ namespace {
|
||||||
<< "register"
|
<< "register"
|
||||||
<< "__restrict"
|
<< "__restrict"
|
||||||
<< "__restrict__" ;
|
<< "__restrict__" ;
|
||||||
}
|
|
||||||
// Remove "volatile", "inline", "register", "restrict", "override", "final", "static" and "constexpr"
|
// Remove "volatile", "inline", "register", "restrict", "override", "final", "static" and "constexpr"
|
||||||
// "restrict" keyword
|
// "restrict" keyword
|
||||||
// - New to 1999 ANSI/ISO C standard
|
// - New to 1999 ANSI/ISO C standard
|
||||||
|
@ -9009,9 +9006,8 @@ void Tokenizer::simplifyBitfields()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
// Types and objects in std namespace that are neither functions nor templates
|
// Types and objects in std namespace that are neither functions nor templates
|
||||||
const std::set<std::string> stdTypes = make_container<std::set<std::string> >() <<
|
static const std::set<std::string> stdTypes = make_container<std::set<std::string> >() <<
|
||||||
"string"<< "wstring"<< "u16string"<< "u32string" <<
|
"string"<< "wstring"<< "u16string"<< "u32string" <<
|
||||||
"iostream"<< "ostream"<< "ofstream"<< "ostringstream" <<
|
"iostream"<< "ostream"<< "ofstream"<< "ostringstream" <<
|
||||||
"istream"<< "ifstream"<< "istringstream"<< "fstream"<< "stringstream" <<
|
"istream"<< "ifstream"<< "istringstream"<< "fstream"<< "stringstream" <<
|
||||||
|
@ -9032,13 +9028,13 @@ namespace {
|
||||||
"internal"<< "left"<< "right" <<
|
"internal"<< "left"<< "right" <<
|
||||||
"fpos"<< "streamoff"<< "streampos"<< "streamsize";
|
"fpos"<< "streamoff"<< "streampos"<< "streamsize";
|
||||||
|
|
||||||
const std::set<std::string> stdTemplates = make_container<std::set<std::string> >() <<
|
static const std::set<std::string> stdTemplates = make_container<std::set<std::string> >() <<
|
||||||
"array"<< "basic_string"<< "bitset"<< "deque"<< "list"<< "map"<< "multimap" <<
|
"array"<< "basic_string"<< "bitset"<< "deque"<< "list"<< "map"<< "multimap" <<
|
||||||
"priority_queue"<< "queue"<< "set"<< "multiset"<< "stack"<< "vector"<< "pair" <<
|
"priority_queue"<< "queue"<< "set"<< "multiset"<< "stack"<< "vector"<< "pair" <<
|
||||||
"iterator"<< "iterator_traits" <<
|
"iterator"<< "iterator_traits" <<
|
||||||
"unordered_map"<< "unordered_multimap"<< "unordered_set"<< "unordered_multiset" <<
|
"unordered_map"<< "unordered_multimap"<< "unordered_set"<< "unordered_multiset" <<
|
||||||
"tuple"<< "function";
|
"tuple"<< "function";
|
||||||
const std::set<std::string> stdFunctions = make_container<std::set<std::string> >() <<
|
static const std::set<std::string> stdFunctions = make_container<std::set<std::string> >() <<
|
||||||
"getline" <<
|
"getline" <<
|
||||||
"for_each"<< "find"<< "find_if"<< "find_end"<< "find_first_of" <<
|
"for_each"<< "find"<< "find_if"<< "find_end"<< "find_first_of" <<
|
||||||
"adjacent_find"<< "count"<< "count_if"<< "mismatch"<< "equal"<< "search"<< "search_n" <<
|
"adjacent_find"<< "count"<< "count_if"<< "mismatch"<< "equal"<< "search"<< "search_n" <<
|
||||||
|
@ -9054,7 +9050,6 @@ namespace {
|
||||||
"min"<< "max"<< "min_element"<< "max_element"<< "lexicographical_compare"<< "next_permutation"<< "prev_permutation" <<
|
"min"<< "max"<< "min_element"<< "max_element"<< "lexicographical_compare"<< "next_permutation"<< "prev_permutation" <<
|
||||||
"advance"<< "back_inserter"<< "distance"<< "front_inserter"<< "inserter" <<
|
"advance"<< "back_inserter"<< "distance"<< "front_inserter"<< "inserter" <<
|
||||||
"make_pair"<< "make_shared"<< "make_tuple";
|
"make_pair"<< "make_shared"<< "make_tuple";
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Add std:: in front of std classes, when using namespace std; was given
|
// Add std:: in front of std classes, when using namespace std; was given
|
||||||
|
|
|
@ -825,6 +825,7 @@ private:
|
||||||
ASSERT_THROW(tokenizeAndStringify(";std::map<int,int> m;",false,false,Settings::Native,"test.c"), InternalError);
|
ASSERT_THROW(tokenizeAndStringify(";std::map<int,int> m;",false,false,Settings::Native,"test.c"), InternalError);
|
||||||
ASSERT_THROW(tokenizeAndStringify(";template<class T> class X { };",false,false,Settings::Native,"test.c"), InternalError);
|
ASSERT_THROW(tokenizeAndStringify(";template<class T> class X { };",false,false,Settings::Native,"test.c"), InternalError);
|
||||||
ASSERT_THROW(tokenizeAndStringify("int X<Y>() {};",false,false,Settings::Native,"test.c"), InternalError);
|
ASSERT_THROW(tokenizeAndStringify("int X<Y>() {};",false,false,Settings::Native,"test.c"), InternalError);
|
||||||
|
ASSERT_THROW(tokenizeAndStringify("void foo(int i) { reinterpret_cast<char>(i) };",false,false,Settings::Native,"test.h"), InternalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
void syntax_case_default() { // correct syntax
|
void syntax_case_default() { // correct syntax
|
||||||
|
|
Loading…
Reference in New Issue