Skip to content

Commit b29d920

Browse files
committed
enabled modernize-use-auto and fixed remaining warnings
1 parent dd5fbdb commit b29d920

6 files changed

Lines changed: 12 additions & 17 deletions

File tree

.clang-tidy

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ Checks: >
4848
-modernize-replace-auto-ptr,
4949
-modernize-return-braced-init-list,
5050
-modernize-type-traits,
51-
-modernize-use-auto,
5251
-modernize-use-designated-initializers,
5352
-modernize-use-nodiscard,
5453
-modernize-use-trailing-return-type,

clang-tidy.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,6 @@ To be evaluated (need to enable explicitly).
147147

148148
These apply to codebases which use later standards then C++11 (C++17 is used when building with Qt6) so we cannot simply apply them.
149149

150-
`modernize-use-auto`<br/>
151-
152-
This cannot be enabled as it might lead to changes in the constness of iterators - see https://github.com/llvm/llvm-project/issues/84324.
153-
154150
### Disabled for performance reasons
155151

156152
`portability-std-allocator-const`<br/>

lib/errorlogger.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ std::string ErrorMessage::toXML() const
496496
if (!remark.empty())
497497
printer.PushAttribute("remark", fixInvalidChars(remark).c_str());
498498

499-
for (std::list<FileLocation>::const_reverse_iterator it = callStack.crbegin(); it != callStack.crend(); ++it) {
499+
for (auto it = callStack.crbegin(); it != callStack.crend(); ++it) {
500500
printer.OpenElement("location", false);
501501
printer.PushAttribute("file", it->getfile().c_str());
502502
printer.PushAttribute("line", std::max(it->line,0));

lib/symboldatabase.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4641,8 +4641,8 @@ const Function * Function::getOverriddenFunctionRecursive(const ::Type* baseType
46414641
const Scope *parent = derivedFromType->classScope;
46424642

46434643
// check if function defined in base class
4644-
auto range = parent->functionMap.equal_range(tokenDef->str());
4645-
for (std::multimap<std::string, const Function*>::const_iterator it = range.first; it != range.second; ++it) {
4644+
auto range = utils::as_const(parent->functionMap).equal_range(tokenDef->str());
4645+
for (auto it = range.first; it != range.second; ++it) {
46464646
const Function * func = it->second;
46474647
if (func->isImplicitlyVirtual()) { // Base is virtual and of same name
46484648
const Token *temp1 = func->tokenDef->previous();
@@ -5549,8 +5549,8 @@ void Scope::findFunctionInBase(const std::string & name, nonneg int args, std::v
55495549
if (base->classScope == this) // Ticket #5120, #5125: Recursive class; tok should have been found already
55505550
continue;
55515551

5552-
auto range = base->classScope->functionMap.equal_range(name);
5553-
for (std::multimap<std::string, const Function*>::const_iterator it = range.first; it != range.second; ++it) {
5552+
auto range = utils::as_const(base->classScope->functionMap).equal_range(name);
5553+
for (auto it = range.first; it != range.second; ++it) {
55545554
const Function *func = it->second;
55555555
if ((func->isVariadic() && args >= (func->argCount() - 1)) ||
55565556
(args == func->argCount() || (args < func->argCount() && args >= func->minArgCount()))) {
@@ -5709,8 +5709,8 @@ const Function* Scope::findFunction(const Token *tok, bool requireConst, Referen
57095709
const std::size_t args = arguments.size();
57105710

57115711
auto addMatchingFunctions = [&](const Scope *scope) {
5712-
auto range = scope->functionMap.equal_range(tok->str());
5713-
for (std::multimap<std::string, const Function *>::const_iterator it = range.first; it != range.second; ++it) {
5712+
auto range = utils::as_const(scope->functionMap).equal_range(tok->str());
5713+
for (auto it = range.first; it != range.second; ++it) {
57145714
const Function *func = it->second;
57155715
if (ref == Reference::LValue && func->hasRvalRefQualifier())
57165716
continue;
@@ -6479,8 +6479,8 @@ Function * SymbolDatabase::findFunctionInScope(const Token *func, const Scope *n
64796479
const Function * function = nullptr;
64806480
const bool destructor = func->strAt(-1) == "~";
64816481

6482-
auto range = ns->functionMap.equal_range(func->str());
6483-
for (std::multimap<std::string, const Function*>::const_iterator it = range.first; it != range.second; ++it) {
6482+
auto range = utils::as_const(ns->functionMap).equal_range(func->str());
6483+
for (auto it = range.first; it != range.second; ++it) {
64846484
if (it->second->argsMatch(ns, it->second->argDef, func->next(), path, path_length) &&
64856485
it->second->isDestructor() == destructor) {
64866486
function = it->second;

lib/templatesimplifier.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3888,7 +3888,7 @@ void TemplateSimplifier::simplifyTemplates(const std::time_t maxtime)
38883888

38893889
std::set<std::string> expandedtemplates;
38903890

3891-
for (std::list<TokenAndName>::const_reverse_iterator iter1 = mTemplateDeclarations.crbegin(); iter1 != mTemplateDeclarations.crend(); ++iter1) {
3891+
for (auto iter1 = mTemplateDeclarations.crbegin(); iter1 != mTemplateDeclarations.crend(); ++iter1) {
38923892
if (iter1->isAlias() || iter1->isFriend())
38933893
continue;
38943894

lib/tokenize.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2052,7 +2052,7 @@ void Tokenizer::simplifyTypedefCpp()
20522052
if (idx != std::string::npos)
20532053
removed1.resize(idx);
20542054
if (removed1 == classPath && !removed1.empty()) {
2055-
for (std::vector<Space>::const_reverse_iterator it = spaceInfo.crbegin(); it != spaceInfo.crend(); ++it) {
2055+
for (auto it = spaceInfo.crbegin(); it != spaceInfo.crend(); ++it) {
20562056
if (it->recordTypes.find(start->str()) != it->recordTypes.end()) {
20572057
std::string::size_type spaceIdx = 0;
20582058
std::string::size_type startIdx = 0;
@@ -3382,7 +3382,7 @@ bool Tokenizer::simplifyUsing()
33823382
}
33833383

33843384
// delete all used type alias definitions
3385-
for (std::list<Using>::reverse_iterator it = usingList.rbegin(); it != usingList.rend(); ++it) {
3385+
for (auto it = usingList.rbegin(); it != usingList.rend(); ++it) {
33863386
Token *usingStart = it->startTok;
33873387
Token *usingEnd = it->endTok;
33883388
if (usingStart->previous()) {

0 commit comments

Comments
 (0)