Library: Renamed Argument to ArgumentChecks to make it a bit more clear

This commit is contained in:
Daniel Marjamäki 2013-07-16 09:40:31 +02:00
parent 548234ba50
commit fa7f8ddc78
3 changed files with 23 additions and 23 deletions

View File

@ -36,7 +36,7 @@ Library::Library() : allocid(0)
Library::Library(const Library &lib) : Library::Library(const Library &lib) :
use(lib.use), use(lib.use),
ignore(lib.ignore), ignore(lib.ignore),
functionArgument(lib.functionArgument), argumentChecks(lib.argumentChecks),
returnuninitdata(lib.returnuninitdata), returnuninitdata(lib.returnuninitdata),
allocid(lib.allocid), allocid(lib.allocid),
_alloc(lib._alloc), _alloc(lib._alloc),
@ -101,8 +101,8 @@ bool Library::load(const char path[])
else else
return false; return false;
} }
functionArgument[name][nr].notnull = notnull; argumentChecks[name][nr].notnull = notnull;
functionArgument[name][nr].notuninit = notuninit; argumentChecks[name][nr].notuninit = notuninit;
} else } else
return false; return false;
} }

View File

@ -71,21 +71,21 @@ public:
return (it != _noreturn.end() && !it->second); return (it != _noreturn.end() && !it->second);
} }
struct Argument { struct ArgumentChecks {
bool notnull; bool notnull;
bool notuninit; bool notuninit;
}; };
// function name, argument nr => argument data // function name, argument nr => argument data
std::map<std::string, std::map<int, Argument> > functionArgument; std::map<std::string, std::map<int, ArgumentChecks> > argumentChecks;
bool isnullargbad(const std::string &functionName, int argnr) const { bool isnullargbad(const std::string &functionName, int argnr) const {
const Argument *arg = getarg(functionName,argnr); const ArgumentChecks *arg = getarg(functionName,argnr);
return arg && arg->notnull; return arg && arg->notnull;
} }
bool isuninitargbad(const std::string &functionName, int argnr) const { bool isuninitargbad(const std::string &functionName, int argnr) const {
const Argument *arg = getarg(functionName,argnr); const ArgumentChecks *arg = getarg(functionName,argnr);
return arg && arg->notuninit; return arg && arg->notuninit;
} }
@ -97,11 +97,11 @@ private:
std::map<std::string, int> _dealloc; // deallocation functions std::map<std::string, int> _dealloc; // deallocation functions
std::map<std::string, bool> _noreturn; // is function noreturn? std::map<std::string, bool> _noreturn; // is function noreturn?
const Argument * getarg(const std::string &functionName, int argnr) const { const ArgumentChecks * getarg(const std::string &functionName, int argnr) const {
std::map<std::string, std::map<int, Argument> >::const_iterator it1; std::map<std::string, std::map<int, ArgumentChecks> >::const_iterator it1;
it1 = functionArgument.find(functionName); it1 = argumentChecks.find(functionName);
if (it1 != functionArgument.end()) { if (it1 != argumentChecks.end()) {
const std::map<int,Argument>::const_iterator it2 = it1->second.find(argnr); const std::map<int,ArgumentChecks>::const_iterator it2 = it1->second.find(argnr);
if (it2 != it1->second.end()) if (it2 != it1->second.end())
return &it2->second; return &it2->second;
} }

View File

@ -2116,9 +2116,9 @@ private:
// nothing bad.. // nothing bad..
{ {
Library library; Library library;
Library::Argument arg = {false, false}; Library::ArgumentChecks arg = {false, false};
library.functionArgument["x"][1] = arg; library.argumentChecks["x"][1] = arg;
library.functionArgument["x"][2] = arg; library.argumentChecks["x"][2] = arg;
std::list<const Token *> null, uninit; std::list<const Token *> null, uninit;
CheckNullPointer::parseFunctionCall(*xtok, null, &library, 0U); CheckNullPointer::parseFunctionCall(*xtok, null, &library, 0U);
@ -2130,10 +2130,10 @@ private:
// for 1st parameter null pointer is not ok.. // for 1st parameter null pointer is not ok..
{ {
Library library; Library library;
struct Library::Argument arg = {false, false}; struct Library::ArgumentChecks arg = {false, false};
library.functionArgument["x"][1] = arg; library.argumentChecks["x"][1] = arg;
library.functionArgument["x"][2] = arg; library.argumentChecks["x"][2] = arg;
library.functionArgument["x"][1].notnull = true; library.argumentChecks["x"][1].notnull = true;
std::list<const Token *> null,uninit; std::list<const Token *> null,uninit;
CheckNullPointer::parseFunctionCall(*xtok, null, &library, 0U); CheckNullPointer::parseFunctionCall(*xtok, null, &library, 0U);
@ -2146,10 +2146,10 @@ private:
// for 2nd parameter uninit data is not ok.. // for 2nd parameter uninit data is not ok..
{ {
Library library; Library library;
Library::Argument arg = {false, false}; Library::ArgumentChecks arg = {false, false};
library.functionArgument["x"][1] = arg; library.argumentChecks["x"][1] = arg;
library.functionArgument["x"][2] = arg; library.argumentChecks["x"][2] = arg;
library.functionArgument["x"][2].notuninit = true; library.argumentChecks["x"][2].notuninit = true;
std::list<const Token *> null,uninit; std::list<const Token *> null,uninit;
CheckNullPointer::parseFunctionCall(*xtok, null, &library, 0U); CheckNullPointer::parseFunctionCall(*xtok, null, &library, 0U);