Verification; save report in custom file
This commit is contained in:
parent
4b4f7ea60b
commit
49ed1a82b4
|
@ -192,8 +192,10 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
|
||||||
// Experimental: Verify
|
// Experimental: Verify
|
||||||
else if (std::strcmp(argv[i], "--verify") == 0)
|
else if (std::strcmp(argv[i], "--verify") == 0)
|
||||||
mSettings->verification = true;
|
mSettings->verification = true;
|
||||||
else if (std::strcmp(argv[i], "--verify-report") == 0)
|
else if (std::strncmp(argv[i], "--verify-report=", 16) == 0) {
|
||||||
mSettings->verification = mSettings->verificationReport = true;
|
mSettings->verification = true;
|
||||||
|
mSettings->verificationReport = argv[i] + 16;
|
||||||
|
}
|
||||||
else if (std::strcmp(argv[i], "--debug-verify") == 0)
|
else if (std::strcmp(argv[i], "--debug-verify") == 0)
|
||||||
mSettings->debugVerification = true;
|
mSettings->debugVerification = true;
|
||||||
|
|
||||||
|
|
|
@ -1066,8 +1066,10 @@ void CppCheckExecutor::reportErr(const ErrorLogger::ErrorMessage &msg)
|
||||||
|
|
||||||
void CppCheckExecutor::reportVerification(const std::string &str)
|
void CppCheckExecutor::reportVerification(const std::string &str)
|
||||||
{
|
{
|
||||||
|
if (!mSettings || str.empty())
|
||||||
|
return;
|
||||||
if (!mVerificationOutput)
|
if (!mVerificationOutput)
|
||||||
mVerificationOutput = new std::ofstream("verification-report.txt");
|
mVerificationOutput = new std::ofstream(mSettings->verificationReport);
|
||||||
(*mVerificationOutput) << str << std::endl;
|
(*mVerificationOutput) << str << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1578,16 +1578,16 @@ void ExprEngine::executeFunction(const Scope *functionScope, const Tokenizer *to
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings->debugVerification && !trackExecution.isAllOk()) {
|
if (settings->debugVerification && !trackExecution.isAllOk()) {
|
||||||
if (settings->verificationReport)
|
if (!settings->verificationReport.empty())
|
||||||
report << "[debug]" << std::endl;
|
report << "[debug]" << std::endl;
|
||||||
trackExecution.print(report);
|
trackExecution.print(report);
|
||||||
if (settings->verificationReport)
|
if (!settings->verificationReport.empty())
|
||||||
report << "[details]" << std::endl;
|
report << "[details]" << std::endl;
|
||||||
trackExecution.report(report, functionScope);
|
trackExecution.report(report, functionScope);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write a verification report
|
// Write a verification report
|
||||||
if (settings->verificationReport) {
|
if (!settings->verificationReport.empty()) {
|
||||||
report << "[function-report] "
|
report << "[function-report] "
|
||||||
<< Path::stripDirectoryPart(tokenizer->list.getFiles().at(functionScope->bodyStart->fileIndex())) << ":"
|
<< Path::stripDirectoryPart(tokenizer->list.getFiles().at(functionScope->bodyStart->fileIndex())) << ":"
|
||||||
<< functionScope->bodyStart->linenr() << ":"
|
<< functionScope->bodyStart->linenr() << ":"
|
||||||
|
@ -1766,6 +1766,6 @@ void ExprEngine::runChecks(ErrorLogger *errorLogger, const Tokenizer *tokenizer,
|
||||||
|
|
||||||
std::ostringstream report;
|
std::ostringstream report;
|
||||||
ExprEngine::executeAllFunctions(tokenizer, settings, callbacks, report);
|
ExprEngine::executeAllFunctions(tokenizer, settings, callbacks, report);
|
||||||
if (errorLogger && settings->verificationReport && !report.str().empty())
|
if (errorLogger && !settings->verificationReport.empty() && !report.str().empty())
|
||||||
errorLogger->reportVerification(report.str());
|
errorLogger->reportVerification(report.str());
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,6 @@ Settings::Settings()
|
||||||
force(false),
|
force(false),
|
||||||
inconclusive(false),
|
inconclusive(false),
|
||||||
verification(false),
|
verification(false),
|
||||||
verificationReport(false),
|
|
||||||
debugVerification(false),
|
debugVerification(false),
|
||||||
inlineSuppressions(false),
|
inlineSuppressions(false),
|
||||||
jobs(1),
|
jobs(1),
|
||||||
|
|
|
@ -191,8 +191,8 @@ public:
|
||||||
/** @brief Enable verification analysis */
|
/** @brief Enable verification analysis */
|
||||||
bool verification;
|
bool verification;
|
||||||
|
|
||||||
/** @brief Generate verification report */
|
/** @brief Verification report filename */
|
||||||
bool verificationReport;
|
std::string verificationReport;
|
||||||
|
|
||||||
/** @brief Generate verification debug output */
|
/** @brief Generate verification debug output */
|
||||||
bool debugVerification;
|
bool debugVerification;
|
||||||
|
|
Loading…
Reference in New Issue