GUI: Clang settings
This commit is contained in:
parent
2c837f2908
commit
f8c4d6cbc7
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
/// @}
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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()) {
|
||||
|
|
|
@ -351,14 +351,11 @@
|
|||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_8">
|
||||
<item>
|
||||
<widget class="QLabel" name="mLabelClangPath">
|
||||
<property name="text">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Clang path (leave empty to use system PATH)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="mEditClangPath">
|
||||
<property name="readOnly">
|
||||
|
@ -374,29 +371,45 @@
|
|||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Clang headers</string>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>51</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_9">
|
||||
<item>
|
||||
<widget class="QLabel" name="mLabelVsIncludePaths">
|
||||
<property name="text">
|
||||
<string><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></string>
|
||||
<string><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></string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</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>
|
||||
<spacer name="verticalSpacer_6">
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue