Skip to content

Commit bfc0069

Browse files
committed
re-added type debug validation after simplification
1 parent 0eb54ba commit bfc0069

2 files changed

Lines changed: 23 additions & 15 deletions

File tree

lib/tokenize.cpp

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3484,6 +3484,8 @@ bool Tokenizer::simplifyTokens1(const std::string &configuration)
34843484
mSymbolDatabase->setArrayDimensionsUsingValueFlow();
34853485
}
34863486

3487+
validateTypes();
3488+
34873489
printDebugOutput(1, std::cout);
34883490

34893491
return true;
@@ -5926,25 +5928,29 @@ void Tokenizer::printDebugOutput(int simplification, std::ostream &out) const
59265928
if (mSettings.xml)
59275929
out << "</debug>" << std::endl;
59285930
}
5931+
}
59295932

5930-
if (mSymbolDatabase && simplification == 2U && mSettings.debugwarnings) {
5931-
printUnknownTypes();
5933+
void Tokenizer::validateTypes() const
5934+
{
5935+
if (!mSymbolDatabase || !mSettings.debugwarnings)
5936+
return;
59325937

5933-
// the typeStartToken() should come before typeEndToken()
5934-
for (const Variable *var : mSymbolDatabase->variableList()) {
5935-
if (!var)
5936-
continue;
5938+
printUnknownTypes();
59375939

5938-
const Token * typetok = var->typeStartToken();
5939-
while (typetok && typetok != var->typeEndToken())
5940-
typetok = typetok->next();
5940+
// the typeStartToken() should come before typeEndToken()
5941+
for (const Variable *var : mSymbolDatabase->variableList()) {
5942+
if (!var)
5943+
continue;
59415944

5942-
if (typetok != var->typeEndToken()) {
5943-
reportError(var->typeStartToken(),
5944-
Severity::debug,
5945-
"debug",
5946-
"Variable::typeStartToken() of variable '" + var->name() + "' is not located before Variable::typeEndToken(). The location of the typeStartToken() is '" + var->typeStartToken()->str() + "' at line " + std::to_string(var->typeStartToken()->linenr()));
5947-
}
5945+
const Token * typetok = var->typeStartToken();
5946+
while (typetok && typetok != var->typeEndToken())
5947+
typetok = typetok->next();
5948+
5949+
if (typetok != var->typeEndToken()) {
5950+
reportError(var->typeStartToken(),
5951+
Severity::debug,
5952+
"debug",
5953+
"Variable::typeStartToken() of variable '" + var->name() + "' is not located before Variable::typeEndToken(). The location of the typeStartToken() is '" + var->typeStartToken()->str() + "' at line " + std::to_string(var->typeStartToken()->linenr()));
59485954
}
59495955
}
59505956
}

lib/tokenize.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,8 @@ class CPPCHECKLIB Tokenizer {
562562

563563
static bool operatorEnd(const Token * tok);
564564

565+
void validateTypes() const;
566+
565567
public:
566568
const SymbolDatabase *getSymbolDatabase() const {
567569
return mSymbolDatabase;

0 commit comments

Comments
 (0)