diff options
author | Ivan Komissarov <ABBAPOH@gmail.com> | 2019-05-19 01:56:22 +0200 |
---|---|---|
committer | Ivan Komissarov <ABBAPOH@gmail.com> | 2019-05-20 16:03:06 +0000 |
commit | c75be7ad516c7cd041820a9e651ae71fcb8248c4 (patch) | |
tree | 479bd08f90687845829fd1a1430dd281491745b6 /src | |
parent | 2ad4ac1b99a17ab9dabd3a29b81f39f3325dd965 (diff) |
Apply modernize-use-auto fix-it
Makes clang-tidy happier
Change-Id: I75f3b6409b425b9a7054d7886ab0160a040b25d5
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/app/qbs/commandlinefrontend.cpp | 4 | ||||
-rw-r--r-- | src/lib/corelib/buildgraph/executor.cpp | 2 | ||||
-rw-r--r-- | src/lib/corelib/parser/qmljsast_p.h | 8 | ||||
-rw-r--r-- | src/lib/corelib/parser/qmljsparser.cpp | 6 | ||||
-rw-r--r-- | src/lib/corelib/tools/launcherinterface.cpp | 2 | ||||
-rw-r--r-- | src/lib/corelib/tools/persistence.cpp | 4 | ||||
-rw-r--r-- | src/lib/corelib/tools/scripttools.h | 2 | ||||
-rw-r--r-- | src/lib/corelib/tools/set.h | 8 | ||||
-rw-r--r-- | src/plugins/generator/visualstudio/msbuild/msbuildimportgroup.cpp | 2 | ||||
-rw-r--r-- | src/plugins/generator/visualstudio/msbuild/msbuilditem.cpp | 2 | ||||
-rw-r--r-- | src/shared/json/json.cpp | 20 |
11 files changed, 30 insertions, 30 deletions
diff --git a/src/app/qbs/commandlinefrontend.cpp b/src/app/qbs/commandlinefrontend.cpp index 1a8e1757d..95c3c10bc 100644 --- a/src/app/qbs/commandlinefrontend.cpp +++ b/src/app/qbs/commandlinefrontend.cpp @@ -230,7 +230,7 @@ void CommandLineFrontend::handleJobFinished(bool success, AbstractJob *job) return; } cancel(); - } else if (SetupProjectJob * const setupJob = qobject_cast<SetupProjectJob *>(job)) { + } else if (const auto setupJob = qobject_cast<SetupProjectJob * const>(job)) { m_resolveJobs.removeOne(job); m_projects.push_back(setupJob->project()); if (m_observer && resolvingMultipleProjects()) @@ -611,7 +611,7 @@ void CommandLineFrontend::connectBuildJob(AbstractJob *job) { connectJob(job); - BuildJob *bjob = qobject_cast<BuildJob *>(job); + const auto bjob = qobject_cast<const BuildJob *>(job); if (!bjob) return; diff --git a/src/lib/corelib/buildgraph/executor.cpp b/src/lib/corelib/buildgraph/executor.cpp index 7d53351c2..930c1698e 100644 --- a/src/lib/corelib/buildgraph/executor.cpp +++ b/src/lib/corelib/buildgraph/executor.cpp @@ -393,7 +393,7 @@ bool Executor::schedulingBlockedByJobLimit(const BuildGraphNode *node) { if (node->type() != BuildGraphNode::ArtifactNodeType) return false; - const Artifact * const artifact = static_cast<const Artifact *>(node); + const auto artifact = static_cast<const Artifact *>(node); if (artifact->artifactType == Artifact::SourceFile) return false; diff --git a/src/lib/corelib/parser/qmljsast_p.h b/src/lib/corelib/parser/qmljsast_p.h index 5fcd7eda4..8c6f32140 100644 --- a/src/lib/corelib/parser/qmljsast_p.h +++ b/src/lib/corelib/parser/qmljsast_p.h @@ -2514,9 +2514,9 @@ public: SourceLocation firstSourceLocation() const override { - if (FunctionDeclaration *funDecl = cast<FunctionDeclaration *>(sourceElement)) + if (const auto funDecl = cast<const FunctionDeclaration *>(sourceElement)) return funDecl->firstSourceLocation(); - else if (VariableStatement *varStmt = cast<VariableStatement *>(sourceElement)) + else if (const auto varStmt = cast<const VariableStatement *>(sourceElement)) return varStmt->firstSourceLocation(); return SourceLocation(); @@ -2524,9 +2524,9 @@ public: SourceLocation lastSourceLocation() const override { - if (FunctionDeclaration *funDecl = cast<FunctionDeclaration *>(sourceElement)) + if (const auto funDecl = cast<const FunctionDeclaration *>(sourceElement)) return funDecl->lastSourceLocation(); - else if (VariableStatement *varStmt = cast<VariableStatement *>(sourceElement)) + else if (const auto varStmt = cast<const VariableStatement *>(sourceElement)) return varStmt->lastSourceLocation(); return SourceLocation(); diff --git a/src/lib/corelib/parser/qmljsparser.cpp b/src/lib/corelib/parser/qmljsparser.cpp index 71cff876d..6390c8a9d 100644 --- a/src/lib/corelib/parser/qmljsparser.cpp +++ b/src/lib/corelib/parser/qmljsparser.cpp @@ -114,13 +114,13 @@ AST::UiQualifiedId *Parser::reparseAsQualifiedId(AST::ExpressionNode *expr) QVarLengthArray<AST::SourceLocation, 4> locations; AST::ExpressionNode *it = expr; - while (AST::FieldMemberExpression *m = AST::cast<AST::FieldMemberExpression *>(it)) { + while (const auto m = AST::cast<AST::FieldMemberExpression *>(it)) { nameIds.append(m->name); locations.append(m->identifierToken); it = m->base; } - if (AST::IdentifierExpression *idExpr = AST::cast<AST::IdentifierExpression *>(it)) { + if (const auto idExpr = AST::cast<AST::IdentifierExpression *>(it)) { const auto q = new (pool) AST::UiQualifiedId(idExpr->name); q->identifierToken = idExpr->identifierToken; @@ -1150,7 +1150,7 @@ case 212: { } break; case 214: { - AST::BinaryExpression *node = new (pool) AST::BinaryExpression(sym(1).Expression, + const auto node = new (pool) AST::BinaryExpression(sym(1).Expression, QSOperator::And, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; diff --git a/src/lib/corelib/tools/launcherinterface.cpp b/src/lib/corelib/tools/launcherinterface.cpp index b16c8563c..f4e80c5e2 100644 --- a/src/lib/corelib/tools/launcherinterface.cpp +++ b/src/lib/corelib/tools/launcherinterface.cpp @@ -67,7 +67,7 @@ private: void setupChildProcess() override { #ifdef Q_OS_UNIX - const pid_t pid = static_cast<pid_t>(processId()); + const auto pid = static_cast<pid_t>(processId()); setpgid(pid, pid); #endif } diff --git a/src/lib/corelib/tools/persistence.cpp b/src/lib/corelib/tools/persistence.cpp index dfa7fb683..3b69926f6 100644 --- a/src/lib/corelib/tools/persistence.cpp +++ b/src/lib/corelib/tools/persistence.cpp @@ -150,7 +150,7 @@ void PersistentPool::closeStream() void PersistentPool::storeVariant(const QVariant &variant) { - const quint32 type = static_cast<quint32>(variant.type()); + const auto type = static_cast<quint32>(variant.type()); m_stream << type; switch (type) { case QMetaType::QString: @@ -172,7 +172,7 @@ void PersistentPool::storeVariant(const QVariant &variant) QVariant PersistentPool::loadVariant() { - const quint32 type = load<quint32>(); + const auto type = load<quint32>(); QVariant value; switch (type) { case QMetaType::QString: diff --git a/src/lib/corelib/tools/scripttools.h b/src/lib/corelib/tools/scripttools.h index 2d8f54204..4a258b98f 100644 --- a/src/lib/corelib/tools/scripttools.h +++ b/src/lib/corelib/tools/scripttools.h @@ -76,7 +76,7 @@ void attachPointerTo(QScriptValue &scriptValue, T *ptr) template <class T> T *attachedPointer(const QScriptValue &scriptValue) { - const quintptr ptr = scriptValue.data().toVariant().value<quintptr>(); + const auto ptr = scriptValue.data().toVariant().value<quintptr>(); return reinterpret_cast<T *>(ptr); } diff --git a/src/lib/corelib/tools/set.h b/src/lib/corelib/tools/set.h index 322074b0d..eb3bf6632 100644 --- a/src/lib/corelib/tools/set.h +++ b/src/lib/corelib/tools/set.h @@ -179,8 +179,8 @@ template<typename T> Set<T>::Set(const std::initializer_list<T> &list) : m_data( template<typename T> Set<T> &Set<T>::intersect(const Set<T> &other) { - iterator it = begin(); - const_iterator otherIt = other.cbegin(); + auto it = begin(); + auto otherIt = other.cbegin(); while (it != end()) { if (otherIt == other.cend()) { m_data.erase(it, end()); @@ -207,8 +207,8 @@ template<typename T> std::pair<typename Set<T>::iterator, bool> Set<T>::insert(c template<typename T> bool Set<T>::contains(const Set<T> &other) const { - const_iterator it = cbegin(); - const_iterator otherIt = other.cbegin(); + auto it = cbegin(); + auto otherIt = other.cbegin(); while (otherIt != other.cend()) { if (it == cend() || *otherIt < *it) return false; diff --git a/src/plugins/generator/visualstudio/msbuild/msbuildimportgroup.cpp b/src/plugins/generator/visualstudio/msbuild/msbuildimportgroup.cpp index 56c48049e..73e1922db 100644 --- a/src/plugins/generator/visualstudio/msbuild/msbuildimportgroup.cpp +++ b/src/plugins/generator/visualstudio/msbuild/msbuildimportgroup.cpp @@ -66,7 +66,7 @@ void MSBuildImportGroup::accept(IMSBuildNodeVisitor *visitor) const visitor->visitStart(this); for (const auto &child : children()) { - if (const MSBuildImport *import = qobject_cast<const MSBuildImport *>(child)) + if (const auto import = qobject_cast<const MSBuildImport *>(child)) import->accept(visitor); } diff --git a/src/plugins/generator/visualstudio/msbuild/msbuilditem.cpp b/src/plugins/generator/visualstudio/msbuild/msbuilditem.cpp index 9a2ffb734..b11b62295 100644 --- a/src/plugins/generator/visualstudio/msbuild/msbuilditem.cpp +++ b/src/plugins/generator/visualstudio/msbuild/msbuilditem.cpp @@ -85,7 +85,7 @@ void MSBuildItem::accept(IMSBuildNodeVisitor *visitor) const visitor->visitStart(this); for (const auto &child : children()) { - if (MSBuildItemMetadata *itemMetadata = qobject_cast<MSBuildItemMetadata *>(child)) + if (const auto itemMetadata = qobject_cast<const MSBuildItemMetadata *>(child)) itemMetadata->accept(visitor); } diff --git a/src/shared/json/json.cpp b/src/shared/json/json.cpp index 82b7467c8..10b211ca8 100644 --- a/src/shared/json/json.cpp +++ b/src/shared/json/json.cpp @@ -542,7 +542,7 @@ public: } char *raw = (char *)malloc(size); memcpy(raw + sizeof(Header), b, b->size); - Header *h = (Header *)raw; + const auto h = (Header *)raw; h->tag = JsonDocument::BinaryFormatTag; h->version = 1; const auto d = new Data(raw, size); @@ -3521,7 +3521,7 @@ bool JsonDocument::isArray() const if (!d) return false; - Internal::Header *h = (Internal::Header *)d->rawData; + const auto h = (Internal::Header *)d->rawData; return h->root()->isArray(); } @@ -3535,7 +3535,7 @@ bool JsonDocument::isObject() const if (!d) return false; - Internal::Header *h = (Internal::Header *)d->rawData; + const auto h = (Internal::Header *)d->rawData; return h->root()->isObject(); } @@ -3731,7 +3731,7 @@ static std::string escapedString(const std::string &in) static void valueToJson(const Base *b, const Value &v, std::string &json, int indent, bool compact) { - JsonValue::Type type = (JsonValue::Type)(uint32_t)v.type; + const auto type = (JsonValue::Type)(uint32_t)v.type; switch (type) { case JsonValue::Bool: json += v.toBoolean() ? "true" : "false"; @@ -4013,7 +4013,7 @@ JsonDocument Parser::parse(JsonParseError *error) data = (char *)malloc(dataLength); // fill in Header data - Header *h = (Header *)data; + const auto h = (Header *)data; h->tag = JsonDocument::BinaryFormatTag; h->version = 1u; @@ -4065,7 +4065,7 @@ error: void Parser::ParsedObject::insert(uint32_t offset) { - const Entry *newEntry = reinterpret_cast<const Entry *>(parser->data + objectPosition + offset); + const auto newEntry = reinterpret_cast<const Entry *>(parser->data + objectPosition + offset); size_t min = 0; size_t n = offsets.size(); while (n > 0) { @@ -4133,7 +4133,7 @@ bool Parser::parseObject() memcpy(data + table, &*parsedObject.offsets.begin(), tableSize); } - Object *o = (Object *)(data + objectOffset); + const auto o = (Object *)(data + objectOffset); o->tableOffset = table - objectOffset; o->size = current - objectOffset; o->is_object = true; @@ -4166,7 +4166,7 @@ bool Parser::parseMember(int baseOffset) return false; // finalize the entry - Entry *e = (Entry *)(data + entryOffset); + const auto e = (Entry *)(data + entryOffset); e->value = val; END; @@ -4224,7 +4224,7 @@ bool Parser::parseArray() memcpy(data + table, values.data(), tableSize); } - Array *a = (Array *)(data + arrayOffset); + const auto a = (Array *)(data + arrayOffset); a->tableOffset = table - arrayOffset; a->size = current - arrayOffset; a->is_object = false; @@ -4632,7 +4632,7 @@ void Data::compact() int size = sizeof(Base) + reserve + base->length*sizeof(offset); int alloc = sizeof(Header) + size; - Header *h = (Header *) malloc(alloc); + const auto h = (Header *) malloc(alloc); h->tag = JsonDocument::BinaryFormatTag; h->version = 1; Base *b = h->root(); |