Commit ee16c210 authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Look at the typedefs defined in local scopes.

parent 68854d81
......@@ -84,14 +84,32 @@ QByteArray CheckUndefinedSymbols::templateParameterName(DeclarationAST *ast) con
bool CheckUndefinedSymbols::isType(const QByteArray &name) const
{
for (int i = _compoundStatementStack.size() - 1; i != -1; --i) {
Scope *members = _compoundStatementStack.at(i)->symbol->members();
for (unsigned m = 0; m < members->symbolCount(); ++m) {
Symbol *member = members->symbolAt(m);
if (member->isTypedef() && member->isDeclaration()) {
if (Identifier *id = member->identifier()) {
if (name == id->chars())
return true;
}
}
}
}
for (int i = _templateDeclarationStack.size() - 1; i != - 1; --i) {
TemplateDeclarationAST *templateDeclaration = _templateDeclarationStack.at(i);
for (DeclarationListAST *it = templateDeclaration->template_parameters; it; it = it->next) {
DeclarationAST *templateParameter = it->declaration;
if (templateParameterName(templateParameter) == name)
return true;
}
}
return _types.contains(name);
}
......@@ -180,10 +198,17 @@ FunctionDeclaratorAST *CheckUndefinedSymbols::currentFunctionDeclarator() const
return _functionDeclaratorStack.last();
}
CompoundStatementAST *CheckUndefinedSymbols::compoundStatement() const
{
if (_compoundStatementStack.isEmpty())
return 0;
return _compoundStatementStack.last();
}
bool CheckUndefinedSymbols::visit(FunctionDeclaratorAST *ast)
{
_functionDeclaratorStack.append(ast);
return true;
}
......@@ -289,6 +314,17 @@ bool CheckUndefinedSymbols::visit(FunctionDefinitionAST *ast)
void CheckUndefinedSymbols::endVisit(FunctionDefinitionAST *)
{ }
bool CheckUndefinedSymbols::visit(CompoundStatementAST *ast)
{
_compoundStatementStack.append(ast);
return true;
}
void CheckUndefinedSymbols::endVisit(CompoundStatementAST *)
{
_compoundStatementStack.removeLast();
}
bool CheckUndefinedSymbols::visit(SimpleDeclarationAST *ast)
{
const bool check = qobjectCheck();
......
......@@ -58,7 +58,9 @@ protected:
void addType(Name *name);
void buildTypeMap(Class *klass);
void buildTypeMap(NamespaceBinding *binding, QSet<NamespaceBinding *> *processed);
FunctionDeclaratorAST *currentFunctionDeclarator() const;
CompoundStatementAST *compoundStatement() const;
bool qobjectCheck() const;
QByteArray templateParameterName(NameAST *ast) const;
......@@ -79,6 +81,9 @@ protected:
virtual bool visit(FunctionDefinitionAST *ast);
virtual void endVisit(FunctionDefinitionAST *ast);
virtual bool visit(CompoundStatementAST *ast);
virtual void endVisit(CompoundStatementAST *ast);
virtual bool visit(SimpleDeclarationAST *ast);
virtual bool visit(BaseSpecifierAST *base);
virtual bool visit(UsingDirectiveAST *ast);
......@@ -92,6 +97,7 @@ private:
QList<bool> _qobjectStack;
QList<FunctionDeclaratorAST *> _functionDeclaratorStack;
QList<TemplateDeclarationAST *> _templateDeclarationStack;
QList<CompoundStatementAST *> _compoundStatementStack;
QSet<QByteArray> _types;
QSet<QByteArray> _namespaceNames;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment