From b29ca1e345ae5358faac872f1d90469f69879e1f Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 1 Jul 2022 09:42:53 +0200 Subject: ProjectExplorer: Drop encoding roundtrip in gcc detection Change-Id: I6fb407465f634287edeba59fe6427ddb0299112f Reviewed-by: Qt CI Bot Reviewed-by: Christian Stenger --- src/plugins/projectexplorer/gcctoolchain.cpp | 34 ++++++++++++++-------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'src/plugins/projectexplorer/gcctoolchain.cpp') diff --git a/src/plugins/projectexplorer/gcctoolchain.cpp b/src/plugins/projectexplorer/gcctoolchain.cpp index c05ed4f42f..ee0a0e3e36 100644 --- a/src/plugins/projectexplorer/gcctoolchain.cpp +++ b/src/plugins/projectexplorer/gcctoolchain.cpp @@ -126,18 +126,18 @@ using namespace Internal; // Helpers: // -------------------------------------------------------------------------- -static const char compilerPlatformCodeGenFlagsKeyC[] = "ProjectExplorer.GccToolChain.PlatformCodeGenFlags"; -static const char compilerPlatformLinkerFlagsKeyC[] = "ProjectExplorer.GccToolChain.PlatformLinkerFlags"; -static const char targetAbiKeyC[] = "ProjectExplorer.GccToolChain.TargetAbi"; -static const char originalTargetTripleKeyC[] = "ProjectExplorer.GccToolChain.OriginalTargetTriple"; -static const char supportedAbisKeyC[] = "ProjectExplorer.GccToolChain.SupportedAbis"; -static const char parentToolChainIdKeyC[] = "ProjectExplorer.ClangToolChain.ParentToolChainId"; -static const char binaryRegexp[] = "(?:^|-|\\b)(?:gcc|g\\+\\+|clang(?:\\+\\+)?)(?:-([\\d.]+))?$"; +const char compilerPlatformCodeGenFlagsKeyC[] = "ProjectExplorer.GccToolChain.PlatformCodeGenFlags"; +const char compilerPlatformLinkerFlagsKeyC[] = "ProjectExplorer.GccToolChain.PlatformLinkerFlags"; +const char targetAbiKeyC[] = "ProjectExplorer.GccToolChain.TargetAbi"; +const char originalTargetTripleKeyC[] = "ProjectExplorer.GccToolChain.OriginalTargetTriple"; +const char supportedAbisKeyC[] = "ProjectExplorer.GccToolChain.SupportedAbis"; +const char parentToolChainIdKeyC[] = "ProjectExplorer.ClangToolChain.ParentToolChainId"; +const char binaryRegexp[] = "(?:^|-|\\b)(?:gcc|g\\+\\+|clang(?:\\+\\+)?)(?:-([\\d.]+))?$"; -static QByteArray runGcc(const FilePath &gcc, const QStringList &arguments, const Environment &env) +static QString runGcc(const FilePath &gcc, const QStringList &arguments, const Environment &env) { if (!gcc.isExecutableFile()) - return QByteArray(); + return {}; QtcProcess cpp; Environment environment(env); @@ -150,11 +150,11 @@ static QByteArray runGcc(const FilePath &gcc, const QStringList &arguments, cons if (cpp.result() != ProcessResult::FinishedWithSuccess || cpp.exitCode() != 0) { Core::MessageManager::writeFlashing({"Compiler feature detection failure!", cpp.exitMessage(), - QString::fromUtf8(cpp.allRawOutput())}); - return QByteArray(); + cpp.allOutput()}); + return {}; } - return cpp.allOutput().toUtf8(); + return cpp.allOutput(); } static ProjectExplorer::Macros gccPredefinedMacros(const FilePath &gcc, @@ -164,7 +164,7 @@ static ProjectExplorer::Macros gccPredefinedMacros(const FilePath &gcc, QStringList arguments = args; arguments << "-"; - ProjectExplorer::Macros predefinedMacros = Macro::toMacros(runGcc(gcc, arguments, env)); + ProjectExplorer::Macros predefinedMacros = Macro::toMacros(runGcc(gcc, arguments, env).toUtf8()); // Sanity check in case we get an error message instead of real output: QTC_CHECK(predefinedMacros.isEmpty() || predefinedMacros.front().type == ProjectExplorer::MacroType::Define); @@ -189,7 +189,7 @@ HeaderPaths GccToolChain::gccHeaderPaths(const FilePath &gcc, { HeaderPaths builtInHeaderPaths; QByteArray line; - QByteArray data = runGcc(gcc, arguments, env); + QByteArray data = runGcc(gcc, arguments, env).toUtf8(); QBuffer cpp(&data); cpp.open(QIODevice::ReadOnly); while (cpp.canReadLine()) { @@ -277,7 +277,7 @@ static GccToolChain::DetectedAbisResult guessGccAbi(const FilePath &path, QStringList arguments = extraArgs; arguments << "-dumpmachine"; - QString machine = QString::fromUtf8(runGcc(path, arguments, env)).trimmed().section('\n', 0, 0, QString::SectionSkipEmpty); + QString machine = runGcc(path, arguments, env).trimmed().section('\n', 0, 0, QString::SectionSkipEmpty); if (machine.isEmpty()) { // ICC does not implement the -dumpmachine option on macOS. if (HostOsInfo::isMacHost() && (path.fileName() == "icc" || path.fileName() == "icpc")) @@ -293,7 +293,7 @@ static QString gccVersion(const FilePath &path, { QStringList arguments = extraArgs; arguments << "-dumpversion"; - return QString::fromUtf8(runGcc(path, arguments, env)).trimmed(); + return runGcc(path, arguments, env).trimmed(); } static FilePath gccInstallDir(const FilePath &compiler, @@ -302,7 +302,7 @@ static FilePath gccInstallDir(const FilePath &compiler, { QStringList arguments = extraArgs; arguments << "-print-search-dirs"; - QString output = QString::fromUtf8(runGcc(compiler, arguments, env)).trimmed(); + QString output = runGcc(compiler, arguments, env).trimmed(); // Expected output looks like this: // install: /usr/lib/gcc/x86_64-linux-gnu/7/ // ... -- cgit v1.2.1