parent
b0ce3e4c0c
commit
fb38e87bf4
|
@ -925,8 +925,8 @@ int CppCheckExecutor::check_internal(CppCheck& cppcheck, int /*argc*/, const cha
|
||||||
++c;
|
++c;
|
||||||
if (!settings.quiet)
|
if (!settings.quiet)
|
||||||
reportStatus(c, settings.project.fileSettings.size(), c, settings.project.fileSettings.size());
|
reportStatus(c, settings.project.fileSettings.size(), c, settings.project.fileSettings.size());
|
||||||
if(settings.clangTidy)
|
if (settings.clangTidy)
|
||||||
cppcheck.analyseClangTidy(fs);
|
cppcheck.analyseClangTidy(fs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,8 @@ static const cppcheck::Platform::PlatformType builtinPlatforms[] = {
|
||||||
|
|
||||||
static const int numberOfBuiltinPlatforms = sizeof(builtinPlatforms) / sizeof(builtinPlatforms[0]);
|
static const int numberOfBuiltinPlatforms = sizeof(builtinPlatforms) / sizeof(builtinPlatforms[0]);
|
||||||
|
|
||||||
QStringList ProjectFileDialog::getProjectConfigs(const QString &fileName) {
|
QStringList ProjectFileDialog::getProjectConfigs(const QString &fileName)
|
||||||
|
{
|
||||||
QStringList ret;
|
QStringList ret;
|
||||||
ImportProject importer;
|
ImportProject importer;
|
||||||
Settings projSettings;
|
Settings projSettings;
|
||||||
|
@ -241,7 +242,7 @@ static void updateAddonCheckBox(QCheckBox *cb, const ProjectFile *projectFile, c
|
||||||
|
|
||||||
void ProjectFileDialog::checkAllVSConfigs()
|
void ProjectFileDialog::checkAllVSConfigs()
|
||||||
{
|
{
|
||||||
if(mUI.mChkAllVsConfigs->isChecked())
|
if (mUI.mChkAllVsConfigs->isChecked())
|
||||||
mUI.mListVsConfigs->selectAll();
|
mUI.mListVsConfigs->selectAll();
|
||||||
mUI.mListVsConfigs->setEnabled(!mUI.mChkAllVsConfigs->isChecked());
|
mUI.mListVsConfigs->setEnabled(!mUI.mChkAllVsConfigs->isChecked());
|
||||||
}
|
}
|
||||||
|
@ -332,15 +333,13 @@ void ProjectFileDialog::loadFromProjectFile(const ProjectFile *projectFile)
|
||||||
}
|
}
|
||||||
mUI.mEditTags->setText(projectFile->getTags().join(';'));
|
mUI.mEditTags->setText(projectFile->getTags().join(';'));
|
||||||
updatePathsAndDefines();
|
updatePathsAndDefines();
|
||||||
if(mUI.mEditImportProject->text().endsWith(".sln") || mUI.mEditImportProject->text().endsWith(".vcxproj")) {
|
if (mUI.mEditImportProject->text().endsWith(".sln") || mUI.mEditImportProject->text().endsWith(".vcxproj")) {
|
||||||
setVsConfigurations(getProjectConfigs(mUI.mEditImportProject->text()));
|
setVsConfigurations(getProjectConfigs(mUI.mEditImportProject->text()));
|
||||||
foreach(const QString &cfg, projectFile->getVsConfigurations()) {
|
foreach (const QString &cfg, projectFile->getVsConfigurations()) {
|
||||||
QList<QListWidgetItem*> items = mUI.mListVsConfigs->findItems(cfg, Qt::MatchFlag::MatchExactly);
|
QList<QListWidgetItem*> items = mUI.mListVsConfigs->findItems(cfg, Qt::MatchFlag::MatchExactly);
|
||||||
items[0]->setSelected(true);
|
items[0]->setSelected(true);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
mUI.mListVsConfigs->clear();
|
mUI.mListVsConfigs->clear();
|
||||||
mUI.mListVsConfigs->setEnabled(false);
|
mUI.mListVsConfigs->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
@ -463,7 +462,7 @@ void ProjectFileDialog::updatePathsAndDefines()
|
||||||
mUI.mBtnIncludeDown->setEnabled(!importProject);
|
mUI.mBtnIncludeDown->setEnabled(!importProject);
|
||||||
mUI.mChkAllVsConfigs->setEnabled(fileName.endsWith(".sln") || fileName.endsWith(".vcxproj"));
|
mUI.mChkAllVsConfigs->setEnabled(fileName.endsWith(".sln") || fileName.endsWith(".vcxproj"));
|
||||||
mUI.mListVsConfigs->setEnabled(fileName.endsWith(".sln") || fileName.endsWith(".vcxproj"));
|
mUI.mListVsConfigs->setEnabled(fileName.endsWith(".sln") || fileName.endsWith(".vcxproj"));
|
||||||
if(!mUI.mListVsConfigs->isEnabled())
|
if (!mUI.mListVsConfigs->isEnabled())
|
||||||
mUI.mListVsConfigs->clear();
|
mUI.mListVsConfigs->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -495,8 +494,8 @@ void ProjectFileDialog::browseImportProject()
|
||||||
QStringList ProjectFileDialog::getVsConfigurations() const
|
QStringList ProjectFileDialog::getVsConfigurations() const
|
||||||
{
|
{
|
||||||
QStringList configs;
|
QStringList configs;
|
||||||
foreach(QListWidgetItem *item, mUI.mListVsConfigs->selectedItems())
|
foreach (QListWidgetItem *item, mUI.mListVsConfigs->selectedItems())
|
||||||
configs << item->text();
|
configs << item->text();
|
||||||
|
|
||||||
return configs;
|
return configs;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1352,7 +1352,7 @@ void CppCheck::getErrorMessages()
|
||||||
Preprocessor::getErrorMessages(this, &s);
|
Preprocessor::getErrorMessages(this, &s);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppCheck::analyseClangTidy(const ImportProject::FileSettings &fileSettings )
|
void CppCheck::analyseClangTidy(const ImportProject::FileSettings &fileSettings)
|
||||||
{
|
{
|
||||||
std::string allIncludes = "";
|
std::string allIncludes = "";
|
||||||
std::string allDefines = "-D"+fileSettings.defines;
|
std::string allDefines = "-D"+fileSettings.defines;
|
||||||
|
@ -1361,8 +1361,7 @@ void CppCheck::analyseClangTidy(const ImportProject::FileSettings &fileSettings
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string::size_type pos = 0u;
|
std::string::size_type pos = 0u;
|
||||||
while ((pos = allDefines.find(";", pos)) != std::string::npos)
|
while ((pos = allDefines.find(";", pos)) != std::string::npos) {
|
||||||
{
|
|
||||||
allDefines.replace(pos, 1, " -D");
|
allDefines.replace(pos, 1, " -D");
|
||||||
pos += 3;
|
pos += 3;
|
||||||
}
|
}
|
||||||
|
@ -1370,16 +1369,15 @@ void CppCheck::analyseClangTidy(const ImportProject::FileSettings &fileSettings
|
||||||
const std::string cmd = "clang-tidy -quiet -checks=*,-clang-analyzer-*,-llvm* \"" + fileSettings.filename + "\" -- " + allIncludes + allDefines;
|
const std::string cmd = "clang-tidy -quiet -checks=*,-clang-analyzer-*,-llvm* \"" + fileSettings.filename + "\" -- " + allIncludes + allDefines;
|
||||||
std::pair<bool, std::string> result = executeCommand(cmd);
|
std::pair<bool, std::string> result = executeCommand(cmd);
|
||||||
if (!result.first) {
|
if (!result.first) {
|
||||||
std::cerr << "Failed to execute '" + cmd + "'" << std::endl;
|
std::cerr << "Failed to execute '" + cmd + "'" << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// parse output and create error messages
|
// parse output and create error messages
|
||||||
std::istringstream istr(result.second);
|
std::istringstream istr(result.second);
|
||||||
std::string line;
|
std::string line;
|
||||||
|
|
||||||
if (!mSettings.buildDir.empty())
|
if (!mSettings.buildDir.empty()) {
|
||||||
{
|
|
||||||
const std::string analyzerInfoFile = AnalyzerInformation::getAnalyzerInfoFile(mSettings.buildDir, fileSettings.filename, "");
|
const std::string analyzerInfoFile = AnalyzerInformation::getAnalyzerInfoFile(mSettings.buildDir, fileSettings.filename, "");
|
||||||
std::ofstream fcmd(analyzerInfoFile + ".clang-tidy-cmd");
|
std::ofstream fcmd(analyzerInfoFile + ".clang-tidy-cmd");
|
||||||
fcmd << istr.str();
|
fcmd << istr.str();
|
||||||
|
@ -1398,7 +1396,7 @@ void CppCheck::analyseClangTidy(const ImportProject::FileSettings &fileSettings
|
||||||
const std::size_t endNamePos = line.rfind(":", endLinePos - 1);
|
const std::size_t endNamePos = line.rfind(":", endLinePos - 1);
|
||||||
const std::size_t endMsgTypePos = line.find(':', endColumnPos + 2);
|
const std::size_t endMsgTypePos = line.find(':', endColumnPos + 2);
|
||||||
const std::size_t endErrorPos = line.rfind('[', std::string::npos);
|
const std::size_t endErrorPos = line.rfind('[', std::string::npos);
|
||||||
if(endLinePos==std::string::npos || endNamePos==std::string::npos || endMsgTypePos==std::string::npos || endErrorPos==std::string::npos)
|
if (endLinePos==std::string::npos || endNamePos==std::string::npos || endMsgTypePos==std::string::npos || endErrorPos==std::string::npos)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const std::string lineNumString = line.substr(endNamePos + 1, endLinePos - endNamePos - 1);
|
const std::string lineNumString = line.substr(endNamePos + 1, endLinePos - endNamePos - 1);
|
||||||
|
|
|
@ -664,7 +664,7 @@ void ImportProject::importVcxproj(const std::string &filename, std::map<std::str
|
||||||
doChecking = true;
|
doChecking = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(!doChecking)
|
if (!doChecking)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue