diff --git a/src/libs/cplusplus/CheckUndefinedSymbols.cpp b/src/libs/cplusplus/CheckUndefinedSymbols.cpp index 30a08ea884f9d2900886ecd46b5a34fe765561ad..9368aa43fa41098139dc61498ea58b4e0321b8d0 100644 --- a/src/libs/cplusplus/CheckUndefinedSymbols.cpp +++ b/src/libs/cplusplus/CheckUndefinedSymbols.cpp @@ -498,8 +498,8 @@ bool CheckUndefinedSymbols::visit(ObjCClassDeclarationAST *ast) bool CheckUndefinedSymbols::visit(ObjCProtocolRefsAST *ast) { - for (IdentifierListAST *iter = ast->identifier_list; iter; iter = iter->next) { - if (NameAST *nameAST = iter->name) { + for (ObjCIdentifierListAST *iter = ast->identifier_list; iter; iter = iter->next) { + if (NameAST *nameAST = iter->value) { bool resolvedProtocolName = false; if (Name *name = nameAST->name) { diff --git a/src/shared/cplusplus/AST.cpp b/src/shared/cplusplus/AST.cpp index f47158ce407e18edd90c0dd5a216451e2bbfb9dd..4cefd9a012998859b51aaae71743ecf0ce0bddb3 100644 --- a/src/shared/cplusplus/AST.cpp +++ b/src/shared/cplusplus/AST.cpp @@ -1816,26 +1816,6 @@ unsigned WhileStatementAST::lastToken() const } // ObjC++ -unsigned IdentifierListAST::firstToken() const -{ - if (name) - return name->firstToken(); - // ### assert? - return 0; -} - -unsigned IdentifierListAST::lastToken() const -{ - for (const IdentifierListAST *it = this; it; it = it->next) { - if (! it->next && it->name) { - return it->name->lastToken(); - } - } - // ### assert? - return 0; -} - - unsigned ObjCClassForwardDeclarationAST::firstToken() const { if (attributes) @@ -1848,9 +1828,9 @@ unsigned ObjCClassForwardDeclarationAST::lastToken() const if (semicolon_token) return semicolon_token + 1; - for (IdentifierListAST *it = identifier_list; it; it = it->next) { - if (! it->next && it->name) - return it->name->lastToken(); + for (ObjCIdentifierListAST *it = identifier_list; it; it = it->next) { + if (! it->next && it->value) + return it->value->lastToken(); } return class_token + 1; @@ -1868,9 +1848,9 @@ unsigned ObjCProtocolForwardDeclarationAST::lastToken() const if (semicolon_token) return semicolon_token + 1; - for (IdentifierListAST *it = identifier_list; it; it = it->next) { - if (! it->next && it->name) - return it->name->lastToken(); + for (ObjCIdentifierListAST *it = identifier_list; it; it = it->next) { + if (! it->next && it->value) + return it->value->lastToken(); } return protocol_token + 1; @@ -1949,9 +1929,9 @@ unsigned ObjCProtocolRefsAST::lastToken() const { if (greater_token) return greater_token + 1; - for (IdentifierListAST *it = identifier_list; it; it = it->next) { - if (! it->next && it->name) - return it->name->lastToken(); + for (ObjCIdentifierListAST *it = identifier_list; it; it = it->next) { + if (! it->next && it->value) + return it->value->lastToken(); } return less_token + 1; diff --git a/src/shared/cplusplus/AST.h b/src/shared/cplusplus/AST.h index 10aa1a0c7bce313f71f40cea4371c15654d70efc..084913fc91f713290aa4274935522e79f4dc8c10 100644 --- a/src/shared/cplusplus/AST.h +++ b/src/shared/cplusplus/AST.h @@ -164,7 +164,7 @@ public: virtual FunctionDeclaratorAST *asFunctionDeclarator() { return 0; } virtual FunctionDefinitionAST *asFunctionDefinition() { return 0; } virtual GotoStatementAST *asGotoStatement() { return 0; } - virtual IdentifierListAST *asIdentifierList() { return 0; } + virtual ObjCIdentifierListAST *asIdentifierList() { return 0; } virtual IfStatementAST *asIfStatement() { return 0; } virtual LabeledStatementAST *asLabeledStatement() { return 0; } virtual LinkageBodyAST *asLinkageBody() { return 0; } @@ -2084,30 +2084,12 @@ protected: virtual void accept0(ASTVisitor *visitor); }; - -// ObjC++ -class CPLUSPLUS_EXPORT IdentifierListAST: public AST -{ -public: - NameAST *name; - IdentifierListAST *next; - -public: - virtual IdentifierListAST *asIdentifierList() { return this; } - - virtual unsigned firstToken() const; - virtual unsigned lastToken() const; - -protected: - virtual void accept0(ASTVisitor *visitor); -}; - class CPLUSPLUS_EXPORT ObjCClassForwardDeclarationAST: public DeclarationAST { public: SpecifierAST *attributes; unsigned class_token; - IdentifierListAST *identifier_list; + ObjCIdentifierListAST *identifier_list; unsigned semicolon_token; public: // annotations @@ -2158,7 +2140,7 @@ class CPLUSPLUS_EXPORT ObjCProtocolForwardDeclarationAST: public DeclarationAST public: SpecifierAST *attributes; unsigned protocol_token; - IdentifierListAST *identifier_list; + ObjCIdentifierListAST *identifier_list; unsigned semicolon_token; public: // annotations @@ -2201,7 +2183,7 @@ class CPLUSPLUS_EXPORT ObjCProtocolRefsAST: public AST { public: unsigned less_token; - IdentifierListAST *identifier_list; + ObjCIdentifierListAST *identifier_list; unsigned greater_token; public: @@ -2621,7 +2603,7 @@ class CPLUSPLUS_EXPORT ObjCDynamicPropertiesDeclarationAST: public DeclarationAS { public: unsigned dynamic_token; - IdentifierListAST *property_identifiers; + ObjCIdentifierListAST *property_identifiers; unsigned semicolon_token; public: diff --git a/src/shared/cplusplus/ASTVisit.cpp b/src/shared/cplusplus/ASTVisit.cpp index f6b0bfb9b8ceb85d32f8f922813071df2b5d9203..8095946f0a2a024b407153c46a2dad8deb69853d 100644 --- a/src/shared/cplusplus/ASTVisit.cpp +++ b/src/shared/cplusplus/ASTVisit.cpp @@ -890,20 +890,12 @@ void WhileStatementAST::accept0(ASTVisitor *visitor) visitor->endVisit(this); } -void IdentifierListAST::accept0(ASTVisitor *visitor) -{ - if (visitor->visit(this)) { - accept(name, visitor); - } - visitor->endVisit(this); -} - void ObjCClassForwardDeclarationAST::accept0(ASTVisitor *visitor) { if (visitor->visit(this)) { for (SpecifierAST *it = attributes; it; it = it->next) accept(it, visitor); - for (IdentifierListAST *it = identifier_list; it; it = it->next) + for (ObjCIdentifierListAST *it = identifier_list; it; it = it->next) accept(it, visitor); } visitor->endVisit(this); @@ -930,7 +922,7 @@ void ObjCProtocolForwardDeclarationAST::accept0(ASTVisitor *visitor) if (visitor->visit(this)) { for (SpecifierAST *it = attributes; it; it = it->next) accept(it, visitor); - for (IdentifierListAST *it = identifier_list; it; it = it->next) + for (ObjCIdentifierListAST *it = identifier_list; it; it = it->next) accept(it, visitor); } visitor->endVisit(this); @@ -952,7 +944,7 @@ void ObjCProtocolDeclarationAST::accept0(ASTVisitor *visitor) void ObjCProtocolRefsAST::accept0(ASTVisitor *visitor) { if (visitor->visit(this)) { - for (IdentifierListAST *it = identifier_list; it; it = it->next) + for (ObjCIdentifierListAST *it = identifier_list; it; it = it->next) accept(it, visitor); } visitor->endVisit(this); @@ -1158,7 +1150,7 @@ void ObjCSynthesizedPropertiesDeclarationAST::accept0(ASTVisitor *visitor) void ObjCDynamicPropertiesDeclarationAST::accept0(ASTVisitor *visitor) { if (visitor->visit(this)) { - for (IdentifierListAST *it = property_identifiers; it; it = it->next) + for (ObjCIdentifierListAST *it = property_identifiers; it; it = it->next) accept(it, visitor); } visitor->endVisit(this); diff --git a/src/shared/cplusplus/ASTVisitor.h b/src/shared/cplusplus/ASTVisitor.h index ed61ea2a142bf85334c412cf0270dbfed58227f7..fff0c9f7d52c9208f2df6982b10eb8e032253bb2 100644 --- a/src/shared/cplusplus/ASTVisitor.h +++ b/src/shared/cplusplus/ASTVisitor.h @@ -192,7 +192,7 @@ public: virtual bool visit(QtMethodAST *) { return true; } // ObjC++ - virtual bool visit(IdentifierListAST *) { return true; } + virtual bool visit(ObjCIdentifierListAST *) { return true; } virtual bool visit(ObjCClassDeclarationAST *) { return true; } virtual bool visit(ObjCClassForwardDeclarationAST *) { return true; } virtual bool visit(ObjCProtocolDeclarationAST *) { return true; } @@ -323,7 +323,7 @@ public: virtual void endVisit(QtMethodAST *) { } // ObjC++ - virtual void endVisit(IdentifierListAST *) { } + virtual void endVisit(ObjCIdentifierListAST *) { } virtual void endVisit(ObjCClassDeclarationAST *) { } virtual void endVisit(ObjCClassForwardDeclarationAST *) { } virtual void endVisit(ObjCProtocolDeclarationAST *) { } diff --git a/src/shared/cplusplus/ASTfwd.h b/src/shared/cplusplus/ASTfwd.h index 50ab749ee5cf87d12b7f9be3b624fceb4013b0dc..c562384bf9a3d28c8ba381dbb02dc61a3ff5b7b3 100644 --- a/src/shared/cplusplus/ASTfwd.h +++ b/src/shared/cplusplus/ASTfwd.h @@ -104,7 +104,6 @@ class ForeachStatementAST; class FunctionDeclaratorAST; class FunctionDefinitionAST; class GotoStatementAST; -class IdentifierListAST; class IfStatementAST; class LabeledStatementAST; class LinkageBodyAST; @@ -201,6 +200,8 @@ typedef List<ExpressionAST *> ExpressionListAST; typedef List<DeclarationAST *> DeclarationListAST; typedef List<StatementAST *> StatementListAST; typedef List<DeclaratorAST *> DeclaratorListAST; +typedef List<NameAST *> ObjCIdentifierListAST; + typedef ExpressionListAST TemplateArgumentListAST; } // end of namespace CPlusPlus diff --git a/src/shared/cplusplus/CheckDeclaration.cpp b/src/shared/cplusplus/CheckDeclaration.cpp index 7adcde83bc04d41371e49fcc2b34e679d4f7426c..6dc9c9a75b923079678e7863a2cf6b4a51669a3f 100644 --- a/src/shared/cplusplus/CheckDeclaration.cpp +++ b/src/shared/cplusplus/CheckDeclaration.cpp @@ -501,14 +501,14 @@ bool CheckDeclaration::visit(ObjCProtocolForwardDeclarationAST *ast) const unsigned sourceLocation = ast->firstToken(); List<ObjCForwardProtocolDeclaration *> **symbolIter = &ast->symbols; - for (IdentifierListAST *it = ast->identifier_list; it; it = it->next) { + for (ObjCIdentifierListAST *it = ast->identifier_list; it; it = it->next) { unsigned declarationLocation; - if (it->name) - declarationLocation = it->name->firstToken(); + if (it->value) + declarationLocation = it->value->firstToken(); else declarationLocation = sourceLocation; - Name *protocolName = semantic()->check(it->name, _scope); + Name *protocolName = semantic()->check(it->value, _scope); ObjCForwardProtocolDeclaration *fwdProtocol = control()->newObjCForwardProtocolDeclaration(sourceLocation, protocolName); fwdProtocol->setStartOffset(tokenAt(ast->firstToken()).offset); fwdProtocol->setEndOffset(tokenAt(ast->lastToken()).offset); @@ -537,8 +537,8 @@ bool CheckDeclaration::visit(ObjCProtocolDeclarationAST *ast) protocol->setEndOffset(tokenAt(ast->lastToken()).offset); if (ast->protocol_refs && ast->protocol_refs->identifier_list) { - for (IdentifierListAST *iter = ast->protocol_refs->identifier_list; iter; iter = iter->next) { - NameAST* name = iter->name; + for (ObjCIdentifierListAST *iter = ast->protocol_refs->identifier_list; iter; iter = iter->next) { + NameAST* name = iter->value; Name *protocolName = semantic()->check(name, _scope); ObjCBaseProtocol *baseProtocol = control()->newObjCBaseProtocol(name->firstToken(), protocolName); protocol->addProtocol(baseProtocol); @@ -562,14 +562,14 @@ bool CheckDeclaration::visit(ObjCClassForwardDeclarationAST *ast) const unsigned sourceLocation = ast->firstToken(); List<ObjCForwardClassDeclaration *> **symbolIter = &ast->symbols; - for (IdentifierListAST *it = ast->identifier_list; it; it = it->next) { + for (ObjCIdentifierListAST *it = ast->identifier_list; it; it = it->next) { unsigned declarationLocation; - if (it->name) - declarationLocation = it->name->firstToken(); + if (it->value) + declarationLocation = it->value->firstToken(); else declarationLocation = sourceLocation; - Name *className = semantic()->check(it->name, _scope); + Name *className = semantic()->check(it->value, _scope); ObjCForwardClassDeclaration *fwdClass = control()->newObjCForwardClassDeclaration(sourceLocation, className); fwdClass->setStartOffset(tokenAt(ast->firstToken()).offset); fwdClass->setEndOffset(tokenAt(ast->lastToken()).offset); @@ -612,8 +612,8 @@ bool CheckDeclaration::visit(ObjCClassDeclarationAST *ast) } if (ast->protocol_refs && ast->protocol_refs->identifier_list) { - for (IdentifierListAST *iter = ast->protocol_refs->identifier_list; iter; iter = iter->next) { - NameAST* name = iter->name; + for (ObjCIdentifierListAST *iter = ast->protocol_refs->identifier_list; iter; iter = iter->next) { + NameAST* name = iter->value; Name *protocolName = semantic()->check(name, _scope); ObjCBaseProtocol *baseProtocol = control()->newObjCBaseProtocol(name->firstToken(), protocolName); klass->addProtocol(baseProtocol); diff --git a/src/shared/cplusplus/Parser.cpp b/src/shared/cplusplus/Parser.cpp index d52431e01c040018834ab6d30c0ee96596d5bd76..8cfa100c6ee9683a7efe69cdd9616c0d7c8c83ce 100644 --- a/src/shared/cplusplus/Parser.cpp +++ b/src/shared/cplusplus/Parser.cpp @@ -4297,20 +4297,20 @@ bool Parser::parseObjCClassForwardDeclaration(DeclarationAST *&node) unsigned identifier_token = 0; match(T_IDENTIFIER, &identifier_token); - ast->identifier_list = new (_pool) IdentifierListAST; + ast->identifier_list = new (_pool) ObjCIdentifierListAST; SimpleNameAST *name = new (_pool) SimpleNameAST; name->identifier_token = identifier_token; - ast->identifier_list->name = name; - IdentifierListAST **nextId = &(ast->identifier_list->next); + ast->identifier_list->value = name; + ObjCIdentifierListAST **nextId = &(ast->identifier_list->next); while (LA() == T_COMMA) { consumeToken(); // consume T_COMMA match(T_IDENTIFIER, &identifier_token); - *nextId = new (_pool) IdentifierListAST; + *nextId = new (_pool) ObjCIdentifierListAST; name = new (_pool) SimpleNameAST; name->identifier_token = identifier_token; - (*nextId)->name = name; + (*nextId)->value = name; nextId = &((*nextId)->next); } @@ -4447,20 +4447,20 @@ bool Parser::parseObjCProtocol(DeclarationAST *&node, ObjCProtocolForwardDeclarationAST *ast = new (_pool) ObjCProtocolForwardDeclarationAST; ast->attributes = attributes; ast->protocol_token = protocol_token; - ast->identifier_list = new (_pool) IdentifierListAST; + ast->identifier_list = new (_pool) ObjCIdentifierListAST; SimpleNameAST *name = new (_pool) SimpleNameAST; name->identifier_token = identifier_token; - ast->identifier_list->name = name; - IdentifierListAST **nextId = &(ast->identifier_list->next); + ast->identifier_list->value = name; + ObjCIdentifierListAST **nextId = &(ast->identifier_list->next); while (LA() == T_COMMA) { consumeToken(); // consume T_COMMA match(T_IDENTIFIER, &identifier_token); - *nextId = new (_pool) IdentifierListAST; + *nextId = new (_pool) ObjCIdentifierListAST; name = new (_pool) SimpleNameAST; name->identifier_token = identifier_token; - (*nextId)->name = name; + (*nextId)->value = name; nextId = &((*nextId)->next); } @@ -4611,20 +4611,20 @@ bool Parser::parseObjCMethodDefinitionList(DeclarationListAST *&node) case T_AT_DYNAMIC: { ObjCDynamicPropertiesDeclarationAST *ast = new (_pool) ObjCDynamicPropertiesDeclarationAST; ast->dynamic_token = consumeToken(); - ast->property_identifiers = new (_pool) IdentifierListAST; + ast->property_identifiers = new (_pool) ObjCIdentifierListAST; SimpleNameAST *name = new (_pool) SimpleNameAST; match(T_IDENTIFIER, &(name->identifier_token)); - ast->property_identifiers->name = name; + ast->property_identifiers->value = name; - IdentifierListAST *last = ast->property_identifiers; + ObjCIdentifierListAST *last = ast->property_identifiers; while (LA() == T_COMMA) { consumeToken(); // consume T_COMMA - last->next = new (_pool) IdentifierListAST; + last->next = new (_pool) ObjCIdentifierListAST; last = last->next; name = new (_pool) SimpleNameAST; match(T_IDENTIFIER, &name->identifier_token); - last->name = name; + last->value = name; } match(T_SEMICOLON, &(ast->semicolon_token)); @@ -4696,20 +4696,20 @@ bool Parser::parseObjCProtocolRefs(ObjCProtocolRefsAST *&node) unsigned identifier_token = 0; match(T_IDENTIFIER, &identifier_token); - ast->identifier_list = new (_pool) IdentifierListAST; + ast->identifier_list = new (_pool) ObjCIdentifierListAST; SimpleNameAST *name = new (_pool) SimpleNameAST; name->identifier_token = identifier_token; - ast->identifier_list->name = name; - IdentifierListAST **nextId = &(ast->identifier_list->next); + ast->identifier_list->value = name; + ObjCIdentifierListAST **nextId = &(ast->identifier_list->next); while (LA() == T_COMMA) { consumeToken(); // consume T_COMMA match(T_IDENTIFIER, &identifier_token); - *nextId = new (_pool) IdentifierListAST; + *nextId = new (_pool) ObjCIdentifierListAST; name = new (_pool) SimpleNameAST; name->identifier_token = identifier_token; - (*nextId)->name = name; + (*nextId)->value = name; nextId = &((*nextId)->next); }