Replace Tokenizer::simplifyBuiltinExpect by a suitable addition to gnu.cfg
This commit is contained in:
parent
57aec12f34
commit
a5aba110a4
|
@ -296,6 +296,9 @@
|
|||
</arg>
|
||||
<leak-ignore/>
|
||||
</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="unlikely(X)" value="(X)"/>
|
||||
</def>
|
||||
|
|
|
@ -3452,9 +3452,6 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
|
|||
// remove Borland stuff..
|
||||
simplifyBorland();
|
||||
|
||||
// Remove __builtin_expect
|
||||
simplifyBuiltinExpect();
|
||||
|
||||
if (hasEnumsWithTypedef()) {
|
||||
// #2449: syntax error: enum with typedef in it
|
||||
list.deallocateTokens();
|
||||
|
@ -6038,7 +6035,7 @@ void Tokenizer::simplifyIfSameInnerCondition()
|
|||
|
||||
// Binary operators simplification map
|
||||
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_eq", "&=")
|
||||
<< std::make_pair("bitand", "&")
|
||||
|
@ -7909,7 +7906,7 @@ void Tokenizer::simplifyEnum()
|
|||
}
|
||||
|
||||
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" <<
|
||||
"strcpy" <<
|
||||
"strncat" <<
|
||||
|
@ -9199,7 +9196,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"
|
||||
<< "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 {
|
||||
// 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" <<
|
||||
"iostream"<< "ostream"<< "ofstream"<< "ostringstream" <<
|
||||
"istream"<< "ifstream"<< "istringstream"<< "fstream"<< "stringstream" <<
|
||||
|
@ -9579,13 +9553,13 @@ namespace {
|
|||
"internal"<< "left"<< "right" <<
|
||||
"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" <<
|
||||
"priority_queue"<< "queue"<< "set"<< "multiset"<< "stack"<< "vector"<< "pair" <<
|
||||
"iterator"<< "iterator_traits" <<
|
||||
"unordered_map"<< "unordered_multimap"<< "unordered_set"<< "unordered_multiset" <<
|
||||
"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" <<
|
||||
"for_each"<< "find"<< "find_if"<< "find_end"<< "find_first_of" <<
|
||||
"adjacent_find"<< "count"<< "count_if"<< "mismatch"<< "equal"<< "search"<< "search_n" <<
|
||||
|
@ -9721,7 +9695,7 @@ namespace {
|
|||
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("_tsopen_s", "_sopen_s", "_wsopen_s") <<
|
||||
triplet("_tfopen", "fopen", "_wfopen") <<
|
||||
|
|
|
@ -649,11 +649,6 @@ private:
|
|||
*/
|
||||
void simplifyBitfields();
|
||||
|
||||
/**
|
||||
* Remove __builtin_expect(...)
|
||||
*/
|
||||
void simplifyBuiltinExpect();
|
||||
|
||||
/**
|
||||
* Remove unnecessary member qualification
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue