summaryrefslogtreecommitdiff
path: root/src/shared/cplusplus
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared/cplusplus')
-rw-r--r--src/shared/cplusplus/AST.h4
-rw-r--r--src/shared/cplusplus/CheckDeclaration.cpp38
-rw-r--r--src/shared/cplusplus/CheckDeclarator.cpp12
-rw-r--r--src/shared/cplusplus/CheckDeclarator.h6
-rw-r--r--src/shared/cplusplus/CheckExpression.cpp7
-rw-r--r--src/shared/cplusplus/CheckName.cpp33
-rw-r--r--src/shared/cplusplus/CheckName.h10
-rw-r--r--src/shared/cplusplus/CheckSpecifier.cpp12
-rw-r--r--src/shared/cplusplus/CheckStatement.cpp11
-rw-r--r--src/shared/cplusplus/Control.cpp167
-rw-r--r--src/shared/cplusplus/Control.h66
-rw-r--r--src/shared/cplusplus/CoreTypes.cpp16
-rw-r--r--src/shared/cplusplus/CoreTypes.h12
-rw-r--r--src/shared/cplusplus/Name.cpp4
-rw-r--r--src/shared/cplusplus/Name.h14
-rw-r--r--src/shared/cplusplus/NameVisitor.cpp4
-rw-r--r--src/shared/cplusplus/NameVisitor.h20
-rw-r--r--src/shared/cplusplus/Names.cpp100
-rw-r--r--src/shared/cplusplus/Names.h65
-rw-r--r--src/shared/cplusplus/Scope.cpp20
-rw-r--r--src/shared/cplusplus/Scope.h2
-rw-r--r--src/shared/cplusplus/Semantic.cpp8
-rw-r--r--src/shared/cplusplus/Semantic.h8
-rw-r--r--src/shared/cplusplus/Symbol.cpp48
-rw-r--r--src/shared/cplusplus/Symbol.h10
-rw-r--r--src/shared/cplusplus/Symbols.cpp68
-rw-r--r--src/shared/cplusplus/Symbols.h55
27 files changed, 376 insertions, 444 deletions
diff --git a/src/shared/cplusplus/AST.h b/src/shared/cplusplus/AST.h
index 3902fcb5c5..47342c2e04 100644
--- a/src/shared/cplusplus/AST.h
+++ b/src/shared/cplusplus/AST.h
@@ -303,7 +303,7 @@ public:
class CPLUSPLUS_EXPORT NameAST: public ExpressionAST
{
public: // annotations
- Name *name;
+ const Name *name;
public:
virtual NameAST *asName() { return this; }
@@ -342,7 +342,7 @@ public:
class CPLUSPLUS_EXPORT ObjCSelectorAST: public AST
{
public: // annotation
- Name *selector_name;
+ const Name *selector_name;
public:
virtual ObjCSelectorAST *asObjCSelector() { return this; }
diff --git a/src/shared/cplusplus/CheckDeclaration.cpp b/src/shared/cplusplus/CheckDeclaration.cpp
index 3fa5922a02..bd6be26743 100644
--- a/src/shared/cplusplus/CheckDeclaration.cpp
+++ b/src/shared/cplusplus/CheckDeclaration.cpp
@@ -153,7 +153,7 @@ bool CheckDeclaration::visit(SimpleDeclarationAST *ast)
if (elab_type_spec->name)
sourceLocation = elab_type_spec->name->firstToken();
- Name *name = semantic()->check(elab_type_spec->name, _scope);
+ const Name *name = semantic()->check(elab_type_spec->name, _scope);
ForwardClassDeclaration *symbol =
control()->newForwardClassDeclaration(sourceLocation, name);
@@ -172,7 +172,7 @@ bool CheckDeclaration::visit(SimpleDeclarationAST *ast)
List<Declaration *> **decl_it = &ast->symbols;
for (DeclaratorListAST *it = ast->declarator_list; it; it = it->next) {
- Name *name = 0;
+ const Name *name = 0;
FullySpecifiedType declTy = semantic()->check(it->value, qualTy,
_scope, &name);
@@ -268,7 +268,7 @@ bool CheckDeclaration::visit(ExceptionDeclarationAST *ast)
FullySpecifiedType ty = semantic()->check(ast->type_specifier_list, _scope);
FullySpecifiedType qualTy = ty.qualifiedType();
- Name *name = 0;
+ const Name *name = 0;
FullySpecifiedType declTy = semantic()->check(ast->declarator, qualTy,
_scope, &name);
@@ -293,7 +293,7 @@ bool CheckDeclaration::visit(FunctionDefinitionAST *ast)
{
FullySpecifiedType ty = semantic()->check(ast->decl_specifier_list, _scope);
FullySpecifiedType qualTy = ty.qualifiedType();
- Name *name = 0;
+ const Name *name = 0;
FullySpecifiedType funTy = semantic()->check(ast->declarator, qualTy,
_scope, &name);
if (! (funTy && funTy->isFunctionType())) {
@@ -379,7 +379,7 @@ bool CheckDeclaration::visit(LinkageSpecificationAST *ast)
bool CheckDeclaration::visit(NamespaceAST *ast)
{
const Identifier *id = identifier(ast->identifier_token);
- Name *namespaceName = control()->nameId(id);
+ const Name *namespaceName = control()->nameId(id);
unsigned sourceLocation = ast->firstToken();
@@ -411,7 +411,7 @@ bool CheckDeclaration::visit(ParameterDeclarationAST *ast)
sourceLocation = ast->firstToken();
}
- Name *argName = 0;
+ const Name *argName = 0;
FullySpecifiedType ty = semantic()->check(ast->type_specifier_list, _scope);
FullySpecifiedType argTy = semantic()->check(ast->declarator, ty.qualifiedType(),
_scope, &argName);
@@ -445,7 +445,7 @@ bool CheckDeclaration::visit(TypenameTypeParameterAST *ast)
if (ast->name)
sourceLocation = ast->name->firstToken();
- Name *name = semantic()->check(ast->name, _scope);
+ const Name *name = semantic()->check(ast->name, _scope);
Argument *arg = control()->newArgument(sourceLocation, name); // ### new template type
ast->symbol = arg;
_scope->enterSymbol(arg);
@@ -458,7 +458,7 @@ bool CheckDeclaration::visit(TemplateTypeParameterAST *ast)
if (ast->name)
sourceLocation = ast->name->firstToken();
- Name *name = semantic()->check(ast->name, _scope);
+ const Name *name = semantic()->check(ast->name, _scope);
Argument *arg = control()->newArgument(sourceLocation, name); // ### new template type
ast->symbol = arg;
_scope->enterSymbol(arg);
@@ -467,7 +467,7 @@ bool CheckDeclaration::visit(TemplateTypeParameterAST *ast)
bool CheckDeclaration::visit(UsingAST *ast)
{
- Name *name = semantic()->check(ast->name, _scope);
+ const Name *name = semantic()->check(ast->name, _scope);
unsigned sourceLocation = ast->firstToken();
if (ast->name)
@@ -481,7 +481,7 @@ bool CheckDeclaration::visit(UsingAST *ast)
bool CheckDeclaration::visit(UsingDirectiveAST *ast)
{
- Name *name = semantic()->check(ast->name, _scope);
+ const Name *name = semantic()->check(ast->name, _scope);
unsigned sourceLocation = ast->firstToken();
if (ast->name)
@@ -510,7 +510,7 @@ bool CheckDeclaration::visit(ObjCProtocolForwardDeclarationAST *ast)
else
declarationLocation = sourceLocation;
- Name *protocolName = semantic()->check(it->value, _scope);
+ const Name *protocolName = semantic()->check(it->value, _scope);
ObjCForwardProtocolDeclaration *fwdProtocol = control()->newObjCForwardProtocolDeclaration(sourceLocation, protocolName);
fwdProtocol->setStartOffset(tokenAt(ast->firstToken()).offset);
fwdProtocol->setEndOffset(tokenAt(ast->lastToken()).offset);
@@ -533,7 +533,7 @@ bool CheckDeclaration::visit(ObjCProtocolDeclarationAST *ast)
else
sourceLocation = ast->firstToken();
- Name *protocolName = semantic()->check(ast->name, _scope);
+ const Name *protocolName = semantic()->check(ast->name, _scope);
ObjCProtocol *protocol = control()->newObjCProtocol(sourceLocation, protocolName);
protocol->setStartOffset(tokenAt(ast->firstToken()).offset);
protocol->setEndOffset(tokenAt(ast->lastToken()).offset);
@@ -541,7 +541,7 @@ bool CheckDeclaration::visit(ObjCProtocolDeclarationAST *ast)
if (ast->protocol_refs && ast->protocol_refs->identifier_list) {
for (ObjCIdentifierListAST *iter = ast->protocol_refs->identifier_list; iter; iter = iter->next) {
NameAST* name = iter->value;
- Name *protocolName = semantic()->check(name, _scope);
+ const Name *protocolName = semantic()->check(name, _scope);
ObjCBaseProtocol *baseProtocol = control()->newObjCBaseProtocol(name->firstToken(), protocolName);
protocol->addProtocol(baseProtocol);
}
@@ -571,7 +571,7 @@ bool CheckDeclaration::visit(ObjCClassForwardDeclarationAST *ast)
else
declarationLocation = sourceLocation;
- Name *className = semantic()->check(it->value, _scope);
+ const Name *className = semantic()->check(it->value, _scope);
ObjCForwardClassDeclaration *fwdClass = control()->newObjCForwardClassDeclaration(sourceLocation, className);
fwdClass->setStartOffset(tokenAt(ast->firstToken()).offset);
fwdClass->setEndOffset(tokenAt(ast->lastToken()).offset);
@@ -594,7 +594,7 @@ bool CheckDeclaration::visit(ObjCClassDeclarationAST *ast)
else
sourceLocation = ast->firstToken();
- Name *className = semantic()->check(ast->class_name, _scope);
+ const Name *className = semantic()->check(ast->class_name, _scope);
ObjCClass *klass = control()->newObjCClass(sourceLocation, className);
klass->setStartOffset(tokenAt(ast->firstToken()).offset);
klass->setEndOffset(tokenAt(ast->lastToken()).offset);
@@ -603,12 +603,12 @@ bool CheckDeclaration::visit(ObjCClassDeclarationAST *ast)
klass->setInterface(ast->interface_token != 0);
if (ast->category_name) {
- Name *categoryName = semantic()->check(ast->category_name, _scope);
+ const Name *categoryName = semantic()->check(ast->category_name, _scope);
klass->setCategoryName(categoryName);
}
if (ast->superclass) {
- Name *superClassName = semantic()->check(ast->superclass, _scope);
+ const Name *superClassName = semantic()->check(ast->superclass, _scope);
ObjCBaseClass *superKlass = control()->newObjCBaseClass(ast->superclass->firstToken(), superClassName);
klass->setBaseClass(superKlass);
}
@@ -616,7 +616,7 @@ bool CheckDeclaration::visit(ObjCClassDeclarationAST *ast)
if (ast->protocol_refs && ast->protocol_refs->identifier_list) {
for (ObjCIdentifierListAST *iter = ast->protocol_refs->identifier_list; iter; iter = iter->next) {
NameAST* name = iter->value;
- Name *protocolName = semantic()->check(name, _scope);
+ const Name *protocolName = semantic()->check(name, _scope);
ObjCBaseProtocol *baseProtocol = control()->newObjCBaseProtocol(name->firstToken(), protocolName);
klass->addProtocol(baseProtocol);
}
@@ -711,7 +711,7 @@ bool CheckDeclaration::visit(ObjCPropertyDeclarationAST *ast)
}
int propAttrs = ObjCPropertyDeclaration::None;
- Name *getterName = 0, *setterName = 0;
+ const Name *getterName = 0, *setterName = 0;
for (ObjCPropertyAttributeListAST *iter= ast->property_attribute_list; iter; iter = iter->next) {
ObjCPropertyAttributeAST *attrAst = iter->value;
diff --git a/src/shared/cplusplus/CheckDeclarator.cpp b/src/shared/cplusplus/CheckDeclarator.cpp
index 9f28381105..7af4e02268 100644
--- a/src/shared/cplusplus/CheckDeclarator.cpp
+++ b/src/shared/cplusplus/CheckDeclarator.cpp
@@ -70,12 +70,12 @@ CheckDeclarator::~CheckDeclarator()
FullySpecifiedType CheckDeclarator::check(DeclaratorAST *declarator,
const FullySpecifiedType &type,
Scope *scope,
- Name **name)
+ const Name **name)
{
FullySpecifiedType previousType = switchFullySpecifiedType(type);
Scope *previousScope = switchScope(scope);
DeclaratorAST *previousDeclarator = switchDeclarator(declarator);
- Name **previousName = switchName(name);
+ const Name **previousName = switchName(name);
accept(declarator);
(void) switchName(previousName);
(void) switchDeclarator(previousDeclarator);
@@ -124,9 +124,9 @@ Scope *CheckDeclarator::switchScope(Scope *scope)
return previousScope;
}
-Name **CheckDeclarator::switchName(Name **name)
+const Name **CheckDeclarator::switchName(const Name **name)
{
- Name **previousName = _name;
+ const Name **previousName = _name;
_name = name;
return previousName;
}
@@ -149,7 +149,7 @@ bool CheckDeclarator::visit(DeclaratorAST *ast)
bool CheckDeclarator::visit(DeclaratorIdAST *ast)
{
- Name *name = semantic()->check(ast->name, _scope);
+ const Name *name = semantic()->check(ast->name, _scope);
if (_name)
*_name = name;
return false;
@@ -219,7 +219,7 @@ bool CheckDeclarator::visit(ArrayDeclaratorAST *ast)
bool CheckDeclarator::visit(PointerToMemberAST *ast)
{
- Name *memberName = semantic()->check(ast->nested_name_specifier_list, _scope);
+ const Name *memberName = semantic()->check(ast->nested_name_specifier_list, _scope);
PointerToMemberType *ptrTy = control()->pointerToMemberType(memberName, _fullySpecifiedType);
FullySpecifiedType ty(ptrTy);
_fullySpecifiedType = ty;
diff --git a/src/shared/cplusplus/CheckDeclarator.h b/src/shared/cplusplus/CheckDeclarator.h
index 1b9e14cb81..81d6c0e4f5 100644
--- a/src/shared/cplusplus/CheckDeclarator.h
+++ b/src/shared/cplusplus/CheckDeclarator.h
@@ -65,7 +65,7 @@ public:
FullySpecifiedType check(DeclaratorAST *declarator,
const FullySpecifiedType &type,
Scope *scope,
- Name **name);
+ const Name **name);
FullySpecifiedType check(PtrOperatorListAST *ptrOperators,
const FullySpecifiedType &type,
@@ -78,7 +78,7 @@ protected:
DeclaratorAST *switchDeclarator(DeclaratorAST *declarator);
FullySpecifiedType switchFullySpecifiedType(const FullySpecifiedType &type);
Scope *switchScope(Scope *scope);
- Name **switchName(Name **name);
+ const Name **switchName(const Name **name);
using ASTVisitor::visit;
@@ -102,7 +102,7 @@ protected:
private:
DeclaratorAST *_declarator;
Scope *_scope;
- Name **_name;
+ const Name **_name;
FullySpecifiedType _fullySpecifiedType;
};
diff --git a/src/shared/cplusplus/CheckExpression.cpp b/src/shared/cplusplus/CheckExpression.cpp
index ad1bb3a46e..f8da07534c 100644
--- a/src/shared/cplusplus/CheckExpression.cpp
+++ b/src/shared/cplusplus/CheckExpression.cpp
@@ -120,7 +120,7 @@ bool CheckExpression::visit(CastExpressionAST *ast)
bool CheckExpression::visit(ConditionAST *ast)
{
FullySpecifiedType typeSpecTy = semantic()->check(ast->type_specifier_list, _scope);
- Name *name = 0;
+ const Name *name = 0;
FullySpecifiedType declTy = semantic()->check(ast->declarator, typeSpecTy.qualifiedType(),
_scope, &name);
Declaration *decl = control()->newDeclaration(ast->declarator->firstToken(), name);
@@ -302,8 +302,7 @@ bool CheckExpression::visit(ThrowExpressionAST *ast)
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 = semantic()->check(ast->declarator, typeSpecTy.qualifiedType(), _scope);
_fullySpecifiedType = declTy;
return false;
}
@@ -316,7 +315,7 @@ bool CheckExpression::visit(UnaryExpressionAST *ast)
bool CheckExpression::visit(QtMethodAST *ast)
{
- Name *name = 0;
+ const Name *name = 0;
Scope dummy;
FullySpecifiedType methTy = semantic()->check(ast->declarator, FullySpecifiedType(),
&dummy, &name);
diff --git a/src/shared/cplusplus/CheckName.cpp b/src/shared/cplusplus/CheckName.cpp
index 1ad29a27d3..11688aba48 100644
--- a/src/shared/cplusplus/CheckName.cpp
+++ b/src/shared/cplusplus/CheckName.cpp
@@ -69,9 +69,9 @@ CheckName::CheckName(Semantic *semantic)
CheckName::~CheckName()
{ }
-Name *CheckName::check(NameAST *name, Scope *scope)
+const Name *CheckName::check(NameAST *name, Scope *scope)
{
- Name *previousName = switchName(0);
+ const Name *previousName = switchName(0);
Scope *previousScope = switchScope(scope);
accept(name);
@@ -82,12 +82,12 @@ Name *CheckName::check(NameAST *name, Scope *scope)
return switchName(previousName);
}
-Name *CheckName::check(NestedNameSpecifierListAST *nested_name_specifier_list, Scope *scope)
+const Name *CheckName::check(NestedNameSpecifierListAST *nested_name_specifier_list, Scope *scope)
{
- Name *previousName = switchName(0);
+ const Name *previousName = switchName(0);
Scope *previousScope = switchScope(scope);
- std::vector<Name *> names;
+ std::vector<const Name *> names;
for (NestedNameSpecifierListAST *it = nested_name_specifier_list; it; it = it->next) {
NestedNameSpecifierAST *nested_name_specifier = it->value;
names.push_back(semantic()->check(nested_name_specifier->class_or_namespace_name, _scope));
@@ -100,9 +100,9 @@ Name *CheckName::check(NestedNameSpecifierListAST *nested_name_specifier_list, S
return switchName(previousName);
}
-Name *CheckName::check(ObjCSelectorAST *args, Scope *scope)
+const Name *CheckName::check(ObjCSelectorAST *args, Scope *scope)
{
- Name *previousName = switchName(0);
+ const Name *previousName = switchName(0);
Scope *previousScope = switchScope(scope);
accept(args);
@@ -113,7 +113,7 @@ Name *CheckName::check(ObjCSelectorAST *args, Scope *scope)
void CheckName::check(ObjCMessageArgumentDeclarationAST *arg, Scope *scope)
{
- Name *previousName = switchName(0);
+ const Name *previousName = switchName(0);
Scope *previousScope = switchScope(scope);
accept(arg);
@@ -122,9 +122,9 @@ void CheckName::check(ObjCMessageArgumentDeclarationAST *arg, Scope *scope)
(void) switchName(previousName);
}
-Name *CheckName::switchName(Name *name)
+const Name *CheckName::switchName(const Name *name)
{
- Name *previousName = _name;
+ const Name *previousName = _name;
_name = name;
return previousName;
}
@@ -138,14 +138,13 @@ Scope *CheckName::switchScope(Scope *scope)
bool CheckName::visit(QualifiedNameAST *ast)
{
- std::vector<Name *> names;
+ std::vector<const Name *> names;
for (NestedNameSpecifierListAST *it = ast->nested_name_specifier_list; it; it = it->next) {
NestedNameSpecifierAST *nested_name_specifier = it->value;
names.push_back(semantic()->check(nested_name_specifier->class_or_namespace_name, _scope));
}
names.push_back(semantic()->check(ast->unqualified_name, _scope));
- _name = control()->qualifiedNameId(&names[0], names.size(),
- ast->global_scope_token != 0);
+ _name = control()->qualifiedNameId(&names[0], names.size(), ast->global_scope_token != 0);
ast->name = _name;
return false;
@@ -379,9 +378,9 @@ bool CheckName::visit(TemplateIdAST *ast)
bool CheckName::visit(ObjCSelectorWithoutArgumentsAST *ast)
{
if (ast->name_token) {
- std::vector<Name *> names;
+ std::vector<const Name *> names;
const Identifier *id = control()->findOrInsertIdentifier(spell(ast->name_token));
- NameId *nameId = control()->nameId(id);
+ const NameId *nameId = control()->nameId(id);
names.push_back(nameId);
_name = control()->selectorNameId(&names[0], names.size(), false);
ast->selector_name = _name;
@@ -392,11 +391,11 @@ bool CheckName::visit(ObjCSelectorWithoutArgumentsAST *ast)
bool CheckName::visit(ObjCSelectorWithArgumentsAST *ast)
{
- std::vector<Name *> names;
+ std::vector<const Name *> names;
for (ObjCSelectorArgumentListAST *it = ast->selector_argument_list; it; it = it->next) {
if (it->value->name_token) {
const Identifier *id = control()->findOrInsertIdentifier(spell(it->value->name_token));
- NameId *nameId = control()->nameId(id);
+ const NameId *nameId = control()->nameId(id);
names.push_back(nameId);
} else {
// we have an incomplete name due, probably due to error recovery. So, back out completely
diff --git a/src/shared/cplusplus/CheckName.h b/src/shared/cplusplus/CheckName.h
index 7f86d75167..1484cb7848 100644
--- a/src/shared/cplusplus/CheckName.h
+++ b/src/shared/cplusplus/CheckName.h
@@ -61,13 +61,13 @@ public:
CheckName(Semantic *semantic);
virtual ~CheckName();
- Name *check(NameAST *name, Scope *scope);
- Name *check(NestedNameSpecifierListAST *name, Scope *scope);
- Name *check(ObjCSelectorAST *args, Scope *scope);
+ const Name *check(NameAST *name, Scope *scope);
+ const Name *check(NestedNameSpecifierListAST *name, Scope *scope);
+ const Name *check(ObjCSelectorAST *args, Scope *scope);
void check(ObjCMessageArgumentDeclarationAST *arg, Scope *scope);
protected:
- Name *switchName(Name *name);
+ const Name *switchName(const Name *name);
Scope *switchScope(Scope *scope);
using ASTVisitor::visit;
@@ -85,7 +85,7 @@ protected:
virtual bool visit(ObjCMessageArgumentDeclarationAST *ast);
private:
- Name *_name;
+ const Name *_name;
Scope *_scope;
};
diff --git a/src/shared/cplusplus/CheckSpecifier.cpp b/src/shared/cplusplus/CheckSpecifier.cpp
index 7f06e2de38..03b2d53d97 100644
--- a/src/shared/cplusplus/CheckSpecifier.cpp
+++ b/src/shared/cplusplus/CheckSpecifier.cpp
@@ -312,7 +312,7 @@ bool CheckSpecifier::visit(ClassSpecifierAST *ast)
if (ast->name)
sourceLocation = ast->name->firstToken();
- Name *className = semantic()->check(ast->name, _scope);
+ const Name *className = semantic()->check(ast->name, _scope);
Class *klass = control()->newClass(sourceLocation, className);
klass->setStartOffset(tokenAt(ast->firstToken()).offset);
klass->setEndOffset(tokenAt(ast->lastToken()).offset);
@@ -330,7 +330,7 @@ bool CheckSpecifier::visit(ClassSpecifierAST *ast)
for (BaseSpecifierListAST *it = ast->base_clause_list; it; it = it->next) {
BaseSpecifierAST *base = it->value;
- Name *baseClassName = semantic()->check(base->name, _scope);
+ const Name *baseClassName = semantic()->check(base->name, _scope);
BaseClass *baseClass = control()->newBaseClass(ast->firstToken(), baseClassName);
base->symbol = baseClass;
if (base->virtual_token)
@@ -359,14 +359,14 @@ bool CheckSpecifier::visit(ClassSpecifierAST *ast)
bool CheckSpecifier::visit(NamedTypeSpecifierAST *ast)
{
- Name *name = semantic()->check(ast->name, _scope);
+ const Name *name = semantic()->check(ast->name, _scope);
_fullySpecifiedType.setType(control()->namedType(name));
return false;
}
bool CheckSpecifier::visit(ElaboratedTypeSpecifierAST *ast)
{
- Name *name = semantic()->check(ast->name, _scope);
+ const Name *name = semantic()->check(ast->name, _scope);
_fullySpecifiedType.setType(control()->namedType(name));
return false;
}
@@ -377,7 +377,7 @@ bool CheckSpecifier::visit(EnumSpecifierAST *ast)
if (ast->name)
sourceLocation = ast->name->firstToken();
- Name *name = semantic()->check(ast->name, _scope);
+ const Name *name = semantic()->check(ast->name, _scope);
Enum *e = control()->newEnum(sourceLocation, name);
e->setStartOffset(tokenAt(ast->firstToken()).offset);
e->setEndOffset(tokenAt(ast->lastToken()).offset);
@@ -389,7 +389,7 @@ bool CheckSpecifier::visit(EnumSpecifierAST *ast)
const Identifier *id = identifier(enumerator->identifier_token);
if (! id)
continue;
- NameId *enumeratorName = control()->nameId(id);
+ const NameId *enumeratorName = control()->nameId(id);
Declaration *decl = control()->newDeclaration(enumerator->firstToken(),
enumeratorName);
e->addMember(decl);
diff --git a/src/shared/cplusplus/CheckStatement.cpp b/src/shared/cplusplus/CheckStatement.cpp
index dec68b1ea4..ec9f6590e2 100644
--- a/src/shared/cplusplus/CheckStatement.cpp
+++ b/src/shared/cplusplus/CheckStatement.cpp
@@ -154,7 +154,7 @@ bool CheckStatement::visit(ForeachStatementAST *ast)
Scope *previousScope = switchScope(block->members());
if (ast->type_specifier_list && ast->declarator) {
FullySpecifiedType ty = semantic()->check(ast->type_specifier_list, _scope);
- Name *name = 0;
+ const Name *name = 0;
ty = semantic()->check(ast->declarator, ty, _scope, &name);
unsigned location = ast->declarator->firstToken();
if (CoreDeclaratorAST *core_declarator = ast->declarator->core_declarator)
@@ -183,7 +183,7 @@ bool CheckStatement::visit(ObjCFastEnumerationAST *ast)
Scope *previousScope = switchScope(block->members());
if (ast->type_specifier_list && ast->declarator) {
FullySpecifiedType ty = semantic()->check(ast->type_specifier_list, _scope);
- Name *name = 0;
+ const Name *name = 0;
ty = semantic()->check(ast->declarator, ty, _scope, &name);
unsigned location = ast->declarator->firstToken();
if (CoreDeclaratorAST *core_declarator = ast->declarator->core_declarator)
@@ -312,7 +312,7 @@ bool CheckStatement::visit(WhileStatementAST *ast)
bool CheckStatement::visit(QtMemberDeclarationAST *ast)
{
- Name *name = 0;
+ const Name *name = 0;
if (tokenKind(ast->q_token) == T_Q_D)
name = control()->nameId(control()->findOrInsertIdentifier("d"));
@@ -323,12 +323,13 @@ bool CheckStatement::visit(QtMemberDeclarationAST *ast)
if (tokenKind(ast->q_token) == T_Q_D) {
if (NamedType *namedTy = declTy->asNamedType()) {
- if (NameId *nameId = namedTy->name()->asNameId()) {
+ if (const NameId *nameId = namedTy->name()->asNameId()) {
std::string privateClass;
privateClass += nameId->identifier()->chars();
privateClass += "Private";
- Name *privName = control()->nameId(control()->findOrInsertIdentifier(privateClass.c_str(), privateClass.size()));
+ const Name *privName = control()->nameId(control()->findOrInsertIdentifier(privateClass.c_str(),
+ privateClass.size()));
declTy.setType(control()->namedType(privName));
}
}
diff --git a/src/shared/cplusplus/Control.cpp b/src/shared/cplusplus/Control.cpp
index 1cd2ad51b0..ec14aa796b 100644
--- a/src/shared/cplusplus/Control.cpp
+++ b/src/shared/cplusplus/Control.cpp
@@ -184,79 +184,78 @@ public:
delete_array_entries(symbols);
}
- NameId *findOrInsertNameId(const Identifier *id)
+ const NameId *findOrInsertNameId(const Identifier *id)
{
if (! id)
return 0;
- std::map<const Identifier *, NameId *>::iterator it = nameIds.lower_bound(id);
+ std::map<const Identifier *, const NameId *>::iterator it = nameIds.lower_bound(id);
if (it == nameIds.end() || it->first != id)
it = nameIds.insert(it, std::make_pair(id, new NameId(id)));
return it->second;
}
- TemplateNameId *findOrInsertTemplateNameId(const Identifier *id,
- const std::vector<FullySpecifiedType> &templateArguments)
+ const TemplateNameId *findOrInsertTemplateNameId(const Identifier *id,
+ const std::vector<FullySpecifiedType> &templateArguments)
{
if (! id)
return 0;
const TemplateNameIdKey key(id, templateArguments);
- std::map<TemplateNameIdKey, TemplateNameId *>::iterator it =
+ std::map<TemplateNameIdKey, const TemplateNameId *>::iterator it =
templateNameIds.lower_bound(key);
if (it == templateNameIds.end() || it->first != key) {
const FullySpecifiedType *args = 0;
if (templateArguments.size())
args = &templateArguments[0];
- TemplateNameId *templ = new TemplateNameId(id, args,
- templateArguments.size());
+ const TemplateNameId *templ = new TemplateNameId(id, args, templateArguments.size());
it = templateNameIds.insert(it, std::make_pair(key, templ));
}
return it->second;
}
- DestructorNameId *findOrInsertDestructorNameId(const Identifier *id)
+ const DestructorNameId *findOrInsertDestructorNameId(const Identifier *id)
{
if (! id)
return 0;
- std::map<const Identifier *, DestructorNameId *>::iterator it = destructorNameIds.lower_bound(id);
+ std::map<const Identifier *, const DestructorNameId *>::iterator it = destructorNameIds.lower_bound(id);
if (it == destructorNameIds.end() || it->first != id)
it = destructorNameIds.insert(it, std::make_pair(id, new DestructorNameId(id)));
return it->second;
}
- OperatorNameId *findOrInsertOperatorNameId(int kind)
+ const OperatorNameId *findOrInsertOperatorNameId(int kind)
{
const int key(kind);
- std::map<int, OperatorNameId *>::iterator it = operatorNameIds.lower_bound(key);
+ std::map<int, const OperatorNameId *>::iterator it = operatorNameIds.lower_bound(key);
if (it == operatorNameIds.end() || it->first != key)
it = operatorNameIds.insert(it, std::make_pair(key, new OperatorNameId(kind)));
return it->second;
}
- ConversionNameId *findOrInsertConversionNameId(const FullySpecifiedType &type)
+ const ConversionNameId *findOrInsertConversionNameId(const FullySpecifiedType &type)
{
- std::map<FullySpecifiedType, ConversionNameId *>::iterator it =
+ std::map<FullySpecifiedType, const ConversionNameId *>::iterator it =
conversionNameIds.lower_bound(type);
if (it == conversionNameIds.end() || it->first != type)
it = conversionNameIds.insert(it, std::make_pair(type, new ConversionNameId(type)));
return it->second;
}
- QualifiedNameId *findOrInsertQualifiedNameId(const std::vector<Name *> &names, bool isGlobal)
+ const QualifiedNameId *findOrInsertQualifiedNameId(const std::vector<const Name *> &names, bool isGlobal)
{
const QualifiedNameIdKey key(names, isGlobal);
- std::map<QualifiedNameIdKey, QualifiedNameId *>::iterator it =
+ std::map<QualifiedNameIdKey, const QualifiedNameId *>::iterator it =
qualifiedNameIds.lower_bound(key);
if (it == qualifiedNameIds.end() || it->first != key) {
- QualifiedNameId *name = new QualifiedNameId(&names[0], names.size(), isGlobal);
+ const QualifiedNameId *name = new QualifiedNameId(&names[0], names.size(), isGlobal);
it = qualifiedNameIds.insert(it, std::make_pair(key, name));
}
return it->second;
}
- SelectorNameId *findOrInsertSelectorNameId(const std::vector<Name *> &names, bool hasArguments)
+ const SelectorNameId *findOrInsertSelectorNameId(const std::vector<const Name *> &names, bool hasArguments)
{
const SelectorNameIdKey key(names, hasArguments);
- std::map<SelectorNameIdKey, SelectorNameId *>::iterator it = selectorNameIds.lower_bound(key);
+ std::map<SelectorNameIdKey, const SelectorNameId *>::iterator it = selectorNameIds.lower_bound(key);
if (it == selectorNameIds.end() || it->first != key)
it = selectorNameIds.insert(it, std::make_pair(key, new SelectorNameId(&names[0], names.size(), hasArguments)));
return it->second;
@@ -272,7 +271,7 @@ public:
return floatTypes.intern(FloatType(kind));
}
- PointerToMemberType *findOrInsertPointerToMemberType(Name *memberName, const FullySpecifiedType &elementType)
+ PointerToMemberType *findOrInsertPointerToMemberType(const Name *memberName, const FullySpecifiedType &elementType)
{
return pointerToMemberTypes.intern(PointerToMemberType(memberName, elementType));
}
@@ -292,12 +291,12 @@ public:
return arrayTypes.intern(ArrayType(elementType, size));
}
- NamedType *findOrInsertNamedType(Name *name)
+ NamedType *findOrInsertNamedType(const Name *name)
{
return namedTypes.intern(NamedType(name));
}
- Declaration *newDeclaration(unsigned sourceLocation, Name *name)
+ Declaration *newDeclaration(unsigned sourceLocation, const Name *name)
{
Declaration *declaration = new Declaration(translationUnit,
sourceLocation, name);
@@ -305,7 +304,7 @@ public:
return declaration;
}
- Argument *newArgument(unsigned sourceLocation, Name *name)
+ Argument *newArgument(unsigned sourceLocation, const Name *name)
{
Argument *argument = new Argument(translationUnit,
sourceLocation, name);
@@ -313,7 +312,7 @@ public:
return argument;
}
- Function *newFunction(unsigned sourceLocation, Name *name)
+ Function *newFunction(unsigned sourceLocation, const Name *name)
{
Function *function = new Function(translationUnit,
sourceLocation, name);
@@ -321,7 +320,7 @@ public:
return function;
}
- BaseClass *newBaseClass(unsigned sourceLocation, Name *name)
+ BaseClass *newBaseClass(unsigned sourceLocation, const Name *name)
{
BaseClass *baseClass = new BaseClass(translationUnit,
sourceLocation, name);
@@ -336,7 +335,7 @@ public:
return block;
}
- Class *newClass(unsigned sourceLocation, Name *name)
+ Class *newClass(unsigned sourceLocation, const Name *name)
{
Class *klass = new Class(translationUnit,
sourceLocation, name);
@@ -344,7 +343,7 @@ public:
return klass;
}
- Namespace *newNamespace(unsigned sourceLocation, Name *name)
+ Namespace *newNamespace(unsigned sourceLocation, const Name *name)
{
Namespace *ns = new Namespace(translationUnit,
sourceLocation, name);
@@ -352,7 +351,7 @@ public:
return ns;
}
- UsingNamespaceDirective *newUsingNamespaceDirective(unsigned sourceLocation, Name *name)
+ UsingNamespaceDirective *newUsingNamespaceDirective(unsigned sourceLocation, const Name *name)
{
UsingNamespaceDirective *u = new UsingNamespaceDirective(translationUnit,
sourceLocation, name);
@@ -360,7 +359,7 @@ public:
return u;
}
- ForwardClassDeclaration *newForwardClassDeclaration(unsigned sourceLocation, Name *name)
+ ForwardClassDeclaration *newForwardClassDeclaration(unsigned sourceLocation, const Name *name)
{
ForwardClassDeclaration *c = new ForwardClassDeclaration(translationUnit,
sourceLocation, name);
@@ -368,63 +367,63 @@ public:
return c;
}
- ObjCBaseClass *newObjCBaseClass(unsigned sourceLocation, Name *name)
+ ObjCBaseClass *newObjCBaseClass(unsigned sourceLocation, const Name *name)
{
ObjCBaseClass *c = new ObjCBaseClass(translationUnit, sourceLocation, name);
symbols.push_back(c);
return c;
}
- ObjCBaseProtocol *newObjCBaseProtocol(unsigned sourceLocation, Name *name)
+ ObjCBaseProtocol *newObjCBaseProtocol(unsigned sourceLocation, const Name *name)
{
ObjCBaseProtocol *p = new ObjCBaseProtocol(translationUnit, sourceLocation, name);
symbols.push_back(p);
return p;
}
- ObjCClass *newObjCClass(unsigned sourceLocation, Name *name)
+ ObjCClass *newObjCClass(unsigned sourceLocation, const Name *name)
{
ObjCClass *c = new ObjCClass(translationUnit, sourceLocation, name);
symbols.push_back(c);
return c;
}
- ObjCForwardClassDeclaration *newObjCForwardClassDeclaration(unsigned sourceLocation, Name *name)
+ ObjCForwardClassDeclaration *newObjCForwardClassDeclaration(unsigned sourceLocation, const Name *name)
{
ObjCForwardClassDeclaration *fwd = new ObjCForwardClassDeclaration(translationUnit, sourceLocation, name);
symbols.push_back(fwd);
return fwd;
}
- ObjCProtocol *newObjCProtocol(unsigned sourceLocation, Name *name)
+ ObjCProtocol *newObjCProtocol(unsigned sourceLocation, const Name *name)
{
ObjCProtocol *p = new ObjCProtocol(translationUnit, sourceLocation, name);
symbols.push_back(p);
return p;
}
- ObjCForwardProtocolDeclaration *newObjCForwardProtocolDeclaration(unsigned sourceLocation, Name *name)
+ ObjCForwardProtocolDeclaration *newObjCForwardProtocolDeclaration(unsigned sourceLocation, const Name *name)
{
ObjCForwardProtocolDeclaration *fwd = new ObjCForwardProtocolDeclaration(translationUnit, sourceLocation, name);
symbols.push_back(fwd);
return fwd;
}
- ObjCMethod *newObjCMethod(unsigned sourceLocation, Name *name)
+ ObjCMethod *newObjCMethod(unsigned sourceLocation, const Name *name)
{
ObjCMethod *method = new ObjCMethod(translationUnit, sourceLocation, name);
symbols.push_back(method);
return method;
}
- ObjCPropertyDeclaration *newObjCPropertyDeclaration(unsigned sourceLocation, Name *name)
+ ObjCPropertyDeclaration *newObjCPropertyDeclaration(unsigned sourceLocation, const Name *name)
{
ObjCPropertyDeclaration *decl = new ObjCPropertyDeclaration(translationUnit, sourceLocation, name);
symbols.push_back(decl);
return decl;
}
- Enum *newEnum(unsigned sourceLocation, Name *name)
+ Enum *newEnum(unsigned sourceLocation, const Name *name)
{
Enum *e = new Enum(translationUnit,
sourceLocation, name);
@@ -432,7 +431,7 @@ public:
return e;
}
- UsingDeclaration *newUsingDeclaration(unsigned sourceLocation, Name *name)
+ UsingDeclaration *newUsingDeclaration(unsigned sourceLocation, const Name *name)
{
UsingDeclaration *u = new UsingDeclaration(translationUnit,
sourceLocation, name);
@@ -466,10 +465,10 @@ public:
};
struct QualifiedNameIdKey {
- std::vector<Name *> names;
+ std::vector<const Name *> names;
bool isGlobal;
- QualifiedNameIdKey(const std::vector<Name *> &names, bool isGlobal) :
+ QualifiedNameIdKey(const std::vector<const Name *> &names, bool isGlobal) :
names(names), isGlobal(isGlobal)
{ }
@@ -489,10 +488,10 @@ public:
};
struct SelectorNameIdKey {
- std::vector<Name *> _names;
+ std::vector<const Name *> _names;
bool _hasArguments;
- SelectorNameIdKey(const std::vector<Name *> &names, bool hasArguments): _names(names), _hasArguments(hasArguments) {}
+ SelectorNameIdKey(const std::vector<const Name *> &names, bool hasArguments): _names(names), _hasArguments(hasArguments) {}
bool operator==(const SelectorNameIdKey &other) const
{ return _names == other._names && _hasArguments == other._hasArguments; }
@@ -522,13 +521,13 @@ public:
// ### replace std::map with lookup tables. ASAP!
// names
- std::map<const Identifier *, NameId *> nameIds;
- std::map<const Identifier *, DestructorNameId *> destructorNameIds;
- std::map<int, OperatorNameId *> operatorNameIds;
- std::map<FullySpecifiedType, ConversionNameId *> conversionNameIds;
- std::map<TemplateNameIdKey, TemplateNameId *> templateNameIds;
- std::map<QualifiedNameIdKey, QualifiedNameId *> qualifiedNameIds;
- std::map<SelectorNameIdKey, SelectorNameId *> selectorNameIds;
+ std::map<const Identifier *, const NameId *> nameIds;
+ std::map<const Identifier *, const DestructorNameId *> destructorNameIds;
+ std::map<int, const OperatorNameId *> operatorNameIds;
+ std::map<FullySpecifiedType, const ConversionNameId *> conversionNameIds;
+ std::map<TemplateNameIdKey, const TemplateNameId *> templateNameIds;
+ std::map<QualifiedNameIdKey, const QualifiedNameId *> qualifiedNameIds;
+ std::map<SelectorNameIdKey, const SelectorNameId *> selectorNameIds;
// types
VoidType voidType;
@@ -635,39 +634,39 @@ const NumericLiteral *Control::findOrInsertNumericLiteral(const char *chars)
return findOrInsertNumericLiteral(chars, length);
}
-NameId *Control::nameId(const Identifier *id)
+const NameId *Control::nameId(const Identifier *id)
{ return d->findOrInsertNameId(id); }
-TemplateNameId *Control::templateNameId(const Identifier *id,
- FullySpecifiedType *const args,
- unsigned argv)
+const TemplateNameId *Control::templateNameId(const Identifier *id,
+ const FullySpecifiedType *const args,
+ unsigned argv)
{
std::vector<FullySpecifiedType> templateArguments(args, args + argv);
return d->findOrInsertTemplateNameId(id, templateArguments);
}
-DestructorNameId *Control::destructorNameId(const Identifier *id)
+const DestructorNameId *Control::destructorNameId(const Identifier *id)
{ return d->findOrInsertDestructorNameId(id); }
-OperatorNameId *Control::operatorNameId(int kind)
+const OperatorNameId *Control::operatorNameId(int kind)
{ return d->findOrInsertOperatorNameId(kind); }
-ConversionNameId *Control::conversionNameId(const FullySpecifiedType &type)
+const ConversionNameId *Control::conversionNameId(const FullySpecifiedType &type)
{ return d->findOrInsertConversionNameId(type); }
-QualifiedNameId *Control::qualifiedNameId(Name *const *names,
- unsigned nameCount,
- bool isGlobal)
+const QualifiedNameId *Control::qualifiedNameId(const Name *const *names,
+ unsigned nameCount,
+ bool isGlobal)
{
- std::vector<Name *> classOrNamespaceNames(names, names + nameCount);
+ std::vector<const Name *> classOrNamespaceNames(names, names + nameCount);
return d->findOrInsertQualifiedNameId(classOrNamespaceNames, isGlobal);
}
-SelectorNameId *Control::selectorNameId(Name *const *names,
- unsigned nameCount,
- bool hasArguments)
+const SelectorNameId *Control::selectorNameId(const Name *const *names,
+ unsigned nameCount,
+ bool hasArguments)
{
- std::vector<Name *> selectorNames(names, names + nameCount);
+ std::vector<const Name *> selectorNames(names, names + nameCount);
return d->findOrInsertSelectorNameId(selectorNames, hasArguments);
}
@@ -681,7 +680,7 @@ IntegerType *Control::integerType(int kind)
FloatType *Control::floatType(int kind)
{ return d->findOrInsertFloatType(kind); }
-PointerToMemberType *Control::pointerToMemberType(Name *memberName, const FullySpecifiedType &elementType)
+PointerToMemberType *Control::pointerToMemberType(const Name *memberName, const FullySpecifiedType &elementType)
{ return d->findOrInsertPointerToMemberType(memberName, elementType); }
PointerType *Control::pointerType(const FullySpecifiedType &elementType)
@@ -693,66 +692,66 @@ ReferenceType *Control::referenceType(const FullySpecifiedType &elementType)
ArrayType *Control::arrayType(const FullySpecifiedType &elementType, unsigned size)
{ return d->findOrInsertArrayType(elementType, size); }
-NamedType *Control::namedType(Name *name)
+NamedType *Control::namedType(const Name *name)
{ return d->findOrInsertNamedType(name); }
-Argument *Control::newArgument(unsigned sourceLocation, Name *name)
+Argument *Control::newArgument(unsigned sourceLocation, const Name *name)
{ return d->newArgument(sourceLocation, name); }
-Function *Control::newFunction(unsigned sourceLocation, Name *name)
+Function *Control::newFunction(unsigned sourceLocation, const Name *name)
{ return d->newFunction(sourceLocation, name); }
-Namespace *Control::newNamespace(unsigned sourceLocation, Name *name)
+Namespace *Control::newNamespace(unsigned sourceLocation, const Name *name)
{ return d->newNamespace(sourceLocation, name); }
-BaseClass *Control::newBaseClass(unsigned sourceLocation, Name *name)
+BaseClass *Control::newBaseClass(unsigned sourceLocation, const Name *name)
{ return d->newBaseClass(sourceLocation, name); }
-Class *Control::newClass(unsigned sourceLocation, Name *name)
+Class *Control::newClass(unsigned sourceLocation, const Name *name)
{ return d->newClass(sourceLocation, name); }
-Enum *Control::newEnum(unsigned sourceLocation, Name *name)
+Enum *Control::newEnum(unsigned sourceLocation, const Name *name)
{ return d->newEnum(sourceLocation, name); }
Block *Control::newBlock(unsigned sourceLocation)
{ return d->newBlock(sourceLocation); }
-Declaration *Control::newDeclaration(unsigned sourceLocation, Name *name)
+Declaration *Control::newDeclaration(unsigned sourceLocation, const Name *name)
{ return d->newDeclaration(sourceLocation, name); }
UsingNamespaceDirective *Control::newUsingNamespaceDirective(unsigned sourceLocation,
- Name *name)
+ const Name *name)
{ return d->newUsingNamespaceDirective(sourceLocation, name); }
-UsingDeclaration *Control::newUsingDeclaration(unsigned sourceLocation, Name *name)
+UsingDeclaration *Control::newUsingDeclaration(unsigned sourceLocation, const Name *name)
{ return d->newUsingDeclaration(sourceLocation, name); }
ForwardClassDeclaration *Control::newForwardClassDeclaration(unsigned sourceLocation,
- Name *name)
+ const Name *name)
{ return d->newForwardClassDeclaration(sourceLocation, name); }
-ObjCBaseClass *Control::newObjCBaseClass(unsigned sourceLocation, Name *name)
+ObjCBaseClass *Control::newObjCBaseClass(unsigned sourceLocation, const Name *name)
{ return d->newObjCBaseClass(sourceLocation, name); }
-ObjCBaseProtocol *Control::newObjCBaseProtocol(unsigned sourceLocation, Name *name)
+ObjCBaseProtocol *Control::newObjCBaseProtocol(unsigned sourceLocation, const Name *name)
{ return d->newObjCBaseProtocol(sourceLocation, name); }
-ObjCClass *Control::newObjCClass(unsigned sourceLocation, Name *name)
+ObjCClass *Control::newObjCClass(unsigned sourceLocation, const Name *name)
{ return d->newObjCClass(sourceLocation, name); }
-ObjCForwardClassDeclaration *Control::newObjCForwardClassDeclaration(unsigned sourceLocation, Name *name)
+ObjCForwardClassDeclaration *Control::newObjCForwardClassDeclaration(unsigned sourceLocation, const Name *name)
{ return d->newObjCForwardClassDeclaration(sourceLocation, name); }
-ObjCProtocol *Control::newObjCProtocol(unsigned sourceLocation, Name *name)
+ObjCProtocol *Control::newObjCProtocol(unsigned sourceLocation, const Name *name)
{ return d->newObjCProtocol(sourceLocation, name); }
-ObjCForwardProtocolDeclaration *Control::newObjCForwardProtocolDeclaration(unsigned sourceLocation, Name *name)
+ObjCForwardProtocolDeclaration *Control::newObjCForwardProtocolDeclaration(unsigned sourceLocation, const Name *name)
{ return d->newObjCForwardProtocolDeclaration(sourceLocation, name); }
-ObjCMethod *Control::newObjCMethod(unsigned sourceLocation, Name *name)
+ObjCMethod *Control::newObjCMethod(unsigned sourceLocation, const Name *name)
{ return d->newObjCMethod(sourceLocation, name); }
-ObjCPropertyDeclaration *Control::newObjCPropertyDeclaration(unsigned sourceLocation, Name *name)
+ObjCPropertyDeclaration *Control::newObjCPropertyDeclaration(unsigned sourceLocation, const Name *name)
{ return d->newObjCPropertyDeclaration(sourceLocation, name); }
const Identifier *Control::objcGetterId() const
diff --git a/src/shared/cplusplus/Control.h b/src/shared/cplusplus/Control.h
index 3fc8543ab1..4881b416e8 100644
--- a/src/shared/cplusplus/Control.h
+++ b/src/shared/cplusplus/Control.h
@@ -66,30 +66,30 @@ public:
void setDiagnosticClient(DiagnosticClient *diagnosticClient);
/// Returns the canonical name id.
- NameId *nameId(const Identifier *id);
+ const NameId *nameId(const Identifier *id);
/// Returns the canonical template name id.
- TemplateNameId *templateNameId(const Identifier *id,
- FullySpecifiedType *const args = 0,
- unsigned argc = 0);
+ const TemplateNameId *templateNameId(const Identifier *id,
+ const FullySpecifiedType *const args = 0,
+ unsigned argc = 0);
/// Returns the canonical destructor name id.
- DestructorNameId *destructorNameId(const Identifier *id);
+ const DestructorNameId *destructorNameId(const Identifier *id);
/// Returns the canonical operator name id.
- OperatorNameId *operatorNameId(int operatorId);
+ const OperatorNameId *operatorNameId(int operatorId);
/// Returns the canonical conversion name id.
- ConversionNameId *conversionNameId(const FullySpecifiedType &type);
+ const ConversionNameId *conversionNameId(const FullySpecifiedType &type);
/// Returns the canonical qualified name id.
- QualifiedNameId *qualifiedNameId(Name *const *names,
- unsigned nameCount,
- bool isGlobal = false);
+ const QualifiedNameId *qualifiedNameId(const Name *const *names,
+ unsigned nameCount,
+ bool isGlobal = false);
- SelectorNameId *selectorNameId(Name *const *names,
- unsigned nameCount,
- bool hasArguments);
+ const SelectorNameId *selectorNameId(const Name *const *names,
+ unsigned nameCount,
+ bool hasArguments);
/// Returns a Type object of type VoidType.
VoidType *voidType();
@@ -101,7 +101,7 @@ public:
FloatType *floatType(int floatId);
/// Returns a Type object of type PointertoMemberType.
- PointerToMemberType *pointerToMemberType(Name *memberName,
+ PointerToMemberType *pointerToMemberType(const Name *memberName,
const FullySpecifiedType &elementType);
/// Returns a Type object of type PointerType.
@@ -114,61 +114,61 @@ public:
ArrayType *arrayType(const FullySpecifiedType &elementType, unsigned size = 0);
/// Returns a Type object of type NamedType.
- NamedType *namedType(Name *name);
+ NamedType *namedType(const Name *name);
/// Creates a new Declaration symbol.
- Declaration *newDeclaration(unsigned sourceLocation, Name *name);
+ Declaration *newDeclaration(unsigned sourceLocation, const Name *name);
/// Creates a new Argument symbol.
- Argument *newArgument(unsigned sourceLocation, Name *name = 0);
+ Argument *newArgument(unsigned sourceLocation, const Name *name = 0);
/// Creates a new Function symbol.
- Function *newFunction(unsigned sourceLocation, Name *name = 0);
+ Function *newFunction(unsigned sourceLocation, const Name *name = 0);
/// Creates a new Namespace symbol.
- Namespace *newNamespace(unsigned sourceLocation, Name *name = 0);
+ Namespace *newNamespace(unsigned sourceLocation, const Name *name = 0);
/// Creates a new BaseClass symbol.
- BaseClass *newBaseClass(unsigned sourceLocation, Name *name = 0);
+ BaseClass *newBaseClass(unsigned sourceLocation, const Name *name = 0);
/// Creates a new Class symbol.
- Class *newClass(unsigned sourceLocation, Name *name = 0);
+ Class *newClass(unsigned sourceLocation, const Name *name = 0);
/// Creates a new Enum symbol.
- Enum *newEnum(unsigned sourceLocation, Name *name = 0);
+ Enum *newEnum(unsigned sourceLocation, const Name *name = 0);
/// Creates a new Block symbol.
Block *newBlock(unsigned sourceLocation);
/// Creates a new UsingNamespaceDirective symbol.
- UsingNamespaceDirective *newUsingNamespaceDirective(unsigned sourceLocation, Name *name = 0);
+ UsingNamespaceDirective *newUsingNamespaceDirective(unsigned sourceLocation, const Name *name = 0);
/// Creates a new UsingDeclaration symbol.
- UsingDeclaration *newUsingDeclaration(unsigned sourceLocation, Name *name = 0);
+ UsingDeclaration *newUsingDeclaration(unsigned sourceLocation, const Name *name = 0);
/// Creates a new ForwardClassDeclaration symbol.
- ForwardClassDeclaration *newForwardClassDeclaration(unsigned sourceLocation, Name *name = 0);
+ ForwardClassDeclaration *newForwardClassDeclaration(unsigned sourceLocation, const Name *name = 0);
- ObjCBaseClass *newObjCBaseClass(unsigned sourceLocation, Name *name);
- ObjCBaseProtocol *newObjCBaseProtocol(unsigned sourceLocation, Name *name);
+ ObjCBaseClass *newObjCBaseClass(unsigned sourceLocation, const Name *name);
+ ObjCBaseProtocol *newObjCBaseProtocol(unsigned sourceLocation, const Name *name);
/// Creates a new Objective-C class symbol.
- ObjCClass *newObjCClass(unsigned sourceLocation, Name *name = 0);
+ ObjCClass *newObjCClass(unsigned sourceLocation, const Name *name = 0);
/// Creates a new Objective-C class forward declaration symbol.
- ObjCForwardClassDeclaration *newObjCForwardClassDeclaration(unsigned sourceLocation, Name *name = 0);
+ ObjCForwardClassDeclaration *newObjCForwardClassDeclaration(unsigned sourceLocation, const Name *name = 0);
/// Creates a new Objective-C protocol symbol.
- ObjCProtocol *newObjCProtocol(unsigned sourceLocation, Name *name = 0);
+ ObjCProtocol *newObjCProtocol(unsigned sourceLocation, const Name *name = 0);
/// Creates a new Objective-C protocol forward declaration symbol.
- ObjCForwardProtocolDeclaration *newObjCForwardProtocolDeclaration(unsigned sourceLocation, Name *name = 0);
+ ObjCForwardProtocolDeclaration *newObjCForwardProtocolDeclaration(unsigned sourceLocation, const Name *name = 0);
/// Creates a new Objective-C method symbol.
- ObjCMethod *newObjCMethod(unsigned sourceLocation, Name *name = 0);
+ ObjCMethod *newObjCMethod(unsigned sourceLocation, const Name *name = 0);
/// Creates a new Objective-C @property declaration symbol.
- ObjCPropertyDeclaration *newObjCPropertyDeclaration(unsigned sourceLocation, Name *name);
+ ObjCPropertyDeclaration *newObjCPropertyDeclaration(unsigned sourceLocation, const Name *name);
// Objective-C specific context keywords.
const Identifier *objcGetterId() const;
diff --git a/src/shared/cplusplus/CoreTypes.cpp b/src/shared/cplusplus/CoreTypes.cpp
index 9bdd17a827..43d9f8bab0 100644
--- a/src/shared/cplusplus/CoreTypes.cpp
+++ b/src/shared/cplusplus/CoreTypes.cpp
@@ -90,7 +90,7 @@ bool VoidType::matchType0(const Type *otherType, TypeMatcher *matcher) const
return false;
}
-PointerToMemberType::PointerToMemberType(Name *memberName, const FullySpecifiedType &elementType)
+PointerToMemberType::PointerToMemberType(const Name *memberName, const FullySpecifiedType &elementType)
: _memberName(memberName),
_elementType(elementType)
{ }
@@ -98,7 +98,7 @@ PointerToMemberType::PointerToMemberType(Name *memberName, const FullySpecifiedT
PointerToMemberType::~PointerToMemberType()
{ }
-Name *PointerToMemberType::memberName() const
+const Name *PointerToMemberType::memberName() const
{ return _memberName; }
FullySpecifiedType PointerToMemberType::elementType() const
@@ -275,14 +275,14 @@ FullySpecifiedType ArrayType::elementType() const
unsigned ArrayType::size() const
{ return _size; }
-NamedType::NamedType(Name *name)
+NamedType::NamedType(const Name *name)
: _name(name)
{ }
NamedType::~NamedType()
{ }
-Name *NamedType::name() const
+const Name *NamedType::name() const
{ return _name; }
bool NamedType::isEqualTo(const Type *other) const
@@ -291,12 +291,12 @@ bool NamedType::isEqualTo(const Type *other) const
if (! o)
return false;
- Name *name = _name;
- if (QualifiedNameId *q = name->asQualifiedNameId())
+ const Name *name = _name;
+ if (const QualifiedNameId *q = name->asQualifiedNameId())
name = q->unqualifiedNameId();
- Name *otherName = o->name();
- if (QualifiedNameId *q = otherName->asQualifiedNameId())
+ const Name *otherName = o->name();
+ if (const QualifiedNameId *q = otherName->asQualifiedNameId())
otherName = q->unqualifiedNameId();
return name->isEqualTo(otherName);
diff --git a/src/shared/cplusplus/CoreTypes.h b/src/shared/cplusplus/CoreTypes.h
index dc70f06ddf..42d69b4cb3 100644
--- a/src/shared/cplusplus/CoreTypes.h
+++ b/src/shared/cplusplus/CoreTypes.h
@@ -186,10 +186,10 @@ private:
class CPLUSPLUS_EXPORT PointerToMemberType: public Type
{
public:
- PointerToMemberType(Name *memberName, const FullySpecifiedType &elementType);
+ PointerToMemberType(const Name *memberName, const FullySpecifiedType &elementType);
virtual ~PointerToMemberType();
- Name *memberName() const;
+ const Name *memberName() const;
FullySpecifiedType elementType() const;
virtual bool isEqualTo(const Type *other) const;
@@ -205,7 +205,7 @@ protected:
virtual bool matchType0(const Type *otherType, TypeMatcher *matcher) const;
private:
- Name *_memberName;
+ const Name *_memberName;
FullySpecifiedType _elementType;
};
@@ -262,10 +262,10 @@ private:
class CPLUSPLUS_EXPORT NamedType: public Type
{
public:
- NamedType(Name *name);
+ NamedType(const Name *name);
virtual ~NamedType();
- Name *name() const;
+ const Name *name() const;
virtual bool isEqualTo(const Type *other) const;
@@ -280,7 +280,7 @@ protected:
virtual bool matchType0(const Type *otherType, TypeMatcher *matcher) const;
private:
- Name *_name;
+ const Name *_name;
};
} // end of namespace CPlusPlus
diff --git a/src/shared/cplusplus/Name.cpp b/src/shared/cplusplus/Name.cpp
index 6354382551..b185409cf6 100644
--- a/src/shared/cplusplus/Name.cpp
+++ b/src/shared/cplusplus/Name.cpp
@@ -79,14 +79,14 @@ bool Name::isQualifiedNameId() const
bool Name::isSelectorNameId() const
{ return asSelectorNameId() != 0; }
-void Name::accept(NameVisitor *visitor)
+void Name::accept(NameVisitor *visitor) const
{
if (visitor->preVisit(this))
accept0(visitor);
visitor->postVisit(this);
}
-void Name::accept(Name *name, NameVisitor *visitor)
+void Name::accept(const Name *name, NameVisitor *visitor)
{
if (! name)
return;
diff --git a/src/shared/cplusplus/Name.h b/src/shared/cplusplus/Name.h
index 8559b6ea2e..ea740bd249 100644
--- a/src/shared/cplusplus/Name.h
+++ b/src/shared/cplusplus/Name.h
@@ -78,21 +78,13 @@ public:
virtual const QualifiedNameId *asQualifiedNameId() const { return 0; }
virtual const SelectorNameId *asSelectorNameId() const { return 0; }
- virtual NameId *asNameId() { return 0; }
- virtual TemplateNameId *asTemplateNameId() { return 0; }
- virtual DestructorNameId *asDestructorNameId() { return 0; }
- virtual OperatorNameId *asOperatorNameId() { return 0; }
- virtual ConversionNameId *asConversionNameId() { return 0; }
- virtual QualifiedNameId *asQualifiedNameId() { return 0; }
- virtual SelectorNameId *asSelectorNameId() { return 0; }
-
virtual bool isEqualTo(const Name *other) const = 0;
- void accept(NameVisitor *visitor);
- static void accept(Name *name, NameVisitor *visitor);
+ void accept(NameVisitor *visitor) const;
+ static void accept(const Name *name, NameVisitor *visitor);
protected:
- virtual void accept0(NameVisitor *visitor) = 0;
+ virtual void accept0(NameVisitor *visitor) const = 0;
};
} // end of namespace CPlusPlus
diff --git a/src/shared/cplusplus/NameVisitor.cpp b/src/shared/cplusplus/NameVisitor.cpp
index 29630661d7..fe9d5cda09 100644
--- a/src/shared/cplusplus/NameVisitor.cpp
+++ b/src/shared/cplusplus/NameVisitor.cpp
@@ -57,7 +57,5 @@ NameVisitor::NameVisitor()
NameVisitor::~NameVisitor()
{ }
-void NameVisitor::accept(Name *name)
+void NameVisitor::accept(const Name *name)
{ Name::accept(name, this); }
-
-
diff --git a/src/shared/cplusplus/NameVisitor.h b/src/shared/cplusplus/NameVisitor.h
index f8889b7d7f..d567c30be8 100644
--- a/src/shared/cplusplus/NameVisitor.h
+++ b/src/shared/cplusplus/NameVisitor.h
@@ -63,18 +63,18 @@ public:
NameVisitor();
virtual ~NameVisitor();
- void accept(Name *name);
+ void accept(const Name *name);
- virtual bool preVisit(Name *) { return true; }
- virtual void postVisit(Name *) {}
+ virtual bool preVisit(const Name *) { return true; }
+ virtual void postVisit(const Name *) {}
- virtual void visit(NameId *) {}
- virtual void visit(TemplateNameId *) {}
- virtual void visit(DestructorNameId *) {}
- virtual void visit(OperatorNameId *) {}
- virtual void visit(ConversionNameId *) {}
- virtual void visit(QualifiedNameId *) {}
- virtual void visit(SelectorNameId *) {}
+ virtual void visit(const NameId *) {}
+ virtual void visit(const TemplateNameId *) {}
+ virtual void visit(const DestructorNameId *) {}
+ virtual void visit(const OperatorNameId *) {}
+ virtual void visit(const ConversionNameId *) {}
+ virtual void visit(const QualifiedNameId *) {}
+ virtual void visit(const SelectorNameId *) {}
};
} // end of namespace CPlusPlus
diff --git a/src/shared/cplusplus/Names.cpp b/src/shared/cplusplus/Names.cpp
index 65703f804b..4bc64f497d 100644
--- a/src/shared/cplusplus/Names.cpp
+++ b/src/shared/cplusplus/Names.cpp
@@ -54,51 +54,42 @@
using namespace CPlusPlus;
-QualifiedNameId::QualifiedNameId(Name *const names[],
+QualifiedNameId::QualifiedNameId(const Name *const *names,
unsigned nameCount,
bool isGlobal)
- : _names(0),
- _nameCount(nameCount),
+ : _names(names, names + nameCount),
_isGlobal(isGlobal)
-{
- if (_nameCount) {
- _names = new Name *[_nameCount];
- std::copy(&names[0], &names[nameCount], _names);
- }
-}
+{ }
QualifiedNameId::~QualifiedNameId()
-{ delete[] _names; }
+{ }
-void QualifiedNameId::accept0(NameVisitor *visitor)
+void QualifiedNameId::accept0(NameVisitor *visitor) const
{ visitor->visit(this); }
const Identifier *QualifiedNameId::identifier() const
{
- if (Name *u = unqualifiedNameId())
+ if (const Name *u = unqualifiedNameId())
return u->identifier();
return 0;
}
unsigned QualifiedNameId::nameCount() const
-{ return _nameCount; }
+{ return _names.size(); }
-Name *QualifiedNameId::nameAt(unsigned index) const
+const Name *QualifiedNameId::nameAt(unsigned index) const
{ return _names[index]; }
-Name *const *QualifiedNameId::names() const
-{ return _names; }
-
bool QualifiedNameId::isGlobal() const
{ return _isGlobal; }
-Name *QualifiedNameId::unqualifiedNameId() const
+const Name *QualifiedNameId::unqualifiedNameId() const
{
- if (! _nameCount)
+ if (_names.empty())
return 0;
- return _names[_nameCount - 1];
+ return _names.back();
}
bool QualifiedNameId::isEqualTo(const Name *other) const
@@ -113,8 +104,8 @@ bool QualifiedNameId::isEqualTo(const Name *other) const
if (count != q->nameCount())
return false;
for (unsigned i = 0; i < count; ++i) {
- Name *l = nameAt(i);
- Name *r = q->nameAt(i);
+ const Name *l = nameAt(i);
+ const Name *r = q->nameAt(i);
if (! l->isEqualTo(r))
return false;
}
@@ -129,7 +120,7 @@ NameId::NameId(const Identifier *identifier)
NameId::~NameId()
{ }
-void NameId::accept0(NameVisitor *visitor)
+void NameId::accept0(NameVisitor *visitor) const
{ visitor->visit(this); }
const Identifier *NameId::identifier() const
@@ -152,7 +143,7 @@ DestructorNameId::DestructorNameId(const Identifier *identifier)
DestructorNameId::~DestructorNameId()
{ }
-void DestructorNameId::accept0(NameVisitor *visitor)
+void DestructorNameId::accept0(NameVisitor *visitor) const
{ visitor->visit(this); }
const Identifier *DestructorNameId::identifier() const
@@ -169,37 +160,27 @@ bool DestructorNameId::isEqualTo(const Name *other) const
}
TemplateNameId::TemplateNameId(const Identifier *identifier,
- const FullySpecifiedType templateArguments[],
- unsigned templateArgumentCount)
+ const FullySpecifiedType templateArguments[],
+ unsigned templateArgumentCount)
: _identifier(identifier),
- _templateArguments(0),
- _templateArgumentCount(templateArgumentCount)
-{
- if (_templateArgumentCount) {
- _templateArguments = new FullySpecifiedType[_templateArgumentCount];
- std::copy(&templateArguments[0], &templateArguments[_templateArgumentCount],
- _templateArguments);
- }
-}
+ _templateArguments(templateArguments, templateArguments + templateArgumentCount)
+{ }
TemplateNameId::~TemplateNameId()
-{ delete[] _templateArguments; }
+{ }
-void TemplateNameId::accept0(NameVisitor *visitor)
+void TemplateNameId::accept0(NameVisitor *visitor) const
{ visitor->visit(this); }
const Identifier *TemplateNameId::identifier() const
{ return _identifier; }
unsigned TemplateNameId::templateArgumentCount() const
-{ return _templateArgumentCount; }
+{ return _templateArguments.size(); }
const FullySpecifiedType &TemplateNameId::templateArgumentAt(unsigned index) const
{ return _templateArguments[index]; }
-const FullySpecifiedType *TemplateNameId::templateArguments() const
-{ return _templateArguments; }
-
bool TemplateNameId::isEqualTo(const Name *other) const
{
const TemplateNameId *t = other->asTemplateNameId();
@@ -209,9 +190,9 @@ bool TemplateNameId::isEqualTo(const Name *other) const
const Identifier *r = t->identifier();
if (! l->isEqualTo(r))
return false;
- if (_templateArgumentCount != t->_templateArgumentCount)
+ if (templateArgumentCount() != t->templateArgumentCount())
return false;
- for (unsigned i = 0; i < _templateArgumentCount; ++i) {
+ for (unsigned i = 0; i < templateArgumentCount(); ++i) {
const FullySpecifiedType &l = _templateArguments[i];
const FullySpecifiedType &r = t->_templateArguments[i];
if (! l.isEqualTo(r))
@@ -227,7 +208,7 @@ OperatorNameId::OperatorNameId(int kind)
OperatorNameId::~OperatorNameId()
{ }
-void OperatorNameId::accept0(NameVisitor *visitor)
+void OperatorNameId::accept0(NameVisitor *visitor) const
{ visitor->visit(this); }
int OperatorNameId::kind() const
@@ -251,7 +232,7 @@ ConversionNameId::ConversionNameId(const FullySpecifiedType &type)
ConversionNameId::~ConversionNameId()
{ }
-void ConversionNameId::accept0(NameVisitor *visitor)
+void ConversionNameId::accept0(NameVisitor *visitor) const
{ visitor->visit(this); }
FullySpecifiedType ConversionNameId::type() const
@@ -268,42 +249,33 @@ bool ConversionNameId::isEqualTo(const Name *other) const
return _type.isEqualTo(c->type());
}
-SelectorNameId::SelectorNameId(Name *const names[],
+SelectorNameId::SelectorNameId(const Name *const *names,
unsigned nameCount,
bool hasArguments)
- : _names(0),
- _nameCount(nameCount),
+ : _names(names, names + nameCount),
_hasArguments(hasArguments)
-{
- if (_nameCount) {
- _names = new Name *[_nameCount];
- std::copy(&names[0], &names[nameCount], _names);
- }
-}
+{ }
SelectorNameId::~SelectorNameId()
-{ delete[] _names; }
+{ }
-void SelectorNameId::accept0(NameVisitor *visitor)
+void SelectorNameId::accept0(NameVisitor *visitor) const
{ visitor->visit(this); }
const Identifier *SelectorNameId::identifier() const
{
- if (! _nameCount)
+ if (_names.empty())
return 0;
return nameAt(0)->identifier();
}
unsigned SelectorNameId::nameCount() const
-{ return _nameCount; }
+{ return _names.size(); }
-Name *SelectorNameId::nameAt(unsigned index) const
+const Name *SelectorNameId::nameAt(unsigned index) const
{ return _names[index]; }
-Name *const *SelectorNameId::names() const
-{ return _names; }
-
bool SelectorNameId::hasArguments() const
{ return _hasArguments; }
@@ -319,8 +291,8 @@ bool SelectorNameId::isEqualTo(const Name *other) const
if (count != q->nameCount())
return false;
for (unsigned i = 0; i < count; ++i) {
- Name *l = nameAt(i);
- Name *r = q->nameAt(i);
+ const Name *l = nameAt(i);
+ const Name *r = q->nameAt(i);
if (! l->isEqualTo(r))
return false;
}
diff --git a/src/shared/cplusplus/Names.h b/src/shared/cplusplus/Names.h
index 5629747de3..9bae0e07fb 100644
--- a/src/shared/cplusplus/Names.h
+++ b/src/shared/cplusplus/Names.h
@@ -52,24 +52,22 @@
#include "CPlusPlusForwardDeclarations.h"
#include "Name.h"
#include "FullySpecifiedType.h"
+#include <vector>
namespace CPlusPlus {
class CPLUSPLUS_EXPORT QualifiedNameId: public Name
{
public:
- QualifiedNameId(Name *const names[],
- unsigned nameCount,
- bool isGlobal = false);
+ QualifiedNameId(const Name *const *names, unsigned nameCount, bool isGlobal = false);
virtual ~QualifiedNameId();
virtual const Identifier *identifier() const;
unsigned nameCount() const;
- Name *nameAt(unsigned index) const;
- Name *const *names() const;
- Name *unqualifiedNameId() const;
-
+ const Name *nameAt(unsigned index) const;
+ const Name *unqualifiedNameId() const;
+ const Name *const *names() const { return &_names[0]; } // ### remove me
bool isGlobal() const;
virtual bool isEqualTo(const Name *other) const;
@@ -77,15 +75,11 @@ public:
virtual const QualifiedNameId *asQualifiedNameId() const
{ return this; }
- virtual QualifiedNameId *asQualifiedNameId()
- { return this; }
-
protected:
- virtual void accept0(NameVisitor *visitor);
+ virtual void accept0(NameVisitor *visitor) const;
private:
- Name **_names;
- unsigned _nameCount;
+ std::vector<const Name *> _names;
bool _isGlobal;
};
@@ -102,11 +96,8 @@ public:
virtual const NameId *asNameId() const
{ return this; }
- virtual NameId *asNameId()
- { return this; }
-
protected:
- virtual void accept0(NameVisitor *visitor);
+ virtual void accept0(NameVisitor *visitor) const;
private:
const Identifier *_identifier;
@@ -125,11 +116,8 @@ public:
virtual const DestructorNameId *asDestructorNameId() const
{ return this; }
- virtual DestructorNameId *asDestructorNameId()
- { return this; }
-
protected:
- virtual void accept0(NameVisitor *visitor);
+ virtual void accept0(NameVisitor *visitor) const;
private:
const Identifier *_identifier;
@@ -148,23 +136,18 @@ public:
// ### find a better name
unsigned templateArgumentCount() const;
const FullySpecifiedType &templateArgumentAt(unsigned index) const;
- const FullySpecifiedType *templateArguments() const;
virtual bool isEqualTo(const Name *other) const;
virtual const TemplateNameId *asTemplateNameId() const
{ return this; }
- virtual TemplateNameId *asTemplateNameId()
- { return this; }
-
protected:
- virtual void accept0(NameVisitor *visitor);
+ virtual void accept0(NameVisitor *visitor) const;
private:
const Identifier *_identifier;
- FullySpecifiedType *_templateArguments;
- unsigned _templateArgumentCount;
+ std::vector<FullySpecifiedType> _templateArguments;
};
class CPLUSPLUS_EXPORT OperatorNameId: public Name
@@ -236,11 +219,8 @@ public:
virtual const OperatorNameId *asOperatorNameId() const
{ return this; }
- virtual OperatorNameId *asOperatorNameId()
- { return this; }
-
protected:
- virtual void accept0(NameVisitor *visitor);
+ virtual void accept0(NameVisitor *visitor) const;
private:
int _kind;
@@ -260,11 +240,8 @@ public:
virtual const ConversionNameId *asConversionNameId() const
{ return this; }
- virtual ConversionNameId *asConversionNameId()
- { return this; }
-
protected:
- virtual void accept0(NameVisitor *visitor);
+ virtual void accept0(NameVisitor *visitor) const;
private:
FullySpecifiedType _type;
@@ -273,17 +250,13 @@ private:
class CPLUSPLUS_EXPORT SelectorNameId: public Name
{
public:
- SelectorNameId(Name *const names[],
- unsigned nameCount,
- bool hasArguments);
+ SelectorNameId(const Name *const *names, unsigned nameCount, bool hasArguments);
virtual ~SelectorNameId();
virtual const Identifier *identifier() const;
unsigned nameCount() const;
- Name *nameAt(unsigned index) const;
- Name *const *names() const;
-
+ const Name *nameAt(unsigned index) const;
bool hasArguments() const;
virtual bool isEqualTo(const Name *other) const;
@@ -291,15 +264,11 @@ public:
virtual const SelectorNameId *asSelectorNameId() const
{ return this; }
- virtual SelectorNameId *asSelectorNameId()
- { return this; }
-
protected:
- virtual void accept0(NameVisitor *visitor);
+ virtual void accept0(NameVisitor *visitor) const;
private:
- Name **_names;
- unsigned _nameCount;
+ std::vector<const Name *> _names;
bool _hasArguments;
};
diff --git a/src/shared/cplusplus/Scope.cpp b/src/shared/cplusplus/Scope.cpp
index 76d09eb2dc..0fae6db391 100644
--- a/src/shared/cplusplus/Scope.cpp
+++ b/src/shared/cplusplus/Scope.cpp
@@ -204,12 +204,12 @@ void Scope::enterSymbol(Symbol *symbol)
}
}
-Symbol *Scope::lookat(Name *name) const
+Symbol *Scope::lookat(const Name *name) const
{
if (! name)
return 0;
- else if (OperatorNameId *opId = name->asOperatorNameId())
+ else if (const OperatorNameId *opId = name->asOperatorNameId())
return lookat(opId->kind());
else if (const Identifier *id = name->identifier())
@@ -227,21 +227,21 @@ Symbol *Scope::lookat(const Identifier *id) const
const unsigned h = id->hashCode() % _hashSize;
Symbol *symbol = _hash[h];
for (; symbol; symbol = symbol->_next) {
- Name *identity = symbol->identity();
+ const Name *identity = symbol->identity();
if (! identity) {
continue;
- } else if (NameId *nameId = identity->asNameId()) {
+ } else if (const NameId *nameId = identity->asNameId()) {
if (nameId->identifier()->isEqualTo(id))
break;
- } else if (TemplateNameId *t = identity->asTemplateNameId()) {
+ } else if (const TemplateNameId *t = identity->asTemplateNameId()) {
if (t->identifier()->isEqualTo(id))
break;
- } else if (DestructorNameId *d = identity->asDestructorNameId()) {
+ } else if (const DestructorNameId *d = identity->asDestructorNameId()) {
if (d->identifier()->isEqualTo(id))
break;
} else if (identity->isQualifiedNameId()) {
- assert(0);
- } else if (SelectorNameId *selectorNameId = identity->asSelectorNameId()) {
+ return 0;
+ } else if (const SelectorNameId *selectorNameId = identity->asSelectorNameId()) {
if (selectorNameId->identifier()->isEqualTo(id))
break;
}
@@ -257,8 +257,8 @@ Symbol *Scope::lookat(int operatorId) const
const unsigned h = operatorId % _hashSize;
Symbol *symbol = _hash[h];
for (; symbol; symbol = symbol->_next) {
- Name *identity = symbol->identity();
- if (OperatorNameId *op = identity->asOperatorNameId()) {
+ const Name *identity = symbol->identity();
+ if (const OperatorNameId *op = identity->asOperatorNameId()) {
if (op->kind() == operatorId)
break;
}
diff --git a/src/shared/cplusplus/Scope.h b/src/shared/cplusplus/Scope.h
index 8587ade8c5..04f735bf2a 100644
--- a/src/shared/cplusplus/Scope.h
+++ b/src/shared/cplusplus/Scope.h
@@ -129,7 +129,7 @@ public:
/// Returns the last Symbol in the scope.
iterator lastSymbol() const;
- Symbol *lookat(Name *name) const;
+ Symbol *lookat(const Name *name) const;
Symbol *lookat(const Identifier *id) const;
Symbol *lookat(int operatorId) const;
diff --git a/src/shared/cplusplus/Semantic.cpp b/src/shared/cplusplus/Semantic.cpp
index 74d870a91c..57ac5fe99f 100644
--- a/src/shared/cplusplus/Semantic.cpp
+++ b/src/shared/cplusplus/Semantic.cpp
@@ -132,7 +132,7 @@ void Semantic::check(DeclarationAST *declaration, Scope *scope, TemplateParamete
{ d->checkDeclaration->check(declaration, scope, templateParameters); }
FullySpecifiedType Semantic::check(DeclaratorAST *declarator, const FullySpecifiedType &type,
- Scope *scope, Name **name)
+ Scope *scope, const Name **name)
{ return d->checkDeclarator->check(declarator, type, scope, name); }
FullySpecifiedType Semantic::check(PtrOperatorListAST *ptrOperators, const FullySpecifiedType &type,
@@ -154,13 +154,13 @@ FullySpecifiedType Semantic::check(ExpressionAST *expression, Scope *scope)
void Semantic::check(StatementAST *statement, Scope *scope)
{ d->checkStatement->check(statement, scope); }
-Name *Semantic::check(NameAST *name, Scope *scope)
+const Name *Semantic::check(NameAST *name, Scope *scope)
{ return d->checkName->check(name, scope); }
-Name *Semantic::check(NestedNameSpecifierListAST *name, Scope *scope)
+const Name *Semantic::check(NestedNameSpecifierListAST *name, Scope *scope)
{ return d->checkName->check(name, scope); }
-Name *Semantic::check(ObjCSelectorAST *args, Scope *scope)
+const Name *Semantic::check(ObjCSelectorAST *args, Scope *scope)
{ return d->checkName->check(args, scope); }
bool Semantic::skipFunctionBodies() const
diff --git a/src/shared/cplusplus/Semantic.h b/src/shared/cplusplus/Semantic.h
index f6a4e528f4..6ca0b81c70 100644
--- a/src/shared/cplusplus/Semantic.h
+++ b/src/shared/cplusplus/Semantic.h
@@ -70,7 +70,7 @@ public:
FullySpecifiedType check(SpecifierListAST *specifier, Scope *scope);
FullySpecifiedType check(DeclaratorAST *declarator, const FullySpecifiedType &type,
- Scope *scope, Name **name = 0); // ### ugly
+ Scope *scope, const Name **name = 0); // ### ugly
FullySpecifiedType check(PtrOperatorListAST *ptrOperators, const FullySpecifiedType &type,
Scope *scope);
@@ -83,11 +83,11 @@ public:
void check(StatementAST *statement, Scope *scope);
- Name *check(NameAST *name, Scope *scope);
+ const Name *check(NameAST *name, Scope *scope);
- Name *check(NestedNameSpecifierListAST *name, Scope *scope);
+ const Name *check(NestedNameSpecifierListAST *name, Scope *scope);
- Name *check(ObjCSelectorAST *args, Scope *scope);
+ const Name *check(ObjCSelectorAST *args, Scope *scope);
FullySpecifiedType check(ObjCTypeNameAST *typeName, Scope *scope);
void check(ObjCMessageArgumentDeclarationAST *arg, Scope *scope);
diff --git a/src/shared/cplusplus/Symbol.cpp b/src/shared/cplusplus/Symbol.cpp
index 57e74e1383..221af1ad82 100644
--- a/src/shared/cplusplus/Symbol.cpp
+++ b/src/shared/cplusplus/Symbol.cpp
@@ -70,7 +70,7 @@ public:
virtual ~HashCode()
{ }
- unsigned operator()(Name *name)
+ unsigned operator()(const Name *name)
{
unsigned previousValue = switchValue(0);
accept(name);
@@ -85,25 +85,25 @@ protected:
return previousValue;
}
- virtual void visit(NameId *name)
+ virtual void visit(const NameId *name)
{ _value = name->identifier()->hashCode(); }
- virtual void visit(TemplateNameId *name)
+ virtual void visit(const TemplateNameId *name)
{ _value = name->identifier()->hashCode(); }
- virtual void visit(DestructorNameId *name)
+ virtual void visit(const DestructorNameId *name)
{ _value = name->identifier()->hashCode(); }
- virtual void visit(OperatorNameId *name)
+ virtual void visit(const OperatorNameId *name)
{ _value = unsigned(name->kind()); }
- virtual void visit(ConversionNameId *)
+ virtual void visit(const ConversionNameId *)
{ _value = 0; } // ### TODO: implement me
- virtual void visit(QualifiedNameId *name)
+ virtual void visit(const QualifiedNameId *name)
{ _value = operator()(name->unqualifiedNameId()); }
- virtual void visit(SelectorNameId *name)
+ virtual void visit(const SelectorNameId *name)
{ _value = name->identifier()->hashCode(); }
private:
@@ -120,47 +120,47 @@ public:
virtual ~IdentityForName()
{ }
- Name *operator()(Name *name)
+ const Name *operator()(const Name *name)
{
- Name *previousIdentity = switchIdentity(0);
+ const Name *previousIdentity = switchIdentity(0);
accept(name);
return switchIdentity(previousIdentity);
}
protected:
- Name *switchIdentity(Name *identity)
+ const Name *switchIdentity(const Name *identity)
{
- Name *previousIdentity = _identity;
+ const Name *previousIdentity = _identity;
_identity = identity;
return previousIdentity;
}
- virtual void visit(NameId *name)
+ virtual void visit(const NameId *name)
{ _identity = name; }
- virtual void visit(TemplateNameId *name)
+ virtual void visit(const TemplateNameId *name)
{ _identity = name; }
- virtual void visit(DestructorNameId *name)
+ virtual void visit(const DestructorNameId *name)
{ _identity = name; }
- virtual void visit(OperatorNameId *name)
+ virtual void visit(const OperatorNameId *name)
{ _identity = name; }
- virtual void visit(ConversionNameId *name)
+ virtual void visit(const ConversionNameId *name)
{ _identity = name; }
- virtual void visit(QualifiedNameId *name)
+ virtual void visit(const QualifiedNameId *name)
{ _identity = name->unqualifiedNameId(); }
- virtual void visit(SelectorNameId *name)
+ virtual void visit(const SelectorNameId *name)
{ _identity = name; }
private:
- Name *_identity;
+ const Name *_identity;
};
-Symbol::Symbol(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name)
+Symbol::Symbol(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name)
: _control(translationUnit->control()),
_sourceLocation(sourceLocation),
_sourceOffset(0),
@@ -280,16 +280,16 @@ unsigned Symbol::endOffset() const
void Symbol::setEndOffset(unsigned offset)
{ _endOffset = offset; }
-Name *Symbol::identity() const
+const Name *Symbol::identity() const
{
IdentityForName id;
return id(_name);
}
-Name *Symbol::name() const
+const Name *Symbol::name() const
{ return _name; }
-void Symbol::setName(Name *name)
+void Symbol::setName(const Name *name)
{
_name = name;
diff --git a/src/shared/cplusplus/Symbol.h b/src/shared/cplusplus/Symbol.h
index 7230a8e0c8..e8615dc75b 100644
--- a/src/shared/cplusplus/Symbol.h
+++ b/src/shared/cplusplus/Symbol.h
@@ -81,7 +81,7 @@ public:
public:
/// Constructs a Symbol with the given source location, name and translation unit.
- Symbol(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name);
+ Symbol(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
/// Destroy this Symbol.
virtual ~Symbol();
@@ -121,10 +121,10 @@ public:
void getEndPosition(unsigned *line, unsigned *column = 0, const StringLiteral **fileId = 0) const;
/// Returns this Symbol's name.
- Name *name() const;
+ const Name *name() const;
/// Sets this Symbol's name.
- void setName(Name *name); // ### dangerous
+ void setName(const Name *name); // ### dangerous
/// Returns this Symbol's (optional) identifier
const Identifier *identifier() const;
@@ -282,7 +282,7 @@ public:
/// Returns this Symbol's index.
unsigned index() const;
- Name *identity() const;
+ const Name *identity() const;
bool isGenerated() const;
@@ -320,7 +320,7 @@ private:
unsigned _sourceOffset;
unsigned _startOffset;
unsigned _endOffset;
- Name *_name;
+ const Name *_name;
unsigned _hashCode;
int _storage;
int _visibility;
diff --git a/src/shared/cplusplus/Symbols.cpp b/src/shared/cplusplus/Symbols.cpp
index 8c044ef03c..22098f82b5 100644
--- a/src/shared/cplusplus/Symbols.cpp
+++ b/src/shared/cplusplus/Symbols.cpp
@@ -76,7 +76,7 @@ Scope *TemplateParameters::scope() const
{ return _scope; }
UsingNamespaceDirective::UsingNamespaceDirective(TranslationUnit *translationUnit,
- unsigned sourceLocation, Name *name)
+ unsigned sourceLocation, const Name *name)
: Symbol(translationUnit, sourceLocation, name)
{ }
@@ -90,7 +90,7 @@ void UsingNamespaceDirective::visitSymbol0(SymbolVisitor *visitor)
{ visitor->visit(this); }
UsingDeclaration::UsingDeclaration(TranslationUnit *translationUnit,
- unsigned sourceLocation, Name *name)
+ unsigned sourceLocation, const Name *name)
: Symbol(translationUnit, sourceLocation, name)
{ }
@@ -103,7 +103,7 @@ FullySpecifiedType UsingDeclaration::type() const
void UsingDeclaration::visitSymbol0(SymbolVisitor *visitor)
{ visitor->visit(this); }
-Declaration::Declaration(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name)
+Declaration::Declaration(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name)
: Symbol(translationUnit, sourceLocation, name),
_templateParameters(0)
{ }
@@ -126,7 +126,7 @@ FullySpecifiedType Declaration::type() const
void Declaration::visitSymbol0(SymbolVisitor *visitor)
{ visitor->visit(this); }
-Argument::Argument(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name)
+Argument::Argument(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name)
: Symbol(translationUnit, sourceLocation, name),
_initializer(false)
{ }
@@ -149,7 +149,7 @@ FullySpecifiedType Argument::type() const
void Argument::visitSymbol0(SymbolVisitor *visitor)
{ visitor->visit(this); }
-Function::Function(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name)
+Function::Function(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name)
: ScopedSymbol(translationUnit, sourceLocation, name),
_templateParameters(0),
_flags(0)
@@ -203,8 +203,8 @@ bool Function::isEqualTo(const Type *other) const
else if (isVolatile() != o->isVolatile())
return false;
- Name *l = identity();
- Name *r = o->identity();
+ const Name *l = identity();
+ const Name *r = o->identity();
if (l == r || (l && l->isEqualTo(r))) {
if (_arguments->symbolCount() != o->_arguments->symbolCount())
return false;
@@ -315,7 +315,7 @@ void Function::visitSymbol0(SymbolVisitor *visitor)
}
}
-ScopedSymbol::ScopedSymbol(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name)
+ScopedSymbol::ScopedSymbol(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name)
: Symbol(translationUnit, sourceLocation, name)
{ _members = new Scope(this); }
@@ -361,7 +361,7 @@ void Block::visitSymbol0(SymbolVisitor *visitor)
}
}
-Enum::Enum(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name)
+Enum::Enum(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name)
: ScopedSymbol(translationUnit, sourceLocation, name)
{ }
@@ -376,8 +376,8 @@ bool Enum::isEqualTo(const Type *other) const
const Enum *o = other->asEnumType();
if (! o)
return false;
- Name *l = identity();
- Name *r = o->identity();
+ const Name *l = identity();
+ const Name *r = o->identity();
if (l == r)
return true;
else if (! l)
@@ -405,7 +405,7 @@ void Enum::visitSymbol0(SymbolVisitor *visitor)
}
}
-Namespace::Namespace(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name)
+Namespace::Namespace(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name)
: ScopedSymbol(translationUnit, sourceLocation, name)
{ }
@@ -417,8 +417,8 @@ bool Namespace::isEqualTo(const Type *other) const
const Namespace *o = other->asNamespaceType();
if (! o)
return false;
- Name *l = identity();
- Name *r = o->identity();
+ const Name *l = identity();
+ const Name *r = o->identity();
if (l == r || (l && l->isEqualTo(r)))
return true;
return false;
@@ -447,7 +447,7 @@ void Namespace::visitSymbol0(SymbolVisitor *visitor)
FullySpecifiedType Namespace::type() const
{ return FullySpecifiedType(const_cast<Namespace *>(this)); }
-BaseClass::BaseClass(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name)
+BaseClass::BaseClass(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name)
: Symbol(translationUnit, sourceLocation, name),
_isVirtual(false)
{ }
@@ -468,7 +468,7 @@ void BaseClass::visitSymbol0(SymbolVisitor *visitor)
{ visitor->visit(this); }
ForwardClassDeclaration::ForwardClassDeclaration(TranslationUnit *translationUnit,
- unsigned sourceLocation, Name *name)
+ unsigned sourceLocation, const Name *name)
: Symbol(translationUnit, sourceLocation, name),
_templateParameters(0)
{ }
@@ -512,7 +512,7 @@ bool ForwardClassDeclaration::matchType0(const Type *otherType, TypeMatcher *mat
return false;
}
-Class::Class(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name)
+Class::Class(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name)
: ScopedSymbol(translationUnit, sourceLocation, name),
_key(ClassKey),
_templateParameters(0)
@@ -581,8 +581,8 @@ bool Class::isEqualTo(const Type *other) const
const Class *o = other->asClassType();
if (! o)
return false;
- Name *l = identity();
- Name *r = o->identity();
+ const Name *l = identity();
+ const Name *r = o->identity();
if (l == r || (l && l->isEqualTo(r)))
return true;
else
@@ -601,7 +601,7 @@ void Class::visitSymbol0(SymbolVisitor *visitor)
}
}
-ObjCBaseClass::ObjCBaseClass(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name)
+ObjCBaseClass::ObjCBaseClass(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name)
: Symbol(translationUnit, sourceLocation, name)
{ }
@@ -614,7 +614,7 @@ FullySpecifiedType ObjCBaseClass::type() const
void ObjCBaseClass::visitSymbol0(SymbolVisitor *visitor)
{ visitor->visit(this); }
-ObjCBaseProtocol::ObjCBaseProtocol(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name)
+ObjCBaseProtocol::ObjCBaseProtocol(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name)
: Symbol(translationUnit, sourceLocation, name)
{ }
@@ -627,7 +627,7 @@ FullySpecifiedType ObjCBaseProtocol::type() const
void ObjCBaseProtocol::visitSymbol0(SymbolVisitor *visitor)
{ visitor->visit(this); }
-ObjCClass::ObjCClass(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name):
+ObjCClass::ObjCClass(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name):
ScopedSymbol(translationUnit, sourceLocation, name),
_isInterface(false),
_categoryName(0),
@@ -647,8 +647,8 @@ bool ObjCClass::isEqualTo(const Type *other) const
if (!o)
return false;
- Name *l = identity();
- Name *r = o->identity();
+ const Name *l = identity();
+ const Name *r = o->identity();
if (l == r || (l && l->isEqualTo(r)))
return true;
else
@@ -680,7 +680,7 @@ bool ObjCClass::matchType0(const Type *otherType, TypeMatcher *matcher) const
return false;
}
-ObjCProtocol::ObjCProtocol(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name):
+ObjCProtocol::ObjCProtocol(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name):
ScopedSymbol(translationUnit, sourceLocation, name)
{
}
@@ -697,8 +697,8 @@ bool ObjCProtocol::isEqualTo(const Type *other) const
if (!o)
return false;
- Name *l = identity();
- Name *r = o->identity();
+ const Name *l = identity();
+ const Name *r = o->identity();
if (l == r || (l && l->isEqualTo(r)))
return true;
else
@@ -724,7 +724,8 @@ bool ObjCProtocol::matchType0(const Type *otherType, TypeMatcher *matcher) const
return false;
}
-ObjCForwardClassDeclaration::ObjCForwardClassDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name):
+ObjCForwardClassDeclaration::ObjCForwardClassDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation,
+ const Name *name):
Symbol(translationUnit, sourceLocation, name)
{
}
@@ -763,7 +764,8 @@ bool ObjCForwardClassDeclaration::matchType0(const Type *otherType, TypeMatcher
return false;
}
-ObjCForwardProtocolDeclaration::ObjCForwardProtocolDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name):
+ObjCForwardProtocolDeclaration::ObjCForwardProtocolDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation,
+ const Name *name):
Symbol(translationUnit, sourceLocation, name)
{
}
@@ -802,7 +804,7 @@ bool ObjCForwardProtocolDeclaration::matchType0(const Type *otherType, TypeMatch
return false;
}
-ObjCMethod::ObjCMethod(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name)
+ObjCMethod::ObjCMethod(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name)
: ScopedSymbol(translationUnit, sourceLocation, name),
_flags(0)
{ _arguments = new Scope(this); }
@@ -818,8 +820,8 @@ bool ObjCMethod::isEqualTo(const Type *other) const
if (! o)
return false;
- Name *l = identity();
- Name *r = o->identity();
+ const Name *l = identity();
+ const Name *r = o->identity();
if (l == r || (l && l->isEqualTo(r))) {
if (_arguments->symbolCount() != o->_arguments->symbolCount())
return false;
@@ -902,7 +904,7 @@ void ObjCMethod::visitSymbol0(SymbolVisitor *visitor)
ObjCPropertyDeclaration::ObjCPropertyDeclaration(TranslationUnit *translationUnit,
unsigned sourceLocation,
- Name *name):
+ const Name *name):
Symbol(translationUnit, sourceLocation, name),
_propertyAttributes(None),
_getterName(0),
diff --git a/src/shared/cplusplus/Symbols.h b/src/shared/cplusplus/Symbols.h
index 022846d3c0..a75d09e0ff 100644
--- a/src/shared/cplusplus/Symbols.h
+++ b/src/shared/cplusplus/Symbols.h
@@ -76,7 +76,7 @@ private:
class CPLUSPLUS_EXPORT UsingNamespaceDirective: public Symbol
{
public:
- UsingNamespaceDirective(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name);
+ UsingNamespaceDirective(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
virtual ~UsingNamespaceDirective();
// Symbol's interface
@@ -95,7 +95,7 @@ protected:
class CPLUSPLUS_EXPORT UsingDeclaration: public Symbol
{
public:
- UsingDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name);
+ UsingDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
virtual ~UsingDeclaration();
// Symbol's interface
@@ -114,7 +114,7 @@ protected:
class CPLUSPLUS_EXPORT Declaration: public Symbol
{
public:
- Declaration(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name);
+ Declaration(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
virtual ~Declaration();
TemplateParameters *templateParameters() const;
@@ -142,7 +142,7 @@ private:
class CPLUSPLUS_EXPORT Argument: public Symbol
{
public:
- Argument(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name);
+ Argument(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
virtual ~Argument();
void setType(const FullySpecifiedType &type);
@@ -170,7 +170,7 @@ private:
class CPLUSPLUS_EXPORT ScopedSymbol: public Symbol
{
public:
- ScopedSymbol(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name);
+ ScopedSymbol(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
virtual ~ScopedSymbol();
unsigned memberCount() const;
@@ -210,7 +210,7 @@ protected:
class CPLUSPLUS_EXPORT ForwardClassDeclaration: public Symbol, public Type
{
public:
- ForwardClassDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name);
+ ForwardClassDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
virtual ~ForwardClassDeclaration();
TemplateParameters *templateParameters() const;
@@ -244,7 +244,7 @@ private:
class CPLUSPLUS_EXPORT Enum: public ScopedSymbol, public Type
{
public:
- Enum(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name);
+ Enum(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
virtual ~Enum();
// Symbol's interface
@@ -281,7 +281,7 @@ public:
};
public:
- Function(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name);
+ Function(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
virtual ~Function();
bool isNormal() const;
@@ -372,7 +372,7 @@ private:
class CPLUSPLUS_EXPORT Namespace: public ScopedSymbol, public Type
{
public:
- Namespace(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name);
+ Namespace(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
virtual ~Namespace();
// Symbol's interface
@@ -402,7 +402,7 @@ protected:
class CPLUSPLUS_EXPORT BaseClass: public Symbol
{
public:
- BaseClass(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name);
+ BaseClass(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
virtual ~BaseClass();
bool isVirtual() const;
@@ -427,7 +427,7 @@ private:
class CPLUSPLUS_EXPORT Class: public ScopedSymbol, public Type
{
public:
- Class(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name);
+ Class(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
virtual ~Class();
enum Key {
@@ -484,7 +484,7 @@ private:
class CPLUSPLUS_EXPORT ObjCBaseClass: public Symbol
{
public:
- ObjCBaseClass(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name);
+ ObjCBaseClass(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
virtual ~ObjCBaseClass();
// Symbol's interface
@@ -505,7 +505,7 @@ private:
class CPLUSPLUS_EXPORT ObjCBaseProtocol: public Symbol
{
public:
- ObjCBaseProtocol(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name);
+ ObjCBaseProtocol(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
virtual ~ObjCBaseProtocol();
// Symbol's interface
@@ -526,7 +526,7 @@ private:
class CPLUSPLUS_EXPORT ObjCForwardProtocolDeclaration: public Symbol, public Type
{
public:
- ObjCForwardProtocolDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name);
+ ObjCForwardProtocolDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
virtual ~ObjCForwardProtocolDeclaration();
virtual FullySpecifiedType type() const;
@@ -556,7 +556,7 @@ private:
class CPLUSPLUS_EXPORT ObjCProtocol: public ScopedSymbol, public Type
{
public:
- ObjCProtocol(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name);
+ ObjCProtocol(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
virtual ~ObjCProtocol();
unsigned protocolCount() const
@@ -598,7 +598,7 @@ private:
class CPLUSPLUS_EXPORT ObjCForwardClassDeclaration: public Symbol, public Type
{
public:
- ObjCForwardClassDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name);
+ ObjCForwardClassDeclaration(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
virtual ~ObjCForwardClassDeclaration();
virtual FullySpecifiedType type() const;
@@ -628,15 +628,15 @@ private:
class CPLUSPLUS_EXPORT ObjCClass: public ScopedSymbol, public Type
{
public:
- ObjCClass(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name);
+ ObjCClass(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
virtual ~ObjCClass();
bool isInterface() const { return _isInterface; }
void setInterface(bool isInterface) { _isInterface = isInterface; }
bool isCategory() const { return _categoryName != 0; }
- Name *categoryName() const { return _categoryName; }
- void setCategoryName(Name *categoryName) { _categoryName = categoryName; }
+ const Name *categoryName() const { return _categoryName; }
+ void setCategoryName(const Name *categoryName) { _categoryName = categoryName; }
ObjCBaseClass *baseClass() const
{ return _baseClass; }
@@ -677,7 +677,7 @@ protected:
private:
bool _isInterface;
- Name *_categoryName;
+ const Name *_categoryName;
ObjCBaseClass * _baseClass;
Array<ObjCBaseProtocol *> _protocols;
};
@@ -685,7 +685,7 @@ private:
class CPLUSPLUS_EXPORT ObjCMethod: public ScopedSymbol, public Type
{
public:
- ObjCMethod(TranslationUnit *translationUnit, unsigned sourceLocation, Name *name);
+ ObjCMethod(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name);
virtual ~ObjCMethod();
FullySpecifiedType returnType() const;
@@ -760,7 +760,7 @@ public:
public:
ObjCPropertyDeclaration(TranslationUnit *translationUnit,
unsigned sourceLocation,
- Name *name);
+ const Name *name);
virtual ~ObjCPropertyDeclaration();
bool hasAttribute(int attribute) const
@@ -775,16 +775,16 @@ public:
bool hasSetter() const
{ return hasAttribute(Setter); }
- Name *getterName() const
+ const Name *getterName() const
{ return _getterName; }
- void setGetterName(Name *getterName)
+ void setGetterName(const Name *getterName)
{ _getterName = getterName; }
- Name *setterName() const
+ const Name *setterName() const
{ return _setterName; }
- void setSetterName(Name *setterName)
+ void setSetterName(const Name *setterName)
{ _setterName = setterName; }
void setType(const FullySpecifiedType &type)
@@ -805,7 +805,8 @@ protected:
private:
FullySpecifiedType _type;
int _propertyAttributes;
- Name *_getterName, *_setterName;
+ const Name *_getterName;
+ const Name *_setterName;
};
} // end of namespace CPlusPlus