diff --git a/gui/checkthread.cpp b/gui/checkthread.cpp index ab14d9c81..5b54d1f65 100644 --- a/gui/checkthread.cpp +++ b/gui/checkthread.cpp @@ -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::const_iterator I = fileSettings->includePaths.begin(); I != fileSettings->includePaths.end(); ++I) - args += " -I" + QString::fromStdString(*I); + args << ("-I" + QString::fromStdString(*I)); for (std::list::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(); diff --git a/gui/checkthread.h b/gui/checkthread.h index 5012e0e05..2855d458a 100644 --- a/gui/checkthread.h +++ b/gui/checkthread.h @@ -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 diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index bece1196a..24ef2d5d9 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -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); } diff --git a/gui/threadhandler.cpp b/gui/threadhandler.cpp index ee24211fa..71bf7f18d 100644 --- a/gui/threadhandler.cpp +++ b/gui/threadhandler.cpp @@ -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); } diff --git a/gui/threadhandler.h b/gui/threadhandler.h index 6de12204d..4821eb222 100644 --- a/gui/threadhandler.h +++ b/gui/threadhandler.h @@ -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: