diff --git a/lib/checkinternal.cpp b/lib/checkinternal.cpp index 9fed59429..994188cfb 100644 --- a/lib/checkinternal.cpp +++ b/lib/checkinternal.cpp @@ -118,7 +118,7 @@ void CheckInternal::checkTokenSimpleMatchPatterns() // Check | usage: Count characters before the symbol char_count = 0; for (std::string::size_type pos = 0; pos < pattern.size(); ++pos) { - char c = pattern[pos]; + const char c = pattern[pos]; if (c == ' ') { char_count = 0; @@ -144,25 +144,25 @@ void CheckInternal::checkTokenSimpleMatchPatterns() } } +namespace { + const std::set magics = make_container< std::set > () + "%any%" + "%bool%" + "%char%" + "%comp%" + "%num%" + "%op%" + "%cop%" + "%or%" + "%oror%" + "%str%" + "%type%" + "%name%" + "%varid%"; +} + void CheckInternal::checkMissingPercentCharacter() { - static std::set magics; - if (magics.empty()) { - magics.insert("%any%"); - magics.insert("%bool%"); - magics.insert("%char%"); - magics.insert("%comp%"); - magics.insert("%num%"); - magics.insert("%op%"); - magics.insert("%cop%"); - magics.insert("%or%"); - magics.insert("%oror%"); - magics.insert("%str%"); - magics.insert("%type%"); - magics.insert("%name%"); - magics.insert("%varid%"); - } - for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) { if (!Token::simpleMatch(tok, "Token :: Match (") && !Token::simpleMatch(tok, "Token :: findmatch (")) continue; @@ -200,26 +200,26 @@ void CheckInternal::checkMissingPercentCharacter() } } +namespace { + const std::set knownPatterns = make_container< std::set > () + << "%any%" + << "%bool%" + << "%char%" + << "%comp%" + << "%name%" + << "%num%" + << "%op%" + << "%cop%" + << "%or%" + << "%oror%" + << "%str%" + << "%type%" + << "%var%" + << "%varid%"; +} + void CheckInternal::checkUnknownPattern() { - static std::set knownPatterns; - if (knownPatterns.empty()) { - knownPatterns.insert("%any%"); - knownPatterns.insert("%bool%"); - knownPatterns.insert("%char%"); - knownPatterns.insert("%comp%"); - knownPatterns.insert("%name%"); - knownPatterns.insert("%num%"); - knownPatterns.insert("%op%"); - knownPatterns.insert("%cop%"); - knownPatterns.insert("%or%"); - knownPatterns.insert("%oror%"); - knownPatterns.insert("%str%"); - knownPatterns.insert("%type%"); - knownPatterns.insert("%var%"); - knownPatterns.insert("%varid%"); - } - for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) { if (!Token::simpleMatch(tok, "Token :: Match (") && !Token::simpleMatch(tok, "Token :: findmatch (")) continue; @@ -238,9 +238,9 @@ void CheckInternal::checkUnknownPattern() else if (pattern[i] == ']') inBrackets = false; else if (pattern[i] == '%' && pattern[i+1] != ' ' && pattern[i+1] != '|' && !inBrackets) { - std::string::size_type end = pattern.find('%', i+1); + const std::string::size_type end = pattern.find('%', i+1); if (end != std::string::npos) { - std::string s = pattern.substr(i, end-i+1); + const std::string s = pattern.substr(i, end-i+1); if (knownPatterns.find(s) == knownPatterns.end()) unknownPatternError(tok, s); } diff --git a/lib/checkio.cpp b/lib/checkio.cpp index 3ea9565bb..060e15b03 100644 --- a/lib/checkio.cpp +++ b/lib/checkio.cpp @@ -1375,15 +1375,15 @@ void CheckIO::checkWrongPrintfScanfArguments() // We currently only support string literals, variables, and functions. /// @todo add non-string literals, and generic expressions -CheckIO::ArgumentInfo::ArgumentInfo(const Token * tok, const Settings *settings, bool isCPP) - : variableInfo(0) - , typeToken(0) - , functionInfo(0) +CheckIO::ArgumentInfo::ArgumentInfo(const Token * tok, const Settings *settings, bool _isCPP) + : variableInfo(nullptr) + , typeToken(nullptr) + , functionInfo(nullptr) , element(false) , _template(false) , address(false) - , tempToken(0) - , isCPP(isCPP) + , isCPP(_isCPP) + , tempToken(nullptr) { if (tok) { if (tok->type() == Token::eString) {