forked from qt-creator/qt-creator
Look at the typedefs defined in local scopes.
This commit is contained in:
@@ -84,14 +84,32 @@ QByteArray CheckUndefinedSymbols::templateParameterName(DeclarationAST *ast) con
|
|||||||
|
|
||||||
bool CheckUndefinedSymbols::isType(const QByteArray &name) const
|
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) {
|
for (int i = _templateDeclarationStack.size() - 1; i != - 1; --i) {
|
||||||
TemplateDeclarationAST *templateDeclaration = _templateDeclarationStack.at(i);
|
TemplateDeclarationAST *templateDeclaration = _templateDeclarationStack.at(i);
|
||||||
|
|
||||||
for (DeclarationListAST *it = templateDeclaration->template_parameters; it; it = it->next) {
|
for (DeclarationListAST *it = templateDeclaration->template_parameters; it; it = it->next) {
|
||||||
DeclarationAST *templateParameter = it->declaration;
|
DeclarationAST *templateParameter = it->declaration;
|
||||||
|
|
||||||
if (templateParameterName(templateParameter) == name)
|
if (templateParameterName(templateParameter) == name)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return _types.contains(name);
|
return _types.contains(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,10 +198,17 @@ FunctionDeclaratorAST *CheckUndefinedSymbols::currentFunctionDeclarator() const
|
|||||||
return _functionDeclaratorStack.last();
|
return _functionDeclaratorStack.last();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CompoundStatementAST *CheckUndefinedSymbols::compoundStatement() const
|
||||||
|
{
|
||||||
|
if (_compoundStatementStack.isEmpty())
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return _compoundStatementStack.last();
|
||||||
|
}
|
||||||
|
|
||||||
bool CheckUndefinedSymbols::visit(FunctionDeclaratorAST *ast)
|
bool CheckUndefinedSymbols::visit(FunctionDeclaratorAST *ast)
|
||||||
{
|
{
|
||||||
_functionDeclaratorStack.append(ast);
|
_functionDeclaratorStack.append(ast);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -289,6 +314,17 @@ bool CheckUndefinedSymbols::visit(FunctionDefinitionAST *ast)
|
|||||||
void CheckUndefinedSymbols::endVisit(FunctionDefinitionAST *)
|
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)
|
bool CheckUndefinedSymbols::visit(SimpleDeclarationAST *ast)
|
||||||
{
|
{
|
||||||
const bool check = qobjectCheck();
|
const bool check = qobjectCheck();
|
||||||
|
@@ -58,7 +58,9 @@ protected:
|
|||||||
void addType(Name *name);
|
void addType(Name *name);
|
||||||
void buildTypeMap(Class *klass);
|
void buildTypeMap(Class *klass);
|
||||||
void buildTypeMap(NamespaceBinding *binding, QSet<NamespaceBinding *> *processed);
|
void buildTypeMap(NamespaceBinding *binding, QSet<NamespaceBinding *> *processed);
|
||||||
|
|
||||||
FunctionDeclaratorAST *currentFunctionDeclarator() const;
|
FunctionDeclaratorAST *currentFunctionDeclarator() const;
|
||||||
|
CompoundStatementAST *compoundStatement() const;
|
||||||
bool qobjectCheck() const;
|
bool qobjectCheck() const;
|
||||||
|
|
||||||
QByteArray templateParameterName(NameAST *ast) const;
|
QByteArray templateParameterName(NameAST *ast) const;
|
||||||
@@ -79,6 +81,9 @@ protected:
|
|||||||
virtual bool visit(FunctionDefinitionAST *ast);
|
virtual bool visit(FunctionDefinitionAST *ast);
|
||||||
virtual void endVisit(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(SimpleDeclarationAST *ast);
|
||||||
virtual bool visit(BaseSpecifierAST *base);
|
virtual bool visit(BaseSpecifierAST *base);
|
||||||
virtual bool visit(UsingDirectiveAST *ast);
|
virtual bool visit(UsingDirectiveAST *ast);
|
||||||
@@ -92,6 +97,7 @@ private:
|
|||||||
QList<bool> _qobjectStack;
|
QList<bool> _qobjectStack;
|
||||||
QList<FunctionDeclaratorAST *> _functionDeclaratorStack;
|
QList<FunctionDeclaratorAST *> _functionDeclaratorStack;
|
||||||
QList<TemplateDeclarationAST *> _templateDeclarationStack;
|
QList<TemplateDeclarationAST *> _templateDeclarationStack;
|
||||||
|
QList<CompoundStatementAST *> _compoundStatementStack;
|
||||||
QSet<QByteArray> _types;
|
QSet<QByteArray> _types;
|
||||||
QSet<QByteArray> _namespaceNames;
|
QSet<QByteArray> _namespaceNames;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user