forked from qt-creator/qt-creator
		
	Clang: Warn of potentially expensive checks
...for the code model. If a diagnostic configuration with potentially expensive checks is selected in Options/Preferences > C++ > Code Model, show a warning below the combo box. Change-Id: I52c5c2e229fd50c0fd82f70154fb5b727726ba31 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
		| @@ -28,10 +28,13 @@ | ||||
| #include "clangdiagnosticconfigswidget.h" | ||||
| #include "cppmodelmanager.h" | ||||
| #include "cpptoolsconstants.h" | ||||
| #include "cpptoolsreuse.h" | ||||
| #include "ui_cppcodemodelsettingspage.h" | ||||
|  | ||||
| #include <clangtools/clangtoolsconstants.h> // for opening the respective options page | ||||
| #include <coreplugin/icore.h> | ||||
| #include <utils/algorithm.h> | ||||
| #include <utils/utilsicons.h> | ||||
|  | ||||
| #include <QTextStream> | ||||
|  | ||||
| @@ -43,6 +46,12 @@ CppCodeModelSettingsWidget::CppCodeModelSettingsWidget(QWidget *parent) | ||||
|     , m_ui(new Ui::CppCodeModelSettingsPage) | ||||
| { | ||||
|     m_ui->setupUi(this); | ||||
|     m_ui->expensiveChecksHintIcon->setPixmap(Utils::Icons::WARNING.pixmap()); | ||||
|     m_ui->expensiveChecksHintIcon->setVisible(false); | ||||
|     m_ui->expensiveChecksHintText->setVisible(false); | ||||
|     connect(m_ui->expensiveChecksHintText, &QLabel::linkActivated, [](const QString &){ | ||||
|         Core::ICore::showOptionsDialog(ClangTools::Constants::SETTINGS_PAGE_ID); | ||||
|     }); | ||||
| } | ||||
|  | ||||
| CppCodeModelSettingsWidget::~CppCodeModelSettingsWidget() | ||||
| @@ -69,6 +78,20 @@ void CppCodeModelSettingsWidget::applyToSettings() const | ||||
|         m_settings->toSettings(Core::ICore::settings()); | ||||
| } | ||||
|  | ||||
| static bool hasConfigExpensiveChecks(const Core::Id &configId) | ||||
| { | ||||
|     if (!configId.isValid()) | ||||
|         return false; | ||||
|  | ||||
|     const ClangDiagnosticConfig config | ||||
|         = ClangDiagnosticConfigsModel( | ||||
|               codeModelSettings()->clangCustomDiagnosticConfigs()) | ||||
|               .configWithId(configId); | ||||
|  | ||||
|     return !config.clazyChecks().isEmpty() | ||||
|         || config.clangTidyMode() != ClangDiagnosticConfig::TidyMode::Disabled; | ||||
| } | ||||
|  | ||||
| void CppCodeModelSettingsWidget::setupClangCodeModelWidgets() | ||||
| { | ||||
|     const bool isClangActive = CppModelManager::instance()->isClangCodeModelActive(); | ||||
| @@ -88,6 +111,17 @@ void CppCodeModelSettingsWidget::setupClangCodeModelWidgets() | ||||
|         if (applyClangCodeModelWidgetsToSettings()) | ||||
|             m_settings->toSettings(Core::ICore::settings()); | ||||
|     }); | ||||
|  | ||||
|     const auto checkForExpensiveChecks = [this](const Core::Id &configId) { | ||||
|         const bool visible = hasConfigExpensiveChecks(configId); | ||||
|         m_ui->expensiveChecksHintIcon->setVisible(visible); | ||||
|         m_ui->expensiveChecksHintText->setVisible(visible); | ||||
|     }; | ||||
|  | ||||
|     checkForExpensiveChecks(m_ui->clangDiagnosticConfigsSelectionWidget->currentConfigId()); | ||||
|     connect(m_ui->clangDiagnosticConfigsSelectionWidget, | ||||
|             &ClangDiagnosticConfigsSelectionWidget::currentConfigChanged, | ||||
|             checkForExpensiveChecks); | ||||
| } | ||||
|  | ||||
| void CppCodeModelSettingsWidget::setupGeneralWidgets() | ||||
|   | ||||
		Reference in New Issue
	
	Block a user