diff options
author | Christian Kandeler <christian.kandeler@theqtcompany.com> | 2015-02-26 15:14:29 +0100 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@theqtcompany.com> | 2015-02-26 17:44:37 +0200 |
commit | bba6f927e90f32e7051d5f8e0e1dfa5ae4413ff2 (patch) | |
tree | 187528ba83f052738be88d08d4e6fed748182352 | |
parent | 7c9c7b297a896d0b1ef82b2b23e0ed789539fdfc (diff) | |
download | qt-creator-bba6f927e90f32e7051d5f8e0e1dfa5ae4413ff2.tar.gz |
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>
8 files changed, 106 insertions, 10 deletions
diff --git a/plugins/clangstaticanalyzer/clangstaticanalyzer.pro b/plugins/clangstaticanalyzer/clangstaticanalyzer.pro index df939e9f36..38ddda3e64 100644 --- a/plugins/clangstaticanalyzer/clangstaticanalyzer.pro +++ b/plugins/clangstaticanalyzer/clangstaticanalyzer.pro @@ -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 \ diff --git a/plugins/clangstaticanalyzer/clangstaticanalyzer.qbs b/plugins/clangstaticanalyzer/clangstaticanalyzer.qbs index 78c7decc5d..9113cc94c3 100644 --- a/plugins/clangstaticanalyzer/clangstaticanalyzer.qbs +++ b/plugins/clangstaticanalyzer/clangstaticanalyzer.qbs @@ -28,6 +28,8 @@ QtcPlugin { "clangstaticanalyzerdiagnosticview.h", "clangstaticanalyzerlogfilereader.cpp", "clangstaticanalyzerlogfilereader.h", + "clangstaticanalyzerpathchooser.cpp", + "clangstaticanalyzerpathchooser.h", "clangstaticanalyzerplugin.cpp", "clangstaticanalyzerplugin.h", "clangstaticanalyzerruncontrol.cpp", diff --git a/plugins/clangstaticanalyzer/clangstaticanalyzerconfigwidget.cpp b/plugins/clangstaticanalyzer/clangstaticanalyzerconfigwidget.cpp index d6ff0fa5b8..6b8b0f0cee 100644 --- a/plugins/clangstaticanalyzer/clangstaticanalyzerconfigwidget.cpp +++ b/plugins/clangstaticanalyzer/clangstaticanalyzerconfigwidget.cpp @@ -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); diff --git a/plugins/clangstaticanalyzer/clangstaticanalyzerconfigwidget.ui b/plugins/clangstaticanalyzer/clangstaticanalyzerconfigwidget.ui index 800733a331..8997f3a7d1 100644 --- a/plugins/clangstaticanalyzer/clangstaticanalyzerconfigwidget.ui +++ b/plugins/clangstaticanalyzer/clangstaticanalyzerconfigwidget.ui @@ -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> diff --git a/plugins/clangstaticanalyzer/clangstaticanalyzerpathchooser.cpp b/plugins/clangstaticanalyzer/clangstaticanalyzerpathchooser.cpp new file mode 100644 index 0000000000..b5711bfeab --- /dev/null +++ b/plugins/clangstaticanalyzer/clangstaticanalyzerpathchooser.cpp @@ -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 diff --git a/plugins/clangstaticanalyzer/clangstaticanalyzerpathchooser.h b/plugins/clangstaticanalyzer/clangstaticanalyzerpathchooser.h new file mode 100644 index 0000000000..b4bc3c5947 --- /dev/null +++ b/plugins/clangstaticanalyzer/clangstaticanalyzerpathchooser.h @@ -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. diff --git a/plugins/clangstaticanalyzer/clangstaticanalyzerutils.cpp b/plugins/clangstaticanalyzer/clangstaticanalyzerutils.cpp index 06401eb287..3860f929a6 100644 --- a/plugins/clangstaticanalyzer/clangstaticanalyzerutils.cpp +++ b/plugins/clangstaticanalyzer/clangstaticanalyzerutils.cpp @@ -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 diff --git a/plugins/clangstaticanalyzer/clangstaticanalyzerutils.h b/plugins/clangstaticanalyzer/clangstaticanalyzerutils.h index e85d25f286..ca06c4874e 100644 --- a/plugins/clangstaticanalyzer/clangstaticanalyzerutils.h +++ b/plugins/clangstaticanalyzer/clangstaticanalyzerutils.h @@ -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); |