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:
parent
e759710198
commit
a17f4d0a2d
|
@ -126,6 +126,10 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[])
|
||||||
else if (std::strcmp(argv[i], "--debug") == 0)
|
else if (std::strcmp(argv[i], "--debug") == 0)
|
||||||
_settings->debug = _settings->debugwarnings = true;
|
_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
|
// Show debug warnings
|
||||||
else if (std::strcmp(argv[i], "--debug-warnings") == 0)
|
else if (std::strcmp(argv[i], "--debug-warnings") == 0)
|
||||||
_settings->debugwarnings = true;
|
_settings->debugwarnings = true;
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
Settings::Settings()
|
Settings::Settings()
|
||||||
: _terminate(false),
|
: _terminate(false),
|
||||||
debug(false),
|
debug(false),
|
||||||
|
debugnormal(false),
|
||||||
debugwarnings(false),
|
debugwarnings(false),
|
||||||
debugFalsePositive(false),
|
debugFalsePositive(false),
|
||||||
dump(false),
|
dump(false),
|
||||||
|
|
|
@ -57,6 +57,9 @@ public:
|
||||||
/** @brief Is --debug given? */
|
/** @brief Is --debug given? */
|
||||||
bool debug;
|
bool debug;
|
||||||
|
|
||||||
|
/** @brief Is --debug-normal given? */
|
||||||
|
bool debugnormal;
|
||||||
|
|
||||||
/** @brief Is --debug-warnings given? */
|
/** @brief Is --debug-warnings given? */
|
||||||
bool debugwarnings;
|
bool debugwarnings;
|
||||||
|
|
||||||
|
|
|
@ -1757,6 +1757,8 @@ bool Tokenizer::tokenize(std::istream &code,
|
||||||
ValueFlow::setValues(&list, _symbolDatabase, _errorLogger, _settings);
|
ValueFlow::setValues(&list, _symbolDatabase, _errorLogger, _settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printDebugOutput(1);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -3785,15 +3787,18 @@ bool Tokenizer::simplifyTokenList2()
|
||||||
if (_settings->terminated())
|
if (_settings->terminated())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
printDebugOutput();
|
printDebugOutput(2);
|
||||||
|
|
||||||
return true;
|
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());
|
list.front()->printOut(0, list.getFiles());
|
||||||
|
|
||||||
if (_settings->_xml)
|
if (_settings->_xml)
|
||||||
|
@ -3815,7 +3820,7 @@ void Tokenizer::printDebugOutput() const
|
||||||
std::cout << "</debug>" << std::endl;
|
std::cout << "</debug>" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_settings->debugwarnings) {
|
if (simplification == 2U && _settings->debugwarnings) {
|
||||||
printUnknownTypes();
|
printUnknownTypes();
|
||||||
|
|
||||||
// #5054 - the typeStartToken() should come before typeEndToken()
|
// #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
|
void Tokenizer::syntaxError(const Token *tok) const
|
||||||
{
|
{
|
||||||
printDebugOutput();
|
printDebugOutput(0);
|
||||||
throw InternalError(tok, "syntax error", InternalError::SYNTAX);
|
throw InternalError(tok, "syntax error", InternalError::SYNTAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tokenizer::syntaxError(const Token *tok, char c) const
|
void Tokenizer::syntaxError(const Token *tok, char c) const
|
||||||
{
|
{
|
||||||
printDebugOutput();
|
printDebugOutput(0);
|
||||||
throw InternalError(tok,
|
throw InternalError(tok,
|
||||||
std::string("Invalid number of character (") + c + ") " +
|
std::string("Invalid number of character (") + c + ") " +
|
||||||
"when these macros are defined: '" + _configuration + "'.",
|
"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
|
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);
|
throw InternalError(tok, "Analysis failed. If the code is valid then please report this failure.", InternalError::INTERNAL);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -755,7 +755,12 @@ public:
|
||||||
void createSymbolDatabase();
|
void createSymbolDatabase();
|
||||||
void deleteSymbolDatabase();
|
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;
|
void dump(std::ostream &out) const;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue