Skip to content

Commit 7820b5d

Browse files
committed
Rename 'Verification' to 'Bug hunting'
1 parent 434b506 commit 7820b5d

8 files changed

Lines changed: 82 additions & 82 deletions

File tree

cli/cmdlineparser.cpp

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -192,33 +192,30 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
192192
else if (std::strcmp(argv[i], "--safe-functions") == 0)
193193
mSettings->safeChecks.externalFunctions = mSettings->safeChecks.internalFunctions = true;
194194

195-
// Experimental: Verify
196-
else if (std::strcmp(argv[i], "--verify") == 0)
197-
mSettings->verification = true;
198-
else if (std::strncmp(argv[i], "--verify-report=", 16) == 0) {
199-
mSettings->verification = true;
200-
mSettings->verificationReport = argv[i] + 16;
201-
} else if (std::strcmp(argv[i], "--debug-verify") == 0)
202-
mSettings->debugVerification = true;
203-
else if (std::strncmp(argv[i], "--verify-diff=", 14) == 0) {
204-
std::ifstream fin(argv[i] + 14);
205-
if (!fin.is_open()) {
206-
printMessage("cppcheck: could not open file " + std::string(argv[i] + 14) + ".");
207-
return false;
208-
}
209-
210-
mSettings->verifyDiff = Settings::loadDiffFile(fin);
211-
mSettings->verification = true;
212-
213-
for (const auto &diff: mSettings->verifyDiff) {
214-
if (!Path::acceptFile(diff.filename))
215-
continue;
216-
const std::string filename = Path::fromNativeSeparators(diff.filename);
217-
if (std::find(mPathNames.begin(), mPathNames.end(), filename) == mPathNames.end())
218-
mPathNames.push_back(filename);
219-
}
220-
}
221-
195+
// Bug hunting
196+
else if (std::strcmp(argv[i], "--bug-hunting") == 0)
197+
mSettings->bugHunting = true;
198+
else if (std::strcmp(argv[i], "--debug-bug-hunting") == 0)
199+
mSettings->bugHunting = mSettings->debugBugHunting = true;
200+
/*
201+
else if (std::strncmp(argv[i], "--check-diff=", 13) == 0) {
202+
std::ifstream fin(argv[i] + 13);
203+
if (!fin.is_open()) {
204+
printMessage("cppcheck: could not open file " + std::string(argv[i] + 13) + ".");
205+
return false;
206+
}
207+
208+
mSettings->checkDiff = Settings::loadDiffFile(fin);
209+
210+
for (const auto &diff: mSettings->bugHuntingDiff) {
211+
if (!Path::acceptFile(diff.filename))
212+
continue;
213+
const std::string filename = Path::fromNativeSeparators(diff.filename);
214+
if (std::find(mPathNames.begin(), mPathNames.end(), filename) == mPathNames.end())
215+
mPathNames.push_back(filename);
216+
}
217+
}
218+
*/
222219
// Enforce language (--language=, -x)
223220
else if (std::strncmp(argv[i], "--language=", 11) == 0 || std::strcmp(argv[i], "-x") == 0) {
224221
std::string str;

cli/cppcheckexecutor.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,14 @@
7979
/*static*/ FILE* CppCheckExecutor::mExceptionOutput = stdout;
8080

8181
CppCheckExecutor::CppCheckExecutor()
82-
: mSettings(nullptr), mLatestProgressOutputTime(0), mErrorOutput(nullptr), mVerificationOutput(nullptr), mShowAllErrors(false)
82+
: mSettings(nullptr), mLatestProgressOutputTime(0), mErrorOutput(nullptr), mBugHuntingReport(nullptr), mShowAllErrors(false)
8383
{
8484
}
8585

8686
CppCheckExecutor::~CppCheckExecutor()
8787
{
8888
delete mErrorOutput;
89-
delete mVerificationOutput;
89+
delete mBugHuntingReport;
9090
}
9191

9292
bool CppCheckExecutor::parseFromArgs(CppCheck *cppcheck, int argc, const char* const argv[])
@@ -1095,9 +1095,9 @@ void CppCheckExecutor::reportVerification(const std::string &str)
10951095
{
10961096
if (!mSettings || str.empty())
10971097
return;
1098-
if (!mVerificationOutput)
1099-
mVerificationOutput = new std::ofstream(mSettings->verificationReport);
1100-
(*mVerificationOutput) << str << std::endl;
1098+
if (!mBugHuntingReport)
1099+
mBugHuntingReport = new std::ofstream(mSettings->bugHuntingReport);
1100+
(*mBugHuntingReport) << str << std::endl;
11011101
}
11021102

11031103
void CppCheckExecutor::setExceptionOutput(FILE* exceptionOutput)

cli/cppcheckexecutor.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,9 @@ class CppCheckExecutor : public ErrorLogger {
190190
std::ofstream *mErrorOutput;
191191

192192
/**
193-
* Verification report
193+
* Bug hunting report
194194
*/
195-
std::ostream *mVerificationOutput;
195+
std::ostream *mBugHuntingReport;
196196

197197
/**
198198
* Has --errorlist been given?

lib/cppcheck.cpp

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ unsigned int CppCheck::check(const std::string &path)
301301
tokenizer.printDebugOutput(1);
302302

303303
#ifdef USE_Z3
304-
if (mSettings.verification)
304+
if (mSettings.bugHunting)
305305
ExprEngine::runChecks(this, &tokenizer, &mSettings);
306306
#endif
307307
return 0;
@@ -838,39 +838,39 @@ void CppCheck::checkRawTokens(const Tokenizer &tokenizer)
838838

839839
void CppCheck::checkNormalTokens(const Tokenizer &tokenizer)
840840
{
841-
// call all "runChecks" in all registered Check classes
842-
for (Check *check : Check::instances()) {
843-
if (Settings::terminated())
844-
return;
845-
846-
if (Tokenizer::isMaxTime())
847-
return;
841+
if (mSettings.bugHunting)
842+
ExprEngine::runChecks(this, &tokenizer, &mSettings);
843+
else {
844+
// call all "runChecks" in all registered Check classes
845+
for (Check *check : Check::instances()) {
846+
if (Settings::terminated())
847+
return;
848848

849-
Timer timerRunChecks(check->name() + "::runChecks", mSettings.showtime, &s_timerResults);
850-
check->runChecks(&tokenizer, &mSettings, this);
851-
}
849+
if (Tokenizer::isMaxTime())
850+
return;
852851

853-
// Verification using ExprEngine..
854-
if (mSettings.verification)
855-
ExprEngine::runChecks(this, &tokenizer, &mSettings);
852+
Timer timerRunChecks(check->name() + "::runChecks", mSettings.showtime, &s_timerResults);
853+
check->runChecks(&tokenizer, &mSettings, this);
854+
}
856855

857-
// Analyse the tokens..
856+
// Analyse the tokens..
858857

859-
CTU::FileInfo *fi1 = CTU::getFileInfo(&tokenizer);
860-
if (fi1) {
861-
mFileInfo.push_back(fi1);
862-
mAnalyzerInformation.setFileInfo("ctu", fi1->toString());
863-
}
858+
CTU::FileInfo *fi1 = CTU::getFileInfo(&tokenizer);
859+
if (fi1) {
860+
mFileInfo.push_back(fi1);
861+
mAnalyzerInformation.setFileInfo("ctu", fi1->toString());
862+
}
864863

865-
for (const Check *check : Check::instances()) {
866-
Check::FileInfo *fi = check->getFileInfo(&tokenizer, &mSettings);
867-
if (fi != nullptr) {
868-
mFileInfo.push_back(fi);
869-
mAnalyzerInformation.setFileInfo(check->name(), fi->toString());
864+
for (const Check *check : Check::instances()) {
865+
Check::FileInfo *fi = check->getFileInfo(&tokenizer, &mSettings);
866+
if (fi != nullptr) {
867+
mFileInfo.push_back(fi);
868+
mAnalyzerInformation.setFileInfo(check->name(), fi->toString());
869+
}
870870
}
871-
}
872871

873-
executeRules("normal", tokenizer);
872+
executeRules("normal", tokenizer);
873+
}
874874
}
875875

876876
//---------------------------------------------------------------------------

lib/exprengine.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1719,20 +1719,20 @@ void ExprEngine::executeFunction(const Scope *functionScope, const Tokenizer *to
17191719
// TODO.. what about functions in headers?
17201720
return;
17211721

1722-
if (!settings->verifyDiff.empty()) {
1722+
if (!settings->checkDiff.empty()) {
17231723
const std::string filename = tokenizer->list.getFiles().at(functionScope->bodyStart->fileIndex());
1724-
bool verify = false;
1725-
for (const auto &diff: settings->verifyDiff) {
1724+
bool check = false;
1725+
for (const auto &diff: settings->checkDiff) {
17261726
if (diff.filename != filename)
17271727
continue;
17281728
if (diff.fromLine > functionScope->bodyEnd->linenr())
17291729
continue;
17301730
if (diff.toLine < functionScope->bodyStart->linenr())
17311731
continue;
1732-
verify = true;
1732+
check = true;
17331733
break;
17341734
}
1735-
if (!verify)
1735+
if (!check)
17361736
return;
17371737
}
17381738

@@ -1757,19 +1757,21 @@ void ExprEngine::executeFunction(const Scope *functionScope, const Tokenizer *to
17571757
}
17581758
}
17591759

1760-
if (settings->debugVerification && (settings->verbose || callbacks.empty() || !trackExecution.isAllOk())) {
1761-
if (!settings->verificationReport.empty())
1760+
const bool bugHuntingReport = !settings->bugHuntingReport.empty();
1761+
1762+
if (settings->debugBugHunting && (settings->verbose || callbacks.empty() || !trackExecution.isAllOk())) {
1763+
if (bugHuntingReport)
17621764
report << "[debug]" << std::endl;
17631765
trackExecution.print(report);
17641766
if (!callbacks.empty()) {
1765-
if (!settings->verificationReport.empty())
1767+
if (bugHuntingReport)
17661768
report << "[details]" << std::endl;
17671769
trackExecution.report(report, functionScope);
17681770
}
17691771
}
17701772

17711773
// Write a verification report
1772-
if (!settings->verificationReport.empty()) {
1774+
if (bugHuntingReport) {
17731775
report << "[function-report] "
17741776
<< Path::stripDirectoryPart(tokenizer->list.getFiles().at(functionScope->bodyStart->fileIndex())) << ":"
17751777
<< functionScope->bodyStart->linenr() << ":"
@@ -2044,7 +2046,7 @@ void ExprEngine::runChecks(ErrorLogger *errorLogger, const Tokenizer *tokenizer,
20442046

20452047
std::ostringstream report;
20462048
ExprEngine::executeAllFunctions(tokenizer, settings, callbacks, report);
2047-
if (settings->verificationReport.empty())
2049+
if (settings->bugHuntingReport.empty())
20482050
std::cout << report.str();
20492051
else if (errorLogger)
20502052
errorLogger->reportVerification(report.str());

lib/settings.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ Settings::Settings()
4646
experimental(false),
4747
force(false),
4848
inconclusive(false),
49-
verification(false),
50-
debugVerification(false),
49+
bugHunting(false),
50+
debugBugHunting(false),
5151
inlineSuppressions(false),
5252
jobs(1),
5353
jointSuppressionReport(false),

lib/settings.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -194,22 +194,22 @@ class CPPCHECKLIB Settings : public cppcheck::Platform {
194194

195195
SafeChecks safeChecks;
196196

197-
/** @brief Enable verification analysis */
198-
bool verification;
197+
/** @brief Bug hunting */
198+
bool bugHunting;
199199

200-
/** @brief Verification report filename */
201-
std::string verificationReport;
200+
/** @brief Debug bug hunting */
201+
bool debugBugHunting;
202202

203-
/** @brief Generate verification debug output */
204-
bool debugVerification;
203+
/** Filename for bug hunting report */
204+
std::string bugHuntingReport;
205205

206-
/** @brief Verify diff */
206+
/** @brief Check diff */
207207
struct Diff {
208208
std::string filename;
209209
int fromLine;
210210
int toLine;
211211
};
212-
std::vector<Diff> verifyDiff;
212+
std::vector<Diff> checkDiff;
213213

214214
/** @brief check unknown function return values */
215215
std::set<std::string> checkUnknownFunctionReturn;

test/testexprengine.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ class TestExprEngine : public TestFixture {
137137

138138
std::string trackExecution(const char code[]) {
139139
Settings settings;
140-
settings.debugVerification = true;
140+
settings.bugHunting = true;
141+
settings.debugBugHunting = true;
141142
settings.platform(cppcheck::Platform::Unix64);
142143
settings.library.smartPointers.insert("std::shared_ptr");
143144
Tokenizer tokenizer(&settings, this);

0 commit comments

Comments
 (0)