diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 498425beb..3cac50b24 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -1330,12 +1330,9 @@ private: std::list::const_iterator it; for (it = checks.begin(); it != checks.end(); ++it) { - if (!(*it)->bailOut()) - { - CheckUninitVar *c = dynamic_cast(*it); - if (c && c->varId == varid) - c->alloc = true; - } + CheckUninitVar *c = dynamic_cast(*it); + if (c && c->varId == varid) + c->alloc = true; } } @@ -1349,21 +1346,18 @@ private: std::list::iterator it = checks.begin(); while (it != checks.end()) { - if (!(*it)->bailOut()) + CheckUninitVar *c = dynamic_cast(*it); + if (c && c->varId == varid) { - CheckUninitVar *c = dynamic_cast(*it); - if (c && c->varId == varid) + if (c->alloc) { - if (c->alloc) - { - delete c; - checks.erase(it++); - continue; - } - else - { - use_pointer(foundError, checks, tok); - } + delete c; + checks.erase(it++); + continue; + } + else + { + use_pointer(foundError, checks, tok); } } @@ -1381,23 +1375,20 @@ private: std::list::const_iterator it; for (it = checks.begin(); it != checks.end(); ++it) { - if (!(*it)->bailOut()) + CheckUninitVar *c = dynamic_cast(*it); + if (c && c->varId == varid) { - CheckUninitVar *c = dynamic_cast(*it); - if (c && c->varId == varid) + if (!c->alloc) { - if (!c->alloc) + CheckOther *checkOther = dynamic_cast(c->owner); + if (checkOther) { - CheckOther *checkOther = dynamic_cast(c->owner); - if (checkOther) - { - foundError = true; - checkOther->uninitvarError(tok, c->varname); - break; - } + foundError = true; + checkOther->uninitvarError(tok, c->varname); + break; } - c->alloc = false; } + c->alloc = false; } } } @@ -1418,33 +1409,30 @@ private: std::list::const_iterator it; for (it = checks.begin(); it != checks.end(); ++it) { - if (!(*it)->bailOut()) + CheckUninitVar *c = dynamic_cast(*it); + if (c && c->varId == varid) { - CheckUninitVar *c = dynamic_cast(*it); - if (c && c->varId == varid) + // mode 0 : the variable is used "directly" + // example: .. = var; + // it is ok to read the address of an uninitialized array. + // it is ok to read the address of an allocated pointer + if (mode == 0 && (c->array || (c->pointer && c->alloc))) + continue; + + // mode 2 : bad usage of pointer. if it's not a pointer then the usage is ok. + // example: ptr->foo(); + if (mode == 2 && !c->pointer) + continue; + + CheckOther *checkOther = dynamic_cast(c->owner); + if (checkOther) { - // mode 0 : the variable is used "directly" - // example: .. = var; - // it is ok to read the address of an uninitialized array. - // it is ok to read the address of an allocated pointer - if (mode == 0 && (c->array || (c->pointer && c->alloc))) - continue; - - // mode 2 : bad usage of pointer. if it's not a pointer then the usage is ok. - // example: ptr->foo(); - if (mode == 2 && !c->pointer) - continue; - - CheckOther *checkOther = dynamic_cast(c->owner); - if (checkOther) - { - if (c->pointer && c->alloc) - checkOther->uninitdataError(tok, c->varname); - else - checkOther->uninitvarError(tok, c->varname); - foundError = true; - break; - } + if (c->pointer && c->alloc) + checkOther->uninitdataError(tok, c->varname); + else + checkOther->uninitvarError(tok, c->varname); + foundError = true; + break; } } } diff --git a/lib/executionpath.cpp b/lib/executionpath.cpp index 72b9724ca..f4a4a43e7 100644 --- a/lib/executionpath.cpp +++ b/lib/executionpath.cpp @@ -175,19 +175,6 @@ static const Token *checkExecutionPaths_(const Token *tok, std::listparse(*tok, foundError, checks); - std::list::iterator it; - for (it = checks.begin(); it != checks.end();) - { - if ((*it)->bailOut()) - { - delete *it; - it = checks.erase(it); - } - else - { - ++it; - } - } if (checks.empty()) return 0; else if (foundError) diff --git a/lib/executionpath.h b/lib/executionpath.h index 00c802e4c..6672baf55 100644 --- a/lib/executionpath.h +++ b/lib/executionpath.h @@ -31,8 +31,6 @@ class Check; class ExecutionPath { private: - bool bailout_; - /** No implementation */ void operator=(const ExecutionPath &); @@ -41,7 +39,7 @@ protected: Check * const owner; public: - ExecutionPath(Check *c, unsigned int id) : bailout_(false), varId(id), owner(c), ifinfo(0) + ExecutionPath(Check *c, unsigned int id) : varId(id), owner(c), ifinfo(0) { } virtual ~ExecutionPath() @@ -53,11 +51,6 @@ public: /** Some kind of if-information */ unsigned int ifinfo; - bool bailOut() const - { - return bailout_; - } - /** * bail out all execution paths * @param checks the execution paths to bail out on