From efe336b6052b278f27838462c749882cb666a18a Mon Sep 17 00:00:00 2001 From: Erik Verbruggen <erik.verbruggen@nokia.com> Date: Fri, 2 Oct 2009 10:28:05 +0200 Subject: [PATCH] Fixed type checking for type definitions inside an @implementation --- src/libs/cplusplus/CheckUndefinedSymbols.cpp | 36 +++++++++++++------- src/libs/cplusplus/CheckUndefinedSymbols.h | 1 + 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/libs/cplusplus/CheckUndefinedSymbols.cpp b/src/libs/cplusplus/CheckUndefinedSymbols.cpp index ca43b1fb3d9..febb19e2723 100644 --- a/src/libs/cplusplus/CheckUndefinedSymbols.cpp +++ b/src/libs/cplusplus/CheckUndefinedSymbols.cpp @@ -135,18 +135,24 @@ void CheckUndefinedSymbols::buildTypeMap(Class *klass) addType(klass->name()); for (unsigned i = 0; i < klass->memberCount(); ++i) { - Symbol *member = klass->memberAt(i); - - if (Class *klass = member->asClass()) { - buildTypeMap(klass); - } else if (Enum *e = member->asEnum()) { - addType(e->name()); - } else if (ForwardClassDeclaration *fwd = member->asForwardClassDeclaration()) { - addType(fwd->name()); - } else if (Declaration *decl = member->asDeclaration()) { - if (decl->isTypedef()) - addType(decl->name()); - } + buildMemberTypeMap(klass->memberAt(i)); + } +} + +void CheckUndefinedSymbols::buildMemberTypeMap(Symbol *member) +{ + if (member == 0) + return; + + if (Class *klass = member->asClass()) { + buildTypeMap(klass); + } else if (Enum *e = member->asEnum()) { + addType(e->name()); + } else if (ForwardClassDeclaration *fwd = member->asForwardClassDeclaration()) { + addType(fwd->name()); + } else if (Declaration *decl = member->asDeclaration()) { + if (decl->isTypedef()) + addType(decl->name()); } } @@ -176,10 +182,16 @@ void CheckUndefinedSymbols::buildTypeMap(NamespaceBinding *binding, QSet<Namespa addType(fKlass->name()); } else if (ObjCClass *klass = member->asObjCClass()) { addType(klass->name()); + + for (unsigned i = 0; i < klass->memberCount(); ++i) + buildMemberTypeMap(klass->memberAt(i)); } else if (ObjCForwardProtocolDeclaration *fProto = member->asObjCForwardProtocolDeclaration()) { addType(fProto->name()); } else if (ObjCProtocol *proto = member->asObjCProtocol()) { addType(proto->name()); + + for (unsigned i = 0; i < proto->memberCount(); ++i) + buildMemberTypeMap(proto->memberAt(i)); } } } diff --git a/src/libs/cplusplus/CheckUndefinedSymbols.h b/src/libs/cplusplus/CheckUndefinedSymbols.h index 3108cda0e6f..745ee50b111 100644 --- a/src/libs/cplusplus/CheckUndefinedSymbols.h +++ b/src/libs/cplusplus/CheckUndefinedSymbols.h @@ -57,6 +57,7 @@ protected: void addType(Name *name); void buildTypeMap(Class *klass); + void buildMemberTypeMap(Symbol *member); void buildTypeMap(NamespaceBinding *binding, QSet<NamespaceBinding *> *processed); FunctionDeclaratorAST *currentFunctionDeclarator() const; -- GitLab