From 4d2c405fe584eafd91a9aec0253d3ed40e27a0be Mon Sep 17 00:00:00 2001 From: Alexey Edelev Date: Wed, 19 Jul 2023 16:05:39 +0200 Subject: [PATCH] Make sure that the 3rdparty directory belongs to the module If the path where Qt sources are located has 3rdparty in it we skip headers processing since all headers are treated as 3rdparty. Use path relative to the source directory when indentifying the 3rdparty header files using regex. Fixes: QTBUG-115324 Change-Id: If97328cb9a9ece01d43c56022f4613da9b29c03f Reviewed-by: Alexandru Croitor (cherry picked from commit ea4a3d78a776e10955caf6cf9b1054ddb50f40d3) Reviewed-by: Qt Cherry-pick Bot --- src/tools/syncqt/main.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/tools/syncqt/main.cpp b/src/tools/syncqt/main.cpp index 6f6a7c31701..21f5bda9897 100644 --- a/src/tools/syncqt/main.cpp +++ b/src/tools/syncqt/main.cpp @@ -780,7 +780,7 @@ public: [[nodiscard]] bool processHeader(const std::filesystem::path &headerFile) { // This regex filters any paths that contain the '3rdparty' directory. - static const std::regex ThirdPartyFolderRegex(".+/3rdparty/.+"); + static const std::regex ThirdPartyFolderRegex("(^|.+/)3rdparty/.+"); // This regex filters '-config.h' and '-config_p.h' header files. static const std::regex ConfigHeaderRegex("^(q|.+-)config(_p)?\\.h"); @@ -872,7 +872,14 @@ public: } bool isGenerated = isHeaderGenerated(m_currentFileString); - bool is3rdParty = std::regex_match(m_currentFileString, ThirdPartyFolderRegex); + + // Make sure that we detect the '3rdparty' directory inside the source directory only, + // since full path to the Qt sources might contain '/3rdparty/' too. + bool is3rdParty = std::regex_match( + std::filesystem::relative(headerFile, m_commandLineArgs->sourceDir()) + .generic_string(), + ThirdPartyFolderRegex); + // No processing of generated Qt config header files. if (!std::regex_match(m_currentFilename, ConfigHeaderRegex)) { unsigned int skipChecks = m_commandLineArgs->scanAllMode() ? AllChecks : NoChecks;