diff options
author | Roberto Raggi <roberto.raggi@nokia.com> | 2010-08-09 15:18:50 +0200 |
---|---|---|
committer | Roberto Raggi <roberto.raggi@nokia.com> | 2010-08-09 15:19:10 +0200 |
commit | a9e980c0c7980a3ddaed94a0c768e2da13f2db9b (patch) | |
tree | 259b833451cb6f158c4084d60f634078d7e1e2bb /src/shared/cplusplus | |
parent | 17bab9dce90f9c12d2982b3e5c28cfa17929aa63 (diff) | |
download | qt-creator-a9e980c0c7980a3ddaed94a0c768e2da13f2db9b.tar.gz |
Apply the decl specifiers.
Diffstat (limited to 'src/shared/cplusplus')
-rw-r--r-- | src/shared/cplusplus/CheckDeclaration.cpp | 95 | ||||
-rw-r--r-- | src/shared/cplusplus/CheckDeclaration.h | 2 | ||||
-rw-r--r-- | src/shared/cplusplus/CheckDeclarator.cpp | 3 |
3 files changed, 51 insertions, 49 deletions
diff --git a/src/shared/cplusplus/CheckDeclaration.cpp b/src/shared/cplusplus/CheckDeclaration.cpp index 5eb98735d1..94b7b845b9 100644 --- a/src/shared/cplusplus/CheckDeclaration.cpp +++ b/src/shared/cplusplus/CheckDeclaration.cpp @@ -113,6 +113,42 @@ TemplateParameters *CheckDeclaration::switchTemplateParameters(TemplateParameter return previousTemplateParameters; } +void CheckDeclaration::setDeclSpecifiers(Symbol *symbol, const FullySpecifiedType &declSpecifiers) +{ + if (! symbol) + return; + + int storage = Symbol::NoStorage; + + if (declSpecifiers.isFriend()) + storage = Symbol::Friend; + else if (declSpecifiers.isAuto()) + storage = Symbol::Auto; + else if (declSpecifiers.isRegister()) + storage = Symbol::Register; + else if (declSpecifiers.isStatic()) + storage = Symbol::Static; + else if (declSpecifiers.isExtern()) + storage = Symbol::Extern; + else if (declSpecifiers.isMutable()) + storage = Symbol::Mutable; + else if (declSpecifiers.isTypedef()) + storage = Symbol::Typedef; + + symbol->setStorage(storage); + + if (Function *funTy = symbol->asFunction()) { + if (declSpecifiers.isVirtual()) + funTy->setVirtual(true); + } + + if (declSpecifiers.isDeprecated()) + symbol->setDeprecated(true); + + if (declSpecifiers.isUnavailable()) + symbol->setUnavailable(true); +} + void CheckDeclaration::checkFunctionArguments(Function *fun) { if (! _checkAnonymousArguments) @@ -133,11 +169,11 @@ void CheckDeclaration::checkFunctionArguments(Function *fun) bool CheckDeclaration::visit(SimpleDeclarationAST *ast) { - FullySpecifiedType ty = semantic()->check(ast->decl_specifier_list, _scope); - FullySpecifiedType qualTy = ty.qualifiedType(); + FullySpecifiedType declSpecifiers = semantic()->check(ast->decl_specifier_list, _scope); + FullySpecifiedType qualTy = declSpecifiers.qualifiedType(); - if (_templateParameters && ty) { - if (Class *klass = ty->asClassType()) { + if (_templateParameters && declSpecifiers) { + if (Class *klass = declSpecifiers->asClassType()) { klass->setTemplateParameters(_templateParameters); _templateParameters = 0; // consume the template parameters } @@ -146,7 +182,7 @@ bool CheckDeclaration::visit(SimpleDeclarationAST *ast) if (ast->decl_specifier_list && ! ast->declarator_list) { ElaboratedTypeSpecifierAST *elab_type_spec = ast->decl_specifier_list->value->asElaboratedTypeSpecifier(); - if (! elab_type_spec && ty.isFriend() && ast->decl_specifier_list->next && ! ast->decl_specifier_list->next->next) { + if (! elab_type_spec && declSpecifiers.isFriend() && ast->decl_specifier_list->next && ! ast->decl_specifier_list->next->next) { // friend template class elab_type_spec = ast->decl_specifier_list->next->value->asElaboratedTypeSpecifier(); } @@ -163,13 +199,7 @@ bool CheckDeclaration::visit(SimpleDeclarationAST *ast) _templateParameters = 0; } - if (ty.isDeprecated()) - symbol->setDeprecated(true); - if (ty.isUnavailable()) - symbol->setUnavailable(true); - - if (ty.isFriend()) - symbol->setStorage(Symbol::Friend); + setDeclSpecifiers(symbol, declSpecifiers); _scope->enterSymbol(symbol); return false; @@ -196,11 +226,9 @@ bool CheckDeclaration::visit(SimpleDeclarationAST *ast) fun->setScope(_scope); fun->setName(name); fun->setMethodKey(semantic()->currentMethodKey()); - fun->setVirtual(ty.isVirtual()); - if (ty.isDeprecated()) - fun->setDeprecated(true); - if (ty.isUnavailable()) - fun->setUnavailable(true); + + setDeclSpecifiers(fun, declSpecifiers); + if (isQ_SIGNAL) fun->setMethodKey(Function::SignalMethod); else if (isQ_SLOT) @@ -216,10 +244,8 @@ bool CheckDeclaration::visit(SimpleDeclarationAST *ast) Declaration *symbol = control()->newDeclaration(location, name); symbol->setType(declTy); - if (declTy.isDeprecated()) - symbol->setDeprecated(true); - if (declTy.isUnavailable()) - symbol->setUnavailable(true); + + setDeclSpecifiers(symbol, declSpecifiers); if (_templateParameters && it == ast->declarator_list) { symbol->setTemplateParameters(_templateParameters); @@ -228,26 +254,6 @@ bool CheckDeclaration::visit(SimpleDeclarationAST *ast) symbol->setVisibility(semantic()->currentVisibility()); - if (ty.isFriend()) - symbol->setStorage(Symbol::Friend); - else if (ty.isAuto()) - symbol->setStorage(Symbol::Auto); - else if (ty.isRegister()) - symbol->setStorage(Symbol::Register); - else if (ty.isStatic()) - symbol->setStorage(Symbol::Static); - else if (ty.isExtern()) - symbol->setStorage(Symbol::Extern); - else if (ty.isMutable()) - symbol->setStorage(Symbol::Mutable); - else if (ty.isTypedef()) - symbol->setStorage(Symbol::Typedef); - - if (ty.isDeprecated()) - symbol->setDeprecated(true); - if (ty.isUnavailable()) - symbol->setUnavailable(true); - if (it->value && it->value->initializer) { FullySpecifiedType initTy = semantic()->check(it->value->initializer, _scope); } @@ -328,11 +334,8 @@ bool CheckDeclaration::visit(FunctionDefinitionAST *ast) } Function *fun = funTy->asFunctionType(); - fun->setVirtual(ty.isVirtual()); - if (ty.isDeprecated()) - fun->setDeprecated(true); - if (ty.isUnavailable()) - fun->setUnavailable(true); + setDeclSpecifiers(fun, ty); + fun->members()->setStartOffset(funStartOffset); fun->members()->setEndOffset(tokenAt(ast->lastToken() - 1).end()); if (ast->declarator) { diff --git a/src/shared/cplusplus/CheckDeclaration.h b/src/shared/cplusplus/CheckDeclaration.h index 90690d2720..562b170123 100644 --- a/src/shared/cplusplus/CheckDeclaration.h +++ b/src/shared/cplusplus/CheckDeclaration.h @@ -69,6 +69,8 @@ protected: Scope *switchScope(Scope *scope); TemplateParameters *switchTemplateParameters(TemplateParameters *templateParameters); + void setDeclSpecifiers(Symbol *symbol, const FullySpecifiedType &declSpecifiers); + void checkFunctionArguments(Function *fun); using ASTVisitor::visit; diff --git a/src/shared/cplusplus/CheckDeclarator.cpp b/src/shared/cplusplus/CheckDeclarator.cpp index 013f3a308c..d9d51b356e 100644 --- a/src/shared/cplusplus/CheckDeclarator.cpp +++ b/src/shared/cplusplus/CheckDeclarator.cpp @@ -169,9 +169,6 @@ bool CheckDeclarator::visit(FunctionDeclaratorAST *ast) ast->symbol = fun; fun->setReturnType(_fullySpecifiedType); - if (_fullySpecifiedType.isVirtual()) - fun->setVirtual(true); - if (ast->parameters) { DeclarationListAST *parameter_declarations = ast->parameters->parameter_declaration_list; for (DeclarationListAST *decl = parameter_declarations; decl; decl = decl->next) { |