aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Komissarov <ABBAPOH@gmail.com>2024-02-18 19:50:26 +0100
committerIvan Komissarov <ABBAPOH@gmail.com>2024-02-26 22:10:20 +0000
commit9a95c34dbf25f5dcf92a9bde3d2701e68eabd002 (patch)
treebf004e1b0f7d057b5627a720c1a8f5ba53521daa
parentf4cddcc516276b572f95cf51028767bb6c010f21 (diff)
clang-tidy: fix 'bugprone-unchecked-optional-access'
Change-Id: I8ec5109b70582115f6d3d19da580fddeb4475ef8 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
-rw-r--r--src/lib/corelib/loader/dependenciesresolver.cpp4
-rw-r--r--src/lib/corelib/loader/loaderutils.cpp4
-rw-r--r--src/lib/corelib/loader/moduleproviderloader.cpp1
-rw-r--r--src/lib/pkgconfig/pcparser.cpp8
4 files changed, 12 insertions, 5 deletions
diff --git a/src/lib/corelib/loader/dependenciesresolver.cpp b/src/lib/corelib/loader/dependenciesresolver.cpp
index b173e4b8a..479318e73 100644
--- a/src/lib/corelib/loader/dependenciesresolver.cpp
+++ b/src/lib/corelib/loader/dependenciesresolver.cpp
@@ -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 &currentDependsItem = 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/pkgconfig/pcparser.cpp b/src/lib/pkgconfig/pcparser.cpp
index e44f293e5..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;