From 7842658cb41ee062045f537eaf491a3e8dad7b00 Mon Sep 17 00:00:00 2001 From: Robert Reif Date: Sun, 18 Jul 2010 20:58:16 +0200 Subject: [PATCH] Refactoring CheckClass::initializeVarList. Ticket #1811 --- lib/checkclass.cpp | 10 ++++++---- lib/checkclass.h | 4 +--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index beb65595d..e6297755b 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -226,8 +226,10 @@ void CheckClass::initVar(Var *varlist, const std::string &varname) } //--------------------------------------------------------------------------- -void CheckClass::initializeVarList(const Token *tok1, const Token *ftok, Var *varlist, const std::string &classname, std::list &callstack, bool isStruct) +void CheckClass::initializeVarList(const Token *tok1, const Token *ftok, Var *varlist, std::list &callstack) { + const std::string &classname = tok1->next()->str(); + bool isStruct = tok1->str() == "struct"; bool Assign = false; unsigned int indentlevel = 0; @@ -361,13 +363,13 @@ void CheckClass::initializeVarList(const Token *tok1, const Token *ftok, Var *va if (ftok2) { callstack.push_back(ftok->str()); - initializeVarList(tok1, ftok2, varlist, classname, callstack, isStruct); + initializeVarList(tok1, ftok2, varlist, callstack); callstack.pop_back(); } else // there is a called member function, but it is not defined where we can find it, so we assume it initializes everything { // check if the function is part of this class.. - const Token *tok = Token::findmatch(_tokenizer->tokens(), ((isStruct ? std::string("struct ") : std::string("class ")) + classname + " {|:").c_str()); + const Token *tok = Token::findmatch(_tokenizer->tokens(), (tok1->str() + " " + classname + " {|:").c_str()); bool derived = false; while (tok && tok->str() != "{") { @@ -761,7 +763,7 @@ void CheckClass::constructors() continue; std::list callstack; - initializeVarList(tok1, it->token, varlist, className, callstack, isStruct); + initializeVarList(tok1, it->token, varlist, callstack); // Check if any variables are uninitialized for (Var *var = varlist; var; var = var->next) diff --git a/lib/checkclass.h b/lib/checkclass.h index 89e4e72f8..4c33b8e7e 100644 --- a/lib/checkclass.h +++ b/lib/checkclass.h @@ -150,11 +150,9 @@ private: * @param tok1 pointer to class declaration * @param ftok pointer to the function that should be checked * @param varlist variable list (the "init" flag will be set in these variables) - * @param classname name of class * @param callstack the function doesn't look into recursive function calls. - * @param isStruct if this is a struct instead of a class */ - void initializeVarList(const Token *tok1, const Token *ftok, Var *varlist, const std::string &classname, std::list &callstack, bool isStruct); + void initializeVarList(const Token *tok1, const Token *ftok, Var *varlist, std::list &callstack); /** @brief initialize a variable in the varlist */ void initVar(Var *varlist, const std::string &varname);