summaryrefslogtreecommitdiff
path: root/src/shared/cplusplus
diff options
context:
space:
mode:
authorRoberto Raggi <roberto.raggi@nokia.com>2009-11-10 16:00:22 +0100
committerRoberto Raggi <roberto.raggi@nokia.com>2009-11-10 16:20:13 +0100
commitcdb144321926d1c43242deeaffa0fb8e55873014 (patch)
treecda282ed4498efe2aaa9e83a294aa33ec5973cf8 /src/shared/cplusplus
parent4fc2ccf0c5af6d93b1edca95518043b84e342c67 (diff)
downloadqt-creator-cdb144321926d1c43242deeaffa0fb8e55873014.tar.gz
Cleanup specifiers.
Diffstat (limited to 'src/shared/cplusplus')
-rw-r--r--src/shared/cplusplus/AST.cpp149
-rw-r--r--src/shared/cplusplus/AST.h53
-rw-r--r--src/shared/cplusplus/ASTVisit.cpp106
-rw-r--r--src/shared/cplusplus/ASTfwd.h1
-rw-r--r--src/shared/cplusplus/CheckDeclaration.cpp2
-rw-r--r--src/shared/cplusplus/CheckDeclarator.cpp11
-rw-r--r--src/shared/cplusplus/CheckDeclarator.h2
-rw-r--r--src/shared/cplusplus/CheckSpecifier.cpp18
-rw-r--r--src/shared/cplusplus/CheckSpecifier.h8
-rw-r--r--src/shared/cplusplus/Parser.cpp112
-rw-r--r--src/shared/cplusplus/Parser.h26
-rw-r--r--src/shared/cplusplus/Semantic.cpp2
-rw-r--r--src/shared/cplusplus/Semantic.h2
13 files changed, 213 insertions, 279 deletions
diff --git a/src/shared/cplusplus/AST.cpp b/src/shared/cplusplus/AST.cpp
index 8785ad6f09..825c7506b9 100644
--- a/src/shared/cplusplus/AST.cpp
+++ b/src/shared/cplusplus/AST.cpp
@@ -391,10 +391,8 @@ unsigned ClassSpecifierAST::lastToken() const
else if (name)
return name->lastToken();
- for (SpecifierAST *it = attributes; it; it = it->next) {
- if (! it->next)
- return it->lastToken();
- }
+ else if (attributes)
+ return attributes->lastToken();
return classkey_token + 1;
}
@@ -409,10 +407,8 @@ unsigned CompoundStatementAST::lastToken() const
if (rbrace_token)
return rbrace_token + 1;
- for (StatementListAST *it = statements; it; it = it->next) {
- if (! it->next)
- return it->value->lastToken();
- }
+ else if (statements)
+ return statements->lastToken();
return lbrace_token + 1;
}
@@ -431,10 +427,8 @@ unsigned ConditionAST::lastToken() const
if (declarator)
return declarator->lastToken();
- for (SpecifierAST *it = type_specifier; it; it = it->next) {
- if (! it->next)
- return it->lastToken();
- }
+ else if (type_specifier)
+ return type_specifier->lastToken();
// ### assert?
return 0;
@@ -486,10 +480,8 @@ unsigned ConversionFunctionIdAST::lastToken() const
if (ptr_operators)
return ptr_operators->lastToken();
- for (SpecifierAST *it = type_specifier; it; it = it->next) {
- if (! it->next)
- return it->lastToken();
- }
+ else if (type_specifier)
+ return type_specifier->lastToken();
return operator_token + 1;
}
@@ -553,24 +545,20 @@ unsigned DeclaratorAST::lastToken() const
if (initializer)
return initializer->lastToken();
- for (SpecifierAST *it = post_attributes; it; it = it->next) {
- if (! it->next)
- return it->lastToken();
- }
+ else if (post_attributes)
+ return post_attributes->lastToken();
- if (postfix_declarators)
+ else if (postfix_declarators)
return postfix_declarators->lastToken();
- if (core_declarator)
+ else if (core_declarator)
return core_declarator->lastToken();
- if (ptr_operators)
+ else if (ptr_operators)
return ptr_operators->lastToken();
- for (SpecifierAST *it = attributes; it; it = it->next) {
- if (! it->next)
- return it->lastToken();
- }
+ else if (attributes)
+ return attributes->lastToken();
// ### assert?
return 0;
@@ -729,12 +717,13 @@ unsigned ExceptionDeclarationAST::lastToken() const
{
if (dot_dot_dot_token)
return dot_dot_dot_token + 1;
+
else if (declarator)
return declarator->lastToken();
- for (SpecifierAST *it = type_specifier; it; it = it->next) {
- if (! it->next)
- return it->lastToken();
- }
+
+ else if (type_specifier)
+ return type_specifier->lastToken();
+
return 0;
}
@@ -845,13 +834,12 @@ unsigned FunctionDeclaratorAST::lastToken() const
if (exception_specification)
return exception_specification->lastToken();
- for (SpecifierAST *it = cv_qualifier_seq; it; it = it->next) {
- if (! it->next)
- return it->lastToken();
- }
+ else if (cv_qualifier_seq)
+ return cv_qualifier_seq->lastToken();
- if (rparen_token)
+ else if (rparen_token)
return rparen_token + 1;
+
else if (parameters)
return parameters->lastToken();
@@ -874,15 +862,15 @@ unsigned FunctionDefinitionAST::lastToken() const
{
if (function_body)
return function_body->lastToken();
+
else if (ctor_initializer)
return ctor_initializer->lastToken();
- if (declarator)
+
+ else if (declarator)
return declarator->lastToken();
- for (SpecifierAST *it = decl_specifier_seq; it; it = it->next) {
- if (! it->next)
- return it->lastToken();
- }
+ else if (decl_specifier_seq)
+ return decl_specifier_seq->lastToken();
// ### assert
return 0;
@@ -1032,12 +1020,10 @@ unsigned NamespaceAST::lastToken() const
if (linkage_body)
return linkage_body->lastToken();
- for (SpecifierAST *it = attributes; it; it = it->next) {
- if (! it->next)
- return it->lastToken();
- }
+ else if (attributes)
+ return attributes->lastToken();
- if (identifier_token)
+ else if (identifier_token)
return identifier_token + 1;
return namespace_token + 1;
@@ -1231,14 +1217,16 @@ unsigned ParameterDeclarationAST::lastToken() const
{
if (expression)
return expression->lastToken();
+
else if (equal_token)
return equal_token + 1;
+
else if (declarator)
return declarator->lastToken();
- for (SpecifierAST *it = type_specifier; it; it = it->next) {
- if (! it->next)
- return it->lastToken();
- }
+
+ else if (type_specifier)
+ return type_specifier->lastToken();
+
// ### assert?
return 0;
}
@@ -1266,10 +1254,9 @@ unsigned PointerAST::firstToken() const
unsigned PointerAST::lastToken() const
{
- for (SpecifierAST *it = cv_qualifier_seq; it; it = it->next) {
- if (! it->next)
- return it->lastToken();
- }
+ if (cv_qualifier_seq)
+ return cv_qualifier_seq->lastToken();
+
return star_token + 1;
}
@@ -1285,12 +1272,10 @@ unsigned PointerToMemberAST::firstToken() const
unsigned PointerToMemberAST::lastToken() const
{
- for (SpecifierAST *it = cv_qualifier_seq; it; it = it->next) {
- if (! it->next)
- return it->lastToken();
- }
+ if (cv_qualifier_seq)
+ return cv_qualifier_seq->lastToken();
- if (star_token)
+ else if (star_token)
return star_token + 1;
else if (nested_name_specifier)
@@ -1299,6 +1284,7 @@ unsigned PointerToMemberAST::lastToken() const
else if (global_scope_token)
return global_scope_token + 1;
+ // ### assert(0);
return 0;
}
@@ -1391,18 +1377,16 @@ unsigned SimpleDeclarationAST::lastToken() const
if (semicolon_token)
return semicolon_token + 1;
- if (declarators)
+ else if (declarators)
return declarators->lastToken();
- for (SpecifierAST *it = decl_specifier_seq; it; it = it->next) {
- if (! it->next)
- return it->lastToken();
- }
+ else if (decl_specifier_seq)
+ return decl_specifier_seq->lastToken();
+ // ### assert(0);
return 0;
}
-
unsigned SimpleNameAST::firstToken() const
{
return identifier_token;
@@ -1630,20 +1614,16 @@ unsigned TypeConstructorCallAST::lastToken() const
if (rparen_token)
return rparen_token + 1;
- for (ExpressionListAST *it = expression_list; it; it = it->next) {
- if (! it->next)
- return it->lastToken();
- }
+ else if (expression_list)
+ return expression_list->lastToken();
- if (lparen_token)
+ else if (lparen_token)
return lparen_token + 1;
+ else if (type_specifier)
+ return type_specifier->lastToken();
- for (SpecifierAST *it = type_specifier; it; it = it->next) {
- if (! it->next)
- return it->lastToken();
- }
-
+ // ### assert(0);
return 0;
}
@@ -1658,11 +1638,10 @@ unsigned TypeIdAST::lastToken() const
if (declarator)
return declarator->lastToken();
- for (SpecifierAST *it = type_specifier; it; it = it->next) {
- if (! it->next)
- return it->lastToken();
- }
+ else if (type_specifier)
+ return type_specifier->lastToken();
+ // ### assert(0);
return 0;
}
@@ -1879,19 +1858,17 @@ unsigned ObjCProtocolDeclarationAST::lastToken() const
if (end_token)
return end_token + 1;
- if (member_declarations)
+ else if (member_declarations)
return member_declarations->lastToken();
- if (protocol_refs)
+ else if (protocol_refs)
return protocol_refs->lastToken();
- if (name)
+ else if (name)
return name->lastToken();
- for (SpecifierAST *it = attributes; it; it = it->next) {
- if (! it->next)
- return it->lastToken();
- }
+ else if (attributes)
+ return attributes->lastToken();
return protocol_token + 1;
}
diff --git a/src/shared/cplusplus/AST.h b/src/shared/cplusplus/AST.h
index e4a61e332b..c8cb6694af 100644
--- a/src/shared/cplusplus/AST.h
+++ b/src/shared/cplusplus/AST.h
@@ -259,9 +259,6 @@ protected:
class CPLUSPLUS_EXPORT SpecifierAST: public AST
{
public:
- SpecifierAST *next;
-
-public:
virtual SpecifierAST *asSpecifier() { return this; }
};
@@ -370,11 +367,11 @@ public:
class CPLUSPLUS_EXPORT DeclaratorAST: public AST
{
public:
- SpecifierAST *attributes;
+ SpecifierListAST *attributes;
PtrOperatorListAST *ptr_operators;
CoreDeclaratorAST *core_declarator;
PostfixDeclaratorListAST *postfix_declarators;
- SpecifierAST *post_attributes;
+ SpecifierListAST *post_attributes;
unsigned equals_token;
ExpressionAST *initializer;
@@ -392,7 +389,7 @@ class CPLUSPLUS_EXPORT SimpleDeclarationAST: public DeclarationAST
{
public:
unsigned qt_invokable_token;
- SpecifierAST *decl_specifier_seq;
+ SpecifierListAST *decl_specifier_seq;
DeclaratorListAST *declarators;
unsigned semicolon_token;
@@ -557,7 +554,7 @@ class CPLUSPLUS_EXPORT ClassSpecifierAST: public SpecifierAST
{
public:
unsigned classkey_token;
- SpecifierAST *attributes;
+ SpecifierListAST *attributes;
NameAST *name;
unsigned colon_token;
BaseSpecifierListAST *base_clause_list;
@@ -619,7 +616,7 @@ protected:
class CPLUSPLUS_EXPORT ConditionAST: public ExpressionAST
{
public:
- SpecifierAST *type_specifier;
+ SpecifierListAST *type_specifier;
DeclaratorAST *declarator;
public:
@@ -741,7 +738,7 @@ public:
unsigned lparen_token;
ParameterDeclarationClauseAST *parameters;
unsigned rparen_token;
- SpecifierAST *cv_qualifier_seq;
+ SpecifierListAST *cv_qualifier_seq;
ExceptionSpecificationAST *exception_specification;
ExpressionAST *as_cpp_initializer;
@@ -885,7 +882,7 @@ protected:
class CPLUSPLUS_EXPORT ExceptionDeclarationAST: public DeclarationAST
{
public:
- SpecifierAST *type_specifier;
+ SpecifierListAST *type_specifier;
DeclaratorAST *declarator;
unsigned dot_dot_dot_token;
@@ -954,7 +951,7 @@ class CPLUSPLUS_EXPORT FunctionDefinitionAST: public DeclarationAST
{
public:
unsigned qt_invokable_token;
- SpecifierAST *decl_specifier_seq;
+ SpecifierListAST *decl_specifier_seq;
DeclaratorAST *declarator;
CtorInitializerAST *ctor_initializer;
StatementAST *function_body;
@@ -978,7 +975,7 @@ public:
unsigned foreach_token;
unsigned lparen_token;
// declaration
- SpecifierAST *type_specifiers;
+ SpecifierListAST *type_specifiers;
DeclaratorAST *declarator;
// or an expression
ExpressionAST *initializer;
@@ -1197,7 +1194,7 @@ class CPLUSPLUS_EXPORT ConversionFunctionIdAST: public NameAST
{
public:
unsigned operator_token;
- SpecifierAST *type_specifier;
+ SpecifierListAST *type_specifier;
PtrOperatorListAST *ptr_operators;
public:
@@ -1264,7 +1261,7 @@ class CPLUSPLUS_EXPORT NamespaceAST: public DeclarationAST
public:
unsigned namespace_token;
unsigned identifier_token;
- SpecifierAST *attributes;
+ SpecifierListAST *attributes;
DeclarationAST *linkage_body;
public: // annotations
@@ -1378,7 +1375,7 @@ protected:
class CPLUSPLUS_EXPORT NewTypeIdAST: public AST
{
public:
- SpecifierAST *type_specifier;
+ SpecifierListAST *type_specifier;
PtrOperatorListAST *ptr_operators;
NewArrayDeclaratorListAST *new_array_declarators;
@@ -1412,7 +1409,7 @@ protected:
class CPLUSPLUS_EXPORT ParameterDeclarationAST: public DeclarationAST
{
public:
- SpecifierAST *type_specifier;
+ SpecifierListAST *type_specifier;
DeclaratorAST *declarator;
unsigned equal_token;
ExpressionAST *expression;
@@ -1558,7 +1555,7 @@ protected:
class CPLUSPLUS_EXPORT TypeConstructorCallAST: public ExpressionAST
{
public:
- SpecifierAST *type_specifier;
+ SpecifierListAST *type_specifier;
unsigned lparen_token;
ExpressionListAST *expression_list;
unsigned rparen_token;
@@ -1601,7 +1598,7 @@ public:
unsigned global_scope_token;
NestedNameSpecifierListAST *nested_name_specifier;
unsigned star_token;
- SpecifierAST *cv_qualifier_seq;
+ SpecifierListAST *cv_qualifier_seq;
public:
virtual PointerToMemberAST *asPointerToMember() { return this; }
@@ -1617,7 +1614,7 @@ class CPLUSPLUS_EXPORT PointerAST: public PtrOperatorAST
{
public:
unsigned star_token;
- SpecifierAST *cv_qualifier_seq;
+ SpecifierListAST *cv_qualifier_seq;
public:
virtual PointerAST *asPointer() { return this; }
@@ -1921,7 +1918,7 @@ protected:
class CPLUSPLUS_EXPORT TypeIdAST: public ExpressionAST
{
public:
- SpecifierAST *type_specifier;
+ SpecifierListAST *type_specifier;
DeclaratorAST *declarator;
public:
@@ -2063,7 +2060,7 @@ protected:
class CPLUSPLUS_EXPORT ObjCClassForwardDeclarationAST: public DeclarationAST
{
public:
- SpecifierAST *attributes;
+ SpecifierListAST *attributes;
unsigned class_token;
ObjCIdentifierListAST *identifier_list;
unsigned semicolon_token;
@@ -2084,7 +2081,7 @@ protected:
class CPLUSPLUS_EXPORT ObjCClassDeclarationAST: public DeclarationAST
{
public:
- SpecifierAST *attributes;
+ SpecifierListAST *attributes;
unsigned interface_token;
unsigned implementation_token;
NameAST *class_name;
@@ -2114,7 +2111,7 @@ protected:
class CPLUSPLUS_EXPORT ObjCProtocolForwardDeclarationAST: public DeclarationAST
{
public:
- SpecifierAST *attributes;
+ SpecifierListAST *attributes;
unsigned protocol_token;
ObjCIdentifierListAST *identifier_list;
unsigned semicolon_token;
@@ -2135,7 +2132,7 @@ protected:
class CPLUSPLUS_EXPORT ObjCProtocolDeclarationAST: public DeclarationAST
{
public:
- SpecifierAST *attributes;
+ SpecifierListAST *attributes;
unsigned protocol_token;
NameAST *name;
ObjCProtocolRefsAST *protocol_refs;
@@ -2384,7 +2381,7 @@ protected:
class CPLUSPLUS_EXPORT ObjCPropertyDeclarationAST: public DeclarationAST
{
public:
- SpecifierAST *attributes;
+ SpecifierListAST *attributes;
unsigned property_token;
unsigned lparen_token;
ObjCPropertyAttributeListAST *property_attributes;
@@ -2405,7 +2402,7 @@ class CPLUSPLUS_EXPORT ObjCMessageArgumentDeclarationAST: public NameAST
{
public:
ObjCTypeNameAST* type_name;
- SpecifierAST *attributes;
+ SpecifierListAST *attributes;
unsigned param_name_token;
public: // annotations
@@ -2429,7 +2426,7 @@ public:
ObjCSelectorAST *selector;
ObjCMessageArgumentDeclarationListAST *arguments;
unsigned dot_dot_dot_token;
- SpecifierAST *attributes;
+ SpecifierListAST *attributes;
public: // annotations
ObjCMethod *symbol;
@@ -2519,7 +2516,7 @@ public:
unsigned lparen_token;
// declaration
- SpecifierAST *type_specifiers;
+ SpecifierListAST *type_specifiers;
DeclaratorAST *declarator;
// or an expression
ExpressionAST *initializer;
diff --git a/src/shared/cplusplus/ASTVisit.cpp b/src/shared/cplusplus/ASTVisit.cpp
index f6d1d9184f..4e4ee1ffca 100644
--- a/src/shared/cplusplus/ASTVisit.cpp
+++ b/src/shared/cplusplus/ASTVisit.cpp
@@ -67,13 +67,11 @@ void TypeofSpecifierAST::accept0(ASTVisitor *visitor)
void DeclaratorAST::accept0(ASTVisitor *visitor)
{
if (visitor->visit(this)) {
- for (SpecifierAST *it = attributes; it; it = it->next)
- accept(it, visitor);
+ accept(attributes, visitor);
accept(ptr_operators, visitor);
accept(core_declarator, visitor);
accept(postfix_declarators, visitor);
- for (SpecifierAST *it = post_attributes; it; it = it->next)
- accept(it, visitor);
+ accept(post_attributes, visitor);
accept(initializer, visitor);
}
visitor->endVisit(this);
@@ -82,10 +80,8 @@ void DeclaratorAST::accept0(ASTVisitor *visitor)
void SimpleDeclarationAST::accept0(ASTVisitor *visitor)
{
if (visitor->visit(this)) {
- for (SpecifierAST *it = decl_specifier_seq; it; it = it->next)
- accept(it, visitor);
- for (DeclaratorListAST *it = declarators; it; it = it->next)
- accept(it, visitor);
+ accept(decl_specifier_seq, visitor);
+ accept(declarators, visitor);
}
visitor->endVisit(this);
}
@@ -157,12 +153,10 @@ void CastExpressionAST::accept0(ASTVisitor *visitor)
void ClassSpecifierAST::accept0(ASTVisitor *visitor)
{
if (visitor->visit(this)) {
- for (SpecifierAST *it = attributes; it; it = it->next)
- accept(it, visitor);
+ accept(attributes, visitor);
accept(name, visitor);
accept(base_clause_list, visitor);
- for (DeclarationListAST *it = member_specifiers; it; it = it->next)
- accept(it, visitor);
+ accept(member_specifiers, visitor);
}
visitor->endVisit(this);
}
@@ -188,8 +182,7 @@ void CompoundStatementAST::accept0(ASTVisitor *visitor)
void ConditionAST::accept0(ASTVisitor *visitor)
{
if (visitor->visit(this)) {
- for (SpecifierAST *it = type_specifier; it; it = it->next)
- accept(it, visitor);
+ accept(type_specifier, visitor);
accept(declarator, visitor);
}
visitor->endVisit(this);
@@ -250,8 +243,7 @@ void FunctionDeclaratorAST::accept0(ASTVisitor *visitor)
{
if (visitor->visit(this)) {
accept(parameters, visitor);
- for (SpecifierAST *it = cv_qualifier_seq; it; it = it->next)
- accept(it, visitor);
+ accept(cv_qualifier_seq, visitor);
accept(exception_specification, visitor);
accept(as_cpp_initializer, visitor);
}
@@ -319,8 +311,7 @@ void EnumeratorAST::accept0(ASTVisitor *visitor)
void ExceptionDeclarationAST::accept0(ASTVisitor *visitor)
{
if (visitor->visit(this)) {
- for (SpecifierAST *it = type_specifier; it; it = it->next)
- accept(it, visitor);
+ accept(type_specifier, visitor);
accept(declarator, visitor);
}
visitor->endVisit(this);
@@ -355,8 +346,7 @@ void ExpressionStatementAST::accept0(ASTVisitor *visitor)
void FunctionDefinitionAST::accept0(ASTVisitor *visitor)
{
if (visitor->visit(this)) {
- for (SpecifierAST *it = decl_specifier_seq; it; it = it->next)
- accept(it, visitor);
+ accept(decl_specifier_seq, visitor);
accept(declarator, visitor);
accept(ctor_initializer, visitor);
accept(function_body, visitor);
@@ -367,8 +357,7 @@ void FunctionDefinitionAST::accept0(ASTVisitor *visitor)
void ForeachStatementAST::accept0(ASTVisitor *visitor)
{
if (visitor->visit(this)) {
- for (SpecifierAST *it = type_specifiers; it; it = it->next)
- accept(it, visitor);
+ accept(type_specifiers, visitor);
accept(declarator, visitor);
accept(initializer, visitor);
accept(expression, visitor);
@@ -469,8 +458,7 @@ void OperatorFunctionIdAST::accept0(ASTVisitor *visitor)
void ConversionFunctionIdAST::accept0(ASTVisitor *visitor)
{
if (visitor->visit(this)) {
- for (SpecifierAST *it = type_specifier; it; it = it->next)
- accept(it, visitor);
+ accept(type_specifier, visitor);
accept(ptr_operators, visitor);
}
visitor->endVisit(this);
@@ -502,8 +490,7 @@ void TemplateIdAST::accept0(ASTVisitor *visitor)
void NamespaceAST::accept0(ASTVisitor *visitor)
{
if (visitor->visit(this)) {
- for (SpecifierAST *it = attributes; it; it = it->next)
- accept(it, visitor);
+ accept(attributes, visitor);
accept(linkage_body, visitor);
}
visitor->endVisit(this);
@@ -556,8 +543,7 @@ void NewInitializerAST::accept0(ASTVisitor *visitor)
void NewTypeIdAST::accept0(ASTVisitor *visitor)
{
if (visitor->visit(this)) {
- for (SpecifierAST *it = type_specifier; it; it = it->next)
- accept(it, visitor);
+ accept(type_specifier, visitor);
accept(ptr_operators, visitor);
accept(new_array_declarators, visitor);
}
@@ -574,8 +560,7 @@ void OperatorAST::accept0(ASTVisitor *visitor)
void ParameterDeclarationAST::accept0(ASTVisitor *visitor)
{
if (visitor->visit(this)) {
- for (SpecifierAST *it = type_specifier; it; it = it->next)
- accept(it, visitor);
+ accept(type_specifier, visitor);
accept(declarator, visitor);
accept(expression, visitor);
}
@@ -644,10 +629,8 @@ void TypenameCallExpressionAST::accept0(ASTVisitor *visitor)
void TypeConstructorCallAST::accept0(ASTVisitor *visitor)
{
if (visitor->visit(this)) {
- for (SpecifierAST *it = type_specifier; it; it = it->next)
- accept(it, visitor);
- for (ExpressionListAST *it = expression_list; it; it = it->next)
- accept(it, visitor);
+ accept(type_specifier, visitor);
+ accept(expression_list, visitor);
}
visitor->endVisit(this);
}
@@ -665,9 +648,7 @@ void PointerToMemberAST::accept0(ASTVisitor *visitor)
{
if (visitor->visit(this)) {
accept(nested_name_specifier, visitor);
-
- for (SpecifierAST *it = cv_qualifier_seq; it; it = it->next)
- accept(it, visitor);
+ accept(cv_qualifier_seq, visitor);
}
visitor->endVisit(this);
}
@@ -675,8 +656,7 @@ void PointerToMemberAST::accept0(ASTVisitor *visitor)
void PointerAST::accept0(ASTVisitor *visitor)
{
if (visitor->visit(this)) {
- for (SpecifierAST *it = cv_qualifier_seq; it; it = it->next)
- accept(it, visitor);
+ accept(cv_qualifier_seq, visitor);
}
visitor->endVisit(this);
}
@@ -818,8 +798,7 @@ void CatchClauseAST::accept0(ASTVisitor *visitor)
void TypeIdAST::accept0(ASTVisitor *visitor)
{
if (visitor->visit(this)) {
- for (SpecifierAST *it = type_specifier; it; it = it->next)
- accept(it, visitor);
+ accept(type_specifier, visitor);
accept(declarator, visitor);
}
visitor->endVisit(this);
@@ -881,10 +860,8 @@ void WhileStatementAST::accept0(ASTVisitor *visitor)
void ObjCClassForwardDeclarationAST::accept0(ASTVisitor *visitor)
{
if (visitor->visit(this)) {
- for (SpecifierAST *it = attributes; it; it = it->next)
- accept(it, visitor);
- for (ObjCIdentifierListAST *it = identifier_list; it; it = it->next)
- accept(it, visitor);
+ accept(attributes, visitor);
+ accept(identifier_list, visitor);
}
visitor->endVisit(this);
}
@@ -892,15 +869,13 @@ void ObjCClassForwardDeclarationAST::accept0(ASTVisitor *visitor)
void ObjCClassDeclarationAST::accept0(ASTVisitor *visitor)
{
if (visitor->visit(this)) {
- for (SpecifierAST *it = attributes; it; it = it->next)
- accept(it, visitor);
+ accept(attributes, visitor);
accept(class_name, visitor);
accept(category_name, visitor);
accept(superclass, visitor);
accept(protocol_refs, visitor);
accept(inst_vars_decl, visitor);
- for (DeclarationListAST *it = member_declarations; it; it = it->next)
- accept(it, visitor);
+ accept(member_declarations, visitor);
}
visitor->endVisit(this);
}
@@ -908,10 +883,8 @@ void ObjCClassDeclarationAST::accept0(ASTVisitor *visitor)
void ObjCProtocolForwardDeclarationAST::accept0(ASTVisitor *visitor)
{
if (visitor->visit(this)) {
- for (SpecifierAST *it = attributes; it; it = it->next)
- accept(it, visitor);
- for (ObjCIdentifierListAST *it = identifier_list; it; it = it->next)
- accept(it, visitor);
+ accept(attributes, visitor);
+ accept(identifier_list, visitor);
}
visitor->endVisit(this);
}
@@ -919,12 +892,10 @@ void ObjCProtocolForwardDeclarationAST::accept0(ASTVisitor *visitor)
void ObjCProtocolDeclarationAST::accept0(ASTVisitor *visitor)
{
if (visitor->visit(this)) {
- for (SpecifierAST *it = attributes; it; it = it->next)
- accept(it, visitor);
+ accept(attributes, visitor);
accept(name, visitor);
accept(protocol_refs, visitor);
- for (DeclarationListAST *it = member_declarations; it; it = it->next)
- accept(it, visitor);
+ accept(member_declarations, visitor);
}
visitor->endVisit(this);
}
@@ -932,8 +903,7 @@ void ObjCProtocolDeclarationAST::accept0(ASTVisitor *visitor)
void ObjCProtocolRefsAST::accept0(ASTVisitor *visitor)
{
if (visitor->visit(this)) {
- for (ObjCIdentifierListAST *it = identifier_list; it; it = it->next)
- accept(it, visitor);
+ accept(identifier_list, visitor);
}
visitor->endVisit(this);
}
@@ -1038,10 +1008,8 @@ void ObjCPropertyAttributeAST::accept0(ASTVisitor *visitor)
void ObjCPropertyDeclarationAST::accept0(ASTVisitor *visitor)
{
if (visitor->visit(this)) {
- for (SpecifierAST *it = attributes; it; it = it->next)
- accept(it, visitor);
- for (ObjCPropertyAttributeListAST *it = property_attributes; it; it = it->next)
- accept(it, visitor);
+ accept(attributes, visitor);
+ accept(property_attributes, visitor);
accept(simple_declaration, visitor);
}
visitor->endVisit(this);
@@ -1051,8 +1019,7 @@ void ObjCMessageArgumentDeclarationAST::accept0(ASTVisitor *visitor)
{
if (visitor->visit(this)) {
accept(type_name, visitor);
- for (SpecifierAST *it = attributes; it; it = it->next)
- accept(it, visitor);
+ accept(attributes, visitor);
}
visitor->endVisit(this);
}
@@ -1062,10 +1029,8 @@ void ObjCMethodPrototypeAST::accept0(ASTVisitor *visitor)
if (visitor->visit(this)) {
accept(type_name, visitor);
accept(selector, visitor);
- for (ObjCMessageArgumentDeclarationListAST *it = arguments; it; it = it->next)
- accept(it, visitor);
- for (SpecifierAST *it = attributes; it; it = it->next)
- accept(it, visitor);
+ accept(arguments, visitor);
+ accept(attributes, visitor);
}
visitor->endVisit(this);
}
@@ -1107,8 +1072,7 @@ void ObjCDynamicPropertiesDeclarationAST::accept0(ASTVisitor *visitor)
void ObjCFastEnumerationAST::accept0(ASTVisitor *visitor)
{
if (visitor->visit(this)) {
- for (SpecifierAST *it = type_specifiers; it; it = it->next)
- accept(it, visitor);
+ accept(type_specifiers, visitor);
accept(declarator, visitor);
accept(initializer, visitor);
accept(fast_enumeratable_expression, visitor);
diff --git a/src/shared/cplusplus/ASTfwd.h b/src/shared/cplusplus/ASTfwd.h
index 483708356b..aaeeed94ae 100644
--- a/src/shared/cplusplus/ASTfwd.h
+++ b/src/shared/cplusplus/ASTfwd.h
@@ -205,6 +205,7 @@ typedef List<AttributeAST *> AttributeListAST;
typedef List<NestedNameSpecifierAST *> NestedNameSpecifierListAST;
typedef List<CatchClauseAST *> CatchClauseListAST;
typedef List<PtrOperatorAST *> PtrOperatorListAST;
+typedef List<SpecifierAST *> SpecifierListAST;
typedef List<NameAST *> ObjCIdentifierListAST;
typedef List<ObjCMessageArgumentAST *> ObjCMessageArgumentListAST;
diff --git a/src/shared/cplusplus/CheckDeclaration.cpp b/src/shared/cplusplus/CheckDeclaration.cpp
index eb67596a35..c0c570c12e 100644
--- a/src/shared/cplusplus/CheckDeclaration.cpp
+++ b/src/shared/cplusplus/CheckDeclaration.cpp
@@ -146,7 +146,7 @@ bool CheckDeclaration::visit(SimpleDeclarationAST *ast)
}
if (! ast->declarators && ast->decl_specifier_seq && ! ast->decl_specifier_seq->next) {
- if (ElaboratedTypeSpecifierAST *elab_type_spec = ast->decl_specifier_seq->asElaboratedTypeSpecifier()) {
+ if (ElaboratedTypeSpecifierAST *elab_type_spec = ast->decl_specifier_seq->value->asElaboratedTypeSpecifier()) {
unsigned sourceLocation = elab_type_spec->firstToken();
diff --git a/src/shared/cplusplus/CheckDeclarator.cpp b/src/shared/cplusplus/CheckDeclarator.cpp
index 0874c1bfa1..d51aaebd52 100644
--- a/src/shared/cplusplus/CheckDeclarator.cpp
+++ b/src/shared/cplusplus/CheckDeclarator.cpp
@@ -196,9 +196,9 @@ bool CheckDeclarator::visit(FunctionDeclaratorAST *ast)
FullySpecifiedType funTy(fun);
_fullySpecifiedType = funTy;
- for (SpecifierAST *it = ast->cv_qualifier_seq; it; it = it->next) {
- SimpleSpecifierAST *cv = static_cast<SimpleSpecifierAST *>(it);
- int k = tokenKind(cv->specifier_token);
+ for (SpecifierListAST *it = ast->cv_qualifier_seq; it; it = it->next) {
+ SimpleSpecifierAST *cv = static_cast<SimpleSpecifierAST *>(it->value);
+ const int k = tokenKind(cv->specifier_token);
if (k == T_CONST)
fun->setConst(true);
else if (k == T_VOLATILE)
@@ -278,9 +278,10 @@ bool CheckDeclarator::visit(ObjCMethodPrototypeAST *ast)
return false;
}
-void CheckDeclarator::applyCvQualifiers(SpecifierAST *cv)
+void CheckDeclarator::applyCvQualifiers(SpecifierListAST *it)
{
- for (; cv; cv = cv->next) {
+ for (; it; it = it->next) {
+ SpecifierAST *cv = it->value;
SimpleSpecifierAST *spec = static_cast<SimpleSpecifierAST *>(cv);
switch (translationUnit()->tokenKind(spec->specifier_token)) {
case T_VOLATILE:
diff --git a/src/shared/cplusplus/CheckDeclarator.h b/src/shared/cplusplus/CheckDeclarator.h
index c24d4a5c38..1b9e14cb81 100644
--- a/src/shared/cplusplus/CheckDeclarator.h
+++ b/src/shared/cplusplus/CheckDeclarator.h
@@ -97,7 +97,7 @@ protected:
virtual bool visit(ObjCMethodPrototypeAST *ast);
void checkMessageArgument(ObjCMessageArgumentDeclarationAST *arg);
- void applyCvQualifiers(SpecifierAST *cv);
+ void applyCvQualifiers(SpecifierListAST *it);
private:
DeclaratorAST *_declarator;
diff --git a/src/shared/cplusplus/CheckSpecifier.cpp b/src/shared/cplusplus/CheckSpecifier.cpp
index 0becef3201..3cf51774da 100644
--- a/src/shared/cplusplus/CheckSpecifier.cpp
+++ b/src/shared/cplusplus/CheckSpecifier.cpp
@@ -69,11 +69,11 @@ CheckSpecifier::CheckSpecifier(Semantic *semantic)
CheckSpecifier::~CheckSpecifier()
{ }
-FullySpecifiedType CheckSpecifier::check(SpecifierAST *specifier, Scope *scope)
+FullySpecifiedType CheckSpecifier::check(SpecifierListAST *specifier, Scope *scope)
{
FullySpecifiedType previousType = switchFullySpecifiedType(FullySpecifiedType());
Scope *previousScope = switchScope(scope);
- SpecifierAST *previousSpecifier = switchSpecifier(specifier);
+ SpecifierListAST *previousSpecifier = switchSpecifier(specifier);
accept(specifier);
(void) switchSpecifier(previousSpecifier);
(void) switchScope(previousScope);
@@ -91,14 +91,14 @@ FullySpecifiedType CheckSpecifier::check(ObjCTypeNameAST *typeName, Scope *scope
return switchFullySpecifiedType(previousType);
}
-SpecifierAST *CheckSpecifier::switchSpecifier(SpecifierAST *specifier)
+SpecifierListAST *CheckSpecifier::switchSpecifier(SpecifierListAST *specifier)
{
- SpecifierAST *previousSpecifier = _specifier;
+ SpecifierListAST *previousSpecifier = _specifier;
_specifier = specifier;
return previousSpecifier;
}
-FullySpecifiedType CheckSpecifier::switchFullySpecifiedType(FullySpecifiedType type)
+FullySpecifiedType CheckSpecifier::switchFullySpecifiedType(const FullySpecifiedType &type)
{
FullySpecifiedType previousType = _fullySpecifiedType;
_fullySpecifiedType = type;
@@ -301,7 +301,7 @@ bool CheckSpecifier::visit(SimpleSpecifierAST *ast)
default:
break;
} // switch
- accept(ast->next);
+
return false;
}
@@ -354,7 +354,6 @@ bool CheckSpecifier::visit(ClassSpecifierAST *ast)
(void) semantic()->switchMethodKey(previousMethodKey);
(void) semantic()->switchVisibility(previousVisibility);
- accept(ast->next);
return false;
}
@@ -362,7 +361,6 @@ bool CheckSpecifier::visit(NamedTypeSpecifierAST *ast)
{
Name *name = semantic()->check(ast->name, _scope);
_fullySpecifiedType.setType(control()->namedType(name));
- accept(ast->next);
return false;
}
@@ -370,7 +368,6 @@ bool CheckSpecifier::visit(ElaboratedTypeSpecifierAST *ast)
{
Name *name = semantic()->check(ast->name, _scope);
_fullySpecifiedType.setType(control()->namedType(name));
- accept(ast->next);
return false;
}
@@ -397,20 +394,17 @@ bool CheckSpecifier::visit(EnumSpecifierAST *ast)
enumeratorName);
e->addMember(decl);
}
- accept(ast->next);
return false;
}
bool CheckSpecifier::visit(TypeofSpecifierAST *ast)
{
semantic()->check(ast->expression, _scope);
- accept(ast->next);
return false;
}
bool CheckSpecifier::visit(AttributeSpecifierAST *ast)
{
- accept(ast->next);
return false;
}
diff --git a/src/shared/cplusplus/CheckSpecifier.h b/src/shared/cplusplus/CheckSpecifier.h
index 9f06a43771..4a46d90174 100644
--- a/src/shared/cplusplus/CheckSpecifier.h
+++ b/src/shared/cplusplus/CheckSpecifier.h
@@ -62,12 +62,12 @@ public:
CheckSpecifier(Semantic *semantic);
virtual ~CheckSpecifier();
- FullySpecifiedType check(SpecifierAST *specifier, Scope *scope);
+ FullySpecifiedType check(SpecifierListAST *specifier, Scope *scope);
FullySpecifiedType check(ObjCTypeNameAST *typeName, Scope *scope);
protected:
- SpecifierAST *switchSpecifier(SpecifierAST *specifier);
- FullySpecifiedType switchFullySpecifiedType(FullySpecifiedType type);
+ SpecifierListAST *switchSpecifier(SpecifierListAST *specifier);
+ FullySpecifiedType switchFullySpecifiedType(const FullySpecifiedType &type);
Scope *switchScope(Scope *scope);
using ASTVisitor::visit;
@@ -83,7 +83,7 @@ protected:
virtual bool visit(ObjCTypeNameAST *ast);
private:
- SpecifierAST *_specifier;
+ SpecifierListAST *_specifier;
FullySpecifiedType _fullySpecifiedType;
Scope *_scope;
};
diff --git a/src/shared/cplusplus/Parser.cpp b/src/shared/cplusplus/Parser.cpp
index 27de8b6c6a..5af2ae9a1c 100644
--- a/src/shared/cplusplus/Parser.cpp
+++ b/src/shared/cplusplus/Parser.cpp
@@ -502,7 +502,7 @@ bool Parser::parseDeclaration(DeclarationAST *&node)
default: {
if (_objCEnabled && LA() == T___ATTRIBUTE__) {
const unsigned start = cursor();
- SpecifierAST *attributes = 0, **attr = &attributes;
+ SpecifierListAST *attributes = 0, **attr = &attributes;
while (parseAttributeSpecifier(*attr))
attr = &(*attr)->next;
if (LA() == T_AT_INTERFACE)
@@ -602,7 +602,7 @@ bool Parser::parseNamespace(DeclarationAST *&node)
ast->namespace_token = namespace_token;
if (LA() == T_IDENTIFIER)
ast->identifier_token = consumeToken();
- SpecifierAST **attr_ptr = &ast->attributes;
+ SpecifierListAST **attr_ptr = &ast->attributes;
while (LA() == T___ATTRIBUTE__) {
parseAttributeSpecifier(*attr_ptr);
attr_ptr = &(*attr_ptr)->next;
@@ -657,7 +657,7 @@ bool Parser::parseConversionFunctionId(NameAST *&node)
if (LA() != T_OPERATOR)
return false;
unsigned operator_token = consumeToken();
- SpecifierAST *type_specifier = 0;
+ SpecifierListAST *type_specifier = 0;
if (! parseTypeSpecifier(type_specifier)) {
return false;
}
@@ -931,11 +931,13 @@ bool Parser::parseOperator(OperatorAST *&node) // ### FIXME
return true;
}
-bool Parser::parseCvQualifiers(SpecifierAST *&node)
+bool Parser::parseCvQualifiers(SpecifierListAST *&node)
{
DEBUG_THIS_RULE();
+
unsigned start = cursor();
- SpecifierAST **ast = &node;
+
+ SpecifierListAST **ast = &node;
while (*ast)
ast = &(*ast)->next;
@@ -943,7 +945,7 @@ bool Parser::parseCvQualifiers(SpecifierAST *&node)
if (tk == T_CONST || tk == T_VOLATILE) {
SimpleSpecifierAST *spec = new (_pool) SimpleSpecifierAST;
spec->specifier_token = consumeToken();
- *ast = spec;
+ *ast = new (_pool) SpecifierListAST(spec);
ast = &(*ast)->next;
} else if(LA() == T___ATTRIBUTE__) {
parseAttributeSpecifier(*ast);
@@ -1007,24 +1009,24 @@ bool Parser::parseTemplateArgument(ExpressionAST *&node)
return parsed;
}
-bool Parser::parseDeclSpecifierSeq(SpecifierAST *&decl_specifier_seq,
+bool Parser::parseDeclSpecifierSeq(SpecifierListAST *&decl_specifier_seq,
bool onlyTypeSpecifiers,
bool simplified)
{
DEBUG_THIS_RULE();
bool has_type_specifier = false;
NameAST *named_type_specifier = 0;
- SpecifierAST **decl_specifier_seq_ptr = &decl_specifier_seq;
+ SpecifierListAST **decl_specifier_seq_ptr = &decl_specifier_seq;
for (;;) {
if (lookAtCVQualifier()) {
SimpleSpecifierAST *spec = new (_pool) SimpleSpecifierAST;
spec->specifier_token = consumeToken();
- *decl_specifier_seq_ptr = spec;
+ *decl_specifier_seq_ptr = new (_pool) SpecifierListAST(spec);
decl_specifier_seq_ptr = &(*decl_specifier_seq_ptr)->next;
} else if (! onlyTypeSpecifiers && lookAtStorageClassSpecifier()) {
SimpleSpecifierAST *spec = new (_pool) SimpleSpecifierAST;
spec->specifier_token = consumeToken();
- *decl_specifier_seq_ptr = spec;
+ *decl_specifier_seq_ptr = new (_pool) SpecifierListAST(spec);
decl_specifier_seq_ptr = &(*decl_specifier_seq_ptr)->next;
} else if (! named_type_specifier && lookAtBuiltinTypeSpecifier()) {
parseBuiltinTypeSpecifier(*decl_specifier_seq_ptr);
@@ -1036,7 +1038,7 @@ bool Parser::parseDeclSpecifierSeq(SpecifierAST *&decl_specifier_seq,
return false;
NamedTypeSpecifierAST *spec = new (_pool) NamedTypeSpecifierAST;
spec->name = named_type_specifier;
- *decl_specifier_seq_ptr = spec;
+ *decl_specifier_seq_ptr = new (_pool) SpecifierListAST(spec);
decl_specifier_seq_ptr = &(*decl_specifier_seq_ptr)->next;
has_type_specifier = true;
} else if (! simplified && ! has_type_specifier && (LA() == T_TYPENAME ||
@@ -1075,8 +1077,8 @@ bool Parser::parseCoreDeclarator(DeclaratorAST *&node)
{
DEBUG_THIS_RULE();
unsigned start = cursor();
- SpecifierAST *attributes = 0;
- SpecifierAST **attribute_ptr = &attributes;
+ SpecifierListAST *attributes = 0;
+ SpecifierListAST **attribute_ptr = &attributes;
while (LA() == T___ATTRIBUTE__) {
parseAttributeSpecifier(*attribute_ptr);
attribute_ptr = &(*attribute_ptr)->next;
@@ -1207,7 +1209,7 @@ bool Parser::parseDeclarator(DeclaratorAST *&node, bool stopAtCppInitializer)
consumeToken(); // skip T_RPAREN
}
- SpecifierAST **spec_ptr = &node->post_attributes;
+ SpecifierListAST **spec_ptr = &node->post_attributes;
while (LA() == T___ATTRIBUTE__) {
parseAttributeSpecifier(*spec_ptr);
spec_ptr = &(*spec_ptr)->next;
@@ -1296,7 +1298,7 @@ bool Parser::parseAbstractDeclarator(DeclaratorAST *&node)
return true;
}
-bool Parser::parseEnumSpecifier(SpecifierAST *&node)
+bool Parser::parseEnumSpecifier(SpecifierListAST *&node)
{
DEBUG_THIS_RULE();
if (LA() == T_ENUM) {
@@ -1327,7 +1329,7 @@ bool Parser::parseEnumSpecifier(SpecifierAST *&node)
match(T_COMMA, &comma_token);
}
match(T_RBRACE, &ast->rbrace_token);
- node = ast;
+ node = new (_pool) SpecifierListAST(ast);
return true;
}
}
@@ -1428,7 +1430,7 @@ bool Parser::parseTypeParameter(DeclarationAST *&node)
bool Parser::parseTypeId(ExpressionAST *&node)
{
DEBUG_THIS_RULE();
- SpecifierAST *type_specifier = 0;
+ SpecifierListAST *type_specifier = 0;
if (parseTypeSpecifier(type_specifier)) {
TypeIdAST *ast = new (_pool) TypeIdAST;
ast->type_specifier = type_specifier;
@@ -1504,7 +1506,7 @@ bool Parser::parseParameterDeclarationList(DeclarationListAST *&node)
bool Parser::parseParameterDeclaration(DeclarationAST *&node)
{
DEBUG_THIS_RULE();
- SpecifierAST *decl_specifier_seq = 0;
+ SpecifierListAST *decl_specifier_seq = 0;
if (parseDeclSpecifierSeq(decl_specifier_seq)) {
ParameterDeclarationAST *ast = new (_pool) ParameterDeclarationAST;
ast->type_specifier = decl_specifier_seq;
@@ -1520,7 +1522,7 @@ bool Parser::parseParameterDeclaration(DeclarationAST *&node)
return false;
}
-bool Parser::parseClassSpecifier(SpecifierAST *&node)
+bool Parser::parseClassSpecifier(SpecifierListAST *&node)
{
DEBUG_THIS_RULE();
if (! lookAtClassKey())
@@ -1528,7 +1530,7 @@ bool Parser::parseClassSpecifier(SpecifierAST *&node)
unsigned classkey_token = consumeToken();
- SpecifierAST *attributes = 0, **attr_ptr = &attributes;
+ SpecifierListAST *attributes = 0, **attr_ptr = &attributes;
while (LA() == T___ATTRIBUTE__) {
parseAttributeSpecifier(*attr_ptr);
attr_ptr = &(*attr_ptr)->next;
@@ -1601,7 +1603,7 @@ bool Parser::parseClassSpecifier(SpecifierAST *&node)
skipUntilDeclaration();
}
}
- node = ast;
+ node = new (_pool) SpecifierListAST(ast);
parsed = true;
}
@@ -1684,19 +1686,17 @@ bool Parser::parseCtorInitializer(CtorInitializerAST *&node)
return false;
}
-bool Parser::parseElaboratedTypeSpecifier(SpecifierAST *&node)
+bool Parser::parseElaboratedTypeSpecifier(SpecifierListAST *&node)
{
DEBUG_THIS_RULE();
if (lookAtClassKey() || LA() == T_ENUM || LA() == T_TYPENAME) {
unsigned classkey_token = consumeToken();
NameAST *name = 0;
if (parseName(name)) {
- ElaboratedTypeSpecifierAST *ast =
- new (_pool) ElaboratedTypeSpecifierAST;
-
+ ElaboratedTypeSpecifierAST *ast = new (_pool) ElaboratedTypeSpecifierAST;
ast->classkey_token = classkey_token;
ast->name = name;
- node = ast;
+ node = new (_pool) SpecifierListAST(ast);
return true;
}
}
@@ -2169,8 +2169,8 @@ bool Parser::isPointerDeclaration(DeclarationStatementAST *ast) const
return false;
if (SimpleDeclarationAST *declaration = ast->declaration->asSimpleDeclaration()) {
- if (SpecifierAST *spec = declaration->decl_specifier_seq) {
- if (spec->asNamedTypeSpecifier() && ! spec->next) {
+ if (SpecifierListAST *spec = declaration->decl_specifier_seq) {
+ if (spec->value->asNamedTypeSpecifier() && ! spec->next) {
if (DeclaratorListAST *declarators = declaration->declarators) {
if (DeclaratorAST *declarator = declarators->value) {
if (declarator->ptr_operators && declarator->equals_token && declarator->initializer) {
@@ -2191,8 +2191,8 @@ bool Parser::maybeAmbiguousStatement(DeclarationStatementAST *ast) const
return false;
if (SimpleDeclarationAST *declaration = ast->declaration->asSimpleDeclaration()) {
- if (SpecifierAST *spec = declaration->decl_specifier_seq) {
- if (spec->asNamedTypeSpecifier() && ! spec->next) {
+ if (SpecifierListAST *spec = declaration->decl_specifier_seq) {
+ if (spec->value->asNamedTypeSpecifier() && ! spec->next) {
if (DeclaratorListAST *declarators = declaration->declarators) {
if (DeclaratorAST *declarator = declarators->value) {
if (declarator->core_declarator &&
@@ -2268,7 +2268,7 @@ bool Parser::parseCondition(ExpressionAST *&node)
unsigned start = cursor();
bool blocked = blockErrors(true);
- SpecifierAST *type_specifier = 0;
+ SpecifierListAST *type_specifier = 0;
if (parseTypeSpecifier(type_specifier)) {
DeclaratorAST *declarator = 0;
if (parseInitDeclarator(declarator, /*acceptStructDeclarator=*/false)) {
@@ -2673,7 +2673,7 @@ bool Parser::lookAtClassKey() const
}
}
-bool Parser::parseAttributeSpecifier(SpecifierAST *&node)
+bool Parser::parseAttributeSpecifier(SpecifierListAST *&node)
{
DEBUG_THIS_RULE();
if (LA() != T___ATTRIBUTE__)
@@ -2686,7 +2686,7 @@ bool Parser::parseAttributeSpecifier(SpecifierAST *&node)
parseAttributeList(ast->attributes);
match(T_RPAREN, &ast->first_rparen_token);
match(T_RPAREN, &ast->second_rparen_token);
- node = ast;
+ node = new (_pool) SpecifierListAST(ast);
return true;
}
@@ -2711,7 +2711,7 @@ bool Parser::parseAttributeList(AttributeListAST *&node) // ### create the AST
return true;
}
-bool Parser::parseBuiltinTypeSpecifier(SpecifierAST *&node)
+bool Parser::parseBuiltinTypeSpecifier(SpecifierListAST *&node)
{
DEBUG_THIS_RULE();
if (LA() == T___ATTRIBUTE__) {
@@ -2724,18 +2724,18 @@ bool Parser::parseBuiltinTypeSpecifier(SpecifierAST *&node)
if (parseTypeId(ast->expression) && LA() == T_RPAREN) {
ast->lparen_token = lparen_token;
ast->rparen_token = consumeToken();
- node = ast;
+ node = new (_pool) SpecifierListAST(ast);
return true;
}
rewind(lparen_token);
}
parseUnaryExpression(ast->expression);
- node = ast;
+ node = new (_pool) SpecifierListAST(ast);
return true;
} else if (lookAtBuiltinTypeSpecifier()) {
SimpleSpecifierAST *ast = new (_pool) SimpleSpecifierAST;
ast->specifier_token = consumeToken();
- node = ast;
+ node = new (_pool) SpecifierListAST(ast);
return true;
}
return false;
@@ -2755,14 +2755,14 @@ bool Parser::parseSimpleDeclaration(DeclarationAST *&node,
bool has_complex_type_specifier = false;
unsigned startOfNamedTypeSpecifier = 0;
NameAST *named_type_specifier = 0;
- SpecifierAST *decl_specifier_seq = 0,
+ SpecifierListAST *decl_specifier_seq = 0,
**decl_specifier_seq_ptr = &decl_specifier_seq;
for (;;) {
if (lookAtCVQualifier() || lookAtFunctionSpecifier()
|| lookAtStorageClassSpecifier()) {
SimpleSpecifierAST *spec = new (_pool) SimpleSpecifierAST;
spec->specifier_token = consumeToken();
- *decl_specifier_seq_ptr = spec;
+ *decl_specifier_seq_ptr = new (_pool) SpecifierListAST(spec);
decl_specifier_seq_ptr = &(*decl_specifier_seq_ptr)->next;
} else if (LA() == T___ATTRIBUTE__) {
parseAttributeSpecifier(*decl_specifier_seq_ptr);
@@ -2777,7 +2777,7 @@ bool Parser::parseSimpleDeclaration(DeclarationAST *&node,
if (parseName(named_type_specifier)) {
NamedTypeSpecifierAST *spec = new (_pool) NamedTypeSpecifierAST;
spec->name = named_type_specifier;
- *decl_specifier_seq_ptr = spec;
+ *decl_specifier_seq_ptr = new (_pool) SpecifierListAST(spec);
decl_specifier_seq_ptr = &(*decl_specifier_seq_ptr)->next;
has_type_specifier = true;
} else {
@@ -2834,7 +2834,7 @@ bool Parser::parseSimpleDeclaration(DeclarationAST *&node,
rewind(startOfNamedTypeSpecifier);
named_type_specifier = 0;
// pop the named type specifier from the decl-specifier-seq
- SpecifierAST **spec_ptr = &decl_specifier_seq;
+ SpecifierListAST **spec_ptr = &decl_specifier_seq;
for (; *spec_ptr; spec_ptr = &(*spec_ptr)->next) {
if (! (*spec_ptr)->next) {
*spec_ptr = 0;
@@ -2907,13 +2907,13 @@ bool Parser::parseSimpleDeclaration(DeclarationAST *&node,
return false;
}
-bool Parser::maybeForwardOrClassDeclaration(SpecifierAST *decl_specifier_seq) const
+bool Parser::maybeForwardOrClassDeclaration(SpecifierListAST *decl_specifier_seq) const
{
// look at the decl_specifier for possible fwd or class declarations.
- if (SpecifierAST *spec = decl_specifier_seq) {
- if (! spec->next && (spec->asElaboratedTypeSpecifier() ||
- spec->asEnumSpecifier() ||
- spec->asClassSpecifier()))
+ if (SpecifierListAST *spec = decl_specifier_seq) {
+ if (! spec->next && (spec->value->asElaboratedTypeSpecifier() ||
+ spec->value->asEnumSpecifier() ||
+ spec->value->asClassSpecifier()))
return true;
}
@@ -2985,7 +2985,7 @@ bool Parser::parseExceptionDeclaration(ExceptionDeclarationAST *&node)
return true;
}
- SpecifierAST *type_specifier = 0;
+ SpecifierListAST *type_specifier = 0;
if (parseTypeSpecifier(type_specifier)) {
ExceptionDeclarationAST *ast = new (_pool) ExceptionDeclarationAST;
ast->type_specifier = type_specifier;
@@ -3539,7 +3539,7 @@ bool Parser::parseCorePostfixExpression(ExpressionAST *&node)
default: {
unsigned start = cursor();
- SpecifierAST *type_specifier = 0;
+ SpecifierListAST *type_specifier = 0;
bool blocked = blockErrors(true);
if (lookAtBuiltinTypeSpecifier() &&
parseSimpleTypeSpecifier(type_specifier) &&
@@ -3794,7 +3794,7 @@ bool Parser::parseNewExpression(ExpressionAST *&node)
bool Parser::parseNewTypeId(NewTypeIdAST *&node)
{
DEBUG_THIS_RULE();
- SpecifierAST *typeSpec = 0;
+ SpecifierListAST *typeSpec = 0;
if (! parseTypeSpecifier(typeSpec))
return false;
@@ -4346,11 +4346,11 @@ bool Parser::parseObjCClassForwardDeclaration(DeclarationAST *&node)
// T_AT_END
//
bool Parser::parseObjCInterface(DeclarationAST *&node,
- SpecifierAST *attributes)
+ SpecifierListAST *attributes)
{
DEBUG_THIS_RULE();
if (! attributes && LA() == T___ATTRIBUTE__) {
- SpecifierAST **attr = &attributes;
+ SpecifierListAST **attr = &attributes;
while (parseAttributeSpecifier(*attr))
attr = &(*attr)->next;
}
@@ -4436,11 +4436,11 @@ bool Parser::parseObjCInterface(DeclarationAST *&node,
// objc-protocol ::= T_AT_PROTOCOL (T_IDENTIFIER @ T_COMMA) T_SEMICOLON
//
bool Parser::parseObjCProtocol(DeclarationAST *&node,
- SpecifierAST *attributes)
+ SpecifierListAST *attributes)
{
DEBUG_THIS_RULE();
if (! attributes && LA() == T___ATTRIBUTE__) {
- SpecifierAST **attr = &attributes;
+ SpecifierListAST **attr = &attributes;
while (parseAttributeSpecifier(*attr))
attr = &(*attr)->next;
}
@@ -4840,7 +4840,7 @@ bool Parser::parseObjCInstanceVariableDeclaration(DeclarationAST *&node)
// objc-property-declaration ::=
// T_AT_PROPERTY T_LPAREN (property-attribute @ T_COMMA) T_RPAREN simple-declaration
//
-bool Parser::parseObjCPropertyDeclaration(DeclarationAST *&node, SpecifierAST *attributes)
+bool Parser::parseObjCPropertyDeclaration(DeclarationAST *&node, SpecifierListAST *attributes)
{
DEBUG_THIS_RULE();
if (LA() != T_AT_PROPERTY)
@@ -4943,7 +4943,7 @@ bool Parser::parseObjCMethodPrototype(ObjCMethodPrototypeAST *&node)
_translationUnit->error(cursor(), "expected a selector");
}
- SpecifierAST **attr = &(ast->attributes);
+ SpecifierListAST **attr = &ast->attributes;
while (parseAttributeSpecifier(*attr))
attr = &(*attr)->next;
@@ -5050,7 +5050,7 @@ bool Parser::parseObjCKeywordDeclaration(ObjCSelectorArgumentAST *&argument, Obj
parseObjCTypeName(node->type_name);
- SpecifierAST **attr = &(node->attributes);
+ SpecifierListAST **attr = &node->attributes;
while (parseAttributeSpecifier(*attr))
attr = &(*attr)->next;
diff --git a/src/shared/cplusplus/Parser.h b/src/shared/cplusplus/Parser.h
index 6ac28e58a7..ba0785e7ea 100644
--- a/src/shared/cplusplus/Parser.h
+++ b/src/shared/cplusplus/Parser.h
@@ -89,7 +89,7 @@ public:
bool parseBlockDeclaration(DeclarationAST *&node);
bool parseCppCastExpression(ExpressionAST *&node);
bool parseCastExpression(ExpressionAST *&node);
- bool parseClassSpecifier(SpecifierAST *&node);
+ bool parseClassSpecifier(SpecifierListAST *&node);
bool parseCommaExpression(ExpressionAST *&node);
bool parseCompoundStatement(StatementAST *&node);
bool parseBreakStatement(StatementAST *&node);
@@ -100,7 +100,7 @@ public:
bool parseConditionalExpression(ExpressionAST *&node);
bool parseConstantExpression(ExpressionAST *&node);
bool parseCtorInitializer(CtorInitializerAST *&node);
- bool parseCvQualifiers(SpecifierAST *&node);
+ bool parseCvQualifiers(SpecifierListAST *&node);
bool parseDeclaratorOrAbstractDeclarator(DeclaratorAST *&node);
bool parseDeclaration(DeclarationAST *&node);
bool parseSimpleDeclaration(DeclarationAST *&node, bool acceptStructDeclarator = false);
@@ -109,8 +109,8 @@ public:
bool parseDeclarator(DeclaratorAST *&node, bool stopAtCppInitializer = false);
bool parseDeleteExpression(ExpressionAST *&node);
bool parseDoStatement(StatementAST *&node);
- bool parseElaboratedTypeSpecifier(SpecifierAST *&node);
- bool parseEnumSpecifier(SpecifierAST *&node);
+ bool parseElaboratedTypeSpecifier(SpecifierListAST *&node);
+ bool parseEnumSpecifier(SpecifierListAST *&node);
bool parseEnumerator(EnumeratorListAST *&node);
bool parseEqualityExpression(ExpressionAST *&node);
bool parseExceptionDeclaration(ExceptionDeclarationAST *&node);
@@ -188,17 +188,17 @@ public:
bool parseTemplateTypeParameter(DeclarationAST *&node);
bool parseTypeParameter(DeclarationAST *&node);
- bool parseBuiltinTypeSpecifier(SpecifierAST *&node);
- bool parseAttributeSpecifier(SpecifierAST *&node);
+ bool parseBuiltinTypeSpecifier(SpecifierListAST *&node);
+ bool parseAttributeSpecifier(SpecifierListAST *&node);
bool parseAttributeList(AttributeListAST *&node);
- bool parseSimpleTypeSpecifier(SpecifierAST *&node)
+ bool parseSimpleTypeSpecifier(SpecifierListAST *&node)
{ return parseDeclSpecifierSeq(node, true, true); }
- bool parseTypeSpecifier(SpecifierAST *&node)
+ bool parseTypeSpecifier(SpecifierListAST *&node)
{ return parseDeclSpecifierSeq(node, true); }
- bool parseDeclSpecifierSeq(SpecifierAST *&node,
+ bool parseDeclSpecifierSeq(SpecifierListAST *&node,
bool onlyTypeSpecifiers = false,
bool simplified = false);
bool parseUnaryExpression(ExpressionAST *&node);
@@ -214,9 +214,9 @@ public:
bool parseObjCExpression(ExpressionAST *&node);
bool parseObjCClassForwardDeclaration(DeclarationAST *&node);
bool parseObjCInterface(DeclarationAST *&node,
- SpecifierAST *attributes = 0);
+ SpecifierListAST *attributes = 0);
bool parseObjCProtocol(DeclarationAST *&node,
- SpecifierAST *attributes = 0);
+ SpecifierListAST *attributes = 0);
bool parseObjCSynchronizedStatement(StatementAST *&node);
bool parseObjCEncodeExpression(ExpressionAST *&node);
@@ -236,7 +236,7 @@ public:
bool parseObjCInterfaceMemberDeclaration(DeclarationAST *&node);
bool parseObjCInstanceVariableDeclaration(DeclarationAST *&node);
bool parseObjCPropertyDeclaration(DeclarationAST *&node,
- SpecifierAST *attributes = 0);
+ SpecifierListAST *attributes = 0);
bool parseObjCImplementation(DeclarationAST *&node);
bool parseObjCMethodPrototype(ObjCMethodPrototypeAST *&node);
bool parseObjCPropertyAttribute(ObjCPropertyAttributeAST *&node);
@@ -264,7 +264,7 @@ public:
void match(int kind, unsigned *token);
bool maybeAmbiguousStatement(DeclarationStatementAST *ast) const;
- bool maybeForwardOrClassDeclaration(SpecifierAST *decl_specifier_seq) const;
+ bool maybeForwardOrClassDeclaration(SpecifierListAST *decl_specifier_seq) const;
bool isPointerDeclaration(DeclarationStatementAST *ast) const;
private:
diff --git a/src/shared/cplusplus/Semantic.cpp b/src/shared/cplusplus/Semantic.cpp
index 8c01a3ee80..134e6c594a 100644
--- a/src/shared/cplusplus/Semantic.cpp
+++ b/src/shared/cplusplus/Semantic.cpp
@@ -120,7 +120,7 @@ Semantic::~Semantic()
Control *Semantic::control() const
{ return d->control; }
-FullySpecifiedType Semantic::check(SpecifierAST *specifier, Scope *scope)
+FullySpecifiedType Semantic::check(SpecifierListAST *specifier, Scope *scope)
{ return d->checkSpecifier->check(specifier, scope); }
void Semantic::check(DeclarationAST *declaration, Scope *scope, TemplateParameters *templateParameters)
diff --git a/src/shared/cplusplus/Semantic.h b/src/shared/cplusplus/Semantic.h
index 3e2d8c4bac..391872d847 100644
--- a/src/shared/cplusplus/Semantic.h
+++ b/src/shared/cplusplus/Semantic.h
@@ -66,7 +66,7 @@ public:
Control *control() const;
- FullySpecifiedType check(SpecifierAST *specifier, Scope *scope);
+ FullySpecifiedType check(SpecifierListAST *specifier, Scope *scope);
FullySpecifiedType check(DeclaratorAST *declarator, FullySpecifiedType type,
Scope *scope, Name **name = 0); // ### ugly