summaryrefslogtreecommitdiff
path: root/src/shared/cplusplus/AST.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared/cplusplus/AST.cpp')
-rw-r--r--src/shared/cplusplus/AST.cpp788
1 files changed, 299 insertions, 489 deletions
diff --git a/src/shared/cplusplus/AST.cpp b/src/shared/cplusplus/AST.cpp
index babf8380c5..5252c2d051 100644
--- a/src/shared/cplusplus/AST.cpp
+++ b/src/shared/cplusplus/AST.cpp
@@ -48,10 +48,10 @@
#include "AST.h"
#include "ASTVisitor.h"
+#include "ASTMatcher.h"
#include "MemoryPool.h"
#include <cassert>
-#include <cstddef>
#include <algorithm>
using namespace CPlusPlus;
@@ -69,6 +69,22 @@ void AST::accept(ASTVisitor *visitor)
visitor->postVisit(this);
}
+bool AST::match(AST *ast, AST *pattern, ASTMatcher *matcher)
+{
+ if (ast == pattern)
+ return true;
+
+ else if (! ast || ! pattern)
+ return false;
+
+ return ast->match(pattern, matcher);
+}
+
+bool AST::match(AST *pattern, ASTMatcher *matcher)
+{
+ return match0(pattern, matcher);
+}
+
unsigned AttributeSpecifierAST::firstToken() const
{
return attribute_token;
@@ -80,8 +96,8 @@ unsigned AttributeSpecifierAST::lastToken() const
return second_rparen_token + 1;
else if (first_rparen_token)
return first_rparen_token + 1;
- else if (attributes)
- return attributes->lastToken();
+ else if (attribute_list)
+ return attribute_list->lastToken();
else if (second_lparen_token)
return second_lparen_token + 1;
else if (first_lparen_token)
@@ -100,17 +116,13 @@ unsigned AttributeAST::lastToken() const
if (rparen_token)
return rparen_token + 1;
- for (ExpressionListAST *it = expression_list;
- it->expression && it->next; it = it->next) {
- if (! it->next && it->expression) {
- return it->expression->lastToken();
- }
- }
+ else if (expression_list)
+ return expression_list->lastToken();
- if (tag_token)
+ else if (tag_token)
return tag_token + 1;
- if (lparen_token)
+ else if (lparen_token)
return lparen_token + 1;
return identifier_token + 1;
@@ -132,6 +144,47 @@ unsigned AccessDeclarationAST::lastToken() const
return access_specifier_token + 1;
}
+#ifdef ICHECK_BUILD
+unsigned QPropertyDeclarationAST::firstToken() const
+{
+ return property_specifier_token;
+}
+
+unsigned QPropertyDeclarationAST::lastToken() const
+{
+ return rparen_token;
+}
+
+unsigned QEnumDeclarationAST::firstToken() const
+{
+ return enum_specifier_token;
+}
+
+unsigned QEnumDeclarationAST::lastToken() const
+{
+ return rparen_token;
+}
+
+unsigned QFlagsDeclarationAST::firstToken() const
+{
+ return this->flags_specifier_token;
+}
+
+unsigned QFlagsDeclarationAST::lastToken() const
+{
+ return rparen_token;
+}
+
+unsigned QDeclareFlagsDeclarationAST::firstToken() const
+{
+ return declareflags_specifier_token;
+}
+
+unsigned QDeclareFlagsDeclarationAST::lastToken() const
+{
+ return rparen_token;
+}
+#endif
unsigned ArrayAccessAST::firstToken() const
{
@@ -173,10 +226,8 @@ unsigned ArrayInitializerAST::lastToken() const
if (rbrace_token)
return rbrace_token + 1;
- for (ExpressionListAST *it = expression_list; it; it = it->next) {
- if (! it->next && it->expression)
- return it->expression->lastToken();
- }
+ else if (expression_list)
+ return expression_list->lastToken();
return lbrace_token + 1;
}
@@ -236,7 +287,21 @@ unsigned QtMethodAST::lastToken() const
return method_token + 1;
}
+unsigned QtMemberDeclarationAST::firstToken() const
+{
+ return q_token;
+}
+unsigned QtMemberDeclarationAST::lastToken() const
+{
+ if (rparen_token)
+ return rparen_token + 1;
+ else if (type_id)
+ return type_id->lastToken();
+ else if (lparen_token)
+ return lparen_token + 1;
+ return q_token + 1;
+}
unsigned BinaryExpressionAST::firstToken() const
{
@@ -303,10 +368,10 @@ unsigned CallAST::lastToken() const
{
if (rparen_token)
return rparen_token + 1;
- for (ExpressionListAST *it = expression_list; it; it = it->next) {
- if (! it->next && it->expression)
- return it->expression->lastToken();
- }
+
+ else if (expression_list)
+ return expression_list->lastToken();
+
return lparen_token + 1;
}
@@ -375,49 +440,27 @@ unsigned ClassSpecifierAST::lastToken() const
if (rbrace_token)
return rbrace_token + 1;
- for (DeclarationListAST *it = member_specifiers; it; it = it->next) {
- if (! it->next)
- return it->lastToken();
- }
+ else if (member_specifier_list)
+ return member_specifier_list->lastToken();
- if (lbrace_token)
+ else if (lbrace_token)
return lbrace_token + 1;
- for (BaseSpecifierAST *it = base_clause; it; it = it->next) {
- if (! it->next)
- return it->lastToken();
- }
+ else if (base_clause_list)
+ return base_clause_list->lastToken();
- if (colon_token)
+ else if (colon_token)
return colon_token + 1;
- if (name)
+ else if (name)
return name->lastToken();
- for (SpecifierAST *it = attributes; it; it = it->next) {
- if (! it->next)
- return it->lastToken();
- }
+ else if (attribute_list)
+ return attribute_list->lastToken();
return classkey_token + 1;
}
-
-unsigned StatementListAST::firstToken() const
-{
- return statement->firstToken();
-}
-
-unsigned StatementListAST::lastToken() const
-{
- for (const StatementListAST *it = this; it; it = it->next) {
- if (! it->next)
- return it->statement->lastToken();
- }
-
- return 0;
-}
-
unsigned CompoundStatementAST::firstToken() const
{
return lbrace_token;
@@ -428,10 +471,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->statement->lastToken();
- }
+ else if (statement_list)
+ return statement_list->lastToken();
return lbrace_token + 1;
}
@@ -439,8 +480,8 @@ unsigned CompoundStatementAST::lastToken() const
unsigned ConditionAST::firstToken() const
{
- if (type_specifier)
- return type_specifier->firstToken();
+ if (type_specifier_list)
+ return type_specifier_list->firstToken();
return declarator->firstToken();
}
@@ -450,10 +491,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_list)
+ return type_specifier_list->lastToken();
// ### assert?
return 0;
@@ -502,15 +541,11 @@ unsigned ConversionFunctionIdAST::firstToken() const
unsigned ConversionFunctionIdAST::lastToken() const
{
- for (PtrOperatorAST *it = ptr_operators; it; it = it->next) {
- if (! it->next)
- return it->lastToken();
- }
+ if (ptr_operator_list)
+ return ptr_operator_list->lastToken();
- for (SpecifierAST *it = type_specifier; it; it = it->next) {
- if (! it->next)
- return it->lastToken();
- }
+ else if (type_specifier_list)
+ return type_specifier_list->lastToken();
return operator_token + 1;
}
@@ -546,40 +581,23 @@ unsigned CtorInitializerAST::firstToken() const
unsigned CtorInitializerAST::lastToken() const
{
- for (MemInitializerAST *it = member_initializers; it; it = it->next) {
- if (! it->next)
- return it->lastToken();
- }
+ if (member_initializer_list)
+ return member_initializer_list->lastToken();
return colon_token + 1;
}
-unsigned DeclarationListAST::firstToken() const
-{
- return declaration->firstToken();
-}
-
-unsigned DeclarationListAST::lastToken() const
-{
- for (const DeclarationListAST *it = this; it; it = it->next) {
- if (! it->next)
- return it->declaration->lastToken();
- }
-
- return 0;
-}
-
unsigned DeclaratorAST::firstToken() const
{
- if (attributes)
- return attributes->firstToken();
- if (ptr_operators)
- return ptr_operators->firstToken();
+ if (attribute_list)
+ return attribute_list->firstToken();
+ if (ptr_operator_list)
+ return ptr_operator_list->firstToken();
else if (core_declarator)
return core_declarator->firstToken();
- else if (postfix_declarators)
- return postfix_declarators->firstToken();
- else if (attributes)
- return attributes->firstToken();
+ else if (postfix_declarator_list)
+ return postfix_declarator_list->firstToken();
+ else if (attribute_list)
+ return attribute_list->firstToken();
else if (initializer)
return initializer->firstToken();
// ### assert?
@@ -591,28 +609,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_attribute_list)
+ return post_attribute_list->lastToken();
- for (PostfixDeclaratorAST *it = postfix_declarators; it; it = it->next) {
- if (! it->next)
- return it->lastToken();
- }
+ else if (postfix_declarator_list)
+ return postfix_declarator_list->lastToken();
- if (core_declarator)
+ else if (core_declarator)
return core_declarator->lastToken();
- for (PtrOperatorAST *it = ptr_operators; it; it = it->next) {
- if (! it->next)
- return it->lastToken();
- }
+ else if (ptr_operator_list)
+ return ptr_operator_list->lastToken();
- for (SpecifierAST *it = attributes; it; it = it->next) {
- if (! it->next)
- return it->lastToken();
- }
+ else if (attribute_list)
+ return attribute_list->lastToken();
// ### assert?
return 0;
@@ -640,30 +650,6 @@ unsigned DeclaratorIdAST::lastToken() const
return name->lastToken();
}
-
-unsigned DeclaratorListAST::firstToken() const
-{
- if (comma_token)
- return comma_token;
-
- return declarator->firstToken();
-}
-
-unsigned DeclaratorListAST::lastToken() const
-{
- for (const DeclaratorListAST *it = this; it; it = it->next) {
- if (! it->next) {
- if (it->declarator)
- return it->declarator->lastToken();
- else if (it->comma_token)
- return it->comma_token + 1;
- }
- }
-
- return 0;
-}
-
-
unsigned DeleteExpressionAST::firstToken() const
{
if (scope_token)
@@ -755,10 +741,8 @@ unsigned EnumSpecifierAST::lastToken() const
if (rbrace_token)
return rbrace_token + 1;
- for (EnumeratorAST *it = enumerators; it; it = it->next) {
- if (! it->next)
- return it->lastToken();
- }
+ if (enumerator_list)
+ return enumerator_list->lastToken();
if (lbrace_token)
return lbrace_token + 1;
@@ -786,8 +770,8 @@ unsigned EnumeratorAST::lastToken() const
unsigned ExceptionDeclarationAST::firstToken() const
{
- if (type_specifier)
- return type_specifier->firstToken();
+ if (type_specifier_list)
+ return type_specifier_list->firstToken();
if (declarator)
return declarator->firstToken();
return dot_dot_dot_token;
@@ -797,12 +781,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_list)
+ return type_specifier_list->lastToken();
+
return 0;
}
@@ -817,35 +802,18 @@ unsigned ExceptionSpecificationAST::lastToken() const
if (rparen_token)
return rparen_token + 1;
- for (ExpressionListAST *it = type_ids; it; it = it->next) {
- if (! it->next && it->expression)
- return it->expression->lastToken();
- }
+ else if (type_id_list)
+ return type_id_list->lastToken();
- if (dot_dot_dot_token)
+ else if (dot_dot_dot_token)
return dot_dot_dot_token + 1;
+
else if (lparen_token)
return lparen_token + 1;
return throw_token + 1;
}
-
-unsigned ExpressionListAST::firstToken() const
-{
- return expression->firstToken();
-}
-
-unsigned ExpressionListAST::lastToken() const
-{
- for (const ExpressionListAST *it = this; it; it = it->next) {
- if (! it->next)
- return it->expression->lastToken();
- }
- return 0;
-}
-
-
unsigned ExpressionOrDeclarationStatementAST::firstToken() const
{
return declaration->firstToken();
@@ -929,13 +897,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_list)
+ return cv_qualifier_list->lastToken();
- if (rparen_token)
+ else if (rparen_token)
return rparen_token + 1;
+
else if (parameters)
return parameters->lastToken();
@@ -945,8 +912,8 @@ unsigned FunctionDeclaratorAST::lastToken() const
unsigned FunctionDefinitionAST::firstToken() const
{
- if (decl_specifier_seq)
- return decl_specifier_seq->firstToken();
+ if (decl_specifier_list)
+ return decl_specifier_list->firstToken();
else if (declarator)
return declarator->firstToken();
else if (ctor_initializer)
@@ -958,15 +925,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_list)
+ return decl_specifier_list->lastToken();
// ### assert
return 0;
@@ -1038,10 +1005,8 @@ unsigned LinkageBodyAST::lastToken() const
if (rbrace_token)
return rbrace_token + 1;
- for (DeclarationListAST *it = declarations; it; it = it->next) {
- if (! it->next)
- return it->lastToken();
- }
+ else if (declaration_list)
+ return declaration_list->lastToken();
return lbrace_token + 1;
}
@@ -1072,8 +1037,8 @@ unsigned MemInitializerAST::lastToken() const
{
if (rparen_token)
return rparen_token + 1;
- else if (expression)
- return expression->lastToken();
+ else if (expression_list)
+ return expression_list->lastToken();
else if (lparen_token)
return lparen_token + 1;
return name->lastToken();
@@ -1116,12 +1081,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 (attribute_list)
+ return attribute_list->lastToken();
- if (identifier_token)
+ else if (identifier_token)
return identifier_token + 1;
return namespace_token + 1;
@@ -1248,23 +1211,19 @@ unsigned NewInitializerAST::lastToken() const
unsigned NewTypeIdAST::firstToken() const
{
- return type_specifier->firstToken();
+ return type_specifier_list->firstToken();
}
unsigned NewTypeIdAST::lastToken() const
{
- for (NewArrayDeclaratorAST *it = new_array_declarators; it; it = it->next) {
- if (! it->next)
- return it->lastToken();
- }
+ if (new_array_declarator_list)
+ return new_array_declarator_list->lastToken();
- for (PtrOperatorAST *it = ptr_operators; it; it = it->next) {
- if (it->next)
- return it->lastToken();
- }
+ else if (ptr_operator_list)
+ return ptr_operator_list->lastToken();
- if (type_specifier)
- return type_specifier->lastToken();
+ else if (type_specifier_list)
+ return type_specifier_list->lastToken();
// ### assert?
return 0;
@@ -1312,21 +1271,23 @@ unsigned OperatorFunctionIdAST::lastToken() const
unsigned ParameterDeclarationAST::firstToken() const
{
- return type_specifier->firstToken();
+ return type_specifier_list->firstToken();
}
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_list)
+ return type_specifier_list->lastToken();
+
// ### assert?
return 0;
}
@@ -1334,8 +1295,8 @@ unsigned ParameterDeclarationAST::lastToken() const
unsigned ParameterDeclarationClauseAST::firstToken() const
{
- if (parameter_declarations)
- return parameter_declarations->firstToken();
+ if (parameter_declaration_list)
+ return parameter_declaration_list->firstToken();
return dot_dot_dot_token;
}
@@ -1343,7 +1304,7 @@ unsigned ParameterDeclarationClauseAST::lastToken() const
{
if (dot_dot_dot_token)
return dot_dot_dot_token + 1;
- return parameter_declarations->lastToken();
+ return parameter_declaration_list->lastToken();
}
@@ -1354,10 +1315,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_list)
+ return cv_qualifier_list->lastToken();
+
return star_token + 1;
}
@@ -1366,29 +1326,26 @@ unsigned PointerToMemberAST::firstToken() const
{
if (global_scope_token)
return global_scope_token;
- else if (nested_name_specifier)
- return nested_name_specifier->firstToken();
+ else if (nested_name_specifier_list)
+ return nested_name_specifier_list->firstToken();
return star_token;
}
unsigned PointerToMemberAST::lastToken() const
{
- for (SpecifierAST *it = cv_qualifier_seq; it; it = it->next) {
- if (! it->next)
- return it->lastToken();
- }
+ if (cv_qualifier_list)
+ return cv_qualifier_list->lastToken();
- if (star_token)
+ else if (star_token)
return star_token + 1;
- for (NestedNameSpecifierAST *it = nested_name_specifier; it; it = it->next) {
- if (! it->next)
- return it->lastToken();
- }
+ else if (nested_name_specifier_list)
+ return nested_name_specifier_list->lastToken();
- if (global_scope_token)
+ else if (global_scope_token)
return global_scope_token + 1;
+ // ### assert(0);
return 0;
}
@@ -1411,10 +1368,8 @@ unsigned PostfixExpressionAST::firstToken() const
unsigned PostfixExpressionAST::lastToken() const
{
- for (PostfixAST *it = postfix_expressions; it; it = it->next) {
- if (! it->next)
- return it->lastToken();
- }
+ if (postfix_expression_list)
+ return postfix_expression_list->lastToken();
return base_expression->lastToken();
}
@@ -1423,8 +1378,8 @@ unsigned QualifiedNameAST::firstToken() const
{
if (global_scope_token)
return global_scope_token;
- else if (nested_name_specifier)
- return nested_name_specifier->firstToken();
+ else if (nested_name_specifier_list)
+ return nested_name_specifier_list->firstToken();
return unqualified_name->firstToken();
}
@@ -1433,10 +1388,8 @@ unsigned QualifiedNameAST::lastToken() const
if (unqualified_name)
return unqualified_name->lastToken();
- for (NestedNameSpecifierAST *it = nested_name_specifier; it; it = it->next) {
- if (! it->next)
- return it->lastToken();
- }
+ if (nested_name_specifier_list)
+ return nested_name_specifier_list->lastToken();
if (global_scope_token)
return global_scope_token + 1;
@@ -1473,10 +1426,10 @@ unsigned ReturnStatementAST::lastToken() const
unsigned SimpleDeclarationAST::firstToken() const
{
- if (decl_specifier_seq)
- return decl_specifier_seq->firstToken();
- else if (declarators)
- return declarators->firstToken();
+ if (decl_specifier_list)
+ return decl_specifier_list->firstToken();
+ else if (declarator_list)
+ return declarator_list->firstToken();
return semicolon_token;
}
@@ -1485,18 +1438,16 @@ unsigned SimpleDeclarationAST::lastToken() const
if (semicolon_token)
return semicolon_token + 1;
- if (declarators)
- return declarators->lastToken();
+ else if (declarator_list)
+ return declarator_list->lastToken();
- for (SpecifierAST *it = decl_specifier_seq; it; it = it->next) {
- if (! it->next)
- return it->lastToken();
- }
+ else if (decl_specifier_list)
+ return decl_specifier_list->lastToken();
+ // ### assert(0);
return 0;
}
-
unsigned SimpleNameAST::firstToken() const
{
return identifier_token;
@@ -1567,35 +1518,24 @@ unsigned SwitchStatementAST::lastToken() const
{
if (statement)
return statement->lastToken();
+
else if (rparen_token)
return rparen_token + 1;
+
else if (condition)
return condition->lastToken();
+
else if (lparen_token)
return lparen_token + 1;
- return switch_token + 1;
-}
-
-
-unsigned TemplateArgumentListAST::firstToken() const
-{
- return template_argument->firstToken();
-}
-unsigned TemplateArgumentListAST::lastToken() const
-{
- for (const TemplateArgumentListAST *it = this; it; it = it->next) {
- if (! it->next && it->template_argument)
- return it->template_argument->lastToken();
- }
- return 0;
+ return switch_token + 1;
}
-
unsigned TemplateDeclarationAST::firstToken() const
{
if (export_token)
return export_token;
+
return template_token;
}
@@ -1603,21 +1543,23 @@ unsigned TemplateDeclarationAST::lastToken() const
{
if (declaration)
return declaration->lastToken();
+
else if (greater_token)
return greater_token + 1;
- for (DeclarationListAST *it = template_parameters; it; it = it->next) {
- if (! it->next)
- return it->lastToken();
- }
+ else if (template_parameter_list)
+ return template_parameter_list->lastToken();
- if (less_token)
+ else if (less_token)
return less_token + 1;
+
else if (template_token)
return template_token + 1;
+
else if (export_token)
return export_token + 1;
+ // ### assert(0);
return 0;
}
@@ -1632,12 +1574,10 @@ unsigned TemplateIdAST::lastToken() const
if (greater_token)
return greater_token + 1;
- for (TemplateArgumentListAST *it = template_arguments; it; it = it->next) {
- if (! it->next && it->template_argument)
- return it->template_argument->lastToken();
- }
+ else if (template_argument_list)
+ return template_argument_list->lastToken();
- if (less_token)
+ else if (less_token)
return less_token + 1;
return identifier_token + 1;
@@ -1653,21 +1593,23 @@ unsigned TemplateTypeParameterAST::lastToken() const
{
if (type_id)
return type_id->lastToken();
+
else if (equal_token)
return equal_token + 1;
+
else if (name)
return name->lastToken();
+
else if (class_token)
return class_token + 1;
+
else if (greater_token)
return greater_token + 1;
- for (DeclarationListAST *it = template_parameters; it; it = it->next) {
- if (! it->next)
- return it->declaration->lastToken();
- }
+ else if (template_parameter_list)
+ return template_parameter_list->lastToken();
- if (less_token)
+ else if (less_token)
return less_token + 1;
return template_token + 1;
@@ -1697,22 +1639,22 @@ unsigned ThrowExpressionAST::lastToken() const
return throw_token + 1;
}
-
unsigned TranslationUnitAST::firstToken() const
{
- return declarations->firstToken();
+ if(declaration_list)
+ return declaration_list->firstToken();
+ return 0;
}
unsigned TranslationUnitAST::lastToken() const
{
- for (DeclarationListAST *it = declarations; it; it = it->next) {
- if (! it->next)
- return it->lastToken();
- }
+ if (declaration_list)
+ return declaration_list->lastToken();
+
+ // ### assert(0);
return 0;
}
-
unsigned TryBlockStatementAST::firstToken() const
{
return try_token;
@@ -1720,12 +1662,10 @@ unsigned TryBlockStatementAST::firstToken() const
unsigned TryBlockStatementAST::lastToken() const
{
- for (CatchClauseAST *it = catch_clause_seq; it; it = it->next) {
- if (! it->next)
- return it->lastToken();
- }
+ if (catch_clause_list)
+ return catch_clause_list->lastToken();
- if (statement)
+ else if (statement)
return statement->lastToken();
return try_token + 1;
@@ -1734,7 +1674,7 @@ unsigned TryBlockStatementAST::lastToken() const
unsigned TypeConstructorCallAST::firstToken() const
{
- return type_specifier->firstToken();
+ return type_specifier_list->firstToken();
}
unsigned TypeConstructorCallAST::lastToken() const
@@ -1742,27 +1682,23 @@ 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_list)
+ return type_specifier_list->lastToken();
- for (SpecifierAST *it = type_specifier; it; it = it->next) {
- if (! it->next)
- return it->lastToken();
- }
-
+ // ### assert(0);
return 0;
}
unsigned TypeIdAST::firstToken() const
{
- return type_specifier->firstToken();
+ return type_specifier_list->firstToken();
}
unsigned TypeIdAST::lastToken() const
@@ -1770,11 +1706,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_list)
+ return type_specifier_list->lastToken();
+ // ### assert(0);
return 0;
}
@@ -1807,13 +1742,12 @@ unsigned TypenameCallExpressionAST::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 (name)
return name->lastToken();
@@ -1894,40 +1828,25 @@ unsigned WhileStatementAST::lastToken() const
{
if (statement)
return statement->lastToken();
+
else if (rparen_token)
return rparen_token + 1;
+
else if (condition)
return condition->lastToken();
+
else if (lparen_token)
return lparen_token + 1;
+
return while_token + 1;
}
// ObjC++
-unsigned IdentifierListAST::firstToken() const
-{
- if (name)
- return name->firstToken();
- else
- return comma_token;
-}
-
-unsigned IdentifierListAST::lastToken() const
-{
- for (const IdentifierListAST *it = this; it; it = it->next) {
- if (! it->next && it->name) {
- return it->name->lastToken();
- }
- }
- // ### assert?
- return 0;
-}
-
-
unsigned ObjCClassForwardDeclarationAST::firstToken() const
{
- if (attributes)
- return attributes->firstToken();
+ if (attribute_list)
+ return attribute_list->firstToken();
+
return class_token;
}
@@ -1936,18 +1855,17 @@ unsigned ObjCClassForwardDeclarationAST::lastToken() const
if (semicolon_token)
return semicolon_token + 1;
- for (IdentifierListAST *it = identifier_list; it; it = it->next) {
- if (! it->next && it->name)
- return it->name->lastToken();
- }
+ else if (identifier_list)
+ return identifier_list->lastToken();
return class_token + 1;
}
unsigned ObjCProtocolForwardDeclarationAST::firstToken() const
{
- if (attributes)
- return attributes->firstToken();
+ if (attribute_list)
+ return attribute_list->firstToken();
+
return protocol_token;
}
@@ -1956,18 +1874,16 @@ unsigned ObjCProtocolForwardDeclarationAST::lastToken() const
if (semicolon_token)
return semicolon_token + 1;
- for (IdentifierListAST *it = identifier_list; it; it = it->next) {
- if (! it->next && it->name)
- return it->name->lastToken();
- }
+ else if (identifier_list)
+ return identifier_list->lastToken();
return protocol_token + 1;
}
unsigned ObjCClassDeclarationAST::firstToken() const
{
- if (attributes)
- return attributes->firstToken();
+ if (attribute_list)
+ return attribute_list->firstToken();
if (interface_token)
return interface_token;
@@ -1978,7 +1894,7 @@ unsigned ObjCClassDeclarationAST::firstToken() const
unsigned ObjCClassDeclarationAST::lastToken() const
{
if (end_token) return end_token + 1;
- if (member_declarations) return member_declarations->lastToken();
+ if (member_declaration_list) return member_declaration_list->lastToken();
if (inst_vars_decl) return inst_vars_decl->lastToken();
if (protocol_refs)
return protocol_refs->lastToken();
@@ -2001,8 +1917,8 @@ unsigned ObjCClassDeclarationAST::lastToken() const
unsigned ObjCProtocolDeclarationAST::firstToken() const
{
- if (attributes)
- return attributes->firstToken();
+ if (attribute_list)
+ return attribute_list->firstToken();
return protocol_token;
}
@@ -2011,19 +1927,17 @@ unsigned ObjCProtocolDeclarationAST::lastToken() const
if (end_token)
return end_token + 1;
- if (member_declarations)
- return member_declarations->lastToken();
+ else if (member_declaration_list)
+ return member_declaration_list->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 (attribute_list)
+ return attribute_list->lastToken();
return protocol_token + 1;
}
@@ -2035,12 +1949,11 @@ unsigned ObjCProtocolRefsAST::firstToken() const
unsigned ObjCProtocolRefsAST::lastToken() const
{
- if (greater_token) return greater_token + 1;
+ if (greater_token)
+ return greater_token + 1;
- for (IdentifierListAST *it = identifier_list; it; it = it->next) {
- if (! it->next && it->name)
- return it->name->lastToken();
- }
+ else if (identifier_list)
+ return identifier_list->lastToken();
return less_token + 1;
}
@@ -2067,30 +1980,15 @@ unsigned ObjCMessageExpressionAST::lastToken() const
return lbracket_token + 1;
}
-unsigned ObjCMessageArgumentListAST::firstToken() const
+unsigned ObjCMessageArgumentAST::firstToken() const
{
- if (arg)
- return arg->firstToken();
- // ### assert?
- return 0;
-}
+ if (parameter_value_expression)
+ return parameter_value_expression->firstToken();
-unsigned ObjCMessageArgumentListAST::lastToken() const
-{
- for (const ObjCMessageArgumentListAST *it = this; it; it = it->next) {
- if (! it->next && it->arg) {
- return it->arg->lastToken();
- }
- }
// ### assert?
return 0;
}
-unsigned ObjCMessageArgumentAST::firstToken() const
-{
- return parameter_value_expression->firstToken();
-}
-
unsigned ObjCMessageArgumentAST::lastToken() const
{
if (parameter_value_expression)
@@ -2174,33 +2072,14 @@ unsigned ObjCSelectorArgumentAST::lastToken() const
return name_token + 1;
}
-unsigned ObjCSelectorArgumentListAST::firstToken() const
-{
- if (argument)
- return argument->firstToken();
-
- // ### assert?
- return 0;
-}
-
-unsigned ObjCSelectorArgumentListAST::lastToken() const
-{
- for (const ObjCSelectorArgumentListAST *it = this; it; it = it->next)
- if (!it->next && it->argument)
- return it->argument->lastToken();
-
- // ### assert?
- return 0;
-}
-
unsigned ObjCSelectorWithArgumentsAST::firstToken() const
{
- return selector_arguments->firstToken();
+ return selector_argument_list->firstToken();
}
unsigned ObjCSelectorWithArgumentsAST::lastToken() const
{
- return selector_arguments->lastToken();
+ return selector_argument_list->lastToken();
}
unsigned ObjCSelectorExpressionAST::firstToken() const
@@ -2229,8 +2108,8 @@ unsigned ObjCInstanceVariablesDeclarationAST::lastToken() const
if (rbrace_token)
return rbrace_token + 1;
- if (instance_variables)
- return instance_variables->lastToken();
+ if (instance_variable_list)
+ return instance_variable_list->lastToken();
return lbrace_token + 1;
}
@@ -2260,37 +2139,10 @@ unsigned ObjCPropertyAttributeAST::lastToken() const
return attribute_identifier_token + 1;
}
-unsigned ObjCPropertyAttributeListAST::firstToken() const
-{
- if (attr)
- return attr->firstToken();
- else if (comma_token)
- return comma_token;
- else if (next)
- return next->lastToken();
- else
- // ### Assert?
- return 0;
-}
-
-unsigned ObjCPropertyAttributeListAST::lastToken() const
-{
- for (const ObjCPropertyAttributeListAST *it = this; it; it = it->next) {
- if (! it->next && (comma_token || it->attr)) {
- if (comma_token)
- return comma_token + 1;
- else
- return it->attr->lastToken();
- }
- }
- // ### assert?
- return 0;
-}
-
unsigned ObjCPropertyDeclarationAST::firstToken() const
{
- if (attributes)
- return attributes->firstToken();
+ if (attribute_list)
+ return attribute_list->firstToken();
return property_token;
}
@@ -2301,12 +2153,12 @@ unsigned ObjCPropertyDeclarationAST::lastToken() const
return simple_declaration->lastToken();
else if (rparen_token)
return rparen_token + 1;
- else if (property_attributes)
- return property_attributes->lastToken();
+ else if (property_attribute_list)
+ return property_attribute_list->lastToken();
else if (lparen_token)
return lparen_token + 1;
- else
- return property_token + 1;
+
+ return property_token + 1;
}
unsigned ObjCMessageArgumentDeclarationAST::firstToken() const
@@ -2328,28 +2180,6 @@ unsigned ObjCMessageArgumentDeclarationAST::lastToken() const
return 0;
}
-unsigned ObjCMessageArgumentDeclarationListAST::firstToken() const
-{
- if (argument_declaration)
- return argument_declaration->firstToken();
- else if (next)
- return next->firstToken();
- else
- // ### Assert?
- return 0;
-}
-
-unsigned ObjCMessageArgumentDeclarationListAST::lastToken() const
-{
- for (const ObjCMessageArgumentDeclarationListAST *it = this; it; it = it->next) {
- if (! it->next && it->argument_declaration) {
- return it->argument_declaration->lastToken();
- }
- }
- // ### assert?
- return 0;
-}
-
unsigned ObjCMethodPrototypeAST::firstToken() const
{
return method_type_token;
@@ -2357,16 +2187,15 @@ unsigned ObjCMethodPrototypeAST::firstToken() const
unsigned ObjCMethodPrototypeAST::lastToken() const
{
- if (attributes)
- return attributes->lastToken();
+ if (attribute_list)
+ return attribute_list->lastToken();
else if (dot_dot_dot_token)
return dot_dot_dot_token + 1;
- else if (arguments)
- return arguments->lastToken();
+ else if (argument_list)
+ return argument_list->lastToken();
else if (type_name)
return type_name->lastToken();
- else
- return method_type_token + 1;
+ return method_type_token + 1;
}
unsigned ObjCMethodDeclarationAST::firstToken() const
@@ -2403,25 +2232,6 @@ unsigned ObjCSynthesizedPropertyAST::lastToken() const
return property_identifier + 1;
}
-unsigned ObjCSynthesizedPropertyListAST::firstToken() const
-{
- if (synthesized_property)
- return synthesized_property->firstToken();
- else
- return comma_token;
-}
-
-unsigned ObjCSynthesizedPropertyListAST::lastToken() const
-{
- for (const ObjCSynthesizedPropertyListAST *it = this; it; it = it->next) {
- if (! it->next && it->synthesized_property) {
- return it->synthesized_property->lastToken();
- }
- }
- // ### assert?
- return 0;
-}
-
unsigned ObjCSynthesizedPropertiesDeclarationAST::firstToken() const
{
return synthesized_token;
@@ -2431,8 +2241,8 @@ unsigned ObjCSynthesizedPropertiesDeclarationAST::lastToken() const
{
if (semicolon_token)
return semicolon_token + 1;
- else if (property_identifiers)
- return property_identifiers->lastToken();
+ else if (property_identifier_list)
+ return property_identifier_list->lastToken();
else
return synthesized_token + 1;
}
@@ -2446,8 +2256,8 @@ unsigned ObjCDynamicPropertiesDeclarationAST::lastToken() const
{
if (semicolon_token)
return semicolon_token + 1;
- else if (property_identifiers)
- return property_identifiers->lastToken();
+ else if (property_identifier_list)
+ return property_identifier_list->lastToken();
else
return dynamic_token + 1;
}
@@ -2459,8 +2269,8 @@ unsigned ObjCFastEnumerationAST::firstToken() const
unsigned ObjCFastEnumerationAST::lastToken() const
{
- if (body_statement)
- return body_statement->lastToken();
+ if (statement)
+ return statement->lastToken();
else if (rparen_token)
return rparen_token + 1;
else if (fast_enumeratable_expression)
@@ -2471,8 +2281,8 @@ unsigned ObjCFastEnumerationAST::lastToken() const
return initializer->lastToken();
else if (declarator)
return declarator->lastToken();
- else if (type_specifiers)
- return type_specifiers->lastToken();
+ else if (type_specifier_list)
+ return type_specifier_list->lastToken();
else if (lparen_token)
return lparen_token + 1;
else