SymbolDatabase: Improved find function functionality. Taking arguments into account
This commit is contained in:
parent
0d4b87c71e
commit
cf7996e299
|
@ -1569,19 +1569,6 @@ void SymbolDatabase::printOut(const char *title) const
|
|||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
unsigned int Function::initializedArgCount() const
|
||||
{
|
||||
unsigned int count = 0;
|
||||
std::list<Variable>::const_iterator var;
|
||||
|
||||
for (var = argumentList.begin(); var != argumentList.end(); ++var) {
|
||||
if (var->hasDefault())
|
||||
++count;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
void Function::addArguments(const SymbolDatabase *symbolDatabase, const Scope *scope)
|
||||
{
|
||||
// check for non-empty argument list "( ... )"
|
||||
|
@ -1642,6 +1629,7 @@ void Function::addArguments(const SymbolDatabase *symbolDatabase, const Scope *s
|
|||
|
||||
// skip default values
|
||||
if (tok->str() == "=") {
|
||||
initArgCount++;
|
||||
while (tok->str() != "," && tok->str() != ")") {
|
||||
if (tok->link() && Token::Match(tok, "[{[(<]"))
|
||||
tok = tok->link();
|
||||
|
@ -2175,8 +2163,7 @@ const Function* SymbolDatabase::findFunctionByNameAndArgs(const Token *tok, cons
|
|||
const Function *func = &*i;
|
||||
if (tok->strAt(1) == "(" && tok->tokAt(2)) {
|
||||
// check if function has no arguments
|
||||
/** @todo check for default arguments */
|
||||
if (tok->strAt(2) == ")" && func->argCount() == 0)
|
||||
if (tok->strAt(2) == ")" && (func->argCount() == 0 || func->argCount() == func->initializedArgCount()))
|
||||
return func;
|
||||
|
||||
// check the arguments
|
||||
|
@ -2184,6 +2171,7 @@ const Function* SymbolDatabase::findFunctionByNameAndArgs(const Token *tok, cons
|
|||
const Token *arg = tok->tokAt(2);
|
||||
while (arg) {
|
||||
/** @todo check argument type for match */
|
||||
/** @todo check for default arguments */
|
||||
args++;
|
||||
arg = arg->nextArgument();
|
||||
}
|
||||
|
|
|
@ -379,6 +379,7 @@ public:
|
|||
arg(NULL),
|
||||
functionScope(NULL),
|
||||
nestedIn(NULL),
|
||||
initArgCount(0),
|
||||
type(eFunction),
|
||||
access(Public),
|
||||
hasBody(false),
|
||||
|
@ -397,7 +398,9 @@ public:
|
|||
return argumentList.size();
|
||||
}
|
||||
const Variable* getArgumentVar(unsigned int num) const;
|
||||
unsigned int initializedArgCount() const;
|
||||
unsigned int initializedArgCount() const {
|
||||
return initArgCount;
|
||||
}
|
||||
void addArguments(const SymbolDatabase *symbolDatabase, const Scope *scope);
|
||||
/** @brief check if this function is virtual in the base classes */
|
||||
bool isImplicitlyVirtual(bool defaultVal = false) const;
|
||||
|
@ -409,6 +412,7 @@ public:
|
|||
Scope *functionScope; // scope of function body
|
||||
Scope* nestedIn; // Scope the function is declared in
|
||||
std::list<Variable> argumentList; // argument list
|
||||
unsigned int initArgCount; // number of args with default values
|
||||
Type type; // constructor, destructor, ...
|
||||
AccessControl access; // public/protected/private
|
||||
bool hasBody; // has implementation
|
||||
|
|
Loading…
Reference in New Issue