Skip to content

Commit 207361b

Browse files
committed
Clang import; This experimental feature didn't "take off" much. After a lot of work we are still far fram the goal. I remove it now but don't rule out completely that it could ever be added again.
1 parent b5aaf8d commit 207361b

32 files changed

Lines changed: 8 additions & 3505 deletions

.github/workflows/CI-windows.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ jobs:
121121
copy .\bin\cppcheck.exe .\cppcheck.exe || exit /b !errorlevel!
122122
copy .\bin\cppcheck-core.dll .\cppcheck-core.dll || exit /b !errorlevel!
123123
cd test/cli || exit /b !errorlevel!
124-
python -m pytest --suppress-no-test-exit-code test-clang-import.py || exit /b !errorlevel!
125124
python -m pytest test-helloworld.py || exit /b !errorlevel!
126125
python -m pytest test-inline-suppress.py || exit /b !errorlevel!
127126
python -m pytest test-more-projects.py || exit /b !errorlevel!

Makefile

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ LIBOBJ = $(libcppdir)/analyzerinfo.o \
185185
$(libcppdir)/checkunusedfunctions.o \
186186
$(libcppdir)/checkunusedvar.o \
187187
$(libcppdir)/checkvaarg.o \
188-
$(libcppdir)/clangimport.o \
189188
$(libcppdir)/cppcheck.o \
190189
$(libcppdir)/ctu.o \
191190
$(libcppdir)/errorlogger.o \
@@ -233,7 +232,6 @@ TESTOBJ = test/options.o \
233232
test/testbufferoverrun.o \
234233
test/testbughuntingchecks.o \
235234
test/testcharvar.o \
236-
test/testclangimport.o \
237235
test/testclass.o \
238236
test/testcmdlineparser.o \
239237
test/testcondition.o \
@@ -493,10 +491,7 @@ $(libcppdir)/checkunusedvar.o: lib/checkunusedvar.cpp externals/simplecpp/simple
493491
$(libcppdir)/checkvaarg.o: lib/checkvaarg.cpp lib/astutils.h lib/check.h lib/checkvaarg.h lib/config.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/timer.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h
494492
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CPPFILESDIR) $(CXXFLAGS) $(UNDEF_STRICT_ANSI) -c -o $(libcppdir)/checkvaarg.o $(libcppdir)/checkvaarg.cpp
495493

496-
$(libcppdir)/clangimport.o: lib/clangimport.cpp lib/astutils.h lib/clangimport.h lib/config.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/timer.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h
497-
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CPPFILESDIR) $(CXXFLAGS) $(UNDEF_STRICT_ANSI) -c -o $(libcppdir)/clangimport.o $(libcppdir)/clangimport.cpp
498-
499-
$(libcppdir)/cppcheck.o: lib/cppcheck.cpp externals/picojson/picojson.h externals/simplecpp/simplecpp.h externals/tinyxml2/tinyxml2.h lib/analyzerinfo.h lib/astutils.h lib/check.h lib/checkunusedfunctions.h lib/clangimport.h lib/config.h lib/cppcheck.h lib/ctu.h lib/errorlogger.h lib/errortypes.h lib/exprengine.h lib/importproject.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.h lib/templatesimplifier.h lib/timer.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h lib/version.h
494+
$(libcppdir)/cppcheck.o: lib/cppcheck.cpp externals/picojson/picojson.h externals/simplecpp/simplecpp.h externals/tinyxml2/tinyxml2.h lib/analyzerinfo.h lib/astutils.h lib/check.h lib/checkunusedfunctions.h lib/config.h lib/cppcheck.h lib/ctu.h lib/errorlogger.h lib/errortypes.h lib/exprengine.h lib/importproject.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.h lib/templatesimplifier.h lib/timer.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h lib/version.h
500495
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CPPFILESDIR) $(CXXFLAGS) $(UNDEF_STRICT_ANSI) -c -o $(libcppdir)/cppcheck.o $(libcppdir)/cppcheck.cpp
501496

502497
$(libcppdir)/ctu.o: lib/ctu.cpp externals/tinyxml2/tinyxml2.h lib/astutils.h lib/check.h lib/config.h lib/ctu.h lib/errorlogger.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/timer.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h
@@ -622,9 +617,6 @@ test/testbughuntingchecks.o: test/testbughuntingchecks.cpp lib/astutils.h lib/co
622617
test/testcharvar.o: test/testcharvar.cpp lib/astutils.h lib/check.h lib/checkother.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/templatesimplifier.h lib/timer.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h test/testsuite.h
623618
$(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CPPFILESDIR) $(CXXFLAGS) $(UNDEF_STRICT_ANSI) -c -o test/testcharvar.o test/testcharvar.cpp
624619

625-
test/testclangimport.o: test/testclangimport.cpp lib/astutils.h lib/clangimport.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/timer.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h test/testsuite.h
626-
$(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CPPFILESDIR) $(CXXFLAGS) $(UNDEF_STRICT_ANSI) -c -o test/testclangimport.o test/testclangimport.cpp
627-
628620
test/testclass.o: test/testclass.cpp externals/tinyxml2/tinyxml2.h lib/astutils.h lib/check.h lib/checkclass.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/timer.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h test/testsuite.h
629621
$(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CPPFILESDIR) $(CXXFLAGS) $(UNDEF_STRICT_ANSI) -c -o test/testclass.o test/testclass.cpp
630622

cli/cmdlineparser.cpp

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,7 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
235235
}
236236

237237
else if (std::strncmp(argv[i], "--clang", 7) == 0) {
238-
mSettings->clang = true;
239-
if (std::strncmp(argv[i], "--clang=", 8) == 0) {
240-
mSettings->clangExecutable = argv[i] + 8;
241-
}
238+
printMessage("Cppcheck: Clang import has been removed");
242239
}
243240

244241
else if (std::strncmp(argv[i], "--config-exclude=",17) ==0) {
@@ -992,18 +989,11 @@ void CmdLineParser::printHelp()
992989
" * faster analysis; Cppcheck will reuse the results if\n"
993990
" the hash for a file is unchanged.\n"
994991
" * some useful debug information, i.e. commands used to\n"
995-
" execute clang/clang-tidy/addons.\n"
992+
" execute clang-tidy/addons.\n"
996993
" --check-config Check cppcheck configuration. The normal code\n"
997994
" analysis is disabled by this flag.\n"
998995
" --check-library Show information messages when library files have\n"
999996
" incomplete info.\n"
1000-
" --clang=<path> Experimental: Use Clang parser instead of the builtin Cppcheck\n"
1001-
" parser. Takes the executable as optional parameter and\n"
1002-
" defaults to `clang`. Cppcheck will run the given Clang\n"
1003-
" executable, import the Clang AST and convert it into\n"
1004-
" Cppcheck data. After that the normal Cppcheck analysis is\n"
1005-
" used. You must have the executable in PATH if no path is\n"
1006-
" given.\n"
1007997
" --config-exclude=<dir>\n"
1008998
" Path (prefix) to be excluded from configuration\n"
1009999
" checking. Preprocessor configurations defined in\n"

gui/mainwindow.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -873,7 +873,6 @@ Settings MainWindow::getCppcheckSettings()
873873
result.userDefines += define.toStdString();
874874
}
875875

876-
result.clang = mProjectFile->clangParser;
877876
result.bugHunting = mProjectFile->bugHunting;
878877
result.bugHuntingReport = " ";
879878

gui/projectfile.cpp

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ ProjectFile::ProjectFile(const QString &filename, QObject *parent) :
4545
void ProjectFile::clear()
4646
{
4747
const Settings settings;
48-
clangParser = false;
4948
bugHunting = false;
5049
mRootPath.clear();
5150
mBuildDir.clear();
@@ -62,7 +61,7 @@ void ProjectFile::clear()
6261
mPlatform.clear();
6362
mSuppressions.clear();
6463
mAddons.clear();
65-
mClangAnalyzer = mClangTidy = false;
64+
mClangTidy = false;
6665
mAnalyzeAllVsConfigs = false;
6766
mCheckHeaders = true;
6867
mCheckUnusedTemplates = true;
@@ -118,9 +117,6 @@ bool ProjectFile::read(const QString &filename)
118117
if (xmlReader.name() == CppcheckXml::AnalyzeAllVsConfigsElementName)
119118
mAnalyzeAllVsConfigs = readBool(xmlReader);
120119

121-
if (xmlReader.name() == CppcheckXml::Parser)
122-
clangParser = true;
123-
124120
if (xmlReader.name() == CppcheckXml::BugHunting)
125121
bugHunting = true;
126122

@@ -186,7 +182,6 @@ bool ProjectFile::read(const QString &filename)
186182
if (xmlReader.name() == CppcheckXml::ToolsElementName) {
187183
QStringList tools;
188184
readStringList(tools, xmlReader, CppcheckXml::ToolElementName);
189-
mClangAnalyzer = tools.contains(CLANG_ANALYZER);
190185
mClangTidy = tools.contains(CLANG_TIDY);
191186
}
192187

@@ -875,12 +870,6 @@ bool ProjectFile::write(const QString &filename)
875870
xmlWriter.writeCharacters(mAnalyzeAllVsConfigs ? "true" : "false");
876871
xmlWriter.writeEndElement();
877872

878-
if (clangParser) {
879-
xmlWriter.writeStartElement(CppcheckXml::Parser);
880-
xmlWriter.writeCharacters("clang");
881-
xmlWriter.writeEndElement();
882-
}
883-
884873
if (bugHunting) {
885874
xmlWriter.writeStartElement(CppcheckXml::BugHunting);
886875
xmlWriter.writeEndElement();
@@ -1016,8 +1005,6 @@ bool ProjectFile::write(const QString &filename)
10161005
CppcheckXml::AddonElementName);
10171006

10181007
QStringList tools;
1019-
if (mClangAnalyzer)
1020-
tools << CLANG_ANALYZER;
10211008
if (mClangTidy)
10221009
tools << CLANG_TIDY;
10231010
writeStringList(xmlWriter,
@@ -1077,8 +1064,6 @@ QStringList ProjectFile::fromNativeSeparators(const QStringList &paths)
10771064
QStringList ProjectFile::getAddonsAndTools() const
10781065
{
10791066
QStringList ret(mAddons);
1080-
if (mClangAnalyzer)
1081-
ret << CLANG_ANALYZER;
10821067
if (mClangTidy)
10831068
ret << CLANG_TIDY;
10841069
return ret;

gui/projectfile.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,6 @@ class ProjectFile : public QObject {
192192
*/
193193
QStringList getAddonsAndTools() const;
194194

195-
bool getClangAnalyzer() const {
196-
return false; //mClangAnalyzer;
197-
}
198-
199-
void setClangAnalyzer(bool c) {
200-
mClangAnalyzer = c;
201-
}
202-
203195
bool getClangTidy() const {
204196
return mClangTidy;
205197
}
@@ -388,9 +380,6 @@ class ProjectFile : public QObject {
388380
mCheckUnknownFunctionReturn = s;
389381
}
390382

391-
/** Use Clang parser */
392-
bool clangParser;
393-
394383
/** Bug hunting */
395384
bool bugHunting;
396385
protected:
@@ -583,9 +572,6 @@ class ProjectFile : public QObject {
583572
*/
584573
QStringList mAddons;
585574

586-
/** @brief Execute clang analyzer? */
587-
bool mClangAnalyzer;
588-
589575
/** @brief Execute clang-tidy? */
590576
bool mClangTidy;
591577

gui/projectfiledialog.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -270,10 +270,6 @@ void ProjectFileDialog::loadFromProjectFile(const ProjectFile *projectFile)
270270
mUI.mCheckUnusedTemplates->setChecked(projectFile->getCheckUnusedTemplates());
271271
mUI.mMaxCtuDepth->setValue(projectFile->getMaxCtuDepth());
272272
mUI.mMaxTemplateRecursion->setValue(projectFile->getMaxTemplateRecursion());
273-
if (projectFile->clangParser)
274-
mUI.mBtnClangParser->setChecked(true);
275-
else
276-
mUI.mBtnCppcheckParser->setChecked(true);
277273
mUI.mBtnSafeClasses->setChecked(projectFile->safeChecks.classes);
278274
mUI.mBtnBugHunting->setChecked(projectFile->bugHunting);
279275
setExcludedPaths(projectFile->getExcludedPaths());
@@ -341,7 +337,6 @@ void ProjectFileDialog::loadFromProjectFile(const ProjectFile *projectFile)
341337
mUI.mAddonMisra->setText(mUI.mAddonMisra->text() + ' ' + tr("(no rule texts file)"));
342338
}
343339

344-
mUI.mToolClangAnalyzer->setChecked(projectFile->getClangAnalyzer());
345340
mUI.mToolClangTidy->setChecked(projectFile->getClangTidy());
346341
if (CheckThread::clangTidyCmd().isEmpty()) {
347342
mUI.mToolClangTidy->setText(tr("Clang-tidy (not found)"));
@@ -368,7 +363,6 @@ void ProjectFileDialog::saveToProjectFile(ProjectFile *projectFile) const
368363
projectFile->setCheckPaths(getCheckPaths());
369364
projectFile->setExcludedPaths(getExcludedPaths());
370365
projectFile->setLibraries(getLibraries());
371-
projectFile->clangParser = mUI.mBtnClangParser->isChecked();
372366
projectFile->safeChecks.classes = mUI.mBtnSafeClasses->isChecked();
373367
projectFile->bugHunting = mUI.mBtnBugHunting->isChecked();
374368
if (mUI.mComboBoxPlatform->currentText().endsWith(".xml"))
@@ -408,7 +402,6 @@ void ProjectFileDialog::saveToProjectFile(ProjectFile *projectFile) const
408402
if (mUI.mAddonMisra->isChecked())
409403
list << "misra";
410404
projectFile->setAddons(list);
411-
projectFile->setClangAnalyzer(mUI.mToolClangAnalyzer->isChecked());
412405
projectFile->setClangTidy(mUI.mToolClangTidy->isChecked());
413406
projectFile->setTags(mUI.mEditTags->text().split(";", QString::SkipEmptyParts));
414407
}

gui/projectfiledialog.ui

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -426,32 +426,6 @@
426426
</layout>
427427
</widget>
428428
</item>
429-
<item>
430-
<widget class="QGroupBox" name="groupBox_10">
431-
<property name="title">
432-
<string>Parser</string>
433-
</property>
434-
<layout class="QVBoxLayout" name="verticalLayout_14">
435-
<item>
436-
<widget class="QRadioButton" name="mBtnCppcheckParser">
437-
<property name="text">
438-
<string>Cppcheck (built in)</string>
439-
</property>
440-
<property name="checked">
441-
<bool>true</bool>
442-
</property>
443-
</widget>
444-
</item>
445-
<item>
446-
<widget class="QRadioButton" name="mBtnClangParser">
447-
<property name="text">
448-
<string>Clang (experimental)</string>
449-
</property>
450-
</widget>
451-
</item>
452-
</layout>
453-
</widget>
454-
</item>
455429
<item>
456430
<widget class="QGroupBox" name="groupBox_11">
457431
<property name="title">

gui/statsdialog.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,6 @@ void StatsDialog::setProject(const ProjectFile* projectFile)
6969
QChartView *chartView;
7070
chartView = createChart(statsFile, "cppcheck");
7171
mUI.mTabHistory->layout()->addWidget(chartView);
72-
if (projectFile->getClangAnalyzer()) {
73-
chartView = createChart(statsFile, CLANG_ANALYZER);
74-
mUI.mTabHistory->layout()->addWidget(chartView);
75-
}
7672
if (projectFile->getClangTidy()) {
7773
chartView = createChart(statsFile, CLANG_TIDY);
7874
mUI.mTabHistory->layout()->addWidget(chartView);

lib/bughuntingchecks.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ static void divByZero(const Token *tok, const ExprEngine::Value &value, ExprEngi
211211
if (tok->astParent()->astOperand2() == tok && value.isEqual(dataBase, 0)) {
212212
const char * const id = (tok->valueType() && tok->valueType()->isFloat()) ? "bughuntingDivByZeroFloat" : "bughuntingDivByZero";
213213
const bool bailout = (value.type == ExprEngine::ValueType::BailoutValue);
214-
dataBase->reportError(dataBase->settings->clang ? tok : tok->astParent(),
214+
dataBase->reportError(tok->astParent(),
215215
Severity::SeverityType::error,
216216
id,
217217
"There is division, cannot determine that there can't be a division by zero.",

0 commit comments

Comments
 (0)