GUI: Working on Clang support on Windows

This commit is contained in:
Daniel Marjamäki 2017-08-04 20:08:01 +02:00
parent c2bb9890e9
commit 7f1db7b716
5 changed files with 33 additions and 17 deletions

View File

@ -117,26 +117,28 @@ void CheckThread::runAddons(const QString &addonPath, const ImportProject::FileS
if (!fileSettings)
continue;
QString args;
QStringList args;
if (addon == CLANG)
args << "--analyze";
else
args << "-checks=*,-clang*,-llvm*" << fileName << "--";
for (std::list<std::string>::const_iterator I = fileSettings->includePaths.begin(); I != fileSettings->includePaths.end(); ++I)
args += " -I" + QString::fromStdString(*I);
args << ("-I" + QString::fromStdString(*I));
for (std::list<std::string>::const_iterator i = fileSettings->systemIncludePaths.begin(); i != fileSettings->systemIncludePaths.end(); ++i)
args += " -isystem " + QString::fromStdString(*i);
args << "-isystem" << QString::fromStdString(*i);
foreach (QString D, QString::fromStdString(fileSettings->defines).split(";")) {
args += " -D" + D;
args << ("-D" + D);
}
if (!fileSettings->standard.empty())
args += " -std=" + QString::fromStdString(fileSettings->standard);
QString cmd;
args << (" -std=" + QString::fromStdString(fileSettings->standard));
if (addon == CLANG)
cmd = addon + " --analyze" + args + ' ' + fileName;
else
cmd = addon + " -checks=*,-clang*,-llvm* " + fileName + " -- " + args;
qDebug() << cmd;
args << fileName;
const QString cmd(mClangPath.isEmpty() ? addon : (mClangPath + '/' + addon + ".exe"));
qDebug() << cmd << args;
QProcess process;
process.start(cmd);
process.start(cmd, args);
process.waitForFinished(600*1000);
if (addon == CLANG)
parseClangErrors(process.readAllStandardError());
@ -231,7 +233,7 @@ void CheckThread::parseClangErrors(QString err)
QTextStream in(&err, QIODevice::ReadOnly);
while (!in.atEnd()) {
QString line = in.readLine();
QRegExp r("([^:]+):([0-9]+):[0-9]+: (warning|error|fatal error): (.*)");
QRegExp r("(.+):([0-9]+):[0-9]+: (warning|error|fatal error): (.*)");
if (!r.exactMatch(line))
continue;
const std::string filename = r.cap(1).toStdString();

View File

@ -60,6 +60,10 @@ public:
mDataDir = dataDir;
}
void setClangPath(const QString &p) {
mClangPath = p;
}
/**
* @brief method that is run in a thread
*
@ -117,6 +121,7 @@ private:
bool mAnalyseWholeProgram;
QStringList mAddons;
QString mDataDir;
QString mClangPath;
};
/// @}
#endif // CHECKTHREAD_H

View File

@ -412,8 +412,14 @@ void MainWindow::doAnalyzeProject(ImportProject p)
}
//mThread->SetanalyzeProject(true);
if (mProjectFile)
if (mProjectFile) {
mThread->setAddons(mProjectFile->getAddons());
#ifdef Q_OS_WIN
// Try to autodetect clang
if (QFileInfo("C:/Program Files/LLVM/bin/clang.exe").exists())
mThread->setClangPath("C:/Program Files/LLVM/bin");
#endif
}
mThread->setProject(p);
mThread->check(checkSettings);
}

View File

@ -93,6 +93,7 @@ void ThreadHandler::check(const Settings &settings)
for (int i = 0; i < mRunningThreadCount; i++) {
mThreads[i]->setAddons(mAddons);
mThreads[i]->setClangPath(mClangPath);
mThreads[i]->setDataDir(mDataDir);
mThreads[i]->check(settings);
}

View File

@ -75,6 +75,10 @@ public:
mAddons = addons;
}
void setClangPath(const QString &p) {
mClangPath = p;
}
void setDataDir(const QString &dataDir) {
mDataDir = dataDir;
}
@ -183,9 +187,6 @@ public slots:
*/
void stop();
protected slots:
/**
* @brief Slot that a single thread is done
*
@ -245,6 +246,7 @@ protected:
bool mAnalyseWholeProgram;
QStringList mAddons;
QString mClangPath;
QString mDataDir;
private: