From c531749d7a62a5df0d9a33b48361e5dda027e827 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Tue, 15 Jul 2014 10:36:13 +0200 Subject: [PATCH] ValueFlow: Small cleanups --- lib/valueflow.cpp | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 4c6a01ac6..b9988c40d 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -23,25 +23,13 @@ #include "symboldatabase.h" #include "token.h" #include "tokenlist.h" - -//#include #include - static void execute(const Token *expr, std::map * const programMemory, MathLib::bigint *result, bool *error); -//static void printvalues(const Token *tok) -//{ -// if (tok->values.empty()) -// std::cout << "empty"; -// for (std::list::const_iterator it = tok->values.begin(); it != tok->values.end(); ++it) -// std::cout << " " << (it->intvalue); -// std::cout << std::endl; -//} - static void bailout(TokenList *tokenlist, ErrorLogger *errorLogger, const Token *tok, const std::string &what) { std::list callstack; @@ -794,13 +782,8 @@ static void valueFlowAfterAssign(TokenList *tokenlist, ErrorLogger *errorLogger, const Variable *var = tok->astOperand1()->variable(); if (!var || !var->isLocal()) continue; - const Token * endToken = 0; - for (const Token *tok2 = var->typeStartToken(); tok2; tok2 = tok2->previous()) { - if (tok2->str() == "{") { - endToken = tok2->link(); - break; - } - } + + const Token * const endOfVarScope = var->typeStartToken()->scope()->classEnd; // Rhs values.. if (!tok->astOperand2() || tok->astOperand2()->values.empty()) @@ -808,7 +791,7 @@ static void valueFlowAfterAssign(TokenList *tokenlist, ErrorLogger *errorLogger, std::list values = tok->astOperand2()->values; const bool constValue = tok->astOperand2()->isNumber(); - valueFlowForward(tok, endToken, var, varid, values, constValue, tokenlist, errorLogger, settings); + valueFlowForward(tok, endOfVarScope, var, varid, values, constValue, tokenlist, errorLogger, settings); } }