Don't attempt to analyze using icecc masquerading as clang.

Also warn the user in the settings page against this.

Change-Id: I4dbae953aa85f8dbdc9baa8dd0fda8ff0da45b76
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
This commit is contained in:
Christian Kandeler
2015-02-26 15:14:29 +01:00
parent 7c9c7b297a
commit bba6f927e9
8 changed files with 106 additions and 10 deletions

View File

@@ -10,6 +10,7 @@ SOURCES += \
clangstaticanalyzerdiagnosticmodel.cpp \
clangstaticanalyzerdiagnosticview.cpp \
clangstaticanalyzerlogfilereader.cpp \
clangstaticanalyzerpathchooser.cpp \
clangstaticanalyzerplugin.cpp \
clangstaticanalyzerruncontrol.cpp \
clangstaticanalyzerruncontrolfactory.cpp \
@@ -26,6 +27,7 @@ HEADERS += \
clangstaticanalyzerdiagnosticview.h \
clangstaticanalyzer_global.h \
clangstaticanalyzerlogfilereader.h \
clangstaticanalyzerpathchooser.h \
clangstaticanalyzerplugin.h \
clangstaticanalyzerruncontrolfactory.h \
clangstaticanalyzerruncontrol.h \

View File

@@ -28,6 +28,8 @@ QtcPlugin {
"clangstaticanalyzerdiagnosticview.h",
"clangstaticanalyzerlogfilereader.cpp",
"clangstaticanalyzerlogfilereader.h",
"clangstaticanalyzerpathchooser.cpp",
"clangstaticanalyzerpathchooser.h",
"clangstaticanalyzerplugin.cpp",
"clangstaticanalyzerplugin.h",
"clangstaticanalyzerruncontrol.cpp",

View File

@@ -33,10 +33,6 @@ ClangStaticAnalyzerConfigWidget::ClangStaticAnalyzerConfigWidget(
{
m_ui->setupUi(this);
m_ui->clangExecutableChooser->setExpectedKind(Utils::PathChooser::ExistingCommand);
m_ui->clangExecutableChooser->setHistoryCompleter(
QLatin1String("ClangStaticAnalyzer.ClangCommand.History"));
m_ui->clangExecutableChooser->setPromptDialogTitle(tr("Clang Command"));
m_ui->clangExecutableChooser->setPath(settings->clangExecutable());
connect(m_ui->clangExecutableChooser, &Utils::PathChooser::changed,
m_settings, &ClangStaticAnalyzerSettings::setClangExecutable);

View File

@@ -30,7 +30,7 @@
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="Utils::PathChooser" name="clangExecutableChooser" native="true"/>
<widget class="ClangStaticAnalyzer::Internal::PathChooser" name="clangExecutableChooser" native="true"/>
</item>
</layout>
</item>
@@ -88,9 +88,9 @@
</widget>
<customwidgets>
<customwidget>
<class>Utils::PathChooser</class>
<class>ClangStaticAnalyzer::Internal::PathChooser</class>
<extends>QWidget</extends>
<header location="global">utils/pathchooser.h</header>
<header location="global">clangstaticanalyzer/clangstaticanalyzerpathchooser.h</header>
<container>1</container>
</customwidget>
</customwidgets>

View File

@@ -0,0 +1,40 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd
** All rights reserved.
** For any questions to The Qt Company, please use contact form at http://www.qt.io/contact-us
**
** This file is part of the Qt Enterprise LicenseChecker Add-on.
**
** Licensees holding valid Qt Enterprise licenses may use this file in
** accordance with the Qt Enterprise License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company.
**
** If you have questions regarding the use of this file, please use
** contact form at http://www.qt.io/contact-us
**
****************************************************************************/
#include "clangstaticanalyzerpathchooser.h"
#include "clangstaticanalyzerutils.h"
namespace ClangStaticAnalyzer {
namespace Internal {
PathChooser::PathChooser(QWidget *parent) : Utils::PathChooser(parent)
{
setExpectedKind(Utils::PathChooser::ExistingCommand);
setHistoryCompleter(QLatin1String("ClangStaticAnalyzer.ClangCommand.History"));
setPromptDialogTitle(tr("Clang Command"));
}
bool PathChooser::validatePath(const QString &path, QString *errorMessage)
{
if (!Utils::PathChooser::validatePath(path, errorMessage))
return false;
return isClangExecutableUsable(fileName().toString(), errorMessage);
}
} // namespace Internal
} // namespace ClangStaticAnalyzer

View File

@@ -0,0 +1,40 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd
** All rights reserved.
** For any questions to The Qt Company, please use contact form at http://www.qt.io/contact-us
**
** This file is part of the Qt Enterprise LicenseChecker Add-on.
**
** Licensees holding valid Qt Enterprise licenses may use this file in
** accordance with the Qt Enterprise License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company.
**
** If you have questions regarding the use of this file, please use
** contact form at http://www.qt.io/contact-us
**
****************************************************************************/
#ifndef QTC_CLANGSTATICANALYZER_PATHCHOOSER_H
#define QTC_CLANGSTATICANALYZER_PATHCHOOSER_H
#include <utils/pathchooser.h>
namespace ClangStaticAnalyzer {
namespace Internal {
class PathChooser : public Utils::PathChooser
{
Q_OBJECT
public:
PathChooser(QWidget *parent = 0);
private:
bool validatePath(const QString &path, QString *errorMessage = 0);
};
} // namespace Internal
} // namespace ClangStaticAnalyzer
#endif // Include guard.

View File

@@ -23,6 +23,7 @@
#include <utils/environment.h>
#include <QCoreApplication>
#include <QFileInfo>
static bool isFileExecutable(const QString &executablePath)
@@ -63,7 +64,7 @@ QString clangExecutable(const QString &fileNameOrPath, bool *isValid)
executable = executableFromPath;
}
*isValid = isFileExecutable(executable);
*isValid = isFileExecutable(executable) && isClangExecutableUsable(executable);
return executable;
}
@@ -74,5 +75,20 @@ QString createFullLocationString(const ClangStaticAnalyzer::Internal::Location &
return filePath + QLatin1Char(':') + lineNumber;
}
bool isClangExecutableUsable(const QString &filePath, QString *errorMessage)
{
const QFileInfo fi(filePath);
if (fi.isSymLink() && fi.symLinkTarget().contains(QLatin1String("icecc"))) {
if (errorMessage) {
*errorMessage = QCoreApplication::translate("ClangStaticAnalyzer",
"The chosen file \"%1\" seems to point to an icecc binary not suitable "
"for analyzing.\nPlease set a real clang executable.")
.arg(filePath);
}
return false;
}
return true;
}
} // namespace Internal
} // namespace ClangStaticAnalyzer

View File

@@ -25,13 +25,13 @@ QT_BEGIN_NAMESPACE
class QString;
QT_END_NAMESPACE
namespace ClangStaticAnalyzer {
namespace Internal {
class Location;
bool isClangExecutableUsable(const QString &filePath, QString *errorMessage = 0);
QString clangExecutable(const QString &fileNameOrPath, bool *isValid);
QString clangExecutableFromSettings(const QString &toolchainType, bool *isValid);