Removed --debug-fp. The reduce tool should be used instead.
This commit is contained in:
parent
932f6ea81b
commit
1f16e72b19
|
@ -132,10 +132,6 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[])
|
||||||
else if (std::strcmp(argv[i], "--debug-warnings") == 0)
|
else if (std::strcmp(argv[i], "--debug-warnings") == 0)
|
||||||
_settings->debugwarnings = true;
|
_settings->debugwarnings = true;
|
||||||
|
|
||||||
// Print out code that triggers false positive
|
|
||||||
else if (std::strcmp(argv[i], "--debug-fp") == 0)
|
|
||||||
_settings->debugFalsePositive = true;
|
|
||||||
|
|
||||||
// dump cppcheck data
|
// dump cppcheck data
|
||||||
else if (std::strcmp(argv[i], "--dump") == 0)
|
else if (std::strcmp(argv[i], "--dump") == 0)
|
||||||
_settings->dump = true;
|
_settings->dump = true;
|
||||||
|
|
|
@ -85,56 +85,6 @@ void CppCheck::replaceAll(std::string& code, const std::string &from, const std:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CppCheck::findError(std::string code, const char FileName[])
|
|
||||||
{
|
|
||||||
std::set<unsigned long long> checksums;
|
|
||||||
// First make sure that error occurs with the original code
|
|
||||||
bool internalErrorFound(false);
|
|
||||||
checkFile(code, FileName, checksums, internalErrorFound);
|
|
||||||
if (_errorList.empty()) {
|
|
||||||
// Error does not occur with this code
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::string previousCode = code;
|
|
||||||
std::string error = _errorList.front();
|
|
||||||
for (;;) {
|
|
||||||
|
|
||||||
// Try to remove included files from the source
|
|
||||||
const std::size_t found = previousCode.rfind("\n#endfile");
|
|
||||||
if (found == std::string::npos) {
|
|
||||||
// No modifications can be done to the code
|
|
||||||
} else {
|
|
||||||
// Modify code and re-check it to see if error
|
|
||||||
// is still there.
|
|
||||||
code = previousCode.substr(found+9);
|
|
||||||
_errorList.clear();
|
|
||||||
checksums.clear();
|
|
||||||
checkFile(code, FileName, checksums, internalErrorFound);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_errorList.empty()) {
|
|
||||||
// Latest code didn't fail anymore. Fall back
|
|
||||||
// to previous code
|
|
||||||
code = previousCode;
|
|
||||||
} else {
|
|
||||||
error = _errorList.front();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add '\n' so that "\n#file" on first line would be found
|
|
||||||
code = "// " + error + "\n" + code;
|
|
||||||
replaceAll(code, "\n#file", "\n// #file");
|
|
||||||
replaceAll(code, "\n#endfile", "\n// #endfile");
|
|
||||||
|
|
||||||
// We have reduced the code as much as we can. Print out
|
|
||||||
// the code and quit.
|
|
||||||
_errorLogger.reportOut(code);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int CppCheck::processFile(const std::string& filename, std::istream& fileStream)
|
unsigned int CppCheck::processFile(const std::string& filename, std::istream& fileStream)
|
||||||
{
|
{
|
||||||
exitcode = 0;
|
exitcode = 0;
|
||||||
|
@ -231,15 +181,9 @@ unsigned int CppCheck::processFile(const std::string& filename, std::istream& fi
|
||||||
|
|
||||||
codeWithoutCfg += _settings.append();
|
codeWithoutCfg += _settings.append();
|
||||||
|
|
||||||
if (_settings.debugFalsePositive) {
|
if (!checkFile(codeWithoutCfg, filename.c_str(), checksums, internalErrorFound)) {
|
||||||
if (findError(codeWithoutCfg, filename.c_str())) {
|
if (_settings.isEnabled("information") && (_settings.debug || _settings._verbose))
|
||||||
return exitcode;
|
purgedConfigurationMessage(filename, cfg);
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!checkFile(codeWithoutCfg, filename.c_str(), checksums, internalErrorFound)) {
|
|
||||||
if (_settings.isEnabled("information") && (_settings.debug || _settings._verbose))
|
|
||||||
purgedConfigurationMessage(filename, cfg);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (const std::runtime_error &e) {
|
} catch (const std::runtime_error &e) {
|
||||||
|
@ -582,12 +526,6 @@ void CppCheck::reportErr(const ErrorLogger::ErrorMessage &msg)
|
||||||
if (std::find(_errorList.begin(), _errorList.end(), errmsg) != _errorList.end())
|
if (std::find(_errorList.begin(), _errorList.end(), errmsg) != _errorList.end())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_settings.debugFalsePositive) {
|
|
||||||
// Don't print out error
|
|
||||||
_errorList.push_back(errmsg);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string file;
|
std::string file;
|
||||||
unsigned int line(0);
|
unsigned int line(0);
|
||||||
if (!msg._callStack.empty()) {
|
if (!msg._callStack.empty()) {
|
||||||
|
|
|
@ -177,13 +177,6 @@ private:
|
||||||
*/
|
*/
|
||||||
virtual void reportOut(const std::string &outmsg);
|
virtual void reportOut(const std::string &outmsg);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Check given code. If error is found, return true
|
|
||||||
* and print out source of the file. Try to reduce the code
|
|
||||||
* while still showing the error.
|
|
||||||
*/
|
|
||||||
bool findError(std::string code, const char FileName[]);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Replace "from" strings with "to" strings in "code"
|
* @brief Replace "from" strings with "to" strings in "code"
|
||||||
* and return it.
|
* and return it.
|
||||||
|
|
|
@ -28,7 +28,6 @@ Settings::Settings()
|
||||||
debug(false),
|
debug(false),
|
||||||
debugnormal(false),
|
debugnormal(false),
|
||||||
debugwarnings(false),
|
debugwarnings(false),
|
||||||
debugFalsePositive(false),
|
|
||||||
dump(false),
|
dump(false),
|
||||||
exceptionHandling(false),
|
exceptionHandling(false),
|
||||||
inconclusive(false),
|
inconclusive(false),
|
||||||
|
|
|
@ -64,9 +64,6 @@ public:
|
||||||
/** @brief Is --debug-warnings given? */
|
/** @brief Is --debug-warnings given? */
|
||||||
bool debugwarnings;
|
bool debugwarnings;
|
||||||
|
|
||||||
/** @brief Is --debug-fp given? */
|
|
||||||
bool debugFalsePositive;
|
|
||||||
|
|
||||||
/** @brief Is --dump given? */
|
/** @brief Is --dump given? */
|
||||||
bool dump;
|
bool dump;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue