Tokenizer: Refactoring, split up the big Tokenizer::setVarId() function

This commit is contained in:
Daniel Marjamäki 2016-05-12 18:20:20 +02:00
parent b04285514f
commit 372763c85e
2 changed files with 21 additions and 9 deletions

View File

@ -2583,12 +2583,6 @@ static void setVarIdClassFunction(const std::string &classname,
} }
// Variable declarations can't start with "return" etc.
static const std::set<std::string> notstart_c = make_container< std::set<std::string> > ()
<< "goto" << "NOT" << "return" << "sizeof"<< "typedef";
static const std::set<std::string> notstart_cpp = make_container< std::set<std::string> > ()
<< notstart_c
<< "delete" << "friend" << "new" << "throw" << "using" << "virtual" << "explicit" << "const_cast" << "dynamic_cast" << "reinterpret_cast" << "static_cast" ;
void Tokenizer::setVarId() void Tokenizer::setVarId()
{ {
@ -2600,6 +2594,21 @@ void Tokenizer::setVarId()
setPodTypes(); setPodTypes();
setVarIdPass1();
setVarIdPass2();
}
// Variable declarations can't start with "return" etc.
static const std::set<std::string> notstart_c = make_container< std::set<std::string> > ()
<< "goto" << "NOT" << "return" << "sizeof"<< "typedef";
static const std::set<std::string> notstart_cpp = make_container< std::set<std::string> > ()
<< notstart_c
<< "delete" << "friend" << "new" << "throw" << "using" << "virtual" << "explicit" << "const_cast" << "dynamic_cast" << "reinterpret_cast" << "static_cast" ;
void Tokenizer::setVarIdPass1()
{
// Variable declarations can't start with "return" etc. // Variable declarations can't start with "return" etc.
const std::set<std::string>& notstart = (isC()) ? notstart_c : notstart_cpp; const std::set<std::string>& notstart = (isC()) ? notstart_c : notstart_cpp;
@ -2841,10 +2850,11 @@ void Tokenizer::setVarId()
tok = tok->previous(); tok = tok->previous();
} }
} }
}
// Clear the structMembers because it will be used when member functions void Tokenizer::setVarIdPass2()
// are parsed. The old info is not bad, it is just redundant. {
structMembers.clear(); std::map<unsigned int, std::map<std::string, unsigned int> > structMembers;
// Member functions and variables in this source // Member functions and variables in this source
std::list<Token *> allMemberFunctions; std::list<Token *> allMemberFunctions;

View File

@ -111,6 +111,8 @@ public:
/** Set variable id */ /** Set variable id */
void setVarId(); void setVarId();
void setVarIdPass1();
void setVarIdPass2();
/** /**
* Basic simplification of tokenlist * Basic simplification of tokenlist