diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index 6d2ba5e41..7fd56590c 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -2586,8 +2586,7 @@ void CheckClass::checkConstError(const Token *tok, const std::string &classname, void CheckClass::checkConstError2(const Token *tok1, const Token *tok2, const std::string &classname, const std::string &funcname, bool suggestStatic) { - std::list toks; - toks.push_back(tok1); + std::list toks{ tok1 }; if (tok2) toks.push_back(tok2); if (!suggestStatic) diff --git a/lib/checkstl.cpp b/lib/checkstl.cpp index a9f1446e9..e07ffbe86 100644 --- a/lib/checkstl.cpp +++ b/lib/checkstl.cpp @@ -2707,7 +2707,7 @@ namespace { const Token* bodyTok = nullptr; const Token* loopVar = nullptr; const Settings* settings = nullptr; - std::set varsChanged = {}; + std::set varsChanged; explicit LoopAnalyzer(const Token* tok, const Settings* psettings) : bodyTok(tok->next()->link()->next()), settings(psettings) diff --git a/lib/checkstring.cpp b/lib/checkstring.cpp index 6c0110b66..c0647fd21 100644 --- a/lib/checkstring.cpp +++ b/lib/checkstring.cpp @@ -73,8 +73,7 @@ void CheckString::stringLiteralWrite() void CheckString::stringLiteralWriteError(const Token *tok, const Token *strValue) { - std::list callstack; - callstack.push_back(tok); + std::list callstack{ tok }; if (strValue) callstack.push_back(strValue); diff --git a/lib/infer.cpp b/lib/infer.cpp index f3a2989f8..28365f0dc 100644 --- a/lib/infer.cpp +++ b/lib/infer.cpp @@ -49,10 +49,8 @@ static const ValueFlow::Value* getCompareValue(const std::list } struct Interval { - std::vector minvalue = {}; - std::vector maxvalue = {}; - std::vector minRef = {}; - std::vector maxRef = {}; + std::vector minvalue, maxvalue; + std::vector minRef, maxRef; std::string str() const { diff --git a/lib/platform.cpp b/lib/platform.cpp index 09983751a..7d3802174 100644 --- a/lib/platform.cpp +++ b/lib/platform.cpp @@ -193,11 +193,12 @@ bool Platform::loadFromFile(const char exename[], const std::string &filename, b { // TODO: only append .xml if missing // TODO: use native separators - std::vector filenames; - filenames.push_back(filename); - filenames.push_back(filename + ".xml"); - filenames.push_back("platforms/" + filename); - filenames.push_back("platforms/" + filename + ".xml"); + std::vector filenames{ + filename, + filename + ".xml", + "platforms/" + filename, + "platforms/" + filename + ".xml" + }; if (exename && (std::string::npos != Path::fromNativeSeparators(exename).find('/'))) { filenames.push_back(Path::getPathFromFilename(Path::fromNativeSeparators(exename)) + filename); filenames.push_back(Path::getPathFromFilename(Path::fromNativeSeparators(exename)) + "platforms/" + filename); diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 895af19e6..329bdd3bf 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -1131,15 +1131,13 @@ void Tokenizer::simplifyTypedef() void Tokenizer::simplifyTypedefCpp() { - std::vector spaceInfo; bool isNamespace = false; - std::string className; - std::string fullClassName; + std::string className, fullClassName; bool hasClass = false; bool goback = false; // add global namespace - spaceInfo.emplace_back(/*Space{}*/); + std::vector spaceInfo(1); // Convert "using a::b;" to corresponding typedef statements simplifyUsingToTypedef(); @@ -5013,8 +5011,7 @@ void Tokenizer::setVarIdPass2() const std::string &scopeName(getScopeName(scopeInfo)); const std::string scopeName2(scopeName.empty() ? std::string() : (scopeName + " :: ")); - std::list classnameTokens; - classnameTokens.push_back(tok->next()); + std::list classnameTokens{ tok->next() }; Token* tokStart = tok->tokAt(2); while (Token::Match(tokStart, ":: %name%") || tokStart->str() == "<") { if (tokStart->str() == "<") { diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 22bf164d4..9fa3ec3c5 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -1775,7 +1775,7 @@ static void valueFlowRightShift(TokenList &tokenList, const Settings* settings) static std::vector minUnsignedValue(const Token* tok, int depth = 8) { - std::vector result = {}; + std::vector result; if (!tok) return result; if (depth < 0) @@ -4942,7 +4942,7 @@ static void valueFlowLifetime(TokenList &tokenlist, ErrorLogger *errorLogger, co continue; } - std::vector toks = {}; + std::vector toks; if (tok->isUnaryOp("*") || parent->originalName() == "->") { for (const ValueFlow::Value& v : tok->values()) { if (!v.isLocalLifetimeValue()) @@ -9180,7 +9180,7 @@ struct ValueFlowState { SymbolDatabase& symboldatabase; ErrorLogger* errorLogger = nullptr; const Settings* settings = nullptr; - std::set skippedFunctions = {}; + std::set skippedFunctions; }; struct ValueFlowPass {