From ad45ba718c6ee24bbced033f58187482b87a77bc Mon Sep 17 00:00:00 2001 From: Robert Reif Date: Sun, 14 Aug 2011 10:39:45 -0400 Subject: [PATCH] convert CheckOther::checkCharVariable() to use symbol database --- lib/checkother.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index edee091fd..3086a48cc 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -2887,6 +2887,8 @@ void CheckOther::checkCharVariable() if (!_settings->isEnabled("style")) return; + const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase(); + for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) { // Declaring the variable.. @@ -2948,7 +2950,8 @@ void CheckOther::checkCharVariable() } // is the result stored in a short|int|long? - if (!Token::findmatch(_tokenizer->tokens(), "short|int|long %varid%", tok2->next()->varId())) + const Variable *var = symbolDatabase->getVariableFromVarId(tok2->next()->varId()); + if (!(var && Token::Match(var->typeEndToken(), "short|int|long"))) continue; // This is an error.. @@ -2963,7 +2966,8 @@ void CheckOther::checkCharVariable() continue; // is the result stored in a short|int|long? - if (!Token::findmatch(_tokenizer->tokens(), "short|int|long %varid%", tok2->next()->varId())) + const Variable *var = symbolDatabase->getVariableFromVarId(tok2->next()->varId()); + if (!(var && Token::Match(var->typeEndToken(), "short|int|long"))) continue; // This is an error..