Visitar URL original
Verification; save report in custom file · napcode/cppcheck@49ed1a8 · GitHub
Skip to content

Commit 49ed1a8

Browse files
committed
Verification; save report in custom file
1 parent 4b4f7ea commit 49ed1a8

5 files changed

Lines changed: 13 additions & 10 deletions

File tree

‎cli/cmdlineparser.cpp‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,10 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
192192
// Experimental: Verify
193193
else if (std::strcmp(argv[i], "--verify") == 0)
194194
mSettings->verification = true;
195-
else if (std::strcmp(argv[i], "--verify-report") == 0)
196-
mSettings->verification = mSettings->verificationReport = true;
195+
else if (std::strncmp(argv[i], "--verify-report=", 16) == 0) {
196+
mSettings->verification = true;
197+
mSettings->verificationReport = argv[i] + 16;
198+
}
197199
else if (std::strcmp(argv[i], "--debug-verify") == 0)
198200
mSettings->debugVerification = true;
199201

‎cli/cppcheckexecutor.cpp‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1066,8 +1066,10 @@ void CppCheckExecutor::reportErr(const ErrorLogger::ErrorMessage &msg)
10661066

10671067
void CppCheckExecutor::reportVerification(const std::string &str)
10681068
{
1069+
if (!mSettings || str.empty())
1070+
return;
10691071
if (!mVerificationOutput)
1070-
mVerificationOutput = new std::ofstream("verification-report.txt");
1072+
mVerificationOutput = new std::ofstream(mSettings->verificationReport);
10711073
(*mVerificationOutput) << str << std::endl;
10721074
}
10731075

‎lib/exprengine.cpp‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,16 +1578,16 @@ void ExprEngine::executeFunction(const Scope *functionScope, const Tokenizer *to
15781578
}
15791579

15801580
if (settings->debugVerification && !trackExecution.isAllOk()) {
1581-
if (settings->verificationReport)
1581+
if (!settings->verificationReport.empty())
15821582
report << "[debug]" << std::endl;
15831583
trackExecution.print(report);
1584-
if (settings->verificationReport)
1584+
if (!settings->verificationReport.empty())
15851585
report << "[details]" << std::endl;
15861586
trackExecution.report(report, functionScope);
15871587
}
15881588

15891589
// Write a verification report
1590-
if (settings->verificationReport) {
1590+
if (!settings->verificationReport.empty()) {
15911591
report << "[function-report] "
15921592
<< Path::stripDirectoryPart(tokenizer->list.getFiles().at(functionScope->bodyStart->fileIndex())) << ":"
15931593
<< functionScope->bodyStart->linenr() << ":"
@@ -1766,6 +1766,6 @@ void ExprEngine::runChecks(ErrorLogger *errorLogger, const Tokenizer *tokenizer,
17661766

17671767
std::ostringstream report;
17681768
ExprEngine::executeAllFunctions(tokenizer, settings, callbacks, report);
1769-
if (errorLogger && settings->verificationReport && !report.str().empty())
1769+
if (errorLogger && !settings->verificationReport.empty() && !report.str().empty())
17701770
errorLogger->reportVerification(report.str());
17711771
}

‎lib/settings.cpp‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ Settings::Settings()
4646
force(false),
4747
inconclusive(false),
4848
verification(false),
49-
verificationReport(false),
5049
debugVerification(false),
5150
inlineSuppressions(false),
5251
jobs(1),

‎lib/settings.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,8 @@ class CPPCHECKLIB Settings : public cppcheck::Platform {
191191
/** @brief Enable verification analysis */
192192
bool verification;
193193

194-
/** @brief Generate verification report */
195-
bool verificationReport;
194+
/** @brief Verification report filename */
195+
std::string verificationReport;
196196

197197
/** @brief Generate verification debug output */
198198
bool debugVerification;

0 commit comments

Comments
 (0)