Skip to content

Commit cb016e7

Browse files
committed
moved some --debug --verbose logic out of Tokenizer
1 parent 291c053 commit cb016e7

2 files changed

Lines changed: 16 additions & 6 deletions

File tree

cli/cmdlineparser.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,7 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
446446

447447
bool def = false;
448448
bool maxconfigs = false;
449+
bool debug = false;
449450

450451
ImportProject::Type projectType = ImportProject::Type::NONE;
451452
ImportProject project;
@@ -651,6 +652,9 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
651652
mSettings.cppHeaderProbe = true;
652653
}
653654

655+
else if (std::strcmp(argv[i], "--debug") == 0)
656+
debug = true;
657+
654658
else if (std::strcmp(argv[i], "--debug-ast") == 0)
655659
mSettings.debugast = true;
656660

@@ -663,8 +667,7 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
663667
mSettings.debugignore = true;
664668

665669
// Show --debug output after the first simplifications
666-
else if (std::strcmp(argv[i], "--debug") == 0 ||
667-
std::strcmp(argv[i], "--debug-normal") == 0)
670+
else if (std::strcmp(argv[i], "--debug-normal") == 0)
668671
mSettings.debugnormal = true;
669672

670673
// Show debug warnings for lookup for configuration files
@@ -1610,10 +1613,17 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
16101613

16111614
if (mSettings.force)
16121615
mSettings.maxConfigs = INT_MAX;
1613-
16141616
else if ((def || mSettings.preprocessOnly) && !maxconfigs)
16151617
mSettings.maxConfigs = 1U;
16161618

1619+
if (debug) {
1620+
mSettings.debugnormal = true;
1621+
if (mSettings.verbose) {
1622+
mSettings.debugast = true;
1623+
mSettings.debugsymdb = true;
1624+
}
1625+
}
1626+
16171627
if (mSettings.jobs > 1 && mSettings.buildDir.empty()) {
16181628
// TODO: bail out instead?
16191629
if (mSettings.checks.isEnabled(Checks::unusedFunction))

lib/tokenize.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5938,7 +5938,6 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
59385938
}
59395939
//---------------------------------------------------------------------------
59405940

5941-
// TODO: do not depend on --verbose
59425941
void Tokenizer::printDebugOutput(std::ostream &out) const
59435942
{
59445943
if (!list.front())
@@ -5959,11 +5958,12 @@ void Tokenizer::printDebugOutput(std::ostream &out) const
59595958
if (mSymbolDatabase) {
59605959
if (xml)
59615960
mSymbolDatabase->printXml(out);
5962-
else if (mSettings.debugsymdb || (mSettings.debugnormal && mSettings.verbose))
5961+
else if (mSettings.debugsymdb)
59635962
mSymbolDatabase->printOut("Symbol database");
59645963
}
59655964

5966-
if (mSettings.debugast || (mSettings.debugnormal && mSettings.verbose))
5965+
// TODO: do not depend on --verbose
5966+
if (mSettings.debugast)
59675967
list.front()->printAst(mSettings.verbose, xml, list.getFiles(), out);
59685968

59695969
if (mSettings.debugnormal || mSettings.debugvalueflow)

0 commit comments

Comments
 (0)