GUI: Select parser; Cppcheck or Clang
This commit is contained in:
parent
103ecb0257
commit
632dc0f141
|
@ -921,8 +921,10 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
|
||||||
printMessage("If --clang is used then --cppcheck-build-dir must be specified also");
|
printMessage("If --clang is used then --cppcheck-build-dir must be specified also");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
std::ofstream fout(mSettings->buildDir + "/__temp__.c");
|
std::ofstream fout1(mSettings->buildDir + "/__temp__.c");
|
||||||
fout << "int x;\n";
|
fout1 << "int x;\n";
|
||||||
|
std::ofstream fout2(mSettings->buildDir + "/__temp__.cpp");
|
||||||
|
fout2 << "int x;\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -839,6 +839,8 @@ Settings MainWindow::getCppcheckSettings()
|
||||||
result.userDefines += define.toStdString();
|
result.userDefines += define.toStdString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result.clang = mProjectFile->clangParser;
|
||||||
|
|
||||||
const QStringList undefines = mProjectFile->getUndefines();
|
const QStringList undefines = mProjectFile->getUndefines();
|
||||||
foreach (QString undefine, undefines)
|
foreach (QString undefine, undefines)
|
||||||
result.userUndefs.insert(undefine.toStdString());
|
result.userUndefs.insert(undefine.toStdString());
|
||||||
|
|
|
@ -45,6 +45,7 @@ ProjectFile::ProjectFile(const QString &filename, QObject *parent) :
|
||||||
|
|
||||||
void ProjectFile::clear()
|
void ProjectFile::clear()
|
||||||
{
|
{
|
||||||
|
clangParser = false;
|
||||||
mRootPath.clear();
|
mRootPath.clear();
|
||||||
mBuildDir.clear();
|
mBuildDir.clear();
|
||||||
mImportProject.clear();
|
mImportProject.clear();
|
||||||
|
@ -111,6 +112,9 @@ bool ProjectFile::read(const QString &filename)
|
||||||
if (xmlReader.name() == CppcheckXml::AnalyzeAllVsConfigsElementName)
|
if (xmlReader.name() == CppcheckXml::AnalyzeAllVsConfigsElementName)
|
||||||
mAnalyzeAllVsConfigs = readBool(xmlReader);
|
mAnalyzeAllVsConfigs = readBool(xmlReader);
|
||||||
|
|
||||||
|
if (xmlReader.name() == CppcheckXml::Parser)
|
||||||
|
clangParser = true;
|
||||||
|
|
||||||
if (xmlReader.name() == CppcheckXml::CheckHeadersElementName)
|
if (xmlReader.name() == CppcheckXml::CheckHeadersElementName)
|
||||||
mCheckHeaders = readBool(xmlReader);
|
mCheckHeaders = readBool(xmlReader);
|
||||||
|
|
||||||
|
@ -709,6 +713,12 @@ bool ProjectFile::write(const QString &filename)
|
||||||
xmlWriter.writeCharacters(mAnalyzeAllVsConfigs ? "true" : "false");
|
xmlWriter.writeCharacters(mAnalyzeAllVsConfigs ? "true" : "false");
|
||||||
xmlWriter.writeEndElement();
|
xmlWriter.writeEndElement();
|
||||||
|
|
||||||
|
if (clangParser) {
|
||||||
|
xmlWriter.writeStartElement(CppcheckXml::Parser);
|
||||||
|
xmlWriter.writeCharacters("clang");
|
||||||
|
xmlWriter.writeEndElement();
|
||||||
|
}
|
||||||
|
|
||||||
xmlWriter.writeStartElement(CppcheckXml::CheckHeadersElementName);
|
xmlWriter.writeStartElement(CppcheckXml::CheckHeadersElementName);
|
||||||
xmlWriter.writeCharacters(mCheckHeaders ? "true" : "false");
|
xmlWriter.writeCharacters(mCheckHeaders ? "true" : "false");
|
||||||
xmlWriter.writeEndElement();
|
xmlWriter.writeEndElement();
|
||||||
|
|
|
@ -363,6 +363,9 @@ public:
|
||||||
mCheckUnknownFunctionReturn = s;
|
mCheckUnknownFunctionReturn = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Use Clang parser */
|
||||||
|
bool clangParser;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -260,6 +260,10 @@ void ProjectFileDialog::loadFromProjectFile(const ProjectFile *projectFile)
|
||||||
mUI.mCheckHeaders->setChecked(projectFile->getCheckHeaders());
|
mUI.mCheckHeaders->setChecked(projectFile->getCheckHeaders());
|
||||||
mUI.mCheckUnusedTemplates->setChecked(projectFile->getCheckUnusedTemplates());
|
mUI.mCheckUnusedTemplates->setChecked(projectFile->getCheckUnusedTemplates());
|
||||||
mUI.mMaxCtuDepth->setValue(projectFile->getMaxCtuDepth());
|
mUI.mMaxCtuDepth->setValue(projectFile->getMaxCtuDepth());
|
||||||
|
if (projectFile->clangParser)
|
||||||
|
mUI.mBtnClangParser->setChecked(true);
|
||||||
|
else
|
||||||
|
mUI.mBtnCppcheckParser->setChecked(true);
|
||||||
setExcludedPaths(projectFile->getExcludedPaths());
|
setExcludedPaths(projectFile->getExcludedPaths());
|
||||||
setLibraries(projectFile->getLibraries());
|
setLibraries(projectFile->getLibraries());
|
||||||
const QString platform = projectFile->getPlatform();
|
const QString platform = projectFile->getPlatform();
|
||||||
|
@ -361,6 +365,7 @@ void ProjectFileDialog::saveToProjectFile(ProjectFile *projectFile) const
|
||||||
projectFile->setCheckPaths(getCheckPaths());
|
projectFile->setCheckPaths(getCheckPaths());
|
||||||
projectFile->setExcludedPaths(getExcludedPaths());
|
projectFile->setExcludedPaths(getExcludedPaths());
|
||||||
projectFile->setLibraries(getLibraries());
|
projectFile->setLibraries(getLibraries());
|
||||||
|
projectFile->clangParser = mUI.mBtnClangParser->isChecked();
|
||||||
if (mUI.mComboBoxPlatform->currentText().endsWith(".xml"))
|
if (mUI.mComboBoxPlatform->currentText().endsWith(".xml"))
|
||||||
projectFile->setPlatform(mUI.mComboBoxPlatform->currentText());
|
projectFile->setPlatform(mUI.mComboBoxPlatform->currentText());
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -344,6 +344,32 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="groupBox_10">
|
||||||
|
<property name="title">
|
||||||
|
<string>Parser</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_14">
|
||||||
|
<item>
|
||||||
|
<widget class="QRadioButton" name="mBtnCppcheckParser">
|
||||||
|
<property name="text">
|
||||||
|
<string>Cppcheck (built in)</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QRadioButton" name="mBtnClangParser">
|
||||||
|
<property name="text">
|
||||||
|
<string>Clang</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBox_6">
|
<widget class="QGroupBox" name="groupBox_6">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
|
|
|
@ -254,14 +254,14 @@ unsigned int CppCheck::check(const std::string &path)
|
||||||
mErrorLogger.reportOut(std::string("Checking ") + path + "...");
|
mErrorLogger.reportOut(std::string("Checking ") + path + "...");
|
||||||
|
|
||||||
const std::string clang = Path::isCPP(path) ? "clang++" : "clang";
|
const std::string clang = Path::isCPP(path) ? "clang++" : "clang";
|
||||||
const std::string temp = mSettings.buildDir + "/__temp__.c";
|
const std::string temp = mSettings.buildDir + (Path::isCPP(path) ? "/__temp__.cpp" : "/__temp__.c");
|
||||||
const std::string clangcmd = AnalyzerInformation::getAnalyzerInfoFile(mSettings.buildDir, path, "") + ".clang-cmd";
|
const std::string clangcmd = AnalyzerInformation::getAnalyzerInfoFile(mSettings.buildDir, path, "") + ".clang-cmd";
|
||||||
const std::string clangStderr = AnalyzerInformation::getAnalyzerInfoFile(mSettings.buildDir, path, "") + ".clang-stderr";
|
const std::string clangStderr = AnalyzerInformation::getAnalyzerInfoFile(mSettings.buildDir, path, "") + ".clang-stderr";
|
||||||
|
|
||||||
const std::string cmd1 = clang + " -v -fsyntax-only " + temp + " 2>&1";
|
const std::string cmd1 = clang + " -v -fsyntax-only " + temp + " 2>&1";
|
||||||
const std::pair<bool, std::string> &result1 = executeCommand(cmd1);
|
const std::pair<bool, std::string> &result1 = executeCommand(cmd1);
|
||||||
if (!result1.first || result1.second.find(" -cc1 ") == std::string::npos) {
|
if (!result1.first || result1.second.find(" -cc1 ") == std::string::npos) {
|
||||||
std::cerr << "Failed to execute '" + cmd1 + "'" << std::endl;
|
mErrorLogger.reportOut("Failed to execute '" + cmd1 + "':" + result1.second);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
std::istringstream details(result1.second);
|
std::istringstream details(result1.second);
|
||||||
|
|
|
@ -1039,6 +1039,8 @@ bool ImportProject::importCppcheckGuiProject(std::istream &istr, Settings *setti
|
||||||
guiProject.platform = node->GetText();
|
guiProject.platform = node->GetText();
|
||||||
else if (strcmp(node->Name(), CppcheckXml::AnalyzeAllVsConfigsElementName) == 0)
|
else if (strcmp(node->Name(), CppcheckXml::AnalyzeAllVsConfigsElementName) == 0)
|
||||||
guiProject.analyzeAllVsConfigs = node->GetText();
|
guiProject.analyzeAllVsConfigs = node->GetText();
|
||||||
|
else if (strcmp(node->Name(), CppcheckXml::Parser) == 0)
|
||||||
|
temp.clang = true;
|
||||||
else if (strcmp(node->Name(), CppcheckXml::AddonsElementName) == 0)
|
else if (strcmp(node->Name(), CppcheckXml::AddonsElementName) == 0)
|
||||||
temp.addons = readXmlStringList(node, "", CppcheckXml::AddonElementName, nullptr);
|
temp.addons = readXmlStringList(node, "", CppcheckXml::AddonElementName, nullptr);
|
||||||
else if (strcmp(node->Name(), CppcheckXml::TagsElementName) == 0)
|
else if (strcmp(node->Name(), CppcheckXml::TagsElementName) == 0)
|
||||||
|
|
|
@ -122,6 +122,7 @@ namespace CppcheckXml {
|
||||||
const char BuildDirElementName[] = "builddir";
|
const char BuildDirElementName[] = "builddir";
|
||||||
const char ImportProjectElementName[] = "importproject";
|
const char ImportProjectElementName[] = "importproject";
|
||||||
const char AnalyzeAllVsConfigsElementName[] = "analyze-all-vs-configs";
|
const char AnalyzeAllVsConfigsElementName[] = "analyze-all-vs-configs";
|
||||||
|
const char Parser[] = "parser";
|
||||||
const char IncludeDirElementName[] = "includedir";
|
const char IncludeDirElementName[] = "includedir";
|
||||||
const char DirElementName[] = "dir";
|
const char DirElementName[] = "dir";
|
||||||
const char DirNameAttrib[] = "name";
|
const char DirNameAttrib[] = "name";
|
||||||
|
|
Loading…
Reference in New Issue