Replace Tokenizer::simplifyBuiltinExpect by a suitable addition to gnu.cfg
This commit is contained in:
parent
57aec12f34
commit
a5aba110a4
|
@ -296,6 +296,9 @@
|
||||||
</arg>
|
</arg>
|
||||||
<leak-ignore/>
|
<leak-ignore/>
|
||||||
</function>
|
</function>
|
||||||
|
<!-- see https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html -->
|
||||||
|
<define name="__builtin_expect(X,Y)" value="(X)"/>
|
||||||
|
<!-- see http://kernelnewbies.org/FAQ/LikelyUnlikely -->
|
||||||
<define name="likely(X)" value="(X)"/>
|
<define name="likely(X)" value="(X)"/>
|
||||||
<define name="unlikely(X)" value="(X)"/>
|
<define name="unlikely(X)" value="(X)"/>
|
||||||
</def>
|
</def>
|
||||||
|
|
|
@ -3452,9 +3452,6 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
|
||||||
// remove Borland stuff..
|
// remove Borland stuff..
|
||||||
simplifyBorland();
|
simplifyBorland();
|
||||||
|
|
||||||
// Remove __builtin_expect
|
|
||||||
simplifyBuiltinExpect();
|
|
||||||
|
|
||||||
if (hasEnumsWithTypedef()) {
|
if (hasEnumsWithTypedef()) {
|
||||||
// #2449: syntax error: enum with typedef in it
|
// #2449: syntax error: enum with typedef in it
|
||||||
list.deallocateTokens();
|
list.deallocateTokens();
|
||||||
|
@ -6038,7 +6035,7 @@ void Tokenizer::simplifyIfSameInnerCondition()
|
||||||
|
|
||||||
// Binary operators simplification map
|
// Binary operators simplification map
|
||||||
namespace {
|
namespace {
|
||||||
static const std::map<std::string, std::string> cAlternativeTokens = make_container< std::map<std::string, std::string> >()
|
const std::map<std::string, std::string> cAlternativeTokens = make_container< std::map<std::string, std::string> >()
|
||||||
<< std::make_pair("and", "&&")
|
<< std::make_pair("and", "&&")
|
||||||
<< std::make_pair("and_eq", "&=")
|
<< std::make_pair("and_eq", "&=")
|
||||||
<< std::make_pair("bitand", "&")
|
<< std::make_pair("bitand", "&")
|
||||||
|
@ -7909,7 +7906,7 @@ void Tokenizer::simplifyEnum()
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
static const std::set<std::string> f = make_container< std::set<std::string> > () <<
|
const std::set<std::string> f = make_container< std::set<std::string> > () <<
|
||||||
"strcat" <<
|
"strcat" <<
|
||||||
"strcpy" <<
|
"strcpy" <<
|
||||||
"strncat" <<
|
"strncat" <<
|
||||||
|
@ -9199,7 +9196,7 @@ void Tokenizer::simplifyAttribute()
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
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"
|
||||||
|
@ -9533,32 +9530,9 @@ void Tokenizer::simplifyBitfields()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Remove __builtin_expect(...)
|
|
||||||
void Tokenizer::simplifyBuiltinExpect()
|
|
||||||
{
|
|
||||||
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
|
||||||
if (!Token::simpleMatch(tok->next(), "__builtin_expect ("))
|
|
||||||
continue;
|
|
||||||
// Count parentheses for tok2
|
|
||||||
const Token* end = tok->linkAt(2);
|
|
||||||
for (Token *tok2 = tok->tokAt(3); tok2 != end; tok2 = tok2->next()) {
|
|
||||||
if (tok2->str() == "(") {
|
|
||||||
tok2 = tok2->link();
|
|
||||||
} else if (tok2->str() == ",") {
|
|
||||||
if (Token::Match(tok2, ", %num% )")) {
|
|
||||||
tok->deleteNext();
|
|
||||||
tok2->deleteNext();
|
|
||||||
tok2->deleteThis();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace {
|
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
|
||||||
static const std::set<std::string> stdTypes = make_container<std::set<std::string> >() <<
|
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" <<
|
||||||
|
@ -9579,13 +9553,13 @@ namespace {
|
||||||
"internal"<< "left"<< "right" <<
|
"internal"<< "left"<< "right" <<
|
||||||
"fpos"<< "streamoff"<< "streampos"<< "streamsize";
|
"fpos"<< "streamoff"<< "streampos"<< "streamsize";
|
||||||
|
|
||||||
static const std::set<std::string> stdTemplates = make_container<std::set<std::string> >() <<
|
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";
|
||||||
static const std::set<std::string> stdFunctions = make_container<std::set<std::string> >() <<
|
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" <<
|
||||||
|
@ -9721,7 +9695,7 @@ namespace {
|
||||||
std::string tchar, mbcs, unicode;
|
std::string tchar, mbcs, unicode;
|
||||||
};
|
};
|
||||||
|
|
||||||
static const std::set<triplet> apis = make_container< std::set<triplet> >() <<
|
const std::set<triplet> apis = make_container< std::set<triplet> >() <<
|
||||||
triplet("_topen", "open", "_wopen") <<
|
triplet("_topen", "open", "_wopen") <<
|
||||||
triplet("_tsopen_s", "_sopen_s", "_wsopen_s") <<
|
triplet("_tsopen_s", "_sopen_s", "_wsopen_s") <<
|
||||||
triplet("_tfopen", "fopen", "_wfopen") <<
|
triplet("_tfopen", "fopen", "_wfopen") <<
|
||||||
|
|
|
@ -649,11 +649,6 @@ private:
|
||||||
*/
|
*/
|
||||||
void simplifyBitfields();
|
void simplifyBitfields();
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove __builtin_expect(...)
|
|
||||||
*/
|
|
||||||
void simplifyBuiltinExpect();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove unnecessary member qualification
|
* Remove unnecessary member qualification
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue