33 unsigned int parlevel = 0;
34 for (
const Token *tok2 = &tok; tok2; tok2 = tok2->
next()) {
35 if (tok2->str() ==
"(")
37 else if (tok2->str() ==
")") {
43 if (tok2->varId() != 0) {
48 for (std::list<ExecutionPath *>::iterator it = checks.begin(); it != checks.end();) {
49 if ((*it)->varId > 0 && (*it)->numberOfIf >= 1) {
64 std::cout <<
" varId=" <<
varId
88 const std::list<ExecutionPath *> &checks,
89 std::list<ExecutionPath *> &newchecks,
90 std::set<unsigned int> &countif)
92 std::set<unsigned int> countif2;
93 std::list<ExecutionPath *> c;
94 if (!checks.empty()) {
95 std::list<ExecutionPath *>::const_iterator it;
96 for (it = checks.begin(); it != checks.end(); ++it) {
97 if ((*it)->numberOfIf == 0)
98 c.push_back((*it)->copy());
99 if ((*it)->varId != 0)
100 countif2.insert((*it)->varId);
105 if (c.back()->varId == 0) {
111 bool duplicate =
false;
112 std::list<ExecutionPath *>::const_iterator it;
113 for (it = checks.begin(); it != checks.end(); ++it) {
114 if (*(*it) == *c.back() && (*it)->numberOfIf == c.back()->numberOfIf) {
116 countif2.erase((*it)->varId);
121 newchecks.push_back(c.back());
128 countif.insert(countif2.begin(), countif2.end());
134 if (!tok || tok->
str() ==
"}" || checks.empty())
137 const std::auto_ptr<ExecutionPath> check(checks.front()->copy());
139 for (; tok; tok = tok->
next()) {
159 if (tok->
str() ==
"}")
162 if (tok->
str() ==
"break") {
169 if (checks.size() > 10 || check->parseCondition(*tok->
tokAt(2), checks)) {
193 if (tok->
str() ==
"?") {
194 for (
const Token *tok2 = tok; tok2 && tok2->
str() !=
";"; tok2 = tok2->next()) {
195 if (tok2->varId() > 0)
204 if (tok2 && tok2->
str() ==
"(")
206 if (tok2 && tok2->
str() ==
")")
208 if (!tok2 || tok2->
str() !=
"{") {
213 if (tok->
str() ==
"switch") {
215 if (checks.size() > 10 || check->parseCondition(*tok->
next(), checks)) {
221 std::set<unsigned int> countif;
223 std::list<ExecutionPath *> newchecks;
225 for (
const Token* tok3 = tok2->
next(); tok3; tok3 = tok3->
next()) {
226 if (tok3->str() ==
"{")
228 else if (tok3->str() ==
"}")
230 else if (tok3->str() ==
"case" &&
237 std::copy(newchecks.begin(), newchecks.end(), std::back_inserter(checks));
240 std::list<ExecutionPath *>::iterator it;
241 for (it = checks.begin(); it != checks.end(); ++it) {
242 if (countif.find((*it)->varId) != countif.end())
248 for (
const Token *tok3 = tok; tok3 && tok3 != tok2; tok3 = tok3->
next()) {
254 for (std::list<ExecutionPath *>::iterator it = checks.begin(); it != checks.end();) {
255 if ((*it)->numberOfIf > 0) {
276 if (t && t->
tokAt(3) == tok4) {
277 for (std::list<ExecutionPath *>::iterator it = checks.begin(); it != checks.end(); ++it) {
278 if ((*it)->varId == tok3->
next()->
varId()) {
291 check->parseLoopBody(tok2->
next(), checks);
303 for (; tok && tok != tok2; tok = tok->
next()) {
304 if (tok->
str() ==
"return")
317 if (tok2 && tok2->
str() ==
"{") {
322 for (; tok && tok != tok2; tok = tok->
next()) {
332 if (tok->
str() ==
")" && tok->
next() && tok->
next()->
str() ==
"{") {
337 if ((tok->
str() ==
"abort" || tok->
str() ==
"exit") &&
344 if (
Token::Match(tok,
"struct|union|class %type% {|:")) {
345 while (tok && tok->
str() !=
"{" && tok->
str() !=
";")
347 tok = tok ? tok->
link() : 0;
362 while (tok && tok != end) {
381 if (tok->
str() ==
"if" && tok->
next() && tok->
next()->
str() ==
"(") {
383 std::set<unsigned int> countif;
385 std::list<ExecutionPath *> newchecks;
386 while (tok->
str() ==
"if" && tok->
next() && tok->
next()->
str() ==
"(") {
391 if (checks.size() > 10 || check->parseCondition(*tok->
next(), checks)) {
403 if (!tok || tok->
str() !=
"{") {
416 if (!tok->next() || tok->next()->str() !=
"else")
425 if (tok->str() ==
"if")
438 std::copy(newchecks.begin(), newchecks.end(), std::back_inserter(checks));
441 std::list<ExecutionPath *>::iterator it;
442 for (it = checks.begin(); it != checks.end(); ++it) {
443 if (countif.find((*it)->varId) != countif.end())
448 for (it = checks.begin(); it != checks.end();) {
449 if ((*it)->varId > 0 && (*it)->numberOfIf >= 2) {
458 tok = check->parse(*tok, checks);
459 if (!tok || checks.empty())
463 if (tok->
str() ==
"return" ||
464 tok->
str() ==
"throw" ||
465 tok->
str() ==
"continue" ||
466 tok->
str() ==
"break") {
474 for (std::list<Scope>::const_iterator i = symbolDatabase->
scopeList.begin(); i != symbolDatabase->
scopeList.end(); ++i) {
479 std::list<ExecutionPath *> checks;
480 checks.push_back(c->
copy());
483 c->
end(checks, i->classEnd);
486 while (!checks.empty()) {
487 delete checks.back();