Small refactorizations:
- Optimized performance of several functions by adding pre-checks - Simplified some code - Fixed VS warning in testsymboldatabase.cpp
This commit is contained in:
parent
8c0eab3eb3
commit
c7b3836379
|
@ -85,7 +85,7 @@ void CheckString::checkAlwaysTrueOrFalseStringCompare()
|
|||
return;
|
||||
|
||||
for (const Token* tok = _tokenizer->tokens(); tok; tok = tok->next()) {
|
||||
if (tok->isName() && Token::Match(tok, "memcmp|strncmp|strcmp|stricmp|strverscmp|bcmp|strcmpi|strcasecmp|strncasecmp|strncasecmp_l|strcasecmp_l|wcsncasecmp|wcscasecmp|wmemcmp|wcscmp|wcscasecmp_l|wcsncasecmp_l|wcsncmp|_mbscmp|_memicmp|_memicmp_l|_stricmp|_wcsicmp|_mbsicmp|_stricmp_l|_wcsicmp_l|_mbsicmp_l (")) {
|
||||
if (tok->isName() && tok->strAt(1) == "(" && Token::Match(tok, "memcmp|strncmp|strcmp|stricmp|strverscmp|bcmp|strcmpi|strcasecmp|strncasecmp|strncasecmp_l|strcasecmp_l|wcsncasecmp|wcscasecmp|wmemcmp|wcscmp|wcscasecmp_l|wcsncasecmp_l|wcsncmp|_mbscmp|_memicmp|_memicmp_l|_stricmp|_wcsicmp|_mbsicmp|_stricmp_l|_wcsicmp_l|_mbsicmp_l")) {
|
||||
if (Token::Match(tok->tokAt(2), "%str% , %str% ,|)")) {
|
||||
const std::string &str1 = tok->strAt(2);
|
||||
const std::string &str2 = tok->strAt(4);
|
||||
|
|
|
@ -1346,11 +1346,10 @@ std::list<std::string> Preprocessor::getcfgs(const std::string &filedata, const
|
|||
}
|
||||
}
|
||||
if (par != 0) {
|
||||
std::ostringstream lineStream;
|
||||
lineStream << __LINE__;
|
||||
const std::string errorId = "preprocessor" + lineStream.str();
|
||||
std::ostringstream errorId;
|
||||
errorId << "preprocessor" << __LINE__;
|
||||
const std::string errorText = "mismatching number of '(' and ')' in this line: " + def;
|
||||
writeError(filename, linenr, _errorLogger, errorId, errorText);
|
||||
writeError(filename, linenr, _errorLogger, errorId.str(), errorText);
|
||||
ret.clear();
|
||||
return ret;
|
||||
}
|
||||
|
@ -1455,8 +1454,7 @@ std::list<std::string> Preprocessor::getcfgs(const std::string &filedata, const
|
|||
deflist.back() = ndeflist.back();
|
||||
ndeflist.pop_back();
|
||||
} else {
|
||||
std::string tempDef((deflist.back() == "1") ? "0" : "1");
|
||||
deflist.back() = tempDef;
|
||||
deflist.back() = (deflist.back() == "1") ? "0" : "1";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1208,7 +1208,7 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
|
|||
|
||||
// find enumerators
|
||||
for (const Token* tok = _tokenizer->list.front(); tok != _tokenizer->list.back(); tok = tok->next()) {
|
||||
if (!tok->isName() || tok->varId() || tok->function() || tok->type() || tok->enumerator())
|
||||
if (tok->tokType() != Token::eName)
|
||||
continue;
|
||||
const Enumerator * enumerator = findEnumerator(tok);
|
||||
if (enumerator)
|
||||
|
|
|
@ -8897,7 +8897,10 @@ void Tokenizer::simplifyBitfields()
|
|||
}
|
||||
Token *last = nullptr;
|
||||
|
||||
if (Token::Match(tok, ";|{|}|public:|protected:|private: const| %type% %name% :") &&
|
||||
if (!Token::Match(tok, ";|{|}|public:|protected:|private:"))
|
||||
continue;
|
||||
|
||||
if (Token::Match(tok->next(), "const| %type% %name% :") &&
|
||||
!Token::Match(tok->next(), "case|public|protected|private|class|struct") &&
|
||||
!Token::simpleMatch(tok->tokAt(2), "default :")) {
|
||||
Token *tok1 = (tok->next()->str() == "const") ? tok->tokAt(3) : tok->tokAt(2);
|
||||
|
@ -8912,7 +8915,7 @@ void Tokenizer::simplifyBitfields()
|
|||
|
||||
last = tok1->next();
|
||||
}
|
||||
} else if (Token::Match(tok, ";|{|}|public:|protected:|private: const| %type% : %any% ;") &&
|
||||
} else if (Token::Match(tok->next(), "const| %type% : %any% ;") &&
|
||||
tok->next()->str() != "default") {
|
||||
const int offset = (tok->next()->str() == "const") ? 1 : 0;
|
||||
|
||||
|
|
|
@ -2297,7 +2297,7 @@ private:
|
|||
void enum4() { // #7493
|
||||
GET_SYMBOL_DB("enum Offsets { O1, O2, O3 };\n"
|
||||
"enum MyEnums { E1=O1+1, E2=O2+1, E3=O3+1 };");
|
||||
ASSERT(db);
|
||||
ASSERT(db != nullptr);
|
||||
if (!db)
|
||||
return;
|
||||
ASSERT_EQUALS(3U, db->scopeList.size());
|
||||
|
|
Loading…
Reference in New Issue