summaryrefslogtreecommitdiff
path: root/src/shared/cplusplus
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared/cplusplus')
-rw-r--r--src/shared/cplusplus/Bind.cpp15
-rw-r--r--src/shared/cplusplus/Bind.h3
-rw-r--r--src/shared/cplusplus/CheckDeclaration.cpp914
-rw-r--r--src/shared/cplusplus/CheckDeclaration.h125
-rw-r--r--src/shared/cplusplus/CheckDeclarator.cpp310
-rw-r--r--src/shared/cplusplus/CheckDeclarator.h112
-rw-r--r--src/shared/cplusplus/CheckExpression.cpp413
-rw-r--r--src/shared/cplusplus/CheckExpression.h129
-rw-r--r--src/shared/cplusplus/CheckName.cpp419
-rw-r--r--src/shared/cplusplus/CheckName.h93
-rw-r--r--src/shared/cplusplus/CheckSpecifier.cpp448
-rw-r--r--src/shared/cplusplus/CheckSpecifier.h92
-rw-r--r--src/shared/cplusplus/CheckStatement.cpp406
-rw-r--r--src/shared/cplusplus/CheckStatement.h114
-rw-r--r--src/shared/cplusplus/Semantic.cpp358
-rw-r--r--src/shared/cplusplus/Semantic.h148
-rw-r--r--src/shared/cplusplus/SemanticCheck.cpp68
-rw-r--r--src/shared/cplusplus/SemanticCheck.h74
-rw-r--r--src/shared/cplusplus/cplusplus.pri16
19 files changed, 14 insertions, 4243 deletions
diff --git a/src/shared/cplusplus/Bind.cpp b/src/shared/cplusplus/Bind.cpp
index 7ee2d8cf1b..436f68ebc1 100644
--- a/src/shared/cplusplus/Bind.cpp
+++ b/src/shared/cplusplus/Bind.cpp
@@ -162,11 +162,20 @@ void Bind::operator()(DeclarationAST *ast, Scope *scope)
(void) switchScope(previousScope);
}
-void Bind::operator()(ExpressionAST *ast, Scope *scope)
+FullySpecifiedType Bind::operator()(ExpressionAST *ast, Scope *scope)
{
Scope *previousScope = switchScope(scope);
- expression(ast);
+ FullySpecifiedType ty = expression(ast);
(void) switchScope(previousScope);
+ return ty;
+}
+
+FullySpecifiedType Bind::operator()(NewTypeIdAST *ast, Scope *scope)
+{
+ Scope *previousScope = switchScope(scope);
+ FullySpecifiedType ty = newTypeId(ast);
+ (void) switchScope(previousScope);
+ return ty;
}
void Bind::statement(StatementAST *ast)
@@ -1875,7 +1884,7 @@ bool Bind::visit(FunctionDefinitionAST *ast)
this->ctorInitializer(ast->ctor_initializer, fun);
- if (! _skipFunctionBodies && ast->function_body) {
+ if (fun && ! _skipFunctionBodies && ast->function_body) {
Scope *previousScope = switchScope(fun);
this->statement(ast->function_body);
(void) switchScope(previousScope);
diff --git a/src/shared/cplusplus/Bind.h b/src/shared/cplusplus/Bind.h
index a92fd2121f..72f0f48ab2 100644
--- a/src/shared/cplusplus/Bind.h
+++ b/src/shared/cplusplus/Bind.h
@@ -61,7 +61,8 @@ public:
void operator()(TranslationUnitAST *ast, Namespace *globalNamespace);
void operator()(DeclarationAST *ast, Scope *scope);
- void operator()(ExpressionAST *ast, Scope *scope);
+ FullySpecifiedType operator()(ExpressionAST *ast, Scope *scope);
+ FullySpecifiedType operator()(NewTypeIdAST *ast, Scope *scope);
bool skipFunctionBodies() const;
void setSkipFunctionBodies(bool skipFunctionBodies);
diff --git a/src/shared/cplusplus/CheckDeclaration.cpp b/src/shared/cplusplus/CheckDeclaration.cpp
deleted file mode 100644
index f2b1b2c391..0000000000
--- a/src/shared/cplusplus/CheckDeclaration.cpp
+++ /dev/null
@@ -1,914 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** Commercial Usage
-**
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Nokia.
-**
-** GNU Lesser General Public License Usage
-**
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
-**
-**************************************************************************/
-// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-#include "CheckDeclaration.h"
-#include "Semantic.h"
-#include "AST.h"
-#include "TranslationUnit.h"
-#include "Scope.h"
-#include "Names.h"
-#include "CoreTypes.h"
-#include "Symbols.h"
-#include "Control.h"
-#include "Literals.h"
-#include "QtContextKeywords.h"
-#include <string>
-#include <cassert>
-
-using namespace CPlusPlus;
-
-CheckDeclaration::CheckDeclaration(Semantic *semantic)
- : SemanticCheck(semantic),
- _declaration(0),
- _scope(0),
- _checkAnonymousArguments(false)
-{ }
-
-CheckDeclaration::~CheckDeclaration()
-{ }
-
-void CheckDeclaration::check(DeclarationAST *declaration, Scope *scope)
-{
- Scope *previousScope = switchScope(scope);
- DeclarationAST *previousDeclaration = switchDeclaration(declaration);
- accept(declaration);
- (void) switchDeclaration(previousDeclaration);
- (void) switchScope(previousScope);
-}
-
-void CheckDeclaration::check(CtorInitializerAST *ast, Scope *scope)
-{
- Scope *previousScope = switchScope(scope);
- accept(ast);
- (void) switchScope(previousScope);
-}
-
-DeclarationAST *CheckDeclaration::switchDeclaration(DeclarationAST *declaration)
-{
- DeclarationAST *previousDeclaration = _declaration;
- _declaration = declaration;
- return previousDeclaration;
-}
-
-Scope *CheckDeclaration::switchScope(Scope *scope)
-{
- Scope *previousScope = _scope;
- _scope = scope;
- return previousScope;
-}
-
-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)
- return;
-
- if (_scope->isClass() && fun->isPublic()) {
- for (unsigned argc = 0; argc < fun->argumentCount(); ++argc) {
- Argument *arg = fun->argumentAt(argc)->asArgument();
- assert(arg != 0);
-
- if (! arg->name()) {
- translationUnit()->warning(arg->sourceLocation(),
- "anonymous argument");
- }
- }
- }
-}
-
-bool CheckDeclaration::visit(SimpleDeclarationAST *ast)
-{
- FullySpecifiedType declSpecifiers = semantic()->check(ast->decl_specifier_list, _scope);
- FullySpecifiedType qualTy = declSpecifiers.qualifiedType();
-
- if (ast->decl_specifier_list && ! ast->declarator_list) {
- ElaboratedTypeSpecifierAST *elab_type_spec = ast->decl_specifier_list->value->asElaboratedTypeSpecifier();
-
- 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();
- }
-
- if (elab_type_spec) {
- unsigned sourceLocation = ast->decl_specifier_list->firstToken();
-
- const Name *name = semantic()->check(elab_type_spec->name, _scope);
- ForwardClassDeclaration *symbol =
- control()->newForwardClassDeclaration(sourceLocation, name);
-
- setDeclSpecifiers(symbol, declSpecifiers);
-
- _scope->addMember(symbol);
- return false;
- }
- }
-
- const bool isQ_SLOT = ast->qt_invokable_token && tokenKind(ast->qt_invokable_token) == T_Q_SLOT;
- const bool isQ_SIGNAL = ast->qt_invokable_token && tokenKind(ast->qt_invokable_token) == T_Q_SIGNAL;
- const bool isQ_INVOKABLE = ast->qt_invokable_token && tokenKind(ast->qt_invokable_token) == T_Q_INVOKABLE;
-
- List<Symbol *> **decl_it = &ast->symbols;
- for (DeclaratorListAST *it = ast->declarator_list; it; it = it->next) {
- const Name *name = 0;
- FullySpecifiedType declTy = semantic()->check(it->value, qualTy,
- _scope, &name);
-
- unsigned location = semantic()->location(it->value);
- if (! location)
- location = ast->firstToken();
-
- Function *fun = 0;
- if (declTy && 0 != (fun = declTy->asFunctionType())) {
- fun->setSourceLocation(location, translationUnit());
- fun->setScope(_scope);
- fun->setName(name);
- fun->setMethodKey(semantic()->currentMethodKey());
-
- setDeclSpecifiers(fun, declSpecifiers);
-
- if (isQ_SIGNAL)
- fun->setMethodKey(Function::SignalMethod);
- else if (isQ_SLOT)
- fun->setMethodKey(Function::SlotMethod);
- else if (isQ_INVOKABLE)
- fun->setMethodKey(Function::InvokableMethod);
- fun->setVisibility(semantic()->currentVisibility());
- } else if (semantic()->currentMethodKey() != Function::NormalMethod) {
- translationUnit()->warning(ast->firstToken(),
- "expected a function declaration");
- }
-
- Declaration *symbol = control()->newDeclaration(location, name);
-
- symbol->setType(declTy);
-
- setDeclSpecifiers(symbol, declSpecifiers);
-
- symbol->setVisibility(semantic()->currentVisibility());
-
- if (it->value && it->value->initializer) {
- FullySpecifiedType initTy = semantic()->check(it->value->initializer, _scope);
- }
-
- *decl_it = new (translationUnit()->memoryPool()) List<Symbol *>();
- (*decl_it)->value = symbol;
- decl_it = &(*decl_it)->next;
-
- _scope->addMember(symbol);
- }
- return false;
-}
-
-bool CheckDeclaration::visit(EmptyDeclarationAST *)
-{
- return false;
-}
-
-bool CheckDeclaration::visit(AccessDeclarationAST *ast)
-{
- int accessSpecifier = tokenKind(ast->access_specifier_token);
- int visibility = semantic()->visibilityForAccessSpecifier(accessSpecifier);
- semantic()->switchVisibility(visibility);
- if (ast->slots_token)
- semantic()->switchMethodKey(Function::SlotMethod);
- else if (accessSpecifier == T_Q_SIGNALS)
- semantic()->switchMethodKey(Function::SignalMethod);
- else
- semantic()->switchMethodKey(Function::NormalMethod);
- return false;
-}
-
-bool CheckDeclaration::visit(AsmDefinitionAST *)
-{
- return false;
-}
-
-bool CheckDeclaration::visit(ExceptionDeclarationAST *ast)
-{
- FullySpecifiedType ty = semantic()->check(ast->type_specifier_list, _scope);
- FullySpecifiedType qualTy = ty.qualifiedType();
-
- const Name *name = 0;
- FullySpecifiedType declTy = semantic()->check(ast->declarator, qualTy,
- _scope, &name);
-
- unsigned location = semantic()->location(ast->declarator);
- if (! location) {
- if (ast->declarator)
- location = ast->declarator->firstToken();
- else
- location = ast->firstToken();
- }
-
- Declaration *symbol = control()->newDeclaration(location, name);
- symbol->setType(declTy);
- _scope->addMember(symbol);
-
- return false;
-}
-
-bool CheckDeclaration::visit(FunctionDefinitionAST *ast)
-{
- FullySpecifiedType ty = semantic()->check(ast->decl_specifier_list, _scope);
- FullySpecifiedType qualTy = ty.qualifiedType();
- const Name *name = 0;
- FullySpecifiedType funTy = semantic()->check(ast->declarator, qualTy,
- _scope, &name);
- if (! funTy->isFunctionType()) {
- translationUnit()->error(ast->firstToken(),
- "expected a function prototype");
- return false;
- }
-
- unsigned funStartOffset = tokenAt(ast->firstToken()).offset;
- if (ast->declarator && ast->declarator->core_declarator) {
- funStartOffset = tokenAt(ast->declarator->core_declarator->lastToken() - 1).end();
- }
-
- Function *fun = funTy->asFunctionType();
- setDeclSpecifiers(fun, ty);
-
- fun->setStartOffset(funStartOffset);
- fun->setEndOffset(tokenAt(ast->lastToken() - 1).end());
- if (ast->declarator) {
- unsigned loc = semantic()->location(ast->declarator);
- if (! loc)
- loc = ast->declarator->firstToken();
- fun->setSourceLocation(loc, translationUnit());
- }
- fun->setName(name);
- fun->setVisibility(semantic()->currentVisibility());
- fun->setMethodKey(semantic()->currentMethodKey());
-
- const bool isQ_SLOT = ast->qt_invokable_token && tokenKind(ast->qt_invokable_token) == T_Q_SLOT;
- const bool isQ_SIGNAL = ast->qt_invokable_token && tokenKind(ast->qt_invokable_token) == T_Q_SIGNAL;
- const bool isQ_INVOKABLE = ast->qt_invokable_token && tokenKind(ast->qt_invokable_token) == T_Q_INVOKABLE;
-
- if (isQ_SIGNAL)
- fun->setMethodKey(Function::SignalMethod);
- else if (isQ_SLOT)
- fun->setMethodKey(Function::SlotMethod);
- else if (isQ_INVOKABLE)
- fun->setMethodKey(Function::InvokableMethod);
-
- checkFunctionArguments(fun);
-
- ast->symbol = fun;
- _scope->addMember(fun);
-
- if (! semantic()->skipFunctionBodies())
- semantic()->checkFunctionDefinition(ast);
-
- return false;
-}
-
-bool CheckDeclaration::visit(MemInitializerAST *ast)
-{
- (void) semantic()->check(ast->name, _scope);
- for (ExpressionListAST *it = ast->expression_list; it; it = it->next) {
- FullySpecifiedType ty = semantic()->check(it->value, _scope);
- }
- return false;
-}
-
-bool CheckDeclaration::visit(LinkageBodyAST *ast)
-{
- for (DeclarationListAST *decl = ast->declaration_list; decl; decl = decl->next) {
- semantic()->check(decl->value, _scope);
- }
- return false;
-}
-
-bool CheckDeclaration::visit(LinkageSpecificationAST *ast)
-{
- semantic()->check(ast->declaration, _scope);
- return false;
-}
-
-bool CheckDeclaration::visit(NamespaceAST *ast)
-{
- const Name *namespaceName = 0;
- if (const Identifier *id = identifier(ast->identifier_token))
- namespaceName = control()->nameId(id);
-
- unsigned sourceLocation = ast->firstToken();
- if (ast->identifier_token)
- sourceLocation = ast->identifier_token;
- unsigned scopeStart = tokenAt(ast->firstToken()).offset;
- if (ast->linkage_body && ast->linkage_body->firstToken())
- scopeStart = tokenAt(ast->linkage_body->firstToken()).offset;
-
- Namespace *ns = control()->newNamespace(sourceLocation, namespaceName);
- ns->setStartOffset(scopeStart);
- ns->setEndOffset(tokenAt(ast->lastToken() - 1).end());
- ast->symbol = ns;
- _scope->addMember(ns);
- semantic()->check(ast->linkage_body, ns); // ### we'll do the merge later.
-
- return false;
-}
-
-bool CheckDeclaration::visit(NamespaceAliasDefinitionAST *ast)
-{
- const Name *name = 0;
-
- if (const Identifier *id = identifier(ast->namespace_name_token))
- name = control()->nameId(id);
-
- unsigned sourceLocation = ast->firstToken();
-
- if (ast->namespace_name_token)
- sourceLocation = ast->namespace_name_token;
-
- const Name *namespaceName = semantic()->check(ast->name, _scope);
-
- NamespaceAlias *namespaceAlias = control()->newNamespaceAlias(sourceLocation, name);
- namespaceAlias->setNamespaceName(namespaceName);
- //ast->symbol = namespaceAlias;
- _scope->addMember(namespaceAlias);
-
- return false;
-}
-
-bool CheckDeclaration::visit(ParameterDeclarationAST *ast)
-{
- unsigned sourceLocation = semantic()->location(ast->declarator);
- if (! sourceLocation) {
- if (ast->declarator)
- sourceLocation = ast->declarator->firstToken();
- else
- sourceLocation = ast->firstToken();
- }
-
- const Name *argName = 0;
- FullySpecifiedType ty = semantic()->check(ast->type_specifier_list, _scope);
- FullySpecifiedType argTy = semantic()->check(ast->declarator, ty.qualifiedType(),
- _scope, &argName);
- FullySpecifiedType exprTy = semantic()->check(ast->expression, _scope);
- Argument *arg = control()->newArgument(sourceLocation, argName);
- ast->symbol = arg;
- if (ast->expression) {
- unsigned startOfExpression = ast->expression->firstToken();
- unsigned endOfExpression = ast->expression->lastToken();
- std::string buffer;
- for (unsigned index = startOfExpression; index != endOfExpression; ++index) {
- const Token &tk = tokenAt(index);
- if (tk.whitespace() || tk.newline())
- buffer += ' ';
- buffer += tk.spell();
- }
- const StringLiteral *initializer = control()->stringLiteral(buffer.c_str(), buffer.size());
- arg->setInitializer(initializer);
- }
- arg->setType(argTy);
- _scope->addMember(arg);
- return false;
-}
-
-bool CheckDeclaration::visit(TemplateDeclarationAST *ast)
-{
- Template *templ = control()->newTemplate(ast->firstToken());
- ast->symbol = templ;
-
- for (DeclarationListAST *param = ast->template_parameter_list; param; param = param->next) {
- semantic()->check(param->value, templ);
- }
-
- semantic()->check(ast->declaration, templ);
-
- if (Symbol *decl = templ->declaration()) {
- // propagate the name
- if (decl->sourceLocation())
- templ->setSourceLocation(decl->sourceLocation(), translationUnit());
- templ->setName(decl->name());
- }
-
- _scope->addMember(templ);
-
- return false;
-}
-
-bool CheckDeclaration::visit(TypenameTypeParameterAST *ast)
-{
- unsigned sourceLocation = ast->firstToken();
- if (ast->name)
- sourceLocation = ast->name->firstToken();
-
- const Name *name = semantic()->check(ast->name, _scope);
- TypenameArgument *arg = control()->newTypenameArgument(sourceLocation, name);
- FullySpecifiedType ty = semantic()->check(ast->type_id, _scope);
- arg->setType(ty);
- ast->symbol = arg;
- _scope->addMember(arg);
- return false;
-}
-
-bool CheckDeclaration::visit(TemplateTypeParameterAST *ast)
-{
- unsigned sourceLocation = ast->firstToken();
- if (ast->name)
- sourceLocation = ast->name->firstToken();
-
- const Name *name = semantic()->check(ast->name, _scope);
- TypenameArgument *arg = control()->newTypenameArgument(sourceLocation, name);
- FullySpecifiedType ty = semantic()->check(ast->type_id, _scope);
- arg->setType(ty);
- ast->symbol = arg;
- _scope->addMember(arg);
- return false;
-}
-
-bool CheckDeclaration::visit(UsingAST *ast)
-{
- const Name *name = semantic()->check(ast->name, _scope);
-
- unsigned sourceLocation = ast->firstToken();
- if (ast->name)
- sourceLocation = ast->name->firstToken();
-
- UsingDeclaration *u = control()->newUsingDeclaration(sourceLocation, name);
- ast->symbol = u;
- _scope->addMember(u);
- return false;
-}
-
-bool CheckDeclaration::visit(UsingDirectiveAST *ast)
-{
- const Name *name = semantic()->check(ast->name, _scope);
-
- unsigned sourceLocation = ast->firstToken();
- if (ast->name)
- sourceLocation = ast->name->firstToken();
-
- UsingNamespaceDirective *u = control()->newUsingNamespaceDirective(sourceLocation, name);
- ast->symbol = u;
- _scope->addMember(u);
-
- if (! (_scope->isBlock() || _scope->isNamespace()))
- translationUnit()->error(ast->firstToken(),
- "using-directive not within namespace or block scope");
-
- return false;
-}
-
-bool CheckDeclaration::visit(ObjCProtocolForwardDeclarationAST *ast)
-{
- const unsigned sourceLocation = ast->firstToken();
-
- List<ObjCForwardProtocolDeclaration *> **symbolIter = &ast->symbols;
- for (NameListAST *it = ast->identifier_list; it; it = it->next) {
- unsigned declarationLocation;
- if (it->value)
- declarationLocation = it->value->firstToken();
- else
- declarationLocation = sourceLocation;
-
- const Name *protocolName = semantic()->check(it->value, _scope);
- ObjCForwardProtocolDeclaration *fwdProtocol = control()->newObjCForwardProtocolDeclaration(sourceLocation, protocolName);
-
- _scope->addMember(fwdProtocol);
-
- *symbolIter = new (translationUnit()->memoryPool()) List<ObjCForwardProtocolDeclaration *>();
- (*symbolIter)->value = fwdProtocol;
- symbolIter = &(*symbolIter)->next;
- }
-
- return false;
-}
-
-unsigned CheckDeclaration::calculateScopeStart(ObjCProtocolDeclarationAST *ast) const
-{
- if (ast->protocol_refs)
- if (unsigned pos = ast->protocol_refs->lastToken())
- return tokenAt(pos - 1).end();
- if (ast->name)
- if (unsigned pos = ast->name->lastToken())
- return tokenAt(pos - 1).end();
-
- return tokenAt(ast->firstToken()).offset;
-}
-
-bool CheckDeclaration::visit(ObjCProtocolDeclarationAST *ast)
-{
- unsigned sourceLocation;
- if (ast->name)
- sourceLocation = ast->name->firstToken();
- else
- sourceLocation = ast->firstToken();
-
- const Name *protocolName = semantic()->check(ast->name, _scope);
- ObjCProtocol *protocol = control()->newObjCProtocol(sourceLocation, protocolName);
- protocol->setStartOffset(calculateScopeStart(ast));
- protocol->setEndOffset(tokenAt(ast->lastToken() - 1).end());
-
- if (ast->protocol_refs && ast->protocol_refs->identifier_list) {
- for (NameListAST *iter = ast->protocol_refs->identifier_list; iter; iter = iter->next) {
- NameAST* name = iter->value;
- const Name *protocolName = semantic()->check(name, _scope);
- ObjCBaseProtocol *baseProtocol = control()->newObjCBaseProtocol(name->firstToken(), protocolName);
- protocol->addProtocol(baseProtocol);
- }
- }
-
- int previousObjCVisibility = semantic()->switchObjCVisibility(Function::Public);
- for (DeclarationListAST *it = ast->member_declaration_list; it; it = it->next) {
- semantic()->check(it->value, protocol);
- }
- (void) semantic()->switchObjCVisibility(previousObjCVisibility);
-
- ast->symbol = protocol;
- _scope->addMember(protocol);
-
- return false;
-}
-
-bool CheckDeclaration::visit(ObjCClassForwardDeclarationAST *ast)
-{
- const unsigned sourceLocation = ast->firstToken();
-
- List<ObjCForwardClassDeclaration *> **symbolIter = &ast->symbols;
- for (NameListAST *it = ast->identifier_list; it; it = it->next) {
- unsigned declarationLocation;
- if (it->value)
- declarationLocation = it->value->firstToken();
- else
- declarationLocation = sourceLocation;
-
- const Name *className = semantic()->check(it->value, _scope);
- ObjCForwardClassDeclaration *fwdClass = control()->newObjCForwardClassDeclaration(sourceLocation, className);
-
- _scope->addMember(fwdClass);
-
- *symbolIter = new (translationUnit()->memoryPool()) List<ObjCForwardClassDeclaration *>();
- (*symbolIter)->value = fwdClass;
- symbolIter = &(*symbolIter)->next;
- }
-
- return false;
-}
-
-unsigned CheckDeclaration::calculateScopeStart(ObjCClassDeclarationAST *ast) const
-{
- if (ast->inst_vars_decl)
- if (unsigned pos = ast->inst_vars_decl->lbrace_token)
- return tokenAt(pos).end();
-
- if (ast->protocol_refs)
- if (unsigned pos = ast->protocol_refs->lastToken())
- return tokenAt(pos - 1).end();
-
- if (ast->superclass)
- if (unsigned pos = ast->superclass->lastToken())
- return tokenAt(pos - 1).end();
-
- if (ast->colon_token)
- return tokenAt(ast->colon_token).end();
-
- if (ast->rparen_token)
- return tokenAt(ast->rparen_token).end();
-
- if (ast->category_name)
- if (unsigned pos = ast->category_name->lastToken())
- return tokenAt(pos - 1).end();
-
- if (ast->lparen_token)
- return tokenAt(ast->lparen_token).end();
-
- if (ast->class_name)
- if (unsigned pos = ast->class_name->lastToken())
- return tokenAt(pos - 1).end();
-
- return tokenAt(ast->firstToken()).offset;
-}
-
-bool CheckDeclaration::visit(ObjCClassDeclarationAST *ast)
-{
- unsigned sourceLocation;
- if (ast->class_name)
- sourceLocation = ast->class_name->firstToken();
- else
- sourceLocation = ast->firstToken();
-
- const Name *className = semantic()->check(ast->class_name, _scope);
- ObjCClass *klass = control()->newObjCClass(sourceLocation, className);
- klass->setStartOffset(calculateScopeStart(ast));
- klass->setEndOffset(tokenAt(ast->lastToken() - 1).offset);
- ast->symbol = klass;
-
- klass->setInterface(ast->interface_token != 0);
-
- if (ast->category_name) {
- const Name *categoryName = semantic()->check(ast->category_name, _scope);
- klass->setCategoryName(categoryName);
- }
-
- if (ast->superclass) {
- const Name *superClassName = semantic()->check(ast->superclass, _scope);
- ObjCBaseClass *superKlass = control()->newObjCBaseClass(ast->superclass->firstToken(), superClassName);
- klass->setBaseClass(superKlass);
- }
-
- if (ast->protocol_refs && ast->protocol_refs->identifier_list) {
- for (NameListAST *iter = ast->protocol_refs->identifier_list; iter; iter = iter->next) {
- NameAST* name = iter->value;
- const Name *protocolName = semantic()->check(name, _scope);
- ObjCBaseProtocol *baseProtocol = control()->newObjCBaseProtocol(name->firstToken(), protocolName);
- klass->addProtocol(baseProtocol);
- }
- }
-
- _scope->addMember(klass);
-
- int previousObjCVisibility = semantic()->switchObjCVisibility(Function::Protected);
-
- if (ast->inst_vars_decl) {
- for (DeclarationListAST *it = ast->inst_vars_decl->instance_variable_list; it; it = it->next) {
- semantic()->check(it->value, klass);
- }
- }
-
- (void) semantic()->switchObjCVisibility(Function::Public);
-
- for (DeclarationListAST *it = ast->member_declaration_list; it; it = it->next) {
- semantic()->check(it->value, klass);
- }
-
- (void) semantic()->switchObjCVisibility(previousObjCVisibility);
-
- return false;
-}
-
-bool CheckDeclaration::visit(ObjCMethodDeclarationAST *ast)
-{
- ObjCMethodPrototypeAST *methodProto = ast->method_prototype;
- if (!methodProto)
- return false;
- ObjCSelectorAST *selector = methodProto->selector;
- if (!selector)
- return false;
-
- FullySpecifiedType ty = semantic()->check(methodProto, _scope);
- ObjCMethod *methodTy = ty.type()->asObjCMethodType();
- if (!methodTy)
- return false;
-
- Symbol *symbol;
- if (ast->function_body) {
- symbol = methodTy;
- methodTy->setStartOffset(tokenAt(ast->function_body->firstToken()).offset);
- methodTy->setEndOffset(tokenAt(ast->lastToken() - 1).end());
- } else {
- Declaration *decl = control()->newDeclaration(selector->firstToken(), methodTy->name());
- decl->setType(methodTy);
- symbol = decl;
- symbol->setStorage(methodTy->storage());
- }
-
- symbol->setVisibility(semantic()->currentObjCVisibility());
- if (ty.isDeprecated())
- symbol->setDeprecated(true);
- if (ty.isUnavailable())
- symbol->setUnavailable(true);
-
- _scope->addMember(symbol);
-
- if (ast->function_body && !semantic()->skipFunctionBodies()) {
- semantic()->check(ast->function_body, methodTy);
- }
-
- return false;
-}
-
-bool CheckDeclaration::visit(ObjCVisibilityDeclarationAST *ast)
-{
- int accessSpecifier = tokenKind(ast->visibility_token);
- int visibility = semantic()->visibilityForObjCAccessSpecifier(accessSpecifier);
- semantic()->switchObjCVisibility(visibility);
- return false;
-}
-
-bool CheckDeclaration::checkPropertyAttribute(ObjCPropertyAttributeAST *attrAst,
- int &flags,
- int attr)
-{
- if (flags & attr) {
- translationUnit()->warning(attrAst->attribute_identifier_token,
- "duplicate property attribute \"%s\"",
- spell(attrAst->attribute_identifier_token));
- return false;
- } else {
- flags |= attr;
- return true;
- }
-}
-
-bool CheckDeclaration::visit(ObjCPropertyDeclarationAST *ast)
-{
- semantic()->check(ast->simple_declaration, _scope);
- SimpleDeclarationAST *simpleDecl = ast->simple_declaration->asSimpleDeclaration();
-
- if (!simpleDecl) {
- translationUnit()->warning(ast->simple_declaration->firstToken(),
- "invalid type for property declaration");
- return false;
- }
-
- int propAttrs = ObjCPropertyDeclaration::None;
- const Name *getterName = 0, *setterName = 0;
-
- for (ObjCPropertyAttributeListAST *iter= ast->property_attribute_list; iter; iter = iter->next) {
- ObjCPropertyAttributeAST *attrAst = iter->value;
- if (!attrAst)
- continue;
-
- const Identifier *attrId = identifier(attrAst->attribute_identifier_token);
- if (attrId == control()->objcGetterId()) {
- if (checkPropertyAttribute(attrAst, propAttrs, ObjCPropertyDeclaration::Getter)) {
- getterName = semantic()->check(attrAst->method_selector, _scope);
- }
- } else if (attrId == control()->objcSetterId()) {
- if (checkPropertyAttribute(attrAst, propAttrs, ObjCPropertyDeclaration::Setter)) {
- setterName = semantic()->check(attrAst->method_selector, _scope);
- }
- } else if (attrId == control()->objcReadwriteId()) {
- checkPropertyAttribute(attrAst, propAttrs, ObjCPropertyDeclaration::ReadWrite);
- } else if (attrId == control()->objcReadonlyId()) {
- checkPropertyAttribute(attrAst, propAttrs, ObjCPropertyDeclaration::ReadOnly);
- } else if (attrId == control()->objcAssignId()) {
- checkPropertyAttribute(attrAst, propAttrs, ObjCPropertyDeclaration::Assign);
- } else if (attrId == control()->objcRetainId()) {
- checkPropertyAttribute(attrAst, propAttrs, ObjCPropertyDeclaration::Retain);
- } else if (attrId == control()->objcCopyId()) {
- checkPropertyAttribute(attrAst, propAttrs, ObjCPropertyDeclaration::Copy);
- } else if (attrId == control()->objcNonatomicId()) {
- checkPropertyAttribute(attrAst, propAttrs, ObjCPropertyDeclaration::NonAtomic);
- }
- }
-
- if (propAttrs & ObjCPropertyDeclaration::ReadOnly &&
- propAttrs & ObjCPropertyDeclaration::ReadWrite)
- // Should this be an error instead of only a warning?
- translationUnit()->warning(ast->property_token,
- "property can have at most one attribute \"readonly\" or \"readwrite\" specified");
- int setterSemAttrs = propAttrs & ObjCPropertyDeclaration::SetterSemanticsMask;
- if (setterSemAttrs
- && setterSemAttrs != ObjCPropertyDeclaration::Assign
- && setterSemAttrs != ObjCPropertyDeclaration::Retain
- && setterSemAttrs != ObjCPropertyDeclaration::Copy) {
- // Should this be an error instead of only a warning?
- translationUnit()->warning(ast->property_token,
- "property can have at most one attribute \"assign\", \"retain\", or \"copy\" specified");
- }
-
- List<ObjCPropertyDeclaration *> **lastSymbols = &ast->symbols;
- for (List<Symbol *> *iter = simpleDecl->symbols; iter; iter = iter->next) {
- ObjCPropertyDeclaration *propDecl = control()->newObjCPropertyDeclaration(ast->firstToken(),
- iter->value->name());
- propDecl->setType(iter->value->type());
- propDecl->setAttributes(propAttrs);
- propDecl->setGetterName(getterName);
- propDecl->setSetterName(setterName);
- _scope->addMember(propDecl);
-
- *lastSymbols = new (translationUnit()->memoryPool()) List<ObjCPropertyDeclaration *>();
- (*lastSymbols)->value = propDecl;
- lastSymbols = &(*lastSymbols)->next;
- }
-
- return false;
-}
-
-bool CheckDeclaration::visit(QtEnumDeclarationAST *ast)
-{
- checkQEnumsQFlagsNames(ast->enumerator_list, "Q_ENUMS");
- return false;
-}
-
-bool CheckDeclaration::visit(QtFlagsDeclarationAST *ast)
-{
- checkQEnumsQFlagsNames(ast->flag_enums_list, "Q_FLAGS");
- return false;
-}
-
-bool CheckDeclaration::visit(QtPropertyDeclarationAST *ast)
-{
- if (ast->type_id)
- semantic()->check(ast->type_id, _scope);
- if (ast->property_name)
- semantic()->check(ast->property_name, _scope);
- for (QtPropertyDeclarationItemListAST *iter = ast->property_declaration_items;
- iter; iter = iter->next) {
- if (iter->value)
- semantic()->check(iter->value->expression, _scope);
- }
- return false;
-}
-
-static bool checkEnumName(const Name *name)
-{
- if (! name)
- return false;
-
- else if (name->asNameId() != 0)
- return true;
-
- else if (const QualifiedNameId *q = name->asQualifiedNameId()) {
- if (! q->base())
- return false; // global qualified name
-
- if (checkEnumName(q->base()) && checkEnumName(q->name()))
- return true;
- }
-
- return false;
-}
-
-void CheckDeclaration::checkQEnumsQFlagsNames(NameListAST *nameListAst, const char *declName)
-{
- for (NameListAST *iter = nameListAst; iter; iter = iter->next) {
- if (const Name *name = semantic()->check(iter->value, _scope)) {
- if (! checkEnumName(name))
- translationUnit()->error(iter->firstToken(), "invalid name in %s", declName);
- }
- }
-}
diff --git a/src/shared/cplusplus/CheckDeclaration.h b/src/shared/cplusplus/CheckDeclaration.h
deleted file mode 100644
index 1ba825dfbe..0000000000
--- a/src/shared/cplusplus/CheckDeclaration.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** Commercial Usage
-**
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Nokia.
-**
-** GNU Lesser General Public License Usage
-**
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
-**
-**************************************************************************/
-// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-#ifndef CPLUSPLUS_CHECKDECLARATION_H
-#define CPLUSPLUS_CHECKDECLARATION_H
-
-#include "CPlusPlusForwardDeclarations.h"
-#include "SemanticCheck.h"
-
-
-namespace CPlusPlus {
-
-class CPLUSPLUS_EXPORT CheckDeclaration: public SemanticCheck
-{
-public:
- CheckDeclaration(Semantic *semantic);
- virtual ~CheckDeclaration();
-
- void check(DeclarationAST *declaration, Scope *scope);
- void check(CtorInitializerAST *ast, Scope *scope);
-
-protected:
- DeclarationAST *switchDeclaration(DeclarationAST *declaration);
- Scope *switchScope(Scope *scope);
-
- void setDeclSpecifiers(Symbol *symbol, const FullySpecifiedType &declSpecifiers);
-
- void checkFunctionArguments(Function *fun);
-
- using ASTVisitor::visit;
-
- virtual bool visit(SimpleDeclarationAST *ast);
- virtual bool visit(EmptyDeclarationAST *ast);
- virtual bool visit(AccessDeclarationAST *ast);
- virtual bool visit(QtPropertyDeclarationAST *ast);
- virtual bool visit(QtEnumDeclarationAST *ast);
- virtual bool visit(QtFlagsDeclarationAST *ast);
- virtual bool visit(AsmDefinitionAST *ast);
- virtual bool visit(ExceptionDeclarationAST *ast);
- virtual bool visit(FunctionDefinitionAST *ast);
- virtual bool visit(LinkageBodyAST *ast);
- virtual bool visit(LinkageSpecificationAST *ast);
- virtual bool visit(NamespaceAST *ast);
- virtual bool visit(NamespaceAliasDefinitionAST *ast);
- virtual bool visit(ParameterDeclarationAST *ast);
- virtual bool visit(TemplateDeclarationAST *ast);
- virtual bool visit(TypenameTypeParameterAST *ast);
- virtual bool visit(TemplateTypeParameterAST *ast);
- virtual bool visit(UsingAST *ast);
- virtual bool visit(UsingDirectiveAST *ast);
- virtual bool visit(MemInitializerAST *ast);
-
- virtual bool visit(ObjCProtocolDeclarationAST *ast);
- virtual bool visit(ObjCProtocolForwardDeclarationAST *ast);
- virtual bool visit(ObjCClassDeclarationAST *ast);
- virtual bool visit(ObjCClassForwardDeclarationAST *ast);
- virtual bool visit(ObjCMethodDeclarationAST *ast);
- virtual bool visit(ObjCVisibilityDeclarationAST *ast);
- virtual bool visit(ObjCPropertyDeclarationAST *ast);
-
-private:
- bool checkPropertyAttribute(ObjCPropertyAttributeAST *attrAst,
- int &flags,
- int attr);
- void checkQEnumsQFlagsNames(NameListAST *nameListAst,
- const char *declName);
-
- unsigned calculateScopeStart(ObjCClassDeclarationAST *ast) const;
- unsigned calculateScopeStart(ObjCProtocolDeclarationAST *ast) const;
-
-private:
- DeclarationAST *_declaration;
- Scope *_scope;
- bool _checkAnonymousArguments: 1;
-};
-
-} // end of namespace CPlusPlus
-
-
-#endif // CPLUSPLUS_CHECKDECLARATION_H
diff --git a/src/shared/cplusplus/CheckDeclarator.cpp b/src/shared/cplusplus/CheckDeclarator.cpp
deleted file mode 100644
index 41b4ea1b3a..0000000000
--- a/src/shared/cplusplus/CheckDeclarator.cpp
+++ /dev/null
@@ -1,310 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** Commercial Usage
-**
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Nokia.
-**
-** GNU Lesser General Public License Usage
-**
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
-**
-**************************************************************************/
-// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-#include "CheckDeclarator.h"
-#include "Semantic.h"
-#include "AST.h"
-#include "Control.h"
-#include "TranslationUnit.h"
-#include "Literals.h"
-#include "CoreTypes.h"
-#include "Symbols.h"
-
-using namespace CPlusPlus;
-
-CheckDeclarator::CheckDeclarator(Semantic *semantic)
- : SemanticCheck(semantic),
- _declarator(0),
- _scope(0),
- _name(0)
-{ }
-
-CheckDeclarator::~CheckDeclarator()
-{ }
-
-FullySpecifiedType CheckDeclarator::check(DeclaratorAST *declarator,
- const FullySpecifiedType &type,
- Scope *scope,
- const Name **name)
-{
- FullySpecifiedType previousType = switchFullySpecifiedType(type);
- Scope *previousScope = switchScope(scope);
- DeclaratorAST *previousDeclarator = switchDeclarator(declarator);
- const Name **previousName = switchName(name);
- accept(declarator);
- (void) switchName(previousName);
- (void) switchDeclarator(previousDeclarator);
- (void) switchScope(previousScope);
- return switchFullySpecifiedType(previousType);
-}
-
-FullySpecifiedType CheckDeclarator::check(PtrOperatorListAST *ptrOperators,
- const FullySpecifiedType &type,
- Scope *scope)
-{
- FullySpecifiedType previousType = switchFullySpecifiedType(type);
- Scope *previousScope = switchScope(scope);
- accept(ptrOperators);
- (void) switchScope(previousScope);
- return switchFullySpecifiedType(previousType);
-}
-
-FullySpecifiedType CheckDeclarator::check(ObjCMethodPrototypeAST *methodPrototype,
- Scope *scope)
-{
- FullySpecifiedType previousType = switchFullySpecifiedType(FullySpecifiedType());
- Scope *previousScope = switchScope(scope);
- accept(methodPrototype);
- (void) switchScope(previousScope);
- return switchFullySpecifiedType(previousType);
-}
-
-DeclaratorAST *CheckDeclarator::switchDeclarator(DeclaratorAST *declarator)
-{
- DeclaratorAST *previousDeclarator = _declarator;
- _declarator = declarator;
- return previousDeclarator;
-}
-
-FullySpecifiedType CheckDeclarator::switchFullySpecifiedType(const FullySpecifiedType &type)
-{
- FullySpecifiedType previousType = _fullySpecifiedType;
- _fullySpecifiedType = type;
- return previousType;
-}
-
-Scope *CheckDeclarator::switchScope(Scope *scope)
-{
- Scope *previousScope = _scope;
- _scope = scope;
- return previousScope;
-}
-
-const Name **CheckDeclarator::switchName(const Name **name)
-{
- const Name **previousName = _name;
- _name = name;
- return previousName;
-}
-
-bool CheckDeclarator::visit(DeclaratorAST *ast)
-{
- accept(ast->ptr_operator_list);
- accept(ast->postfix_declarator_list);
- accept(ast->core_declarator);
-
- if (ast->initializer) {
- FullySpecifiedType exprTy = semantic()->check(ast->initializer, _scope);
-
- if (Function *funTy = _fullySpecifiedType->asFunctionType())
- funTy->setPureVirtual(true);
- }
-
- return false;
-}
-
-bool CheckDeclarator::visit(DeclaratorIdAST *ast)
-{
- const Name *name = semantic()->check(ast->name, _scope);
- if (_name)
- *_name = name;
- return false;
-}
-
-bool CheckDeclarator::visit(NestedDeclaratorAST *ast)
-{
- accept(ast->declarator);
- return false;
-}
-
-bool CheckDeclarator::visit(FunctionDeclaratorAST *ast)
-{
- Function *fun = control()->newFunction(ast->firstToken());
- fun->setAmbiguous(ast->as_cpp_initializer != 0);
- ast->symbol = fun;
- fun->setReturnType(_fullySpecifiedType);
-
- if (ast->parameters) {
- DeclarationListAST *parameter_declarations = ast->parameters->parameter_declaration_list;
- for (DeclarationListAST *decl = parameter_declarations; decl; decl = decl->next) {
- semantic()->check(decl->value, fun);
- }
-
- if (ast->parameters->dot_dot_dot_token)
- fun->setVariadic(true);
- }
-
- // check the arguments
- bool hasDefaultArguments = false;
- for (unsigned i = 0; i < fun->argumentCount(); ++i) {
- Argument *arg = fun->argumentAt(i)->asArgument();
- if (hasDefaultArguments && ! arg->hasInitializer()) {
- translationUnit()->error(ast->firstToken(),
- "default argument missing for parameter at position %d", i + 1);
- } else if (! hasDefaultArguments) {
- hasDefaultArguments = arg->hasInitializer();
- }
- }
-
- FullySpecifiedType funTy(fun);
- funTy = semantic()->check(ast->cv_qualifier_list, _scope, funTy);
-
- fun->setConst(funTy.isConst());
- fun->setVolatile(funTy.isVolatile());
-
- _fullySpecifiedType = funTy;
- return false;
-}
-
-bool CheckDeclarator::visit(ArrayDeclaratorAST *ast)
-{
- ArrayType *ty = control()->arrayType(_fullySpecifiedType); // ### set the dimension
- FullySpecifiedType exprTy = semantic()->check(ast->expression, _scope);
- FullySpecifiedType arrTy(ty);
- _fullySpecifiedType = ty;
- return false;
-}
-
-bool CheckDeclarator::visit(PointerToMemberAST *ast)
-{
- const Name *memberName = semantic()->check(ast->nested_name_specifier_list, _scope);
- PointerToMemberType *ptrTy = control()->pointerToMemberType(memberName, _fullySpecifiedType);
- FullySpecifiedType ty(ptrTy);
- _fullySpecifiedType = ty;
- applyCvQualifiers(ast->cv_qualifier_list);
- return false;
-}
-
-bool CheckDeclarator::visit(PointerAST *ast)
-{
- if (_fullySpecifiedType->isReferenceType())
- translationUnit()->error(ast->firstToken(), "cannot declare pointer to a reference");
-
- PointerType *ptrTy = control()->pointerType(_fullySpecifiedType);
- FullySpecifiedType ty(ptrTy);
- _fullySpecifiedType = ty;
- applyCvQualifiers(ast->cv_qualifier_list);
- return false;
-}
-
-bool CheckDeclarator::visit(ReferenceAST *ast)
-{
- const bool rvalueRef = (tokenKind(ast->reference_token) == T_AMPER_AMPER);
-
- if (_fullySpecifiedType->isReferenceType())
- translationUnit()->error(ast->firstToken(), "cannot declare reference to a reference");
-
- ReferenceType *refTy = control()->referenceType(_fullySpecifiedType, rvalueRef);
- FullySpecifiedType ty(refTy);
- _fullySpecifiedType = ty;
- return false;
-}
-
-bool CheckDeclarator::visit(ObjCMethodPrototypeAST *ast)
-{
- if (!ast)
- return false;
-
- if (!ast->selector) {
- // TODO: (EV) this currently happens when parsing:
- // + (id<NSSomeProtocol>) zoo;
- // where the parser will start doing template magic. We'll need to disambiguate this case.
- return false;
- }
-
- FullySpecifiedType returnType;
- if (ast->type_name && ast->type_name->type_id)
- returnType = semantic()->check(ast->type_name->type_id, _scope);
-
- unsigned location = ast->selector->firstToken();
-
- semantic()->check(ast->selector, _scope);
-
- ObjCMethod *method = control()->newObjCMethod(location, ast->selector->name);
- ast->symbol = method;
- method->setScope(_scope);
- method->setVisibility(semantic()->currentVisibility());
- method->setReturnType(returnType);
- if (semantic()->isObjCClassMethod(tokenKind(ast->method_type_token)))
- method->setStorage(Symbol::Static);
-
- for (ObjCMessageArgumentDeclarationListAST *it = ast->argument_list; it; it = it->next) {
- ObjCMessageArgumentDeclarationAST *argDecl = it->value;
-
- semantic()->check(argDecl, method);
- }
-
- if (ast->dot_dot_dot_token)
- method->setVariadic(true);
-
- _fullySpecifiedType = FullySpecifiedType(method);
- _fullySpecifiedType = semantic()->check(ast->attribute_list, _scope,
- _fullySpecifiedType);
-
- return false;
-}
-
-void CheckDeclarator::applyCvQualifiers(SpecifierListAST *it)
-{
- for (; it; it = it->next) {
- SpecifierAST *cv = it->value;
- SimpleSpecifierAST *spec = static_cast<SimpleSpecifierAST *>(cv);
- switch (translationUnit()->tokenKind(spec->specifier_token)) {
- case T_VOLATILE:
- _fullySpecifiedType.setVolatile(true);
- break;
- case T_CONST:
- _fullySpecifiedType.setConst(true);
- break;
- default:
- break;
- } // switch
- }
-}
-
-
diff --git a/src/shared/cplusplus/CheckDeclarator.h b/src/shared/cplusplus/CheckDeclarator.h
deleted file mode 100644
index cfd1c93bbe..0000000000
--- a/src/shared/cplusplus/CheckDeclarator.h
+++ /dev/null
@@ -1,112 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** Commercial Usage
-**
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Nokia.
-**
-** GNU Lesser General Public License Usage
-**
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
-**
-**************************************************************************/
-// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-#ifndef CPLUSPLUS_CHECKDECLARATOR_H
-#define CPLUSPLUS_CHECKDECLARATOR_H
-
-#include "CPlusPlusForwardDeclarations.h"
-#include "SemanticCheck.h"
-#include "FullySpecifiedType.h"
-
-
-namespace CPlusPlus {
-
-class CPLUSPLUS_EXPORT CheckDeclarator: public SemanticCheck
-{
-public:
- CheckDeclarator(Semantic *semantic);
- virtual ~CheckDeclarator();
-
- FullySpecifiedType check(DeclaratorAST *declarator,
- const FullySpecifiedType &type,
- Scope *scope,
- const Name **name);
-
- FullySpecifiedType check(PtrOperatorListAST *ptrOperators,
- const FullySpecifiedType &type,
- Scope *scope);
-
- FullySpecifiedType check(ObjCMethodPrototypeAST *methodPrototype,
- Scope *scope);
-
-protected:
- DeclaratorAST *switchDeclarator(DeclaratorAST *declarator);
- FullySpecifiedType switchFullySpecifiedType(const FullySpecifiedType &type);
- Scope *switchScope(Scope *scope);
- const Name **switchName(const Name **name);
-
- using ASTVisitor::visit;
-
- virtual bool visit(DeclaratorAST *ast);
- // ptr operators
- virtual bool visit(PointerToMemberAST *ast);
- virtual bool visit(PointerAST *ast);
- virtual bool visit(ReferenceAST *ast);
- // core declarators
- virtual bool visit(DeclaratorIdAST *ast);
- virtual bool visit(NestedDeclaratorAST *ast);
- // postfix declarators
- virtual bool visit(FunctionDeclaratorAST *ast);
- virtual bool visit(ArrayDeclaratorAST *ast);
- // ObjC
- virtual bool visit(ObjCMethodPrototypeAST *ast);
-
- void checkMessageArgument(ObjCMessageArgumentDeclarationAST *arg);
- void applyCvQualifiers(SpecifierListAST *it);
-
-private:
- DeclaratorAST *_declarator;
- Scope *_scope;
- const Name **_name;
- FullySpecifiedType _fullySpecifiedType;
-};
-
-} // end of namespace CPlusPlus
-
-
-#endif // CPLUSPLUS_CHECKDECLARATOR_H
diff --git a/src/shared/cplusplus/CheckExpression.cpp b/src/shared/cplusplus/CheckExpression.cpp
deleted file mode 100644
index 1f402dca55..0000000000
--- a/src/shared/cplusplus/CheckExpression.cpp
+++ /dev/null
@@ -1,413 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** Commercial Usage
-**
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Nokia.
-**
-** GNU Lesser General Public License Usage
-**
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
-**
-**************************************************************************/
-// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-#include "CheckExpression.h"
-#include "Semantic.h"
-#include "TranslationUnit.h"
-#include "AST.h"
-#include "Scope.h"
-#include "Literals.h"
-#include "CoreTypes.h"
-#include "Symbols.h"
-#include "Control.h"
-
-using namespace CPlusPlus;
-
-CheckExpression::CheckExpression(Semantic *semantic)
- : SemanticCheck(semantic),
- _expression(0),
- _scope(0),
- _checkOldStyleCasts(false)
-{ }
-
-CheckExpression::~CheckExpression()
-{ }
-
-FullySpecifiedType CheckExpression::check(ExpressionAST *expression, Scope *scope)
-{
- FullySpecifiedType previousType = switchFullySpecifiedType(FullySpecifiedType());
- Scope *previousScope = switchScope(scope);
- ExpressionAST *previousExpression = switchExpression(expression);
- accept(expression);
- (void) switchExpression(previousExpression);
- (void) switchScope(previousScope);
- return switchFullySpecifiedType(previousType);
-}
-
-ExpressionAST *CheckExpression::switchExpression(ExpressionAST *expression)
-{
- ExpressionAST *previousExpression = _expression;
- _expression = expression;
- return previousExpression;
-}
-
-FullySpecifiedType CheckExpression::switchFullySpecifiedType(const FullySpecifiedType &type)
-{
- FullySpecifiedType previousType = _fullySpecifiedType;
- _fullySpecifiedType = type;
- return previousType;
-}
-
-Scope *CheckExpression::switchScope(Scope *scope)
-{
- Scope *previousScope = _scope;
- _scope = scope;
- return previousScope;
-}
-
-bool CheckExpression::visit(BinaryExpressionAST *ast)
-{
- FullySpecifiedType leftExprTy = semantic()->check(ast->left_expression, _scope);
- FullySpecifiedType rightExprTy = semantic()->check(ast->right_expression, _scope);
- return false;
-}
-
-bool CheckExpression::visit(CastExpressionAST *ast)
-{
- FullySpecifiedType castTy = semantic()->check(ast->type_id, _scope);
- FullySpecifiedType exprTy = semantic()->check(ast->expression, _scope);
- if (_checkOldStyleCasts && ! castTy->isVoidType())
- translationUnit()->warning(ast->firstToken(),
- "ugly old style cast");
- return false;
-}
-
-bool CheckExpression::visit(ConditionAST *ast)
-{
- FullySpecifiedType typeSpecTy = semantic()->check(ast->type_specifier_list, _scope);
- const Name *name = 0;
- FullySpecifiedType declTy = semantic()->check(ast->declarator, typeSpecTy.qualifiedType(),
- _scope, &name);
- Declaration *decl = control()->newDeclaration(semantic()->location(ast->declarator), name);
- decl->setType(declTy);
- _scope->addMember(decl);
- return false;
-}
-
-bool CheckExpression::visit(ConditionalExpressionAST *ast)
-{
- FullySpecifiedType condTy = semantic()->check(ast->condition, _scope);
- FullySpecifiedType leftExprTy = semantic()->check(ast->left_expression, _scope);
- FullySpecifiedType rightExprTy = semantic()->check(ast->right_expression, _scope);
- return false;
-}
-
-bool CheckExpression::visit(CppCastExpressionAST *ast)
-{
- FullySpecifiedType typeIdTy = semantic()->check(ast->type_id, _scope);
- FullySpecifiedType exprTy = semantic()->check(ast->expression, _scope);
- return false;
-}
-
-bool CheckExpression::visit(DeleteExpressionAST *ast)
-{
- FullySpecifiedType exprTy = semantic()->check(ast->expression, _scope);
- return false;
-}
-
-bool CheckExpression::visit(ArrayInitializerAST *ast)
-{
- for (ExpressionListAST *it = ast->expression_list; it; it = it->next) {
- FullySpecifiedType exprTy = semantic()->check(it->value, _scope);
- }
- return false;
-}
-
-bool CheckExpression::visit(QualifiedNameAST *ast)
-{
- (void) semantic()->check(ast, _scope);
- return false;
-}
-
-bool CheckExpression::visit(OperatorFunctionIdAST *ast)
-{
- (void) semantic()->check(ast, _scope);
- return false;
-}
-
-bool CheckExpression::visit(ConversionFunctionIdAST *ast)
-{
- (void) semantic()->check(ast, _scope);
- return false;
-}
-
-bool CheckExpression::visit(SimpleNameAST *ast)
-{
- (void) semantic()->check(ast, _scope);
- return false;
-}
-
-bool CheckExpression::visit(DestructorNameAST *ast)
-{
- (void) semantic()->check(ast, _scope);
- return false;
-}
-
-bool CheckExpression::visit(TemplateIdAST *ast)
-{
- (void) semantic()->check(ast, _scope);
- return false;
-}
-
-bool CheckExpression::visit(NewExpressionAST *ast)
-{
- if (ast->new_placement) {
- for (ExpressionListAST *it = ast->new_placement->expression_list; it; it = it->next) {
- FullySpecifiedType exprTy = semantic()->check(it->value, _scope);
- }
- }
-
- FullySpecifiedType typeIdTy = semantic()->check(ast->type_id, _scope);
-
- if (ast->new_type_id) {
- FullySpecifiedType ty = semantic()->check(ast->new_type_id->type_specifier_list, _scope);
-
- for (NewArrayDeclaratorListAST *it = ast->new_type_id->new_array_declarator_list; it; it = it->next) {
- if (NewArrayDeclaratorAST *declarator = it->value) {
- FullySpecifiedType exprTy = semantic()->check(declarator->expression, _scope);
- }
- }
- }
-
- // ### process new-initializer
- if (ast->new_initializer) {
- FullySpecifiedType exprTy = semantic()->check(ast->new_initializer->expression, _scope);
- }
-
- return false;
-}
-
-bool CheckExpression::visit(TypeidExpressionAST *ast)
-{
- FullySpecifiedType exprTy = semantic()->check(ast->expression, _scope);
- return false;
-}
-
-bool CheckExpression::visit(TypenameCallExpressionAST *ast)
-{
- (void) semantic()->check(ast->name, _scope);
-
- for (ExpressionListAST *it = ast->expression_list; it; it = it->next) {
- FullySpecifiedType exprTy = semantic()->check(it->value, _scope);
- (void) exprTy;
- }
- return false;
-}
-
-bool CheckExpression::visit(TypeConstructorCallAST *ast)
-{
- FullySpecifiedType typeSpecTy = semantic()->check(ast->type_specifier_list, _scope);
- for (ExpressionListAST *it = ast->expression_list; it; it = it->next) {
- FullySpecifiedType exprTy = semantic()->check(it->value, _scope);
- }
- return false;
-}
-
-bool CheckExpression::visit(SizeofExpressionAST *ast)
-{
- FullySpecifiedType exprTy = semantic()->check(ast->expression, _scope);
- return false;
-}
-
-bool CheckExpression::visit(NumericLiteralAST *)
-{
- _fullySpecifiedType.setType(control()->integerType(IntegerType::Int));
- return false;
-}
-
-bool CheckExpression::visit(BoolLiteralAST *)
-{
- _fullySpecifiedType.setType(control()->integerType(IntegerType::Bool));
- return false;
-}
-
-bool CheckExpression::visit(StringLiteralAST *)
-{
- IntegerType *charTy = control()->integerType(IntegerType::Char);
- _fullySpecifiedType.setType(control()->pointerType(charTy));
- return false;
-}
-
-bool CheckExpression::visit(ThisExpressionAST *)
-{
- return false;
-}
-
-bool CheckExpression::visit(CompoundExpressionAST *ast)
-{
- _fullySpecifiedType = semantic()->check(ast->statement, _scope);
- return false;
-}
-
-bool CheckExpression::visit(NestedExpressionAST *ast)
-{
- _fullySpecifiedType = semantic()->check(ast->expression, _scope);
- return false;
-}
-
-bool CheckExpression::visit(ThrowExpressionAST *ast)
-{
- FullySpecifiedType exprTy = semantic()->check(ast->expression, _scope);
- return false;
-}
-
-bool CheckExpression::visit(TypeIdAST *ast)
-{
- FullySpecifiedType typeSpecTy = semantic()->check(ast->type_specifier_list, _scope);
- FullySpecifiedType declTy = semantic()->check(ast->declarator, typeSpecTy.qualifiedType(), _scope);
- _fullySpecifiedType = declTy;
- return false;
-}
-
-bool CheckExpression::visit(UnaryExpressionAST *ast)
-{
- FullySpecifiedType exprTy = semantic()->check(ast->expression, _scope);
- return false;
-}
-
-bool CheckExpression::visit(QtMethodAST *ast)
-{
- (void) ast;
- // ### port this code
-#if 0
- const Name *name = 0;
- Scope *dummy = 0;
- FullySpecifiedType methTy = semantic()->check(ast->declarator, FullySpecifiedType(),
- dummy, &name);
- Function *fty = methTy->asFunctionType();
- if (! fty)
- translationUnit()->warning(ast->firstToken(), "expected a function declarator");
- else {
- for (unsigned i = 0; i < fty->argumentCount(); ++i) {
- Symbol *arg = fty->argumentAt(i);
- if (arg->name())
- translationUnit()->warning(arg->sourceLocation(),
- "argument should be anonymous");
- }
- }
-#endif
- return false;
-}
-
-bool CheckExpression::visit(CompoundLiteralAST *ast)
-{
- /*FullySpecifiedType exprTy = */ semantic()->check(ast->type_id, _scope);
- /*FullySpecifiedType initTy = */ semantic()->check(ast->initializer, _scope);
- return false;
-}
-
-bool CheckExpression::visit(CallAST *ast)
-{
- FullySpecifiedType baseTy = semantic()->check(ast->base_expression, _scope);
- for (ExpressionListAST *it = ast->expression_list; it; it = it->next) {
- FullySpecifiedType exprTy = semantic()->check(it->value, _scope);
- }
- return false;
-}
-
-bool CheckExpression::visit(ArrayAccessAST *ast)
-{
- FullySpecifiedType baseTy = semantic()->check(ast->base_expression, _scope);
- FullySpecifiedType exprTy = semantic()->check(ast->expression, _scope);
- return false;
-}
-
-bool CheckExpression::visit(PostIncrDecrAST *ast)
-{
- FullySpecifiedType baseTy = semantic()->check(ast->base_expression, _scope);
- return false;
-}
-
-bool CheckExpression::visit(MemberAccessAST *ast)
-{
- FullySpecifiedType baseTy = semantic()->check(ast->base_expression, _scope);
- const Name *memberName = semantic()->check(ast->member_name, _scope);
- (void) memberName;
- return false;
-}
-
-bool CheckExpression::visit(ObjCMessageExpressionAST *ast)
-{
- (void) semantic()->check(ast->receiver_expression, _scope);
- (void) semantic()->check(ast->selector, _scope);
-
- accept(ast->argument_list); // ### not necessary.
- return false;
-}
-
-bool CheckExpression::visit(ObjCEncodeExpressionAST * /*ast*/)
-{
- // TODO: visit the type name, but store the type here? (EV)
- return true;
-}
-
-bool CheckExpression::visit(ObjCSelectorExpressionAST *ast)
-{
- if (_scope->isFunction())
- return false;
-
- (void) semantic()->check(ast->selector, _scope);
- return false;
-}
-
-bool CheckExpression::visit(LambdaExpressionAST *ast)
-{
- if (_scope->isFunction())
- return false;
-
- (void) semantic()->check(ast->statement, _scope);
- return false;
-}
-
-bool CheckExpression::visit(BracedInitializerAST *ast)
-{
- for (ExpressionListAST *it = ast->expression_list; it; it = it->next)
- (void) semantic()->check(it->value, _scope);
-
- return false;
-}
diff --git a/src/shared/cplusplus/CheckExpression.h b/src/shared/cplusplus/CheckExpression.h
deleted file mode 100644
index ce51541af3..0000000000
--- a/src/shared/cplusplus/CheckExpression.h
+++ /dev/null
@@ -1,129 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** Commercial Usage
-**
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Nokia.
-**
-** GNU Lesser General Public License Usage
-**
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
-**
-**************************************************************************/
-// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-#ifndef CPLUSPLUS_CHECKEXPRESSION_H
-#define CPLUSPLUS_CHECKEXPRESSION_H
-
-#include "CPlusPlusForwardDeclarations.h"
-#include "SemanticCheck.h"
-#include "FullySpecifiedType.h"
-
-
-namespace CPlusPlus {
-
-class CPLUSPLUS_EXPORT CheckExpression: public SemanticCheck
-{
-public:
- CheckExpression(Semantic *semantic);
- virtual ~CheckExpression();
-
- FullySpecifiedType check(ExpressionAST *expression, Scope *scope);
-
-protected:
- ExpressionAST *switchExpression(ExpressionAST *expression);
- FullySpecifiedType switchFullySpecifiedType(const FullySpecifiedType &type);
- Scope *switchScope(Scope *scope);
-
- using ASTVisitor::visit;
-
- virtual bool visit(BinaryExpressionAST *ast);
- virtual bool visit(CastExpressionAST *ast);
- virtual bool visit(ConditionAST *ast);
- virtual bool visit(ConditionalExpressionAST *ast);
- virtual bool visit(CppCastExpressionAST *ast);
- virtual bool visit(DeleteExpressionAST *ast);
- virtual bool visit(ArrayInitializerAST *ast);
- virtual bool visit(NewExpressionAST *ast);
- virtual bool visit(TypeidExpressionAST *ast);
- virtual bool visit(TypenameCallExpressionAST *ast);
- virtual bool visit(TypeConstructorCallAST *ast);
- virtual bool visit(SizeofExpressionAST *ast);
- virtual bool visit(NumericLiteralAST *ast);
- virtual bool visit(BoolLiteralAST *ast);
- virtual bool visit(ThisExpressionAST *ast);
- virtual bool visit(NestedExpressionAST *ast);
- virtual bool visit(StringLiteralAST *ast);
- virtual bool visit(ThrowExpressionAST *ast);
- virtual bool visit(TypeIdAST *ast);
- virtual bool visit(UnaryExpressionAST *ast);
- virtual bool visit(QtMethodAST *ast);
- virtual bool visit(CompoundLiteralAST *ast);
- virtual bool visit(CompoundExpressionAST *ast);
- virtual bool visit(LambdaExpressionAST *ast);
- virtual bool visit(BracedInitializerAST *ast);
-
- //names
- virtual bool visit(QualifiedNameAST *ast);
- virtual bool visit(OperatorFunctionIdAST *ast);
- virtual bool visit(ConversionFunctionIdAST *ast);
- virtual bool visit(SimpleNameAST *ast);
- virtual bool visit(DestructorNameAST *ast);
- virtual bool visit(TemplateIdAST *ast);
-
- // postfix expressions
- virtual bool visit(CallAST *ast);
- virtual bool visit(ArrayAccessAST *ast);
- virtual bool visit(PostIncrDecrAST *ast);
- virtual bool visit(MemberAccessAST *ast);
-
- // ObjC
- virtual bool visit(ObjCMessageExpressionAST *ast);
- virtual bool visit(ObjCEncodeExpressionAST *ast);
- virtual bool visit(ObjCSelectorExpressionAST *ast);
-
-private:
- ExpressionAST *_expression;
- FullySpecifiedType _fullySpecifiedType;
- Scope *_scope;
- bool _checkOldStyleCasts: 1;
-};
-
-} // end of namespace CPlusPlus
-
-
-#endif // CPLUSPLUS_CHECKEXPRESSION_H
diff --git a/src/shared/cplusplus/CheckName.cpp b/src/shared/cplusplus/CheckName.cpp
deleted file mode 100644
index 4e67a6124c..0000000000
--- a/src/shared/cplusplus/CheckName.cpp
+++ /dev/null
@@ -1,419 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** Commercial Usage
-**
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Nokia.
-**
-** GNU Lesser General Public License Usage
-**
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
-**
-**************************************************************************/
-// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-#include "CheckName.h"
-#include "Semantic.h"
-#include "AST.h"
-#include "Control.h"
-#include "TranslationUnit.h"
-#include "Literals.h"
-#include "Names.h"
-#include "CoreTypes.h"
-#include "Symbols.h"
-#include "Scope.h"
-#include <cassert>
-
-using namespace CPlusPlus;
-
-CheckName::CheckName(Semantic *semantic)
- : SemanticCheck(semantic),
- _name(0),
- _scope(0)
-{ }
-
-CheckName::~CheckName()
-{ }
-
-const Name *CheckName::check(NameAST *name, Scope *scope)
-{
- const Name *previousName = switchName(0);
- Scope *previousScope = switchScope(scope);
- accept(name);
-
- if (_name && name)
- name->name = _name;
-
- (void) switchScope(previousScope);
- return switchName(previousName);
-}
-
-const Name *CheckName::check(NestedNameSpecifierListAST *nested_name_specifier_list, Scope *scope)
-{
- const Name *previousName = switchName(0);
- Scope *previousScope = switchScope(scope);
-
- for (NestedNameSpecifierListAST *it = nested_name_specifier_list; it; it = it->next) {
- NestedNameSpecifierAST *nested_name_specifier = it->value;
- const Name *n = semantic()->check(nested_name_specifier->class_or_namespace_name, _scope);
- if (! _name)
- _name = n;
- else
- _name = control()->qualifiedNameId(_name, n);
- }
-
- (void) switchScope(previousScope);
- return switchName(previousName);
-}
-
-void CheckName::check(ObjCMessageArgumentDeclarationAST *arg, Scope *scope)
-{
- const Name *previousName = switchName(0);
- Scope *previousScope = switchScope(scope);
-
- accept(arg);
-
- (void) switchScope(previousScope);
- (void) switchName(previousName);
-}
-
-const Name *CheckName::switchName(const Name *name)
-{
- const Name *previousName = _name;
- _name = name;
- return previousName;
-}
-
-Scope *CheckName::switchScope(Scope *scope)
-{
- Scope *previousScope = _scope;
- _scope = scope;
- return previousScope;
-}
-
-bool CheckName::visit(QualifiedNameAST *ast)
-{
- for (NestedNameSpecifierListAST *it = ast->nested_name_specifier_list; it; it = it->next) {
- NestedNameSpecifierAST *nested_name_specifier = it->value;
- const Name *n = semantic()->check(nested_name_specifier->class_or_namespace_name, _scope);
- if (_name || ast->global_scope_token)
- _name = control()->qualifiedNameId(_name, n);
- else
- _name = n;
- }
-
- const Name *n = semantic()->check(ast->unqualified_name, _scope);
- if (_name || ast->global_scope_token)
- _name = control()->qualifiedNameId(_name, n);
- else
- _name = n;
-
- ast->name = _name;
- return false;
-}
-
-bool CheckName::visit(OperatorFunctionIdAST *ast)
-{
- assert(ast->op != 0);
-
- OperatorNameId::Kind kind = OperatorNameId::InvalidOp;
-
- switch (tokenKind(ast->op->op_token)) {
- case T_NEW:
- if (ast->op->open_token)
- kind = OperatorNameId::NewArrayOp;
- else
- kind = OperatorNameId::NewOp;
- break;
-
- case T_DELETE:
- if (ast->op->open_token)
- kind = OperatorNameId::DeleteArrayOp;
- else
- kind = OperatorNameId::DeleteOp;
- break;
-
- case T_PLUS:
- kind = OperatorNameId::PlusOp;
- break;
-
- case T_MINUS:
- kind = OperatorNameId::MinusOp;
- break;
-
- case T_STAR:
- kind = OperatorNameId::StarOp;
- break;
-
- case T_SLASH:
- kind = OperatorNameId::SlashOp;
- break;
-
- case T_PERCENT:
- kind = OperatorNameId::PercentOp;
- break;
-
- case T_CARET:
- kind = OperatorNameId::CaretOp;
- break;
-
- case T_AMPER:
- kind = OperatorNameId::AmpOp;
- break;
-
- case T_PIPE:
- kind = OperatorNameId::PipeOp;
- break;
-
- case T_TILDE:
- kind = OperatorNameId::TildeOp;
- break;
-
- case T_EXCLAIM:
- kind = OperatorNameId::ExclaimOp;
- break;
-
- case T_EQUAL:
- kind = OperatorNameId::EqualOp;
- break;
-
- case T_LESS:
- kind = OperatorNameId::LessOp;
- break;
-
- case T_GREATER:
- kind = OperatorNameId::GreaterOp;
- break;
-
- case T_PLUS_EQUAL:
- kind = OperatorNameId::PlusEqualOp;
- break;
-
- case T_MINUS_EQUAL:
- kind = OperatorNameId::MinusEqualOp;
- break;
-
- case T_STAR_EQUAL:
- kind = OperatorNameId::StarEqualOp;
- break;
-
- case T_SLASH_EQUAL:
- kind = OperatorNameId::SlashEqualOp;
- break;
-
- case T_PERCENT_EQUAL:
- kind = OperatorNameId::PercentEqualOp;
- break;
-
- case T_CARET_EQUAL:
- kind = OperatorNameId::CaretEqualOp;
- break;
-
- case T_AMPER_EQUAL:
- kind = OperatorNameId::AmpEqualOp;
- break;
-
- case T_PIPE_EQUAL:
- kind = OperatorNameId::PipeEqualOp;
- break;
-
- case T_LESS_LESS:
- kind = OperatorNameId::LessLessOp;
- break;
-
- case T_GREATER_GREATER:
- kind = OperatorNameId::GreaterGreaterOp;
- break;
-
- case T_LESS_LESS_EQUAL:
- kind = OperatorNameId::LessLessEqualOp;
- break;
-
- case T_GREATER_GREATER_EQUAL:
- kind = OperatorNameId::GreaterGreaterEqualOp;
- break;
-
- case T_EQUAL_EQUAL:
- kind = OperatorNameId::EqualEqualOp;
- break;
-
- case T_EXCLAIM_EQUAL:
- kind = OperatorNameId::ExclaimEqualOp;
- break;
-
- case T_LESS_EQUAL:
- kind = OperatorNameId::LessEqualOp;
- break;
-
- case T_GREATER_EQUAL:
- kind = OperatorNameId::GreaterEqualOp;
- break;
-
- case T_AMPER_AMPER:
- kind = OperatorNameId::AmpAmpOp;
- break;
-
- case T_PIPE_PIPE:
- kind = OperatorNameId::PipePipeOp;
- break;
-
- case T_PLUS_PLUS:
- kind = OperatorNameId::PlusPlusOp;
- break;
-
- case T_MINUS_MINUS:
- kind = OperatorNameId::MinusMinusOp;
- break;
-
- case T_COMMA:
- kind = OperatorNameId::CommaOp;
- break;
-
- case T_ARROW_STAR:
- kind = OperatorNameId::ArrowStarOp;
- break;
-
- case T_ARROW:
- kind = OperatorNameId::ArrowOp;
- break;
-
- case T_LPAREN:
- kind = OperatorNameId::FunctionCallOp;
- break;
-
- case T_LBRACKET:
- kind = OperatorNameId::ArrayAccessOp;
- break;
-
- default:
- kind = OperatorNameId::InvalidOp;
- } // switch
-
- _name = control()->operatorNameId(kind);
- ast->name = _name;
- return false;
-}
-
-bool CheckName::visit(ConversionFunctionIdAST *ast)
-{
- FullySpecifiedType ty = semantic()->check(ast->type_specifier_list, _scope);
- ty = semantic()->check(ast->ptr_operator_list, ty, _scope);
- _name = control()->conversionNameId(ty);
- return false;
-}
-
-bool CheckName::visit(SimpleNameAST *ast)
-{
- const Identifier *id = identifier(ast->identifier_token);
- _name = control()->nameId(id);
- ast->name = _name;
- return false;
-}
-
-bool CheckName::visit(DestructorNameAST *ast)
-{
- const Identifier *id = identifier(ast->identifier_token);
- _name = control()->destructorNameId(id);
- ast->name = _name;
- return false;
-}
-
-bool CheckName::visit(TemplateIdAST *ast)
-{
- const Identifier *id = identifier(ast->identifier_token);
- std::vector<FullySpecifiedType> templateArguments;
- for (ExpressionListAST *it = ast->template_argument_list; it;
- it = it->next) {
- ExpressionAST *arg = it->value;
- FullySpecifiedType exprTy = semantic()->check(arg, _scope);
- templateArguments.push_back(exprTy);
- }
- if (templateArguments.empty())
- _name = control()->templateNameId(id);
- else
- _name = control()->templateNameId(id, &templateArguments[0],
- templateArguments.size());
- ast->name = _name;
- return false;
-}
-
-bool CheckName::visit(ObjCSelectorAST *ast)
-{
- std::vector<const Name *> names;
- bool hasArgs = false;
- for (ObjCSelectorArgumentListAST *it = ast->selector_argument_list; it; it = it->next) {
- if (it->value->name_token) {
- const Identifier *id = control()->identifier(spell(it->value->name_token));
- const NameId *nameId = control()->nameId(id);
- names.push_back(nameId);
-
- if (!hasArgs && it->value->colon_token)
- hasArgs = true;
- } else {
- // we have an incomplete name due, probably due to error recovery. So, back out completely
- return false;
- }
- }
-
- if (!names.empty()) {
- _name = control()->selectorNameId(&names[0], names.size(), hasArgs);
- ast->name = _name;
- }
-
- return false;
-}
-
-bool CheckName::visit(ObjCMessageArgumentDeclarationAST *ast)
-{
- FullySpecifiedType type;
-
- if (ast->type_name && ast->type_name->type_id)
- type = semantic()->check(ast->type_name->type_id, _scope);
-
- if (ast->param_name) {
- accept(ast->param_name);
-
- Argument *arg = control()->newArgument(ast->param_name->firstToken(),
- ast->param_name->name);
- ast->argument = arg;
- arg->setType(type);
- arg->setInitializer(0);
- _scope->addMember(arg);
- }
-
- return false;
-}
diff --git a/src/shared/cplusplus/CheckName.h b/src/shared/cplusplus/CheckName.h
deleted file mode 100644
index 46a4cf2a8c..0000000000
--- a/src/shared/cplusplus/CheckName.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** Commercial Usage
-**
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Nokia.
-**
-** GNU Lesser General Public License Usage
-**
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
-**
-**************************************************************************/
-// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-#ifndef CPLUSPLUS_CHECKNAME_H
-#define CPLUSPLUS_CHECKNAME_H
-
-#include "CPlusPlusForwardDeclarations.h"
-#include "SemanticCheck.h"
-
-
-namespace CPlusPlus {
-
-class CPLUSPLUS_EXPORT CheckName: public SemanticCheck
-{
-public:
- CheckName(Semantic *semantic);
- virtual ~CheckName();
-
- const Name *check(NameAST *name, Scope *scope);
- const Name *check(NestedNameSpecifierListAST *name, Scope *scope);
- void check(ObjCMessageArgumentDeclarationAST *arg, Scope *scope);
-
-protected:
- const Name *switchName(const Name *name);
- Scope *switchScope(Scope *scope);
-
- using ASTVisitor::visit;
-
- virtual bool visit(QualifiedNameAST *ast);
- virtual bool visit(OperatorFunctionIdAST *ast);
- virtual bool visit(ConversionFunctionIdAST *ast);
- virtual bool visit(SimpleNameAST *ast);
- virtual bool visit(DestructorNameAST *ast);
- virtual bool visit(TemplateIdAST *ast);
-
- // ObjC
- virtual bool visit(ObjCSelectorAST *ast);
- virtual bool visit(ObjCMessageArgumentDeclarationAST *ast);
-
-private:
- const Name *_name;
- Scope *_scope;
-};
-
-} // end of namespace CPlusPlus
-
-
-#endif // CPLUSPLUS_CHECKNAME_H
diff --git a/src/shared/cplusplus/CheckSpecifier.cpp b/src/shared/cplusplus/CheckSpecifier.cpp
deleted file mode 100644
index 6bb4879246..0000000000
--- a/src/shared/cplusplus/CheckSpecifier.cpp
+++ /dev/null
@@ -1,448 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** Commercial Usage
-**
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Nokia.
-**
-** GNU Lesser General Public License Usage
-**
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
-**
-**************************************************************************/
-// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-#include "CheckSpecifier.h"
-#include "Semantic.h"
-#include "AST.h"
-#include "Token.h"
-#include "TranslationUnit.h"
-#include "Literals.h"
-#include "Names.h"
-#include "CoreTypes.h"
-#include "Symbols.h"
-#include "Control.h"
-#include "Scope.h"
-
-using namespace CPlusPlus;
-
-CheckSpecifier::CheckSpecifier(Semantic *semantic)
- : SemanticCheck(semantic),
- _specifier(0),
- _scope(0)
-{ }
-
-CheckSpecifier::~CheckSpecifier()
-{ }
-
-FullySpecifiedType CheckSpecifier::check(SpecifierListAST *specifier,
- Scope *scope,
- const FullySpecifiedType &ty)
-{
- FullySpecifiedType previousType = switchFullySpecifiedType(ty);
- Scope *previousScope = switchScope(scope);
- SpecifierListAST *previousSpecifier = switchSpecifier(specifier);
- accept(specifier);
- (void) switchSpecifier(previousSpecifier);
- (void) switchScope(previousScope);
- return switchFullySpecifiedType(previousType);
-}
-
-SpecifierListAST *CheckSpecifier::switchSpecifier(SpecifierListAST *specifier)
-{
- SpecifierListAST *previousSpecifier = _specifier;
- _specifier = specifier;
- return previousSpecifier;
-}
-
-FullySpecifiedType CheckSpecifier::switchFullySpecifiedType(const FullySpecifiedType &type)
-{
- FullySpecifiedType previousType = _fullySpecifiedType;
- _fullySpecifiedType = type;
- return previousType;
-}
-
-Scope *CheckSpecifier::switchScope(Scope *scope)
-{
- Scope *previousScope = _scope;
- _scope = scope;
- return previousScope;
-}
-
-bool CheckSpecifier::visit(SimpleSpecifierAST *ast)
-{
- switch (tokenKind(ast->specifier_token)) {
- case T_CONST:
- if (_fullySpecifiedType.isConst())
- translationUnit()->error(ast->specifier_token,
- "duplicate `%s'", spell(ast->specifier_token));
- _fullySpecifiedType.setConst(true);
- break;
-
- case T_VOLATILE:
- if (_fullySpecifiedType.isVolatile())
- translationUnit()->error(ast->specifier_token,
- "duplicate `%s'", spell(ast->specifier_token));
- _fullySpecifiedType.setVolatile(true);
- break;
-
- case T_FRIEND:
- if (_fullySpecifiedType.isFriend())
- translationUnit()->error(ast->specifier_token,
- "duplicate `%s'", spell(ast->specifier_token));
- _fullySpecifiedType.setFriend(true);
- break;
-
- case T_AUTO:
- if (_fullySpecifiedType.isAuto())
- translationUnit()->error(ast->specifier_token,
- "duplicate `%s'", spell(ast->specifier_token));
- _fullySpecifiedType.setAuto(true);
- break;
-
- case T_REGISTER:
- if (_fullySpecifiedType.isRegister())
- translationUnit()->error(ast->specifier_token,
- "duplicate `%s'", spell(ast->specifier_token));
- _fullySpecifiedType.setRegister(true);
- break;
-
- case T_STATIC:
- if (_fullySpecifiedType.isStatic())
- translationUnit()->error(ast->specifier_token,
- "duplicate `%s'", spell(ast->specifier_token));
- _fullySpecifiedType.setStatic(true);
- break;
-
- case T_EXTERN:
- if (_fullySpecifiedType.isExtern())
- translationUnit()->error(ast->specifier_token,
- "duplicate `%s'", spell(ast->specifier_token));
- _fullySpecifiedType.setExtern(true);
- break;
-
- case T_MUTABLE:
- if (_fullySpecifiedType.isMutable())
- translationUnit()->error(ast->specifier_token,
- "duplicate `%s'", spell(ast->specifier_token));
- _fullySpecifiedType.setMutable(true);
- break;
-
- case T_TYPEDEF:
- if (_fullySpecifiedType.isTypedef())
- translationUnit()->error(ast->specifier_token,
- "duplicate `%s'", spell(ast->specifier_token));
- _fullySpecifiedType.setTypedef(true);
- break;
-
- case T_INLINE:
- if (_fullySpecifiedType.isInline())
- translationUnit()->error(ast->specifier_token,
- "duplicate `%s'", spell(ast->specifier_token));
- _fullySpecifiedType.setInline(true);
- break;
-
- case T_VIRTUAL:
- if (_fullySpecifiedType.isVirtual())
- translationUnit()->error(ast->specifier_token,
- "duplicate `%s'", spell(ast->specifier_token));
- _fullySpecifiedType.setVirtual(true);
- break;
-
- case T_EXPLICIT:
- if (_fullySpecifiedType.isExplicit())
- translationUnit()->error(ast->specifier_token,
- "duplicate `%s'", spell(ast->specifier_token));
- _fullySpecifiedType.setExplicit(true);
- break;
-
- case T_SIGNED:
- if (_fullySpecifiedType.isSigned())
- translationUnit()->error(ast->specifier_token,
- "duplicate `%s'", spell(ast->specifier_token));
- _fullySpecifiedType.setSigned(true);
- break;
-
- case T_UNSIGNED:
- if (_fullySpecifiedType.isUnsigned())
- translationUnit()->error(ast->specifier_token,
- "duplicate `%s'", spell(ast->specifier_token));
- _fullySpecifiedType.setUnsigned(true);
- break;
-
- case T_CHAR:
- if (_fullySpecifiedType)
- translationUnit()->error(ast->specifier_token,
- "duplicate data type in declaration");
- _fullySpecifiedType.setType(control()->integerType(IntegerType::Char));
- break;
-
- case T_WCHAR_T:
- if (_fullySpecifiedType)
- translationUnit()->error(ast->specifier_token,
- "duplicate data type in declaration");
- _fullySpecifiedType.setType(control()->integerType(IntegerType::WideChar));
- break;
-
- case T_BOOL:
- if (_fullySpecifiedType)
- translationUnit()->error(ast->specifier_token,
- "duplicate data type in declaration");
- _fullySpecifiedType.setType(control()->integerType(IntegerType::Bool));
- break;
-
- case T_SHORT:
- if (_fullySpecifiedType) {
- IntegerType *intType = control()->integerType(IntegerType::Int);
- if (_fullySpecifiedType.type() != intType)
- translationUnit()->error(ast->specifier_token,
- "duplicate data type in declaration");
- }
- _fullySpecifiedType.setType(control()->integerType(IntegerType::Short));
- break;
-
- case T_INT:
- if (_fullySpecifiedType) {
- Type *tp = _fullySpecifiedType.type();
- IntegerType *shortType = control()->integerType(IntegerType::Short);
- IntegerType *longType = control()->integerType(IntegerType::Long);
- IntegerType *longLongType = control()->integerType(IntegerType::LongLong);
- if (tp == shortType || tp == longType || tp == longLongType)
- break;
- translationUnit()->error(ast->specifier_token,
- "duplicate data type in declaration");
- }
- _fullySpecifiedType.setType(control()->integerType(IntegerType::Int));
- break;
-
- case T_LONG:
- if (_fullySpecifiedType) {
- Type *tp = _fullySpecifiedType.type();
- IntegerType *intType = control()->integerType(IntegerType::Int);
- IntegerType *longType = control()->integerType(IntegerType::Long);
- FloatType *doubleType = control()->floatType(FloatType::Double);
- if (tp == longType) {
- _fullySpecifiedType.setType(control()->integerType(IntegerType::LongLong));
- break;
- } else if (tp == doubleType) {
- _fullySpecifiedType.setType(control()->floatType(FloatType::LongDouble));
- break;
- } else if (tp != intType) {
- translationUnit()->error(ast->specifier_token,
- "duplicate data type in declaration");
- }
- }
- _fullySpecifiedType.setType(control()->integerType(IntegerType::Long));
- break;
-
- case T_FLOAT:
- if (_fullySpecifiedType)
- translationUnit()->error(ast->specifier_token,
- "duplicate data type in declaration");
- _fullySpecifiedType.setType(control()->floatType(FloatType::Float));
- break;
-
- case T_DOUBLE:
- if (_fullySpecifiedType) {
- IntegerType *longType = control()->integerType(IntegerType::Long);
- if (_fullySpecifiedType.type() == longType) {
- _fullySpecifiedType.setType(control()->floatType(FloatType::LongDouble));
- break;
- }
- translationUnit()->error(ast->specifier_token,
- "duplicate data type in declaration");
- }
- _fullySpecifiedType.setType(control()->floatType(FloatType::Double));
- break;
-
- case T_VOID:
- if (_fullySpecifiedType)
- translationUnit()->error(ast->specifier_token,
- "duplicate data type in declaration");
- _fullySpecifiedType.setType(control()->voidType());
- break;
-
- default:
- break;
- } // switch
-
- return false;
-}
-
-bool CheckSpecifier::visit(ClassSpecifierAST *ast)
-{
- unsigned sourceLocation = ast->firstToken();
-
- if (ast->name)
- sourceLocation = ast->name->firstToken();
-
- unsigned classScopeStart = tokenAt(ast->firstToken()).offset;
- if (ast->lbrace_token)
- classScopeStart = tokenAt(ast->lbrace_token).end();
-
- const Name *className = semantic()->check(ast->name, _scope);
- Class *klass = control()->newClass(sourceLocation, className);
- klass->setStartOffset(classScopeStart);
- klass->setEndOffset(tokenAt(ast->lastToken() - 1).end());
- ast->symbol = klass;
- unsigned classKey = tokenKind(ast->classkey_token);
- if (classKey == T_CLASS)
- klass->setClassKey(Class::ClassKey);
- else if (classKey == T_STRUCT)
- klass->setClassKey(Class::StructKey);
- else if (classKey == T_UNION)
- klass->setClassKey(Class::UnionKey);
- klass->setVisibility(semantic()->currentVisibility());
- _scope->addMember(klass);
-
- ClassSpecifierAST *previousClassSpecifier = semantic()->switchDeclaringClass(ast);
-
- _fullySpecifiedType.setType(klass);
-
- accept(ast->attribute_list);
-
- if (_fullySpecifiedType.isDeprecated())
- klass->setDeprecated(true);
- if (_fullySpecifiedType.isUnavailable())
- klass->setUnavailable(true);
-
- for (BaseSpecifierListAST *it = ast->base_clause_list; it; it = it->next) {
- BaseSpecifierAST *base = it->value;
- const Name *baseClassName = semantic()->check(base->name, _scope);
- BaseClass *baseClass = control()->newBaseClass(ast->firstToken(), baseClassName);
- base->symbol = baseClass;
- if (base->virtual_token)
- baseClass->setVirtual(true);
- if (base->access_specifier_token) {
- int accessSpecifier = tokenKind(base->access_specifier_token);
- int visibility = semantic()->visibilityForAccessSpecifier(accessSpecifier);
- baseClass->setVisibility(visibility);
- }
- klass->addBaseClass(baseClass);
- }
-
- int visibility = semantic()->visibilityForClassKey(classKey);
- int previousVisibility = semantic()->switchVisibility(visibility);
- int previousMethodKey = semantic()->switchMethodKey(Function::NormalMethod);
-
- DeclarationAST *previousDeclaration = 0;
- for (DeclarationListAST *it = ast->member_specifier_list; it; it = it->next) {
- DeclarationAST *declaration = it->value;
- semantic()->check(declaration, klass);
-
- if (previousDeclaration && declaration &&
- declaration->asEmptyDeclaration() != 0 &&
- previousDeclaration->asFunctionDefinition() != 0)
- translationUnit()->warning(declaration->firstToken(), "unnecessary semicolon after function body");
-
- previousDeclaration = declaration;
- }
-
- (void) semantic()->switchMethodKey(previousMethodKey);
- (void) semantic()->switchVisibility(previousVisibility);
-
- (void) semantic()->switchDeclaringClass(previousClassSpecifier);
-
- return false;
-}
-
-bool CheckSpecifier::visit(NamedTypeSpecifierAST *ast)
-{
- const Name *name = semantic()->check(ast->name, _scope);
- _fullySpecifiedType.setType(control()->namedType(name));
- return false;
-}
-
-bool CheckSpecifier::visit(ElaboratedTypeSpecifierAST *ast)
-{
- const Name *name = semantic()->check(ast->name, _scope);
- _fullySpecifiedType.setType(control()->namedType(name));
- accept(ast->attribute_list);
- return false;
-}
-
-bool CheckSpecifier::visit(EnumSpecifierAST *ast)
-{
- unsigned sourceLocation = ast->firstToken();
- if (ast->name)
- sourceLocation = ast->name->firstToken();
-
- unsigned scopeStart = tokenAt(ast->firstToken()).offset;
- if (ast->lbrace_token)
- scopeStart = tokenAt(ast->lbrace_token).end();
-
- const Name *name = semantic()->check(ast->name, _scope);
- Enum *e = control()->newEnum(sourceLocation, name);
- ast->symbol = e;
- e->setStartOffset(scopeStart);
- e->setEndOffset(tokenAt(ast->lastToken() - 1).end());
- e->setVisibility(semantic()->currentVisibility());
- _scope->addMember(e);
- _fullySpecifiedType.setType(e);
- for (EnumeratorListAST *it = ast->enumerator_list; it; it = it->next) {
- EnumeratorAST *enumerator = it->value;
- const Identifier *id = identifier(enumerator->identifier_token);
- if (! id)
- continue;
- const NameId *enumeratorName = control()->nameId(id);
- Declaration *decl = control()->newDeclaration(enumerator->firstToken(),
- enumeratorName);
-
- FullySpecifiedType initTy = semantic()->check(enumerator->expression, _scope);
- e->addMember(decl);
- }
- return false;
-}
-
-bool CheckSpecifier::visit(TypeofSpecifierAST *ast)
-{
- semantic()->check(ast->expression, _scope);
- return false;
-}
-
-bool CheckSpecifier::visit(AttributeAST *ast)
-{
- if (ast->identifier_token) {
- const Identifier *id = identifier(ast->identifier_token);
-
- if (id == control()->deprecatedId())
- _fullySpecifiedType.setDeprecated(true);
- else if (id == control()->unavailableId())
- _fullySpecifiedType.setUnavailable(true);
- }
- return false;
-}
diff --git a/src/shared/cplusplus/CheckSpecifier.h b/src/shared/cplusplus/CheckSpecifier.h
deleted file mode 100644
index d4a1f4ed22..0000000000
--- a/src/shared/cplusplus/CheckSpecifier.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** Commercial Usage
-**
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Nokia.
-**
-** GNU Lesser General Public License Usage
-**
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
-**
-**************************************************************************/
-// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-#ifndef CPLUSPLUS_CHECKSPECIFIER_H
-#define CPLUSPLUS_CHECKSPECIFIER_H
-
-#include "CPlusPlusForwardDeclarations.h"
-#include "SemanticCheck.h"
-#include "FullySpecifiedType.h"
-
-
-namespace CPlusPlus {
-
-class CPLUSPLUS_EXPORT CheckSpecifier: public SemanticCheck
-{
-public:
- CheckSpecifier(Semantic *semantic);
- virtual ~CheckSpecifier();
-
- FullySpecifiedType check(SpecifierListAST *specifier, Scope *scope,
- const FullySpecifiedType &ty = FullySpecifiedType());
-
-protected:
- SpecifierListAST *switchSpecifier(SpecifierListAST *specifier);
- FullySpecifiedType switchFullySpecifiedType(const FullySpecifiedType &type);
- Scope *switchScope(Scope *scope);
-
- using ASTVisitor::visit;
-
- virtual bool visit(SimpleSpecifierAST *ast);
- virtual bool visit(ClassSpecifierAST *ast);
- virtual bool visit(NamedTypeSpecifierAST *ast);
- virtual bool visit(ElaboratedTypeSpecifierAST *ast);
- virtual bool visit(EnumSpecifierAST *ast);
- virtual bool visit(TypeofSpecifierAST *ast);
- virtual bool visit(AttributeAST *ast);
-
-private:
- SpecifierListAST *_specifier;
- FullySpecifiedType _fullySpecifiedType;
- Scope *_scope;
-};
-
-} // end of namespace CPlusPlus
-
-
-#endif // CPLUSPLUS_CHECKSPECIFIER_H
diff --git a/src/shared/cplusplus/CheckStatement.cpp b/src/shared/cplusplus/CheckStatement.cpp
deleted file mode 100644
index fc63434bb6..0000000000
--- a/src/shared/cplusplus/CheckStatement.cpp
+++ /dev/null
@@ -1,406 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** Commercial Usage
-**
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Nokia.
-**
-** GNU Lesser General Public License Usage
-**
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
-**
-**************************************************************************/
-// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-#include "CheckStatement.h"
-#include "Semantic.h"
-#include "AST.h"
-#include "TranslationUnit.h"
-#include "Scope.h"
-#include "CoreTypes.h"
-#include "Control.h"
-#include "Symbols.h"
-#include "Names.h"
-#include "Literals.h"
-#include <string>
-
-using namespace CPlusPlus;
-
-CheckStatement::CheckStatement(Semantic *semantic)
- : SemanticCheck(semantic),
- _statement(0),
- _scope(0)
-{ }
-
-CheckStatement::~CheckStatement()
-{ }
-
-FullySpecifiedType CheckStatement::check(StatementAST *statement, Scope *scope)
-{
- FullySpecifiedType previousExprType = switchExprType(FullySpecifiedType());
- Scope *previousScope = switchScope(scope);
- StatementAST *previousStatement = switchStatement(statement);
- accept(statement);
- (void) switchStatement(previousStatement);
- (void) switchScope(previousScope);
- return switchExprType(previousExprType);
-}
-
-FullySpecifiedType CheckStatement::switchExprType(const FullySpecifiedType &type)
-{
- const FullySpecifiedType &previousExprType = _exprType;
- _exprType = type;
- return previousExprType;
-}
-
-StatementAST *CheckStatement::switchStatement(StatementAST *statement)
-{
- StatementAST *previousStatement = _statement;
- _statement = statement;
- return previousStatement;
-}
-
-Scope *CheckStatement::switchScope(Scope *scope)
-{
- Scope *previousScope = _scope;
- _scope = scope;
- return previousScope;
-}
-
-bool CheckStatement::visit(CaseStatementAST *ast)
-{
- (void) semantic()->check(ast->expression, _scope);
- _exprType = semantic()->check(ast->statement, _scope);
- return false;
-}
-
-bool CheckStatement::visit(CompoundStatementAST *ast)
-{
- Block *block = control()->newBlock(ast->lbrace_token);
- block->setStartOffset(tokenAt(ast->firstToken()).end());
- block->setEndOffset(tokenAt(ast->lastToken() - 1).end());
- ast->symbol = block;
- _scope->addMember(block);
- Scope *previousScope = switchScope(block);
- StatementAST *previousStatement = 0;
- for (StatementListAST *it = ast->statement_list; it; it = it->next) {
- StatementAST *statement = it->value;
- _exprType = semantic()->check(statement, _scope);
-
- if (statement && previousStatement) {
- ExpressionStatementAST *expressionStatement = statement->asExpressionStatement();
- CompoundStatementAST *compoundStatement = previousStatement->asCompoundStatement();
- if (expressionStatement && ! expressionStatement->expression && compoundStatement && compoundStatement->rbrace_token)
- translationUnit()->warning(compoundStatement->rbrace_token, "unnecessary semicolon after block");
- }
-
- previousStatement = statement;
- }
- (void) switchScope(previousScope);
- return false;
-}
-
-bool CheckStatement::visit(DeclarationStatementAST *ast)
-{
- semantic()->check(ast->declaration, _scope);
- _exprType = FullySpecifiedType();
- return false;
-}
-
-bool CheckStatement::visit(DoStatementAST *ast)
-{
- semantic()->check(ast->statement, _scope);
- (void) semantic()->check(ast->expression, _scope);
- _exprType = FullySpecifiedType();
- return false;
-}
-
-bool CheckStatement::visit(ExpressionOrDeclarationStatementAST *ast)
-{
-// translationUnit()->warning(ast->firstToken(),
-// "ambiguous expression or declaration statement");
-
- semantic()->check(ast->declaration, _scope);
- _exprType = semantic()->check(ast->expression, _scope);
-
- return false;
-}
-
-bool CheckStatement::visit(ExpressionStatementAST *ast)
-{
- _exprType = semantic()->check(ast->expression, _scope);
- return false;
-}
-
-bool CheckStatement::forEachFastEnum(unsigned firstToken,
- unsigned lparen,
- unsigned lastToken,
- SpecifierListAST *type_specifier_list,
- DeclaratorAST *declarator,
- ExpressionAST *initializer,
- ExpressionAST *expression,
- StatementAST *statement,
- Block *&symbol)
-{
- unsigned scopeStart = tokenAt(firstToken).offset;
- if (lparen)
- scopeStart = tokenAt(lparen).end();
-
- Block *block = control()->newBlock(firstToken);
- block->setStartOffset(scopeStart);
- block->setEndOffset(tokenAt(lastToken - 1).end());
- symbol = block;
- _scope->addMember(block);
- Scope *previousScope = switchScope(block);
- if (type_specifier_list && declarator) {
- FullySpecifiedType ty = semantic()->check(type_specifier_list, _scope);
- const Name *name = 0;
- ty = semantic()->check(declarator, ty, _scope, &name);
- unsigned location = declarator->firstToken();
- if (CoreDeclaratorAST *core_declarator = declarator->core_declarator)
- location = core_declarator->firstToken();
- Declaration *decl = control()->newDeclaration(location, name);
- decl->setType(ty);
- _scope->addMember(decl);
- } else {
- (void) semantic()->check(initializer, _scope);
- }
-
- (void) semantic()->check(expression, _scope);
- semantic()->check(statement, _scope);
- (void) switchScope(previousScope);
- _exprType = FullySpecifiedType();
- return false;
-}
-
-bool CheckStatement::visit(ForeachStatementAST *ast)
-{
- return forEachFastEnum(ast->firstToken(),
- ast->lparen_token,
- ast->lastToken(),
- ast->type_specifier_list,
- ast->declarator,
- ast->initializer,
- ast->expression,
- ast->statement,
- ast->symbol);
-}
-
-bool CheckStatement::visit(ObjCFastEnumerationAST *ast)
-{
- return forEachFastEnum(ast->firstToken(),
- ast->lparen_token,
- ast->lastToken(),
- ast->type_specifier_list,
- ast->declarator,
- ast->initializer,
- ast->fast_enumeratable_expression,
- ast->statement,
- ast->symbol);
-}
-
-bool CheckStatement::visit(ForStatementAST *ast)
-{
- unsigned scopeStart = tokenAt(ast->firstToken()).offset;
- if (ast->lparen_token)
- scopeStart = tokenAt(ast->lparen_token).end();
-
- Block *block = control()->newBlock(ast->for_token);
- block->setStartOffset(scopeStart);
- block->setEndOffset(tokenAt(ast->lastToken() - 1).end());
- ast->symbol = block;
- _scope->addMember(block);
- Scope *previousScope = switchScope(block);
- semantic()->check(ast->initializer, _scope);
- FullySpecifiedType condTy = semantic()->check(ast->condition, _scope);
- FullySpecifiedType exprTy = semantic()->check(ast->expression, _scope);
- semantic()->check(ast->statement, _scope);
- (void) switchScope(previousScope);
- _exprType = FullySpecifiedType();
- return false;
-}
-
-bool CheckStatement::visit(IfStatementAST *ast)
-{
- unsigned scopeStart = tokenAt(ast->firstToken()).offset;
- if (ast->lparen_token)
- scopeStart = tokenAt(ast->lparen_token).end();
-
- Block *block = control()->newBlock(ast->if_token);
- block->setStartOffset(scopeStart);
- block->setEndOffset(tokenAt(ast->lastToken() - 1).end());
- ast->symbol = block;
- _scope->addMember(block);
- Scope *previousScope = switchScope(block);
- FullySpecifiedType exprTy = semantic()->check(ast->condition, _scope);
- semantic()->check(ast->statement, _scope);
- semantic()->check(ast->else_statement, _scope);
- (void) switchScope(previousScope);
- _exprType = FullySpecifiedType();
- return false;
-}
-
-bool CheckStatement::visit(LabeledStatementAST *ast)
-{
- semantic()->check(ast->statement, _scope);
- _exprType = FullySpecifiedType();
- return false;
-}
-
-bool CheckStatement::visit(BreakStatementAST *)
-{
- _exprType = FullySpecifiedType();
- return false;
-}
-
-bool CheckStatement::visit(ContinueStatementAST *)
-{
- _exprType = FullySpecifiedType();
- return false;
-}
-
-bool CheckStatement::visit(GotoStatementAST *)
-{
- _exprType = FullySpecifiedType();
- return false;
-}
-
-bool CheckStatement::visit(ReturnStatementAST *ast)
-{
- _exprType = semantic()->check(ast->expression, _scope);
- return false;
-}
-
-bool CheckStatement::visit(SwitchStatementAST *ast)
-{
- unsigned scopeStart = tokenAt(ast->firstToken()).offset;
- if (ast->lparen_token)
- scopeStart = tokenAt(ast->lparen_token).offset;
-
- Block *block = control()->newBlock(ast->switch_token);
- block->setStartOffset(scopeStart);
- block->setEndOffset(tokenAt(ast->lastToken() - 1).end());
- ast->symbol = block;
- _scope->addMember(block);
- Scope *previousScope = switchScope(block);
- FullySpecifiedType condTy = semantic()->check(ast->condition, _scope);
- semantic()->check(ast->statement, _scope);
- (void) switchScope(previousScope);
- _exprType = FullySpecifiedType();
- return false;
-}
-
-bool CheckStatement::visit(TryBlockStatementAST *ast)
-{
- semantic()->check(ast->statement, _scope);
- for (CatchClauseListAST *it = ast->catch_clause_list; it; it = it->next) {
- semantic()->check(it->value, _scope);
- }
- _exprType = FullySpecifiedType();
- return false;
-}
-
-bool CheckStatement::visit(CatchClauseAST *ast)
-{
- unsigned scopeStart = tokenAt(ast->firstToken()).offset;
- if (ast->lparen_token)
- scopeStart = tokenAt(ast->lparen_token).end();
-
- Block *block = control()->newBlock(ast->catch_token);
- block->setStartOffset(scopeStart);
- block->setEndOffset(tokenAt(ast->lastToken() - 1).end());
- ast->symbol = block;
- _scope->addMember(block);
- Scope *previousScope = switchScope(block);
- semantic()->check(ast->exception_declaration, _scope);
- semantic()->check(ast->statement, _scope);
- (void) switchScope(previousScope);
- _exprType = FullySpecifiedType();
- return false;
-}
-
-bool CheckStatement::visit(WhileStatementAST *ast)
-{
- unsigned scopeStart = tokenAt(ast->firstToken()).offset;
- if (ast->lparen_token)
- scopeStart = tokenAt(ast->lparen_token).end();
-
- Block *block = control()->newBlock(ast->while_token);
- block->setStartOffset(scopeStart);
- block->setEndOffset(tokenAt(ast->lastToken() - 1).end());
- ast->symbol = block;
- _scope->addMember(block);
- Scope *previousScope = switchScope(block);
- FullySpecifiedType condTy = semantic()->check(ast->condition, _scope);
- semantic()->check(ast->statement, _scope);
- (void) switchScope(previousScope);
- _exprType = FullySpecifiedType();
- return false;
-}
-
-bool CheckStatement::visit(QtMemberDeclarationAST *ast)
-{
- const Name *name = 0;
-
- if (tokenKind(ast->q_token) == T_Q_D)
- name = control()->nameId(control()->identifier("d"));
- else
- name = control()->nameId(control()->identifier("q"));
-
- FullySpecifiedType declTy = semantic()->check(ast->type_id, _scope);
-
- if (tokenKind(ast->q_token) == T_Q_D) {
- if (NamedType *namedTy = declTy->asNamedType()) {
- if (const NameId *nameId = namedTy->name()->asNameId()) {
- std::string privateClass;
- privateClass += nameId->identifier()->chars();
- privateClass += "Private";
-
- const Name *privName = control()->nameId(control()->identifier(privateClass.c_str(),
- privateClass.size()));
- declTy.setType(control()->namedType(privName));
- }
- }
- }
-
- Declaration *symbol = control()->newDeclaration(/*generated*/ 0, name);
- symbol->setType(control()->pointerType(declTy));
-
- _scope->addMember(symbol);
- _exprType = FullySpecifiedType();
- return false;
-}
diff --git a/src/shared/cplusplus/CheckStatement.h b/src/shared/cplusplus/CheckStatement.h
deleted file mode 100644
index 3f96a14fdf..0000000000
--- a/src/shared/cplusplus/CheckStatement.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** Commercial Usage
-**
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Nokia.
-**
-** GNU Lesser General Public License Usage
-**
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
-**
-**************************************************************************/
-// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-#ifndef CPLUSPLUS_CHECKSTATEMENT_H
-#define CPLUSPLUS_CHECKSTATEMENT_H
-
-#include "CPlusPlusForwardDeclarations.h"
-#include "FullySpecifiedType.h"
-#include "SemanticCheck.h"
-
-namespace CPlusPlus {
-
-class CPLUSPLUS_EXPORT CheckStatement: public SemanticCheck
-{
-public:
- CheckStatement(Semantic *semantic);
- virtual ~CheckStatement();
-
- FullySpecifiedType check(StatementAST *statement, Scope *scope);
-
-protected:
- FullySpecifiedType switchExprType(const FullySpecifiedType &type);
- StatementAST *switchStatement(StatementAST *statement);
- Scope *switchScope(Scope *scope);
-
- using ASTVisitor::visit;
-
- virtual bool visit(CaseStatementAST *ast);
- virtual bool visit(CompoundStatementAST *ast);
- virtual bool visit(DeclarationStatementAST *ast);
- virtual bool visit(DoStatementAST *ast);
- virtual bool visit(ExpressionOrDeclarationStatementAST *ast);
- virtual bool visit(ExpressionStatementAST *ast);
- virtual bool visit(ForeachStatementAST *ast);
- virtual bool visit(ObjCFastEnumerationAST *ast);
- virtual bool visit(ForStatementAST *ast);
- virtual bool visit(IfStatementAST *ast);
- virtual bool visit(LabeledStatementAST *ast);
- virtual bool visit(BreakStatementAST *ast);
- virtual bool visit(ContinueStatementAST *ast);
- virtual bool visit(GotoStatementAST *ast);
- virtual bool visit(ReturnStatementAST *ast);
- virtual bool visit(SwitchStatementAST *ast);
- virtual bool visit(TryBlockStatementAST *ast);
- virtual bool visit(CatchClauseAST *ast);
- virtual bool visit(WhileStatementAST *ast);
- virtual bool visit(QtMemberDeclarationAST *ast);
-
- bool forEachFastEnum(unsigned firstToken,
- unsigned lparen,
- unsigned lastToken,
- SpecifierListAST *type_specifier_list,
- DeclaratorAST *declarator,
- ExpressionAST *initializer,
- ExpressionAST *expression,
- StatementAST *statement,
- Block *&symbol);
- FullySpecifiedType checkCompoundStmt(CompoundStatementAST *stmt);
-
-private:
- StatementAST *_statement;
- Scope *_scope;
- FullySpecifiedType _exprType;
-};
-
-} // end of namespace CPlusPlus
-
-
-#endif // CPLUSPLUS_CHECKSTATEMENT_H
diff --git a/src/shared/cplusplus/Semantic.cpp b/src/shared/cplusplus/Semantic.cpp
deleted file mode 100644
index 46c9648d38..0000000000
--- a/src/shared/cplusplus/Semantic.cpp
+++ /dev/null
@@ -1,358 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** Commercial Usage
-**
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Nokia.
-**
-** GNU Lesser General Public License Usage
-**
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
-**
-**************************************************************************/
-// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-#include "Semantic.h"
-#include "TranslationUnit.h"
-#include "Control.h"
-#include "Scope.h"
-#include "Symbols.h"
-#include "Token.h"
-#include "AST.h"
-#include "CheckSpecifier.h"
-#include "CheckDeclaration.h"
-#include "CheckDeclarator.h"
-#include "CheckStatement.h"
-#include "CheckExpression.h"
-#include "CheckName.h"
-
-using namespace CPlusPlus;
-
-SemanticClient::SemanticClient(Semantic *semantic)
- : _semantic(semantic)
-{
-}
-
-SemanticClient::~SemanticClient()
-{
-}
-
-Semantic *SemanticClient::semantic() const
-{
- return _semantic;
-}
-
-class Semantic::Data
-{
-public:
- Data(Semantic *semantic, TranslationUnit *translationUnit)
- : semantic(semantic),
- translationUnit(translationUnit),
- control(translationUnit->control()),
- semanticClient(0),
- skipFunctionBodies(false),
- visibility(Symbol::Public),
- ojbcVisibility(Symbol::Protected),
- methodKey(Function::NormalMethod),
- declaringClass(0),
- checkSpecifier(0),
- checkDeclaration(0),
- checkDeclarator(0),
- checkExpression(0),
- checkStatement(0),
- checkName(0)
- { }
-
- ~Data()
- {
- delete checkSpecifier;
- delete checkDeclaration;
- delete checkDeclarator;
- delete checkExpression;
- delete checkStatement;
- delete checkName;
- }
-
- Semantic *semantic;
- TranslationUnit *translationUnit;
- Control *control;
- SemanticClient *semanticClient;
- bool skipFunctionBodies;
- int visibility;
- int ojbcVisibility;
- int methodKey;
- ClassSpecifierAST *declaringClass;
- CheckSpecifier *checkSpecifier;
- CheckDeclaration *checkDeclaration;
- CheckDeclarator *checkDeclarator;
- CheckExpression *checkExpression;
- CheckStatement *checkStatement;
- CheckName *checkName;
- std::vector<FunctionDefinitionAST *> functionsToProcess;
-};
-
-Semantic::Semantic(TranslationUnit *translationUnit)
-{
- d = new Data(this, translationUnit);
- d->checkSpecifier = new CheckSpecifier(this);
- d->checkDeclaration = new CheckDeclaration(this);
- d->checkDeclarator = new CheckDeclarator(this);
- d->checkExpression = new CheckExpression(this);
- d->checkStatement = new CheckStatement(this);
- d->checkName = new CheckName(this);
-}
-
-Semantic::~Semantic()
-{ delete d; }
-
-SemanticClient *Semantic::semanticClient() const
-{ return d->semanticClient; }
-
-void Semantic::setSemanticClient(SemanticClient *client)
-{ d->semanticClient = client; }
-
-TranslationUnit *Semantic::translationUnit() const
-{ return d->translationUnit; }
-
-Control *Semantic::control() const
-{ return d->control; }
-
-FullySpecifiedType Semantic::check(SpecifierListAST *specifier, Scope *scope,
- const FullySpecifiedType &type)
-{ return d->checkSpecifier->check(specifier, scope, type); }
-
-void Semantic::check(DeclarationAST *declaration, Scope *scope)
-{ d->checkDeclaration->check(declaration, scope); }
-
-FullySpecifiedType Semantic::check(DeclaratorAST *declarator, const FullySpecifiedType &type,
- Scope *scope, const Name **name)
-{ return d->checkDeclarator->check(declarator, type, scope, name); }
-
-FullySpecifiedType Semantic::check(PtrOperatorListAST *ptrOperators, const FullySpecifiedType &type, Scope *scope)
-{ return d->checkDeclarator->check(ptrOperators, type, scope); }
-
-FullySpecifiedType Semantic::check(ObjCMethodPrototypeAST *methodPrototype, Scope *scope)
-{ return d->checkDeclarator->check(methodPrototype, scope); }
-
-void Semantic::check(ObjCMessageArgumentDeclarationAST *arg, Scope *scope)
-{ return d->checkName->check(arg, scope); }
-
-FullySpecifiedType Semantic::check(ExpressionAST *expression, Scope *scope)
-{ return d->checkExpression->check(expression, scope); }
-
-FullySpecifiedType Semantic::check(StatementAST *statement, Scope *scope)
-{ return d->checkStatement->check(statement, scope); }
-
-const Name *Semantic::check(NameAST *name, Scope *scope)
-{ return d->checkName->check(name, scope); }
-
-const Name *Semantic::check(NestedNameSpecifierListAST *name, Scope *scope)
-{ return d->checkName->check(name, scope); }
-
-void Semantic::checkFunctionDefinition(FunctionDefinitionAST *ast)
-{
- if (d->declaringClass != 0)
- d->functionsToProcess.push_back(ast);
- else
- finishFunctionDefinition(ast);
-}
-
-void Semantic::finishFunctionDefinition(FunctionDefinitionAST *ast)
-{
- const int previousVisibility = switchVisibility(Symbol::Public);
- const int previousMethodKey = switchMethodKey(Function::NormalMethod);
-
- Function *fun = ast->symbol;
- d->checkDeclaration->check(ast->ctor_initializer, fun->scope());
-
- if (ast->function_body) {
- check(ast->function_body, fun);
-
- if (CompoundStatementAST *c = ast->function_body->asCompoundStatement())
- fun->setBlock(c->symbol);
- }
-
- switchMethodKey(previousMethodKey);
- switchVisibility(previousVisibility);
-}
-
-bool Semantic::skipFunctionBodies() const
-{ return d->skipFunctionBodies; }
-
-void Semantic::setSkipFunctionBodies(bool skipFunctionBodies)
-{ d->skipFunctionBodies = skipFunctionBodies; }
-
-int Semantic::currentVisibility() const
-{ return d->visibility; }
-
-int Semantic::switchVisibility(int visibility)
-{
- int previousVisibility = d->visibility;
- d->visibility = visibility;
- return previousVisibility;
-}
-
-int Semantic::currentObjCVisibility() const
-{ return d->ojbcVisibility; }
-
-int Semantic::switchObjCVisibility(int visibility)
-{
- int previousOjbCVisibility = d->ojbcVisibility;
- d->ojbcVisibility = visibility;
- return previousOjbCVisibility;
-}
-
-int Semantic::currentMethodKey() const
-{ return d->methodKey; }
-
-int Semantic::switchMethodKey(int methodKey)
-{
- int previousMethodKey = d->methodKey;
- d->methodKey = methodKey;
- return previousMethodKey;
-}
-
-ClassSpecifierAST *Semantic::declatingClass() const
-{ return d->declaringClass; }
-
-ClassSpecifierAST *Semantic::switchDeclaringClass(ClassSpecifierAST *ast)
-{
- ClassSpecifierAST *previous = d->declaringClass;
- d->declaringClass = ast;
-
- if (! ast && ! d->functionsToProcess.empty()) {
- const std::vector<FunctionDefinitionAST *> todo = d->functionsToProcess;
- d->functionsToProcess.clear();
-
- for (std::vector<FunctionDefinitionAST *>::const_iterator it = todo.begin(); it != todo.end(); ++it)
- finishFunctionDefinition(*it);
- }
-
- return previous;
-}
-
-int Semantic::visibilityForAccessSpecifier(int tokenKind) const
-{
- switch (tokenKind) {
- case T_PUBLIC:
- return Symbol::Public;
- case T_PROTECTED:
- return Symbol::Protected;
- case T_PRIVATE:
- return Symbol::Private;
- case T_Q_SIGNALS:
- return Symbol::Protected;
- default:
- return Symbol::Public;
- }
-}
-
-int Semantic::visibilityForObjCAccessSpecifier(int tokenKind) const
-{
- switch (tokenKind) {
- case T_AT_PUBLIC:
- return Symbol::Public;
- case T_AT_PROTECTED:
- return Symbol::Protected;
- case T_AT_PRIVATE:
- return Symbol::Private;
- case T_AT_PACKAGE:
- return Symbol::Package;
- default:
- return Symbol::Protected;
- }
-}
-
-bool Semantic::isObjCClassMethod(int tokenKind) const
-{
- switch (tokenKind) {
- case T_PLUS:
- return true;
- case T_MINUS:
- default:
- return false;
- }
-}
-
-int Semantic::visibilityForClassKey(int tokenKind) const
-{
- switch (tokenKind) {
- case T_CLASS:
- return Symbol::Private;
- case T_STRUCT:
- case T_UNION:
- return Symbol::Public;
- default:
- return Symbol::Public;
- }
-}
-
-unsigned Semantic::location(DeclaratorAST *ast) const
-{
- if (! ast)
- return 0;
-
- else if (CPlusPlus::CoreDeclaratorAST *core = ast->core_declarator)
- return location(core);
-
- return ast->firstToken();
-}
-
-unsigned Semantic::location(CoreDeclaratorAST *ast) const
-{
- if (! ast)
- return 0;
-
- else if (CPlusPlus::DeclaratorIdAST *declaratorId = ast->asDeclaratorId())
- return location(declaratorId->name);
-
- else if (CPlusPlus::NestedDeclaratorAST *nested = ast->asNestedDeclarator())
- return location(nested->declarator);
-
- return ast->firstToken();
-}
-
-unsigned Semantic::location(NameAST *ast) const
-{
- if (! ast)
- return 0;
-
- else if (CPlusPlus::QualifiedNameAST *qualifiedName = ast->asQualifiedName())
- return location(qualifiedName->unqualified_name);
-
- return ast->firstToken();
-}
diff --git a/src/shared/cplusplus/Semantic.h b/src/shared/cplusplus/Semantic.h
deleted file mode 100644
index 71e72b2ee0..0000000000
--- a/src/shared/cplusplus/Semantic.h
+++ /dev/null
@@ -1,148 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** Commercial Usage
-**
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Nokia.
-**
-** GNU Lesser General Public License Usage
-**
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
-**
-**************************************************************************/
-// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-#ifndef CPLUSPLUS_SEMANTIC_H
-#define CPLUSPLUS_SEMANTIC_H
-
-#include "CPlusPlusForwardDeclarations.h"
-#include "ASTfwd.h"
-#include "FullySpecifiedType.h"
-
-namespace CPlusPlus {
-
-class CPLUSPLUS_EXPORT SemanticClient
-{
- SemanticClient(const SemanticClient &other);
- void operator = (const SemanticClient &other);
-
-public:
- SemanticClient(Semantic *semantic);
- virtual ~SemanticClient();
-
- Semantic *semantic() const;
-
-private:
- Semantic *_semantic;
-};
-
-
-class CPLUSPLUS_EXPORT Semantic
-{
- Semantic(const Semantic &other);
- void operator =(const Semantic &other);
-
-public:
- Semantic(TranslationUnit *translationUnit);
- virtual ~Semantic();
-
- TranslationUnit *translationUnit() const;
- Control *control() const;
-
- SemanticClient *semanticClient() const;
- void setSemanticClient(SemanticClient *client);
-
- FullySpecifiedType check(SpecifierListAST *specifier, Scope *scope,
- const FullySpecifiedType &type = FullySpecifiedType());
-
- FullySpecifiedType check(DeclaratorAST *declarator, const FullySpecifiedType &type,
- Scope *scope, const Name **name = 0); // ### ugly
-
- FullySpecifiedType check(PtrOperatorListAST *ptrOperators, const FullySpecifiedType &type,
- Scope *scope);
-
- FullySpecifiedType check(ObjCMethodPrototypeAST *methodPrototype, Scope *scope);
-
- FullySpecifiedType check(ExpressionAST *expression, Scope *scope);
-
- void check(DeclarationAST *declaration, Scope *scope);
-
- FullySpecifiedType check(StatementAST *statement, Scope *scope);
-
- const Name *check(NameAST *name, Scope *scope);
-
- const Name *check(NestedNameSpecifierListAST *name, Scope *scope);
-
- void check(ObjCMessageArgumentDeclarationAST *arg, Scope *scope);
-
- void checkFunctionDefinition(FunctionDefinitionAST *ast);
- void finishFunctionDefinition(FunctionDefinitionAST *ast);
-
- bool skipFunctionBodies() const;
- void setSkipFunctionBodies(bool skipFunctionBodies);
-
- int currentVisibility() const;
- int switchVisibility(int visibility);
-
- int currentObjCVisibility() const;
- int switchObjCVisibility(int visibility);
-
- int currentMethodKey() const;
- int switchMethodKey(int methodKey);
-
- ClassSpecifierAST *declatingClass() const;
- ClassSpecifierAST *switchDeclaringClass(ClassSpecifierAST *ast);
-
- int visibilityForClassKey(int tokenKind) const;
- int visibilityForAccessSpecifier(int tokenKind) const;
- int visibilityForObjCAccessSpecifier(int tokenKind) const;
- bool isObjCClassMethod(int tokenKind) const;
-
- unsigned location(DeclaratorAST *ast) const;
- unsigned location(CoreDeclaratorAST *ast) const;
- unsigned location(NameAST *ast) const;
-
-private:
- class Data;
- friend class Data;
- Data *d;
-};
-
-} // end of namespace CPlusPlus
-
-
-#endif // CPLUSPLUS_SEMANTIC_H
diff --git a/src/shared/cplusplus/SemanticCheck.cpp b/src/shared/cplusplus/SemanticCheck.cpp
deleted file mode 100644
index 4a23eb6e37..0000000000
--- a/src/shared/cplusplus/SemanticCheck.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** Commercial Usage
-**
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Nokia.
-**
-** GNU Lesser General Public License Usage
-**
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
-**
-**************************************************************************/
-// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-#include "SemanticCheck.h"
-#include "Semantic.h"
-
-using namespace CPlusPlus;
-
-SemanticCheck::SemanticCheck(Semantic *semantic)
- : ASTVisitor(semantic->translationUnit()),
- _semantic(semantic)
-{ }
-
-SemanticCheck::~SemanticCheck()
-{ }
-
-Semantic *SemanticCheck::semantic() const
-{ return _semantic; }
-
-Control *SemanticCheck::control() const
-{ return _semantic->control(); }
-
-
diff --git a/src/shared/cplusplus/SemanticCheck.h b/src/shared/cplusplus/SemanticCheck.h
deleted file mode 100644
index 930782b95d..0000000000
--- a/src/shared/cplusplus/SemanticCheck.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** Commercial Usage
-**
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Nokia.
-**
-** GNU Lesser General Public License Usage
-**
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
-**
-**************************************************************************/
-// Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-#ifndef CPLUSPLUS_SEMANTICCHECK_H
-#define CPLUSPLUS_SEMANTICCHECK_H
-
-#include "CPlusPlusForwardDeclarations.h"
-#include "ASTVisitor.h"
-
-
-namespace CPlusPlus {
-
-class CPLUSPLUS_EXPORT SemanticCheck: public ASTVisitor
-{
-public:
- SemanticCheck(Semantic *semantic);
- virtual ~SemanticCheck();
-
- Control *control() const;
- Semantic *semantic() const;
-
-private:
- Semantic *_semantic;
-};
-
-} // end of namespace CPlusPlus
-
-
-#endif // CPLUSPLUS_SEMANTICCHECK_H
diff --git a/src/shared/cplusplus/cplusplus.pri b/src/shared/cplusplus/cplusplus.pri
index 0c007abde6..4614167092 100644
--- a/src/shared/cplusplus/cplusplus.pri
+++ b/src/shared/cplusplus/cplusplus.pri
@@ -10,12 +10,6 @@ HEADERS += \
$$PWD/ASTfwd.h \
$$PWD/TypeMatcher.h \
$$PWD/CPlusPlusForwardDeclarations.h \
- $$PWD/CheckDeclaration.h \
- $$PWD/CheckDeclarator.h \
- $$PWD/CheckExpression.h \
- $$PWD/CheckName.h \
- $$PWD/CheckSpecifier.h \
- $$PWD/CheckStatement.h \
$$PWD/Control.h \
$$PWD/CoreTypes.h \
$$PWD/DiagnosticClient.h \
@@ -30,8 +24,6 @@ HEADERS += \
$$PWD/Parser.h \
$$PWD/Scope.h \
$$PWD/Bind.h \
- $$PWD/Semantic.h \
- $$PWD/SemanticCheck.h \
$$PWD/Symbol.h \
$$PWD/Symbols.h \
$$PWD/SymbolVisitor.h \
@@ -51,12 +43,6 @@ SOURCES += \
$$PWD/ASTPatternBuilder.cpp \
$$PWD/ASTMatcher.cpp \
$$PWD/TypeMatcher.cpp \
- $$PWD/CheckDeclaration.cpp \
- $$PWD/CheckDeclarator.cpp \
- $$PWD/CheckExpression.cpp \
- $$PWD/CheckName.cpp \
- $$PWD/CheckSpecifier.cpp \
- $$PWD/CheckStatement.cpp \
$$PWD/Control.cpp \
$$PWD/CoreTypes.cpp \
$$PWD/DiagnosticClient.cpp \
@@ -74,8 +60,6 @@ SOURCES += \
$$PWD/Parser.cpp \
$$PWD/Scope.cpp \
$$PWD/Bind.cpp \
- $$PWD/Semantic.cpp \
- $$PWD/SemanticCheck.cpp \
$$PWD/Symbol.cpp \
$$PWD/Symbols.cpp \
$$PWD/SymbolVisitor.cpp \