diff options
Diffstat (limited to 'src/lib')
22 files changed, 73 insertions, 54 deletions
diff --git a/src/lib/corelib/api/jobs.cpp b/src/lib/corelib/api/jobs.cpp index 7a845b0ac..10c96bfee 100644 --- a/src/lib/corelib/api/jobs.cpp +++ b/src/lib/corelib/api/jobs.cpp @@ -231,7 +231,7 @@ Project SetupProjectJob::project() const { auto const wrapper = qobject_cast<const InternalJobThreadWrapper *>(internalJob()); auto const job = qobject_cast<const InternalSetupProjectJob *>(wrapper->synchronousJob()); - return Project(job->project(), job->logger()); + return {job->project(), job->logger()}; } void SetupProjectJob::resolve(const Project &existingProject, diff --git a/src/lib/corelib/api/project.cpp b/src/lib/corelib/api/project.cpp index 0588b822c..53c711b49 100644 --- a/src/lib/corelib/api/project.cpp +++ b/src/lib/corelib/api/project.cpp @@ -797,8 +797,14 @@ RunEnvironment Project::getRunEnvironment(const ProductData &product, const QStringList &setupRunEnvConfig, Settings *settings) const { const ResolvedProductPtr resolvedProduct = d->internalProduct(product); - return RunEnvironment(resolvedProduct, d->internalProject, installOptions, environment, - setupRunEnvConfig, settings, d->logger); + return { + resolvedProduct, + d->internalProject, + installOptions, + environment, + setupRunEnvConfig, + settings, + d->logger}; } /*! diff --git a/src/lib/corelib/api/projectdata.cpp b/src/lib/corelib/api/projectdata.cpp index 34e679d6d..628fe2a5d 100644 --- a/src/lib/corelib/api/projectdata.cpp +++ b/src/lib/corelib/api/projectdata.cpp @@ -75,7 +75,7 @@ static QVariant getModuleProperty(const PropertyMap &properties, const QString & { const int lastDotIndex = fullPropertyName.lastIndexOf(QLatin1Char('.')); if (lastDotIndex == -1) - return QVariant(); + return {}; return properties.getModuleProperty(fullPropertyName.left(lastDotIndex), fullPropertyName.mid(lastDotIndex + 1)); } diff --git a/src/lib/corelib/api/runenvironment.cpp b/src/lib/corelib/api/runenvironment.cpp index adf0c4557..23d0359b0 100644 --- a/src/lib/corelib/api/runenvironment.cpp +++ b/src/lib/corelib/api/runenvironment.cpp @@ -363,16 +363,16 @@ int RunEnvironment::doRunTarget(const QString &targetBin, const QStringList &arg << arguments; } } else { - if (QFileInfo(targetExecutable = findExecutable(QStringList() - << QStringLiteral("iostool"))).isExecutable()) { + if (targetExecutable = findExecutable(QStringList{QStringLiteral("iostool")}); + QFileInfo(targetExecutable).isExecutable()) { targetArguments = QStringList() << QStringLiteral("-run") << QStringLiteral("-bundle") << QDir::cleanPath(bundlePath); if (!arguments.empty()) targetArguments << QStringLiteral("-extra-args") << arguments; - } else if (QFileInfo(targetExecutable = findExecutable(QStringList() - << QStringLiteral("ios-deploy"))).isExecutable()) { + } else if (targetExecutable = findExecutable(QStringList{QStringLiteral("ios-deploy")}); + QFileInfo(targetExecutable).isExecutable()) { targetArguments = QStringList() << QStringLiteral("--no-wifi") << QStringLiteral("--noninteractive") diff --git a/src/lib/corelib/buildgraph/inputartifactscanner.cpp b/src/lib/corelib/buildgraph/inputartifactscanner.cpp index fb582c457..0c73f599f 100644 --- a/src/lib/corelib/buildgraph/inputartifactscanner.cpp +++ b/src/lib/corelib/buildgraph/inputartifactscanner.cpp @@ -103,9 +103,14 @@ static void resolveDepencency(const RawScannedDependency &dependency, } // prioritize found artifacts - if ((result->file = dependencyInProduct) - || (result->file = dependencyInOtherProduct) - || (result->file = fileDependencyArtifact)) { + if (dependencyInProduct) + result->file = dependencyInProduct; + else if (dependencyInOtherProduct) + result->file = dependencyInOtherProduct; + else + result->file = fileDependencyArtifact; + + if (result->file) { result->filePath = result->file->filePath(); if (result->file == dependencyInOtherProduct && !productOfDependencyIsDependency) { diff --git a/src/lib/corelib/buildgraph/nodetreedumper.cpp b/src/lib/corelib/buildgraph/nodetreedumper.cpp index 8475a46cf..6ad597c70 100644 --- a/src/lib/corelib/buildgraph/nodetreedumper.cpp +++ b/src/lib/corelib/buildgraph/nodetreedumper.cpp @@ -120,7 +120,7 @@ bool NodeTreeDumper::doVisit(BuildGraphNode *node, const QString &nodeRepr) QByteArray NodeTreeDumper::indentation() const { - return QByteArray(m_indentation, ' '); + return {m_indentation, ' '}; } } // namespace Internal diff --git a/src/lib/corelib/jsextensions/utilitiesextension.cpp b/src/lib/corelib/jsextensions/utilitiesextension.cpp index e733d618b..cdcee59fa 100644 --- a/src/lib/corelib/jsextensions/utilitiesextension.cpp +++ b/src/lib/corelib/jsextensions/utilitiesextension.cpp @@ -782,7 +782,7 @@ static QStringList detectMachOArchs(QIODevice *device) if (strncmp(ar_header, ARMAG, SARMAG) == 0) { while (!device->atEnd()) { static_assert(sizeof(ar_hdr) == 60, "sizeof(ar_hdr) != 60"); - ar_hdr header; + ar_hdr header{}; if (device->read(reinterpret_cast<char *>(&header), sizeof(ar_hdr)) != sizeof(ar_hdr)) return {}; @@ -832,7 +832,7 @@ static QStringList detectMachOArchs(QIODevice *device) pos = device->pos(); - fat_header fatheader; + fat_header fatheader{}; fatheader.magic = readInt(device, nullptr, false); if (fatheader.magic == FAT_MAGIC || fatheader.magic == FAT_CIGAM || fatheader.magic == FAT_MAGIC_64 || fatheader.magic == FAT_CIGAM_64) { @@ -845,7 +845,7 @@ static QStringList detectMachOArchs(QIODevice *device) QStringList archs; for (uint32_t n = 0; n < fatheader.nfat_arch; ++n) { - fat_arch_64 fatarch; + fat_arch_64 fatarch{}; static_assert(sizeof(fat_arch_64) == 32, "sizeof(fat_arch_64) != 32"); static_assert(sizeof(fat_arch) == 20, "sizeof(fat_arch) != 20"); const qint64 expectedBytes = is64bit ? sizeof(fat_arch_64) : sizeof(fat_arch); @@ -875,7 +875,7 @@ static QStringList detectMachOArchs(QIODevice *device) return {}; bool swap = false; - mach_header header; + mach_header header{}; header.magic = readInt(device, nullptr, swap); switch (header.magic) { case MH_CIGAM: diff --git a/src/lib/corelib/language/builtindeclarations.cpp b/src/lib/corelib/language/builtindeclarations.cpp index 4a83279a8..491b005e8 100644 --- a/src/lib/corelib/language/builtindeclarations.cpp +++ b/src/lib/corelib/language/builtindeclarations.cpp @@ -166,25 +166,28 @@ void BuiltinDeclarations::insert(const ItemDeclaration &decl) static PropertyDeclaration conditionProperty() { - return PropertyDeclaration(StringConstants::conditionProperty(), PropertyDeclaration::Boolean, - StringConstants::trueValue()); + return { + StringConstants::conditionProperty(), + PropertyDeclaration::Boolean, + StringConstants::trueValue()}; } static PropertyDeclaration alwaysRunProperty() { - return PropertyDeclaration(StringConstants::alwaysRunProperty(), PropertyDeclaration::Boolean, - StringConstants::falseValue()); + return { + StringConstants::alwaysRunProperty(), + PropertyDeclaration::Boolean, + StringConstants::falseValue()}; } static PropertyDeclaration nameProperty() { - return PropertyDeclaration(StringConstants::nameProperty(), PropertyDeclaration::String); + return {StringConstants::nameProperty(), PropertyDeclaration::String}; } static PropertyDeclaration buildDirProperty() { - return PropertyDeclaration(StringConstants::buildDirectoryProperty(), - PropertyDeclaration::Path); + return {StringConstants::buildDirectoryProperty(), PropertyDeclaration::Path}; } static PropertyDeclaration prepareScriptProperty() diff --git a/src/lib/corelib/language/item.cpp b/src/lib/corelib/language/item.cpp index 29fa1417d..e5de8f195 100644 --- a/src/lib/corelib/language/item.cpp +++ b/src/lib/corelib/language/item.cpp @@ -142,7 +142,8 @@ ValuePtr Item::property(const QString &name) const ValuePtr value; const Item *item = this; do { - if ((value = item->m_properties.value(name))) + value = item->m_properties.value(name); + if (value) break; item = item->m_prototype; } while (item); @@ -172,7 +173,7 @@ ItemValuePtr Item::itemProperty(const QString &name, const Item *itemTemplate, if (v && v->type() == Value::ItemValueType) return std::static_pointer_cast<ItemValue>(v); if (!itemTemplate) - return ItemValuePtr(); + return {}; const bool createdByPropertiesBlock = itemValue && itemValue->createdByPropertiesBlock(); ItemValuePtr result = ItemValue::create(Item::create(&pool, itemTemplate->type()), createdByPropertiesBlock); @@ -184,7 +185,7 @@ JSSourceValuePtr Item::sourceProperty(const QString &name) const { ValuePtr v = property(name); if (!v || v->type() != Value::JSSourceValueType) - return JSSourceValuePtr(); + return {}; return std::static_pointer_cast<JSSourceValue>(v); } @@ -192,7 +193,7 @@ VariantValuePtr Item::variantProperty(const QString &name) const { ValuePtr v = property(name); if (!v || v->type() != Value::VariantValueType) - return VariantValuePtr(); + return {}; return std::static_pointer_cast<VariantValue>(v); } diff --git a/src/lib/corelib/language/qualifiedid.cpp b/src/lib/corelib/language/qualifiedid.cpp index 9eb0e9463..87248ac21 100644 --- a/src/lib/corelib/language/qualifiedid.cpp +++ b/src/lib/corelib/language/qualifiedid.cpp @@ -58,7 +58,7 @@ QualifiedId::QualifiedId(const QStringList &nameParts) QualifiedId QualifiedId::fromString(const QString &str) { - return QualifiedId(str.split(QLatin1Char('.'))); + return {str.split(QLatin1Char('.'))}; } QString QualifiedId::toString() const diff --git a/src/lib/corelib/language/scriptengine.cpp b/src/lib/corelib/language/scriptengine.cpp index 7847cb24d..9131db7f5 100644 --- a/src/lib/corelib/language/scriptengine.cpp +++ b/src/lib/corelib/language/scriptengine.cpp @@ -808,7 +808,7 @@ JSValue ScriptEngine::evaluate(JsValueOwner resultOwner, const QString &code, m_scopeChains << scopeChain; const QByteArray &codeStr = code.toUtf8(); - m_evalPositions.emplace(std::make_pair(filePath, line)); + m_evalPositions.emplace(filePath, line); const JSValue v = JS_EvalThis(m_context, globalObject(), codeStr.constData(), codeStr.length(), filePath.toUtf8().constData(), line, JS_EVAL_TYPE_GLOBAL); m_evalPositions.pop(); @@ -829,7 +829,7 @@ ScopedJsValueList ScriptEngine::argumentList(const QStringList &argumentNames, JSValueList result; for (const auto &name : argumentNames) result.push_back(getJsProperty(m_context, context, name)); - return ScopedJsValueList(m_context, result); + return {m_context, result}; } JSClassID ScriptEngine::registerClass(const char *name, JSClassCall *constructor, diff --git a/src/lib/corelib/loader/astpropertiesitemhandler.cpp b/src/lib/corelib/loader/astpropertiesitemhandler.cpp index cd6a32908..8183e6b79 100644 --- a/src/lib/corelib/loader/astpropertiesitemhandler.cpp +++ b/src/lib/corelib/loader/astpropertiesitemhandler.cpp @@ -159,8 +159,7 @@ static JSSourceValue::AltProperty getPropertyData(const Item *propertiesItem, co throw ErrorInfo(Tr::tr("Properties.condition must be provided."), propertiesItem->location()); } - return JSSourceValue::AltProperty(StringConstants::falseValue(), - propertiesItem->location()); + return {StringConstants::falseValue(), propertiesItem->location()}; } if (Q_UNLIKELY(value->type() != Value::JSSourceValueType)) { throw ErrorInfo(Tr::tr("Properties.%1 must be a value binding.").arg(name), @@ -180,7 +179,7 @@ static JSSourceValue::AltProperty getPropertyData(const Item *propertiesItem, co } const JSSourceValuePtr srcval = std::static_pointer_cast<JSSourceValue>(value); - return JSSourceValue::AltProperty(srcval->sourceCodeForEvaluation(), srcval->location()); + return {srcval->sourceCodeForEvaluation(), srcval->location()}; } void ASTPropertiesItemHandler::handlePropertiesBlock(const Item *propertiesItem) diff --git a/src/lib/corelib/loader/dependenciesresolver.cpp b/src/lib/corelib/loader/dependenciesresolver.cpp index 5df47217f..479318e73 100644 --- a/src/lib/corelib/loader/dependenciesresolver.cpp +++ b/src/lib/corelib/loader/dependenciesresolver.cpp @@ -432,7 +432,7 @@ LoadModuleResult DependenciesResolver::loadModule( dependency.parameters); } else if (dependency.product) { productDep = dependency.product; // We have already done the look-up. - } else if (!(productDep = findMatchingProduct(dependency))) { + } else if (productDep = findMatchingProduct(dependency); !productDep) { moduleItem = findMatchingModule(dependency); } @@ -1125,8 +1125,8 @@ DependenciesContextImpl::DependenciesContextImpl(ProductContext &product, Loader std::pair<ProductDependency, ProductContext *> DependenciesContextImpl::pendingDependency() const { QBS_CHECK(!stateStack.empty()); - if (stateStack.front().currentDependsItem - && !stateStack.front().currentDependsItem->productTypes.empty()) { + if (const auto ¤tDependsItem = stateStack.front().currentDependsItem; + currentDependsItem && !currentDependsItem->productTypes.empty()) { qCDebug(lcLoaderScheduling) << "product" << m_product.displayName() << "to be delayed because of bulk dependency"; return {ProductDependency::Bulk, nullptr}; diff --git a/src/lib/corelib/loader/loaderutils.cpp b/src/lib/corelib/loader/loaderutils.cpp index a6105ee50..05a077dbe 100644 --- a/src/lib/corelib/loader/loaderutils.cpp +++ b/src/lib/corelib/loader/loaderutils.cpp @@ -435,7 +435,9 @@ void TopLevelProjectContext::removeModuleFileFromDirectoryCache(const QString &f auto &moduleFiles = moduleFilesGuard.get(); const auto it = moduleFiles.find(FileInfo::path(filePath)); QBS_CHECK(it != moduleFiles.end()); - it->second->removeOne(filePath); + auto &files = it->second; + QBS_CHECK(files); + files->removeOne(filePath); } void TopLevelProjectContext::addUnknownProfilePropertyError(const Item *moduleProto, diff --git a/src/lib/corelib/loader/moduleproviderloader.cpp b/src/lib/corelib/loader/moduleproviderloader.cpp index bceed8ece..a9f5eb26f 100644 --- a/src/lib/corelib/loader/moduleproviderloader.cpp +++ b/src/lib/corelib/loader/moduleproviderloader.cpp @@ -168,6 +168,7 @@ ModuleProviderLoader::findOrCreateProviderInfo( const QualifiedId &moduleName, const QualifiedId &name, ModuleProviderLookup lookupType, const QVariantMap &qbsModule) { + QBS_CHECK(product.providerConfig); const QVariantMap config = product.providerConfig->value(name.toString()).toMap(); std::lock_guard lock(m_loaderState.topLevelProject().moduleProvidersCacheLock()); ModuleProvidersCacheKey cacheKey{name.toString(), {}, config, qbsModule, int(lookupType)}; diff --git a/src/lib/corelib/logging/logger.cpp b/src/lib/corelib/logging/logger.cpp index d4f51cd30..65d0cc27f 100644 --- a/src/lib/corelib/logging/logger.cpp +++ b/src/lib/corelib/logging/logger.cpp @@ -231,7 +231,7 @@ void Logger::printWarning(const ErrorInfo &warning) LogWriter Logger::qbsLog(LoggerLevel level, bool force) const { - return LogWriter(m_logSink, level, force); + return {m_logSink, level, force}; } } // namespace Internal diff --git a/src/lib/corelib/parser/qmljslexer.cpp b/src/lib/corelib/parser/qmljslexer.cpp index 684be9317..e148652ad 100644 --- a/src/lib/corelib/parser/qmljslexer.cpp +++ b/src/lib/corelib/parser/qmljslexer.cpp @@ -1071,7 +1071,7 @@ bool Lexer::scanDirectives(Directives *directives) const int lineNumber = tokenStartLine(); - if (! (_tokenKind == T_IDENTIFIER || _tokenKind == T_RESERVED_WORD)) + if (_tokenKind != T_IDENTIFIER && _tokenKind != T_RESERVED_WORD) return false; // expected a valid QML/JS directive const QString directiveName = tokenText(); @@ -1083,7 +1083,7 @@ bool Lexer::scanDirectives(Directives *directives) // it must be a pragma or an import directive. if (directiveName == QLatin1String("pragma")) { // .pragma library - if (! (lex() == T_IDENTIFIER && tokenText() == QLatin1String("library"))) + if (lex() != T_IDENTIFIER || tokenText() != QLatin1String("library")) return false; // expected `library // we found a .pragma library directive @@ -1126,7 +1126,7 @@ bool Lexer::scanDirectives(Directives *directives) // // recognize the mandatory `as' followed by the module name // - if (! (lex() == T_RESERVED_WORD && tokenText() == QLatin1String("as"))) + if (lex() != T_RESERVED_WORD || tokenText() != QLatin1String("as")) return false; // expected `as' if (lex() != T_IDENTIFIER) diff --git a/src/lib/corelib/tools/clangclinfo.cpp b/src/lib/corelib/tools/clangclinfo.cpp index d89c5cb9b..fd907ebf1 100644 --- a/src/lib/corelib/tools/clangclinfo.cpp +++ b/src/lib/corelib/tools/clangclinfo.cpp @@ -47,7 +47,7 @@ static std::vector<MSVCInstallInfo> compatibleMsvcs(Logger &logger) return true; bool ok = false; const int major = versions.at(0).toInt(&ok); - return !(ok && major >= 15); // support MSVC2017 and above + return !ok || major < 15; // support MSVC2017 and above }; Internal::removeIf(msvcs, filter); for (const auto &msvc: msvcs) { diff --git a/src/lib/corelib/tools/profiling.cpp b/src/lib/corelib/tools/profiling.cpp index 62815912d..b93d3fa17 100644 --- a/src/lib/corelib/tools/profiling.cpp +++ b/src/lib/corelib/tools/profiling.cpp @@ -104,7 +104,7 @@ void AccumulatingTimer::stop() QString elapsedTimeString(qint64 elapsedTimeInNs) { - qint64 ms = elapsedTimeInNs / (1000 * 1000); + qint64 ms = elapsedTimeInNs / (1000ll * 1000ll); qint64 s = ms/1000; ms -= s*1000; qint64 m = s/60; diff --git a/src/lib/corelib/tools/scripttools.cpp b/src/lib/corelib/tools/scripttools.cpp index 6262e7cf7..e89e4a0ad 100644 --- a/src/lib/corelib/tools/scripttools.cpp +++ b/src/lib/corelib/tools/scripttools.cpp @@ -123,7 +123,7 @@ ErrorInfo JsException::toErrorInfo() const ErrorInfo e(msg, stackTrace()); if (e.hasLocation() || !m_fallbackLocation.isValid()) return e; - return ErrorInfo(msg, m_fallbackLocation); + return {msg, m_fallbackLocation}; } void defineJsProperty(JSContext *ctx, JSValueConst obj, const QString &prop, JSValue val) diff --git a/src/lib/corelib/tools/settingsmodel.cpp b/src/lib/corelib/tools/settingsmodel.cpp index e3c995db3..4fa0e14da 100644 --- a/src/lib/corelib/tools/settingsmodel.cpp +++ b/src/lib/corelib/tools/settingsmodel.cpp @@ -281,10 +281,10 @@ bool SettingsModel::setData(const QModelIndex &index, const QVariant &value, int const QString valueString = value.toString(); QString *toChange = nullptr; if (index.column() == keyColumn() && !valueString.isEmpty() - && !node->parent->hasDirectChildWithName(valueString) - && !(node->parent->parent == &d->rootNode - && node->parent->name == Internal::StringConstants::profilesSettingsKey() - && valueString == Profile::fallbackName())) { + && !node->parent->hasDirectChildWithName(valueString) + && (node->parent->parent != &d->rootNode + || node->parent->name != Internal::StringConstants::profilesSettingsKey() + || valueString != Profile::fallbackName())) { toChange = &node->name; } else if (index.column() == valueColumn() && valueString != node->value) { toChange = &node->value; diff --git a/src/lib/pkgconfig/pcparser.cpp b/src/lib/pkgconfig/pcparser.cpp index 4469ca193..eb07aa5ef 100644 --- a/src/lib/pkgconfig/pcparser.cpp +++ b/src/lib/pkgconfig/pcparser.cpp @@ -524,9 +524,11 @@ void PcParser::parseLibs( raiseDuplicateFieldException(fieldName, pkg.filePath); const auto trimmed = trimAndSubstitute(pkg, str); + if (trimmed.empty()) + return; const auto argv = splitCommand(trimmed); - if (!trimmed.empty() && !argv) + if (!argv) throw PcException("Couldn't parse Libs field into an argument vector"); libs = doParseLibs(*argv); @@ -593,9 +595,11 @@ void PcParser::parseCFlags(PcPackage &pkg, std::string_view str) raiseDuplicateFieldException("Cflags", pkg.filePath); const auto command = trimAndSubstitute(pkg, str); + if (command.empty()) + return; const auto argv = splitCommand(command); - if (!command.empty() && !argv) + if (!argv) throw PcException("Couldn't parse Cflags field into an argument vector"); std::vector<PcPackage::Flag> cflags; @@ -722,10 +726,8 @@ void PcParser::parseLine(PcPackage &pkg, std::string_view str) size_t pos = 0; for (; pos < s.size(); ++pos) { auto p = s.data() + pos; - if (!((*p >= 'A' && *p <= 'Z') || - (*p >= 'a' && *p <= 'z') || - (*p >= '0' && *p <= '9') || - *p == '_' || *p == '.')) { + if ((*p < 'A' || *p > 'Z') && (*p < 'a' || *p > 'z') && (*p < '0' || *p > '9') + && *p != '_' && *p != '.') { break; } } |