diff --git a/.clang-tidy b/.clang-tidy index 4e769dbd1..6ca666dbc 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,5 +1,5 @@ --- -Checks: '*,-abseil-*,-altera-*,-android-*,-cert-*,-cppcoreguidelines-*,-fuchsia-*,-google-*,-hicpp-*,-linuxkernel-*,-llvm-*,-llvmlibc-*,-mpi-*,-objc-*,-openmp-*,-zircon-*,-readability-braces-around-statements,-readability-magic-numbers,-bugprone-macro-parentheses,-readability-isolate-declaration,-readability-function-size,-modernize-use-trailing-return-type,-readability-implicit-bool-conversion,-readability-uppercase-literal-suffix,-modernize-use-auto,-readability-else-after-return,-modernize-use-default-member-init,-readability-named-parameter,-readability-redundant-member-init,-performance-faster-string-find,-modernize-avoid-c-arrays,-modernize-use-equals-default,-readability-container-size-empty,-readability-simplify-boolean-expr,-modernize-use-override,-modernize-pass-by-value,-bugprone-branch-clone,-bugprone-narrowing-conversions,-modernize-raw-string-literal,-readability-convert-member-functions-to-static,-modernize-loop-convert,-misc-unused-using-decls,-modernize-use-emplace,-readability-const-return-type,-performance-unnecessary-value-param,-modernize-return-braced-init-list,-performance-inefficient-string-concatenation,-misc-throw-by-value-catch-by-reference,-readability-avoid-const-params-in-decls,-readability-non-const-parameter,-misc-non-private-member-variables-in-classes,-bugprone-suspicious-string-compare,-clang-analyzer-*,-bugprone-signed-char-misuse,-readability-make-member-function-const,-misc-no-recursion,-readability-use-anyofallof,-performance-no-automatic-move,-bugprone-suspicious-include,-modernize-replace-random-shuffle,-readability-function-cognitive-complexity,-readability-redundant-access-specifiers,-modernize-use-equals-delete,-performance-noexcept-move-constructor,-concurrency-mt-unsafe,-bugprone-easily-swappable-parameters,-readability-suspicious-call-argument,-readability-identifier-length,-readability-container-data-pointer' +Checks: '*,-abseil-*,-altera-*,-android-*,-cert-*,-cppcoreguidelines-*,-fuchsia-*,-google-*,-hicpp-*,-linuxkernel-*,-llvm-*,-llvmlibc-*,-mpi-*,-objc-*,-openmp-*,-zircon-*,-readability-braces-around-statements,-readability-magic-numbers,-bugprone-macro-parentheses,-readability-isolate-declaration,-readability-function-size,-modernize-use-trailing-return-type,-readability-implicit-bool-conversion,-readability-uppercase-literal-suffix,-modernize-use-auto,-readability-else-after-return,-modernize-use-default-member-init,-readability-named-parameter,-readability-redundant-member-init,-performance-faster-string-find,-modernize-avoid-c-arrays,-modernize-use-equals-default,-readability-container-size-empty,-readability-simplify-boolean-expr,-modernize-use-override,-modernize-pass-by-value,-bugprone-branch-clone,-bugprone-narrowing-conversions,-modernize-raw-string-literal,-readability-convert-member-functions-to-static,-modernize-loop-convert,-misc-unused-using-decls,-readability-const-return-type,-performance-unnecessary-value-param,-modernize-return-braced-init-list,-performance-inefficient-string-concatenation,-misc-throw-by-value-catch-by-reference,-readability-avoid-const-params-in-decls,-readability-non-const-parameter,-misc-non-private-member-variables-in-classes,-bugprone-suspicious-string-compare,-clang-analyzer-*,-bugprone-signed-char-misuse,-readability-make-member-function-const,-misc-no-recursion,-readability-use-anyofallof,-performance-no-automatic-move,-bugprone-suspicious-include,-modernize-replace-random-shuffle,-readability-function-cognitive-complexity,-readability-redundant-access-specifiers,-modernize-use-equals-delete,-performance-noexcept-move-constructor,-concurrency-mt-unsafe,-bugprone-easily-swappable-parameters,-readability-suspicious-call-argument,-readability-identifier-length,-readability-container-data-pointer' WarningsAsErrors: '*' CheckOptions: - key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic diff --git a/cli/cmdlineparser.cpp b/cli/cmdlineparser.cpp index d170b500c..69af1c4ec 100644 --- a/cli/cmdlineparser.cpp +++ b/cli/cmdlineparser.cpp @@ -365,7 +365,7 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[]) // use a file filter else if (std::strncmp(argv[i], "--file-filter=", 14) == 0) - mSettings->fileFilters.push_back(argv[i] + 14); + mSettings->fileFilters.emplace_back(argv[i] + 14); // file list specified else if (std::strncmp(argv[i], "--file-list=", 12) == 0) diff --git a/gui/checkthread.cpp b/gui/checkthread.cpp index bb8662bae..d0a3a550a 100644 --- a/gui/checkthread.cpp +++ b/gui/checkthread.cpp @@ -398,7 +398,7 @@ void CheckThread::parseClangErrors(const QString &tool, const QString &file0, QS std::list callstack; for (const QErrorPathItem &path : e.errorPath) { - callstack.push_back(ErrorMessage::FileLocation(path.file.toStdString(), path.info.toStdString(), path.line, path.column)); + callstack.emplace_back(path.file.toStdString(), path.info.toStdString(), path.line, path.column); } const std::string f0 = file0.toStdString(); const std::string msg = e.message.toStdString(); diff --git a/lib/clangimport.cpp b/lib/clangimport.cpp index bf3c15203..5be38e6f0 100644 --- a/lib/clangimport.cpp +++ b/lib/clangimport.cpp @@ -163,7 +163,7 @@ static std::vector splitString(const std::string &line) line.find("::", pos1) < line.find("<", pos1)) { pos2 = line.find("::", pos1); ret.push_back(line.substr(pos1, pos2-pos1)); - ret.push_back("::"); + ret.emplace_back("::"); pos1 = pos2 + 2; continue; } @@ -643,7 +643,7 @@ Scope *clangimport::AstNode::createScope(TokenList *tokenList, Scope::ScopeType Scope *nestedIn = const_cast(getNestedInScope(tokenList)); - symbolDatabase->scopeList.push_back(Scope(nullptr, nullptr, nestedIn)); + symbolDatabase->scopeList.emplace_back(nullptr, nullptr, nestedIn); Scope *scope = &symbolDatabase->scopeList.back(); if (scopeType == Scope::ScopeType::eEnum) scope->enumeratorList.reserve(children2.size()); @@ -968,7 +968,7 @@ Token *clangimport::AstNode::createTokens(TokenList *tokenList) if (nodeType == EnumConstantDecl) { Token *nameToken = addtoken(tokenList, getSpelling()); Scope *scope = const_cast(nameToken->scope()); - scope->enumeratorList.push_back(Enumerator(nameToken->scope())); + scope->enumeratorList.emplace_back(nameToken->scope()); Enumerator *e = &scope->enumeratorList.back(); e->name = nameToken; e->value = mData->enumValue++; @@ -1004,7 +1004,7 @@ Token *clangimport::AstNode::createTokens(TokenList *tokenList) const_cast(enumscope->bodyEnd)->deletePrevious(); // Create enum type - mData->mSymbolDatabase->typeList.push_back(Type(enumtok, enumscope, enumtok->scope())); + mData->mSymbolDatabase->typeList.emplace_back(enumtok, enumscope, enumtok->scope()); enumscope->definedType = &mData->mSymbolDatabase->typeList.back(); if (nametok) const_cast(enumtok->scope())->definedTypesMap[nametok->str()] = enumscope->definedType; @@ -1171,7 +1171,7 @@ Token *clangimport::AstNode::createTokens(TokenList *tokenList) } Scope *recordScope = createScope(tokenList, Scope::ScopeType::eStruct, children, classDef); - mData->mSymbolDatabase->typeList.push_back(Type(classDef, recordScope, classDef->scope())); + mData->mSymbolDatabase->typeList.emplace_back(classDef, recordScope, classDef->scope()); recordScope->definedType = &mData->mSymbolDatabase->typeList.back(); if (!recordName.empty()) { recordScope->className = recordName; @@ -1326,7 +1326,7 @@ void clangimport::AstNode::createTokensFunctionDecl(TokenList *tokenList) mData->ref(addr, nameToken); } if (!nameToken->function()) { - nestedIn->functionList.push_back(Function(nameToken, unquote(getFullType()))); + nestedIn->functionList.emplace_back(nameToken, unquote(getFullType())); mData->funcDecl(mExtTokens.front(), nameToken, &nestedIn->functionList.back()); if (nodeType == CXXConstructorDecl) nestedIn->functionList.back().type = Function::Type::eConstructor; @@ -1346,7 +1346,7 @@ void clangimport::AstNode::createTokensFunctionDecl(TokenList *tokenList) Scope *scope = nullptr; if (hasBody) { - symbolDatabase->scopeList.push_back(Scope(nullptr, nullptr, nestedIn)); + symbolDatabase->scopeList.emplace_back(nullptr, nullptr, nestedIn); scope = &symbolDatabase->scopeList.back(); scope->check = symbolDatabase; scope->function = function; @@ -1379,7 +1379,7 @@ void clangimport::AstNode::createTokensFunctionDecl(TokenList *tokenList) if (!spelling.empty()) vartok = child->addtoken(tokenList, spelling); if (!prev) { - function->argumentList.push_back(Variable(vartok, child->getType(), nullptr, typeEndToken, i, AccessControl::Argument, recordType, scope)); + function->argumentList.emplace_back(vartok, child->getType(), nullptr, typeEndToken, i, AccessControl::Argument, recordType, scope); if (vartok) { const std::string addr = child->mExtTokens[0]; mData->varDecl(addr, vartok, &function->argumentList.back()); @@ -1455,7 +1455,7 @@ void clangimport::AstNode::createTokensForCXXRecord(TokenList *tokenList) const std::string addr = mExtTokens[0]; mData->scopeDecl(addr, scope); scope->className = className; - mData->mSymbolDatabase->typeList.push_back(Type(classToken, scope, classToken->scope())); + mData->mSymbolDatabase->typeList.emplace_back(classToken, scope, classToken->scope()); scope->definedType = &mData->mSymbolDatabase->typeList.back(); const_cast(classToken->scope())->definedTypesMap[className] = scope->definedType; } @@ -1481,7 +1481,7 @@ Token * clangimport::AstNode::createTokensVarDecl(TokenList *tokenList) startToken = startToken->next(); Token *vartok1 = addtoken(tokenList, name); Scope *scope = const_cast(tokenList->back()->scope()); - scope->varlist.push_back(Variable(vartok1, unquote(type), startToken, vartok1->previous(), 0, scope->defaultAccess(), recordType, scope)); + scope->varlist.emplace_back(vartok1, unquote(type), startToken, vartok1->previous(), 0, scope->defaultAccess(), recordType, scope); mData->varDecl(addr, vartok1, &scope->varlist.back()); if (mExtTokens.back() == "cinit" && !children.empty()) { Token *eq = addtoken(tokenList, "="); @@ -1562,7 +1562,7 @@ void clangimport::parseClangAstDump(Tokenizer *tokenizer, std::istream &f) tokenizer->createSymbolDatabase(); SymbolDatabase *symbolDatabase = const_cast(tokenizer->getSymbolDatabase()); - symbolDatabase->scopeList.push_back(Scope(nullptr, nullptr, nullptr)); + symbolDatabase->scopeList.emplace_back(nullptr, nullptr, nullptr); symbolDatabase->scopeList.back().type = Scope::ScopeType::eGlobal; symbolDatabase->scopeList.back().check = symbolDatabase; diff --git a/lib/preprocessor.cpp b/lib/preprocessor.cpp index 6958c7103..36c7f13df 100644 --- a/lib/preprocessor.cpp +++ b/lib/preprocessor.cpp @@ -438,8 +438,8 @@ static void getConfigs(const simplecpp::TokenList &tokens, std::set } } if (includeGuard) { - configs_if.push_back(std::string()); - configs_ifndef.push_back(std::string()); + configs_if.emplace_back(std::string()); + configs_ifndef.emplace_back(std::string()); continue; } } diff --git a/lib/templatesimplifier.cpp b/lib/templatesimplifier.cpp index 2b50f481f..c98dda935 100644 --- a/lib/templatesimplifier.cpp +++ b/lib/templatesimplifier.cpp @@ -2967,11 +2967,11 @@ std::string TemplateSimplifier::getNewName( const bool constconst = tok3->str() == "const" && tok3->strAt(1) == "const"; if (!constconst) { if (tok3->isUnsigned()) - typeStringsUsedInTemplateInstantiation.push_back("unsigned"); + typeStringsUsedInTemplateInstantiation.emplace_back("unsigned"); else if (tok3->isSigned()) - typeStringsUsedInTemplateInstantiation.push_back("signed"); + typeStringsUsedInTemplateInstantiation.emplace_back("signed"); if (tok3->isLong()) - typeStringsUsedInTemplateInstantiation.push_back("long"); + typeStringsUsedInTemplateInstantiation.emplace_back("long"); typeStringsUsedInTemplateInstantiation.push_back(tok3->str()); } // add additional type information