ClangTools: Remove dependency to libclang and custom clang binary

Before this change, we've invoked a custom clang binary that had clazy
statically compiled into it. The invocation also ensured that the
diagnostics were serialized to a file, so that libclang could be used
afterwards to read them.

As the clazy-standalone executable supports exporting diagnostics to a
YAML file now (just as clang-tidy) and Qt Creator ships it already, rely
on that executable alone instead of the clang/libclang combo.

While we do not depend on any clang header or library at build-time now,
the CompilerOptionsBuilder constructor still needs the CLANG_VERSION and
CLANG_RESOURCE_DIR pieces from llvm-config. This dependency should be
removed as next.

Change-Id: I4fa5753ab09008fd24bc5247b28c4836b5e8ca45
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Nikolai Kosjar
2020-05-13 14:47:35 +02:00
parent e2a68edbc1
commit 9fc2fda07e
11 changed files with 14 additions and 282 deletions

View File

@@ -53,28 +53,6 @@ static bool isClMode(const QStringList &options)
return options.contains("--driver-mode=cl");
}
static QStringList serializeDiagnosticsArguments(const QStringList &baseOptions,
const QString &outputFilePath)
{
const QStringList serializeArgs{"-serialize-diagnostics", outputFilePath};
if (isClMode(baseOptions))
return clangArgsForCl(serializeArgs);
return serializeArgs;
}
static QStringList clazyPluginArguments(const ClangDiagnosticConfig diagnosticConfig)
{
QStringList arguments;
if (diagnosticConfig.isClazyEnabled()) {
arguments << XclangArgs({"-add-plugin", "clazy"});
if (!diagnosticConfig.clazyChecks().isEmpty())
arguments << XclangArgs({"-plugin-arg-clazy", diagnosticConfig.clazyChecks()});
}
return arguments;
}
static QStringList tidyChecksArguments(const ClangDiagnosticConfig diagnosticConfig)
{
const ClangDiagnosticConfig::TidyMode tidyMode = diagnosticConfig.clangTidyMode();
@@ -147,19 +125,5 @@ ClazyStandaloneRunner::ClazyStandaloneRunner(const ClangDiagnosticConfig &config
});
}
ClazyPluginRunner::ClazyPluginRunner(const ClangDiagnosticConfig &config, QObject *parent)
: ClangToolRunner(parent)
{
setName(tr("Clazy"));
setOutputFileFormat(OutputFileFormat::Serialized);
setExecutable(Core::ICore::clangExecutable(CLANG_BINDIR));
setArgsCreator([this, config](const QStringList &baseOptions) {
return serializeDiagnosticsArguments(baseOptions, outputFilePath())
<< clazyPluginArguments(config)
<< clangArguments(config, baseOptions)
<< QDir::toNativeSeparators(fileToAnalyze());
});
}
} // namespace Internal
} // namespace ClangTools