CppEditor: Do not use clangd < 13

We will shortly need to use a command-line option that is new in clangd
13. Rather than starting to add checks for versions that won't work as
expected anyway, we simply refuse to use clangd < 13 now.

Change-Id: I42ec679e0f58449a2593cf92b4be7ed3101fa787
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Kandeler
2021-11-01 12:06:38 +01:00
parent a2cb1edb69
commit 4dfdbf91f6
3 changed files with 47 additions and 20 deletions

View File

@@ -35,7 +35,6 @@
#include <utils/algorithm.h>
#include <utils/infolabel.h>
#include <utils/pathchooser.h>
#include <utils/qtcprocess.h>
#include <QFormLayout>
#include <QSpinBox>
@@ -285,30 +284,14 @@ ClangdSettingsWidget::ClangdSettingsWidget(const ClangdSettings::Data &settingsD
if (!d->clangdChooser.isValid())
return;
const Utils::FilePath clangdPath = d->clangdChooser.filePath();
Utils::QtcProcess clangdProc;
clangdProc.setCommand({clangdPath, {"--version"}});
clangdProc.start();
if (!clangdProc.waitForStarted() || !clangdProc.waitForFinished()) {
labelSetter.setWarning(tr("Failed to retrieve clangd version: %1")
.arg(clangdProc.exitMessage()));
return;
}
const QString output = clangdProc.allOutput();
static const QString versionPrefix = "clangd version ";
const int prefixOffset = output.indexOf(versionPrefix);
QVersionNumber clangdVersion;
if (prefixOffset != -1) {
clangdVersion = QVersionNumber::fromString(output.mid(prefixOffset
+ versionPrefix.length()));
}
const QVersionNumber clangdVersion = ClangdSettings::clangdVersion(clangdPath);
if (clangdVersion.isNull()) {
labelSetter.setWarning(tr("Failed to retrieve clangd version: "
"Unexpected clangd output."));
return;
}
if (clangdVersion < QVersionNumber(13)) {
labelSetter.setWarning(tr("The clangd version is %1, but %2 or greater is "
"recommended for full functionality.")
labelSetter.setWarning(tr("The clangd version is %1, but %2 or greater is required.")
.arg(clangdVersion.toString()).arg(13));
return;
}