From 4eec360563f0433705608b6d4a3b41704575fbd8 Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 6 Jul 2021 09:12:35 +0200 Subject: [PATCH] Utils: Remove one ProcessArgs::expandMacros overload Only used once. Also allow logging of expansion failures. Change-Id: I357ed6ed28fe379d482358c46b495bc727f86902 Reviewed-by: Christian Stenger --- src/libs/utils/commandline.cpp | 7 ------- src/libs/utils/commandline.h | 2 -- src/libs/utils/macroexpander.cpp | 8 +++++++- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/libs/utils/commandline.cpp b/src/libs/utils/commandline.cpp index 3ae7984275f..da44b02e089 100644 --- a/src/libs/utils/commandline.cpp +++ b/src/libs/utils/commandline.cpp @@ -1089,13 +1089,6 @@ bool ProcessArgs::expandMacros(QString *cmd, AbstractMacroExpander *mx, OsType o return true; } -QString ProcessArgs::expandMacros(const QString &str, AbstractMacroExpander *mx, OsType osType) -{ - QString ret = str; - expandMacros(&ret, mx, osType); - return ret; -} - bool ProcessArgs::ArgIterator::next() { // We delay the setting of m_prev so we can still delete the last argument diff --git a/src/libs/utils/commandline.h b/src/libs/utils/commandline.h index 473c2677206..a2a43a82e16 100644 --- a/src/libs/utils/commandline.h +++ b/src/libs/utils/commandline.h @@ -81,8 +81,6 @@ public: //! Safely replace the expandos in a shell command static bool expandMacros(QString *cmd, AbstractMacroExpander *mx, OsType osType = HostOsInfo::hostOs()); - static QString expandMacros(const QString &str, AbstractMacroExpander *mx, - OsType osType = HostOsInfo::hostOs()); /*! Iterate over arguments from a command line. * Assumes that the name of the actual command is *not* part of the line. diff --git a/src/libs/utils/macroexpander.cpp b/src/libs/utils/macroexpander.cpp index 5e203762132..5cf279660ed 100644 --- a/src/libs/utils/macroexpander.cpp +++ b/src/libs/utils/macroexpander.cpp @@ -35,11 +35,14 @@ #include #include #include +#include #include namespace Utils { namespace Internal { +static Q_LOGGING_CATEGORY(expanderLog, "qtc.utils.macroexpander", QtWarningMsg) + const char kFilePathPostfix[] = ":FilePath"; const char kPathPostfix[] = ":Path"; const char kNativeFilePathPostfix[] = ":NativeFilePath"; @@ -327,7 +330,10 @@ QVariant MacroExpander::expandVariant(const QVariant &v) const QString MacroExpander::expandProcessArgs(const QString &argsWithVariables) const { - return ProcessArgs::expandMacros(argsWithVariables, d); + QString result = argsWithVariables; + const bool ok = ProcessArgs::expandMacros(&result, d); + QTC_ASSERT(ok, qCDebug(expanderLog) << "Expanding failed: " << argsWithVariables); + return result; } static QByteArray fullPrefix(const QByteArray &prefix)