From f8c4d6cbc70ca584279aa9a0b3513339c419c9e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 12 Aug 2017 12:04:42 +0200 Subject: [PATCH] GUI: Clang settings --- gui/checkthread.cpp | 11 +++-- gui/checkthread.h | 10 ++--- gui/common.h | 2 +- gui/mainwindow.cpp | 7 +++- gui/settings.ui | 91 ++++++++++++++++++++++++------------------ gui/settingsdialog.cpp | 21 +++++++--- gui/settingsdialog.h | 3 ++ gui/threadhandler.cpp | 2 +- gui/threadhandler.h | 10 ++--- 9 files changed, 94 insertions(+), 63 deletions(-) mode change 100644 => 100755 gui/settingsdialog.cpp mode change 100644 => 100755 gui/settingsdialog.h diff --git a/gui/checkthread.cpp b/gui/checkthread.cpp index 7b1b08376..eaa3ad49c 100644 --- a/gui/checkthread.cpp +++ b/gui/checkthread.cpp @@ -145,10 +145,10 @@ void CheckThread::runAddons(const QString &addonPath, const ImportProject::FileS // To create compile_commands.json in windows see: // https://bitsmaker.gitlab.io/post/clang-tidy-from-vs2015/ - foreach (QString s, mVsIncludePaths.split(";")) { - if (!s.isEmpty()) { - s.replace("\\", "/"); - args << "-isystem" << s.trimmed(); + foreach (QString includePath, mClangIncludePaths) { + if (!includePath.isEmpty()) { + includePath.replace("\\", "/"); + args << "-isystem" << includePath.trimmed(); } } @@ -157,8 +157,6 @@ void CheckThread::runAddons(const QString &addonPath, const ImportProject::FileS if (!fileSettings->standard.empty()) args << ("-std=" + QString::fromStdString(fileSettings->standard)); - else if (!mVsIncludePaths.isEmpty() && fileName.endsWith(".cpp")) - args << "-std=c++14"; QString analyzerInfoFile; @@ -239,6 +237,7 @@ void CheckThread::runAddons(const QString &addonPath, const ImportProject::FileS out << errout; } } + parseClangErrors(addon, fileName, errout); } else { QString a; diff --git a/gui/checkthread.h b/gui/checkthread.h index 5cc17becf..367b3cec4 100644 --- a/gui/checkthread.h +++ b/gui/checkthread.h @@ -56,10 +56,6 @@ public: mAddons = addons; } - void setVsIncludePaths(const QString &s) { - mVsIncludePaths = s; - } - void setDataDir(const QString &dataDir) { mDataDir = dataDir; } @@ -68,6 +64,10 @@ public: mClangPath = p; } + void setClangIncludePaths(const QStringList &s) { + mClangIncludePaths = s; + } + void setSuppressions(const QStringList s) { mSuppressions = s; } @@ -128,9 +128,9 @@ private: QStringList mFiles; bool mAnalyseWholeProgram; QStringList mAddons; - QString mVsIncludePaths; QString mDataDir; QString mClangPath; + QStringList mClangIncludePaths; QStringList mSuppressions; }; /// @} diff --git a/gui/common.h b/gui/common.h index 953f518bd..8fb49fb89 100644 --- a/gui/common.h +++ b/gui/common.h @@ -81,7 +81,7 @@ #define SETTINGS_LANGUAGE "Application language" #define SETTINGS_GLOBAL_INCLUDE_PATHS "Global include paths" #define SETTINGS_CLANG_PATH "Clang path" -#define SETTINGS_VS_INCLUDE_PATHS "Visual studio include paths" +#define SETTINGS_CLANG_HEADERS "Clang headers" #define SETTINGS_INLINE_SUPPRESSIONS "Inline suppressions" #define SETTINGS_INCONCLUSIVE_ERRORS "Inconclusive errors" #define SETTINGS_MRU_PROJECTS "MRU Projects" diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index e8e835747..6e5902a45 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -444,7 +444,12 @@ void MainWindow::doAnalyzeProject(ImportProject p) //mThread->SetanalyzeProject(true); if (mProjectFile) { mThread->setAddons(mProjectFile->getAddons()); - mThread->setVsIncludePaths(mSettings->value(SETTINGS_VS_INCLUDE_PATHS).toString()); + QString clangHeaders = mSettings->value(SETTINGS_CLANG_HEADERS).toString(); + QStringList includePaths; + if (!clangHeaders.isEmpty()) { + includePaths << clangHeaders << (clangHeaders+"/ATLMFC") << (clangHeaders+"/c++") << (clangHeaders+"/c++/i686-w64-mingw32"); + } + mThread->setClangIncludePaths(includePaths); #ifdef Q_OS_WIN QString clangPath = mSettings->value(SETTINGS_CLANG_PATH,QString()).toString(); if (clangPath.isEmpty()) { diff --git a/gui/settings.ui b/gui/settings.ui index 643e8cffb..9430c988f 100644 --- a/gui/settings.ui +++ b/gui/settings.ui @@ -351,53 +351,66 @@ - - + + Clang path (leave empty to use system PATH) + + + + + false + + + + + + + ... + + + + - - - - - false - - - - - - - ... - - - - - - - - - Qt::Vertical - - - - 20 - 51 - - - - - - - - <html><head/><body><p>Visual Studio include paths.</p><p>Open Visual Studio Command Prompt. Type &quot;SET INSTALL&quot; and then copy paste the output here</p></body></html> + + + Clang headers + + + + + <html><head/><body><p>Download the "clang headers" archive and unpack it. You can get it here: <a href="http://sourceforge.net/projects/cppcheck/files/other/">http://sourceforge.net/projects/cppcheck/files/other</a></p> +<p>Path:</p></body></html> + + + true + + + + + + + + + true + + + + + + + ... + + + + + + - - - diff --git a/gui/settingsdialog.cpp b/gui/settingsdialog.cpp old mode 100644 new mode 100755 index 046d055b9..e4e4b9fd4 --- a/gui/settingsdialog.cpp +++ b/gui/settingsdialog.cpp @@ -57,8 +57,9 @@ SettingsDialog::SettingsDialog(ApplicationList *list, #ifdef Q_OS_WIN //mUI.mTabClang->setVisible(true); mUI.mEditClangPath->setText(settings.value(SETTINGS_CLANG_PATH, QString()).toString()); - mUI.mEditVsIncludePaths->setText(settings.value(SETTINGS_VS_INCLUDE_PATHS, QString()).toString()); + mUI.mEditClangHeaders->setText(settings.value(SETTINGS_CLANG_HEADERS, QString()).toString()); connect(mUI.mBtnBrowseClangPath, &QPushButton::released, this, &SettingsDialog::browseClangPath); + connect(mUI.mButtonBrowseClangHeaders, &QPushButton::released, this, &SettingsDialog::browseClangHeaders); #else mUI.mTabClang->setVisible(false); #endif @@ -187,10 +188,7 @@ void SettingsDialog::saveSettingValues() const #ifdef Q_OS_WIN settings.setValue(SETTINGS_CLANG_PATH, mUI.mEditClangPath->text()); - QString vsIncludePaths = mUI.mEditVsIncludePaths->text(); - if (vsIncludePaths.startsWith("INCLUDE=")) - vsIncludePaths.remove(0, 8); - settings.setValue(SETTINGS_VS_INCLUDE_PATHS, vsIncludePaths); + settings.setValue(SETTINGS_CLANG_HEADERS, mUI.mEditClangHeaders->text()); #endif const QListWidgetItem *currentLang = mUI.mListLanguages->currentItem(); @@ -369,3 +367,16 @@ void SettingsDialog::browseClangPath() mUI.mEditClangPath->setText(selectedDir); } } + +void SettingsDialog::browseClangHeaders() +{ + QString selectedDir = QFileDialog::getExistingDirectory(this, + tr("Select path for clang headers"), + QDir::homePath()); + + if (!selectedDir.isEmpty()) { + mUI.mEditClangHeaders->setText(selectedDir); + } +} + + diff --git a/gui/settingsdialog.h b/gui/settingsdialog.h old mode 100644 new mode 100755 index 0ff5187e8..00bea4ee5 --- a/gui/settingsdialog.h +++ b/gui/settingsdialog.h @@ -145,6 +145,9 @@ protected slots: /** @brief Slot for browsing for the clang binary */ void browseClangPath(); + /** @brief Slot for browsing for the clang headers */ + void browseClangHeaders(); + protected: /** diff --git a/gui/threadhandler.cpp b/gui/threadhandler.cpp index 500f1cac0..49df67002 100644 --- a/gui/threadhandler.cpp +++ b/gui/threadhandler.cpp @@ -95,8 +95,8 @@ void ThreadHandler::check(const Settings &settings) for (int i = 0; i < mRunningThreadCount; i++) { mThreads[i]->setAddons(mAddons); mThreads[i]->setSuppressions(mSuppressions); - mThreads[i]->setVsIncludePaths(mVsIncludePaths); mThreads[i]->setClangPath(mClangPath); + mThreads[i]->setClangIncludePaths(mClangIncludePaths); mThreads[i]->setDataDir(mDataDir); mThreads[i]->check(settings); } diff --git a/gui/threadhandler.h b/gui/threadhandler.h index 363e2e52a..797e4edc3 100644 --- a/gui/threadhandler.h +++ b/gui/threadhandler.h @@ -79,14 +79,14 @@ public: mSuppressions = s; } - void setVsIncludePaths(const QString &s) { - mVsIncludePaths = s; - } - void setClangPath(const QString &p) { mClangPath = p; } + void setClangIncludePaths(const QStringList &s) { + mClangIncludePaths = s; + } + void setDataDir(const QString &dataDir) { mDataDir = dataDir; } @@ -255,8 +255,8 @@ protected: QStringList mAddons; QStringList mSuppressions; - QString mVsIncludePaths; QString mClangPath; + QStringList mClangIncludePaths; QString mDataDir; private: