GUI: Clang settings

This commit is contained in:
Daniel Marjamäki 2017-08-12 12:04:42 +02:00
parent 2c837f2908
commit f8c4d6cbc7
9 changed files with 94 additions and 63 deletions

View File

@ -145,10 +145,10 @@ void CheckThread::runAddons(const QString &addonPath, const ImportProject::FileS
// To create compile_commands.json in windows see: // To create compile_commands.json in windows see:
// https://bitsmaker.gitlab.io/post/clang-tidy-from-vs2015/ // https://bitsmaker.gitlab.io/post/clang-tidy-from-vs2015/
foreach (QString s, mVsIncludePaths.split(";")) { foreach (QString includePath, mClangIncludePaths) {
if (!s.isEmpty()) { if (!includePath.isEmpty()) {
s.replace("\\", "/"); includePath.replace("\\", "/");
args << "-isystem" << s.trimmed(); args << "-isystem" << includePath.trimmed();
} }
} }
@ -157,8 +157,6 @@ void CheckThread::runAddons(const QString &addonPath, const ImportProject::FileS
if (!fileSettings->standard.empty()) if (!fileSettings->standard.empty())
args << ("-std=" + QString::fromStdString(fileSettings->standard)); args << ("-std=" + QString::fromStdString(fileSettings->standard));
else if (!mVsIncludePaths.isEmpty() && fileName.endsWith(".cpp"))
args << "-std=c++14";
QString analyzerInfoFile; QString analyzerInfoFile;
@ -239,6 +237,7 @@ void CheckThread::runAddons(const QString &addonPath, const ImportProject::FileS
out << errout; out << errout;
} }
} }
parseClangErrors(addon, fileName, errout); parseClangErrors(addon, fileName, errout);
} else { } else {
QString a; QString a;

View File

@ -56,10 +56,6 @@ public:
mAddons = addons; mAddons = addons;
} }
void setVsIncludePaths(const QString &s) {
mVsIncludePaths = s;
}
void setDataDir(const QString &dataDir) { void setDataDir(const QString &dataDir) {
mDataDir = dataDir; mDataDir = dataDir;
} }
@ -68,6 +64,10 @@ public:
mClangPath = p; mClangPath = p;
} }
void setClangIncludePaths(const QStringList &s) {
mClangIncludePaths = s;
}
void setSuppressions(const QStringList s) { void setSuppressions(const QStringList s) {
mSuppressions = s; mSuppressions = s;
} }
@ -128,9 +128,9 @@ private:
QStringList mFiles; QStringList mFiles;
bool mAnalyseWholeProgram; bool mAnalyseWholeProgram;
QStringList mAddons; QStringList mAddons;
QString mVsIncludePaths;
QString mDataDir; QString mDataDir;
QString mClangPath; QString mClangPath;
QStringList mClangIncludePaths;
QStringList mSuppressions; QStringList mSuppressions;
}; };
/// @} /// @}

View File

@ -81,7 +81,7 @@
#define SETTINGS_LANGUAGE "Application language" #define SETTINGS_LANGUAGE "Application language"
#define SETTINGS_GLOBAL_INCLUDE_PATHS "Global include paths" #define SETTINGS_GLOBAL_INCLUDE_PATHS "Global include paths"
#define SETTINGS_CLANG_PATH "Clang path" #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_INLINE_SUPPRESSIONS "Inline suppressions"
#define SETTINGS_INCONCLUSIVE_ERRORS "Inconclusive errors" #define SETTINGS_INCONCLUSIVE_ERRORS "Inconclusive errors"
#define SETTINGS_MRU_PROJECTS "MRU Projects" #define SETTINGS_MRU_PROJECTS "MRU Projects"

View File

@ -444,7 +444,12 @@ void MainWindow::doAnalyzeProject(ImportProject p)
//mThread->SetanalyzeProject(true); //mThread->SetanalyzeProject(true);
if (mProjectFile) { if (mProjectFile) {
mThread->setAddons(mProjectFile->getAddons()); 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 #ifdef Q_OS_WIN
QString clangPath = mSettings->value(SETTINGS_CLANG_PATH,QString()).toString(); QString clangPath = mSettings->value(SETTINGS_CLANG_PATH,QString()).toString();
if (clangPath.isEmpty()) { if (clangPath.isEmpty()) {

View File

@ -351,14 +351,11 @@
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout_8"> <layout class="QVBoxLayout" name="verticalLayout_8">
<item> <item>
<widget class="QLabel" name="mLabelClangPath"> <widget class="QGroupBox" name="groupBox">
<property name="text"> <property name="title">
<string>Clang path (leave empty to use system PATH)</string> <string>Clang path (leave empty to use system PATH)</string>
</property> </property>
</widget> <layout class="QHBoxLayout" name="horizontalLayout_5">
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item> <item>
<widget class="QLineEdit" name="mEditClangPath"> <widget class="QLineEdit" name="mEditClangPath">
<property name="readOnly"> <property name="readOnly">
@ -374,29 +371,45 @@
</widget> </widget>
</item> </item>
</layout> </layout>
</widget>
</item> </item>
<item> <item>
<spacer name="verticalSpacer_5"> <widget class="QGroupBox" name="groupBox_2">
<property name="orientation"> <property name="title">
<enum>Qt::Vertical</enum> <string>Clang headers</string>
</property> </property>
<property name="sizeHint" stdset="0"> <layout class="QVBoxLayout" name="verticalLayout_9">
<size>
<width>20</width>
<height>51</height>
</size>
</property>
</spacer>
</item>
<item> <item>
<widget class="QLabel" name="mLabelVsIncludePaths"> <widget class="QLabel" name="mLabelVsIncludePaths">
<property name="text"> <property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Visual Studio include paths.&lt;/p&gt;&lt;p&gt;Open Visual Studio Command Prompt. Type &amp;quot;SET INSTALL&amp;quot; and then copy paste the output here&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Download the &quot;clang headers&quot; archive and unpack it. You can get it here: &lt;a href=&quot;http://sourceforge.net/projects/cppcheck/files/other/&quot;&gt;http://sourceforge.net/projects/cppcheck/files/other&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Path:&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLineEdit" name="mEditVsIncludePaths"/> <layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLineEdit" name="mEditClangHeaders">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="mButtonBrowseClangHeaders">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item> </item>
<item> <item>
<spacer name="verticalSpacer_6"> <spacer name="verticalSpacer_6">

21
gui/settingsdialog.cpp Normal file → Executable file
View File

@ -57,8 +57,9 @@ SettingsDialog::SettingsDialog(ApplicationList *list,
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
//mUI.mTabClang->setVisible(true); //mUI.mTabClang->setVisible(true);
mUI.mEditClangPath->setText(settings.value(SETTINGS_CLANG_PATH, QString()).toString()); 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.mBtnBrowseClangPath, &QPushButton::released, this, &SettingsDialog::browseClangPath);
connect(mUI.mButtonBrowseClangHeaders, &QPushButton::released, this, &SettingsDialog::browseClangHeaders);
#else #else
mUI.mTabClang->setVisible(false); mUI.mTabClang->setVisible(false);
#endif #endif
@ -187,10 +188,7 @@ void SettingsDialog::saveSettingValues() const
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
settings.setValue(SETTINGS_CLANG_PATH, mUI.mEditClangPath->text()); settings.setValue(SETTINGS_CLANG_PATH, mUI.mEditClangPath->text());
QString vsIncludePaths = mUI.mEditVsIncludePaths->text(); settings.setValue(SETTINGS_CLANG_HEADERS, mUI.mEditClangHeaders->text());
if (vsIncludePaths.startsWith("INCLUDE="))
vsIncludePaths.remove(0, 8);
settings.setValue(SETTINGS_VS_INCLUDE_PATHS, vsIncludePaths);
#endif #endif
const QListWidgetItem *currentLang = mUI.mListLanguages->currentItem(); const QListWidgetItem *currentLang = mUI.mListLanguages->currentItem();
@ -369,3 +367,16 @@ void SettingsDialog::browseClangPath()
mUI.mEditClangPath->setText(selectedDir); 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);
}
}

3
gui/settingsdialog.h Normal file → Executable file
View File

@ -145,6 +145,9 @@ protected slots:
/** @brief Slot for browsing for the clang binary */ /** @brief Slot for browsing for the clang binary */
void browseClangPath(); void browseClangPath();
/** @brief Slot for browsing for the clang headers */
void browseClangHeaders();
protected: protected:
/** /**

View File

@ -95,8 +95,8 @@ void ThreadHandler::check(const Settings &settings)
for (int i = 0; i < mRunningThreadCount; i++) { for (int i = 0; i < mRunningThreadCount; i++) {
mThreads[i]->setAddons(mAddons); mThreads[i]->setAddons(mAddons);
mThreads[i]->setSuppressions(mSuppressions); mThreads[i]->setSuppressions(mSuppressions);
mThreads[i]->setVsIncludePaths(mVsIncludePaths);
mThreads[i]->setClangPath(mClangPath); mThreads[i]->setClangPath(mClangPath);
mThreads[i]->setClangIncludePaths(mClangIncludePaths);
mThreads[i]->setDataDir(mDataDir); mThreads[i]->setDataDir(mDataDir);
mThreads[i]->check(settings); mThreads[i]->check(settings);
} }

View File

@ -79,14 +79,14 @@ public:
mSuppressions = s; mSuppressions = s;
} }
void setVsIncludePaths(const QString &s) {
mVsIncludePaths = s;
}
void setClangPath(const QString &p) { void setClangPath(const QString &p) {
mClangPath = p; mClangPath = p;
} }
void setClangIncludePaths(const QStringList &s) {
mClangIncludePaths = s;
}
void setDataDir(const QString &dataDir) { void setDataDir(const QString &dataDir) {
mDataDir = dataDir; mDataDir = dataDir;
} }
@ -255,8 +255,8 @@ protected:
QStringList mAddons; QStringList mAddons;
QStringList mSuppressions; QStringList mSuppressions;
QString mVsIncludePaths;
QString mClangPath; QString mClangPath;
QStringList mClangIncludePaths;
QString mDataDir; QString mDataDir;
private: private: