enabled and fixed `modernize-use-emplace` clang-tidy warnings (#4165)
* enabled and fixed `modernize-use-emplace` clang-tidy warnings * avoid unnecessary creation of temporaries in `emplace_back()` calls
This commit is contained in:
parent
111f4e17da
commit
d36e05af28
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -398,7 +398,7 @@ void CheckThread::parseClangErrors(const QString &tool, const QString &file0, QS
|
|||
|
||||
std::list<ErrorMessage::FileLocation> 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();
|
||||
|
|
|
@ -163,7 +163,7 @@ static std::vector<std::string> 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<Scope *>(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<Scope *>(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<Token *>(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<Scope *>(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<Scope *>(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<Scope *>(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<SymbolDatabase *>(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;
|
||||
|
||||
|
|
|
@ -438,8 +438,8 @@ static void getConfigs(const simplecpp::TokenList &tokens, std::set<std::string>
|
|||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue