Removed --debug-fp. The reduce tool should be used instead.

This commit is contained in:
Daniel Marjamäki 2015-12-10 10:44:36 +01:00
parent 932f6ea81b
commit 1f16e72b19
5 changed files with 3 additions and 80 deletions

View File

@ -132,10 +132,6 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[])
else if (std::strcmp(argv[i], "--debug-warnings") == 0)
_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
else if (std::strcmp(argv[i], "--dump") == 0)
_settings->dump = true;

View File

@ -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)
{
exitcode = 0;
@ -231,17 +181,11 @@ unsigned int CppCheck::processFile(const std::string& filename, std::istream& fi
codeWithoutCfg += _settings.append();
if (_settings.debugFalsePositive) {
if (findError(codeWithoutCfg, filename.c_str())) {
return exitcode;
}
} 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) {
internalError(filename, e.what());
} catch (const InternalError &e) {
@ -582,12 +526,6 @@ void CppCheck::reportErr(const ErrorLogger::ErrorMessage &msg)
if (std::find(_errorList.begin(), _errorList.end(), errmsg) != _errorList.end())
return;
if (_settings.debugFalsePositive) {
// Don't print out error
_errorList.push_back(errmsg);
return;
}
std::string file;
unsigned int line(0);
if (!msg._callStack.empty()) {

View File

@ -177,13 +177,6 @@ private:
*/
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"
* and return it.

View File

@ -28,7 +28,6 @@ Settings::Settings()
debug(false),
debugnormal(false),
debugwarnings(false),
debugFalsePositive(false),
dump(false),
exceptionHandling(false),
inconclusive(false),

View File

@ -64,9 +64,6 @@ public:
/** @brief Is --debug-warnings given? */
bool debugwarnings;
/** @brief Is --debug-fp given? */
bool debugFalsePositive;
/** @brief Is --dump given? */
bool dump;