CLI: Added --debug-normal option that will show --debug output after 1st simplifications. This output is relevant for the 'normal' checkers.

This commit is contained in:
Daniel Marjamäki 2015-07-28 12:46:32 +02:00
parent e759710198
commit a17f4d0a2d
5 changed files with 26 additions and 8 deletions

View File

@ -126,6 +126,10 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[])
else if (std::strcmp(argv[i], "--debug") == 0)
_settings->debug = _settings->debugwarnings = true;
// Show --debug output after the first simplifications
else if (std::strcmp(argv[i], "--debug-normal") == 0)
_settings->debugnormal = true;
// Show debug warnings
else if (std::strcmp(argv[i], "--debug-warnings") == 0)
_settings->debugwarnings = true;

View File

@ -27,6 +27,7 @@
Settings::Settings()
: _terminate(false),
debug(false),
debugnormal(false),
debugwarnings(false),
debugFalsePositive(false),
dump(false),

View File

@ -57,6 +57,9 @@ public:
/** @brief Is --debug given? */
bool debug;
/** @brief Is --debug-normal given? */
bool debugnormal;
/** @brief Is --debug-warnings given? */
bool debugwarnings;

View File

@ -1757,6 +1757,8 @@ bool Tokenizer::tokenize(std::istream &code,
ValueFlow::setValues(&list, _symbolDatabase, _errorLogger, _settings);
}
printDebugOutput(1);
return true;
}
return false;
@ -3785,15 +3787,18 @@ bool Tokenizer::simplifyTokenList2()
if (_settings->terminated())
return false;
printDebugOutput();
printDebugOutput(2);
return true;
}
//---------------------------------------------------------------------------
void Tokenizer::printDebugOutput() const
void Tokenizer::printDebugOutput(unsigned int simplification) const
{
if (_settings->debug) {
const bool debug = (simplification != 1U && _settings->debug) ||
(simplification != 2U && _settings->debugnormal);
if (debug) {
list.front()->printOut(0, list.getFiles());
if (_settings->_xml)
@ -3815,7 +3820,7 @@ void Tokenizer::printDebugOutput() const
std::cout << "</debug>" << std::endl;
}
if (_settings->debugwarnings) {
if (simplification == 2U && _settings->debugwarnings) {
printUnknownTypes();
// #5054 - the typeStartToken() should come before typeEndToken()
@ -8235,13 +8240,13 @@ void Tokenizer::eraseDeadCode(Token *begin, const Token *end)
void Tokenizer::syntaxError(const Token *tok) const
{
printDebugOutput();
printDebugOutput(0);
throw InternalError(tok, "syntax error", InternalError::SYNTAX);
}
void Tokenizer::syntaxError(const Token *tok, char c) const
{
printDebugOutput();
printDebugOutput(0);
throw InternalError(tok,
std::string("Invalid number of character (") + c + ") " +
"when these macros are defined: '" + _configuration + "'.",
@ -8262,7 +8267,7 @@ void Tokenizer::unhandled_macro_class_x_y(const Token *tok) const
void Tokenizer::cppcheckError(const Token *tok) const
{
printDebugOutput();
printDebugOutput(0);
throw InternalError(tok, "Analysis failed. If the code is valid then please report this failure.", InternalError::INTERNAL);
}
/**

View File

@ -755,7 +755,12 @@ public:
void createSymbolDatabase();
void deleteSymbolDatabase();
void printDebugOutput() const;
/** print --debug output if debug flags match the simplification:
* 0=unknown/both simplifications
* 1=1st simplifications
* 2=2nd simplifications
*/
void printDebugOutput(unsigned int simplification) const;
void dump(std::ostream &out) const;