diff options
author | Roberto Raggi <roberto.raggi@nokia.com> | 2009-08-26 14:22:00 +0200 |
---|---|---|
committer | Roberto Raggi <roberto.raggi@nokia.com> | 2009-08-26 14:22:00 +0200 |
commit | ee16c21067c45ee1e95516c1e164b503129afa53 (patch) | |
tree | f047273677b358360f7af6ef921b70e2668677bc /src/libs/cplusplus/CheckUndefinedSymbols.cpp | |
parent | 68854d81a54bbc68fe574dcbcdcc8b2125c76e14 (diff) | |
download | qt-creator-ee16c21067c45ee1e95516c1e164b503129afa53.tar.gz |
Look at the typedefs defined in local scopes.
Diffstat (limited to 'src/libs/cplusplus/CheckUndefinedSymbols.cpp')
-rw-r--r-- | src/libs/cplusplus/CheckUndefinedSymbols.cpp | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/src/libs/cplusplus/CheckUndefinedSymbols.cpp b/src/libs/cplusplus/CheckUndefinedSymbols.cpp index 19b17c4fbb..ca43b1fb3d 100644 --- a/src/libs/cplusplus/CheckUndefinedSymbols.cpp +++ b/src/libs/cplusplus/CheckUndefinedSymbols.cpp @@ -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(); |