From 8efb73f5d2a84d70aae134dcf45cac87c70fa76f Mon Sep 17 00:00:00 2001
From: Roberto Raggi <roberto.raggi@nokia.com>
Date: Tue, 10 Nov 2009 12:37:46 +0100
Subject: [PATCH] Removed TemplateArgumentListAST

Done with Erik Verbruggen
---
 src/libs/cplusplus/FindUsages.cpp   |  6 +++---
 src/plugins/cppeditor/cppeditor.cpp |  4 ++--
 src/shared/cplusplus/AST.cpp        | 20 ++------------------
 src/shared/cplusplus/AST.h          | 16 ----------------
 src/shared/cplusplus/ASTVisit.cpp   |  8 --------
 src/shared/cplusplus/ASTVisitor.h   |  2 --
 src/shared/cplusplus/ASTfwd.h       |  2 +-
 src/shared/cplusplus/CheckName.cpp  |  2 +-
 src/shared/cplusplus/Parser.cpp     |  8 ++++----
 9 files changed, 13 insertions(+), 55 deletions(-)

diff --git a/src/libs/cplusplus/FindUsages.cpp b/src/libs/cplusplus/FindUsages.cpp
index d6ecca8cbf9..d58d17a9716 100644
--- a/src/libs/cplusplus/FindUsages.cpp
+++ b/src/libs/cplusplus/FindUsages.cpp
@@ -301,7 +301,7 @@ bool FindUsages::visit(QualifiedNameAST *ast)
                 if (template_id) {
                     for (TemplateArgumentListAST *template_arguments = template_id->template_arguments;
                          template_arguments; template_arguments = template_arguments->next) {
-                        accept(template_arguments->template_argument);
+                        accept(template_arguments->value);
                     }
                 }
             }
@@ -335,7 +335,7 @@ bool FindUsages::visit(QualifiedNameAST *ast)
 
                 for (TemplateArgumentListAST *template_arguments = template_id->template_arguments;
                      template_arguments; template_arguments = template_arguments->next) {
-                    accept(template_arguments->template_argument);
+                    accept(template_arguments->value);
                 }
             }
         }
@@ -395,7 +395,7 @@ bool FindUsages::visit(TemplateIdAST *ast)
 
     for (TemplateArgumentListAST *template_arguments = ast->template_arguments;
          template_arguments; template_arguments = template_arguments->next) {
-        accept(template_arguments->template_argument);
+        accept(template_arguments->value);
     }
 
     return false;
diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp
index 53a471bae0a..5925a50f518 100644
--- a/src/plugins/cppeditor/cppeditor.cpp
+++ b/src/plugins/cppeditor/cppeditor.cpp
@@ -240,7 +240,7 @@ protected:
 
         else if (TemplateIdAST *template_id = name->asTemplateId()) {
             for (TemplateArgumentListAST *it = template_id->template_arguments; it; it = it->next) {
-                accept(it->template_argument);
+                accept(it->value);
             }
         }
     }
@@ -277,7 +277,7 @@ protected:
     virtual bool visit(TemplateIdAST *ast)
     {
         for (TemplateArgumentListAST *arg = ast->template_arguments; arg; arg = arg->next)
-            accept(arg->template_argument);
+            accept(arg->value);
 
         unsigned line, column;
         getTokenStartPosition(ast->firstToken(), &line, &column);
diff --git a/src/shared/cplusplus/AST.cpp b/src/shared/cplusplus/AST.cpp
index db6a31fe2a4..f47158ce407 100644
--- a/src/shared/cplusplus/AST.cpp
+++ b/src/shared/cplusplus/AST.cpp
@@ -1504,22 +1504,6 @@ unsigned SwitchStatementAST::lastToken() const
     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;
-}
-
-
 unsigned TemplateDeclarationAST::firstToken() const
 {
     if (export_token)
@@ -1561,8 +1545,8 @@ unsigned TemplateIdAST::lastToken() const
         return greater_token + 1;
 
     for (TemplateArgumentListAST *it = template_arguments; it; it = it->next) {
-        if (! it->next && it->template_argument)
-            return it->template_argument->lastToken();
+        if (! it->next && it->value)
+            return it->value->lastToken();
     }
 
     if (less_token)
diff --git a/src/shared/cplusplus/AST.h b/src/shared/cplusplus/AST.h
index 04709031add..10aa1a0c7bc 100644
--- a/src/shared/cplusplus/AST.h
+++ b/src/shared/cplusplus/AST.h
@@ -1851,22 +1851,6 @@ protected:
     virtual void accept0(ASTVisitor *visitor);
 };
 
-class CPLUSPLUS_EXPORT TemplateArgumentListAST: public AST
-{
-public:
-    ExpressionAST *template_argument;
-    TemplateArgumentListAST *next;
-
-public:
-    virtual TemplateArgumentListAST *asTemplateArgumentList() { return this; }
-
-    virtual unsigned firstToken() const;
-    virtual unsigned lastToken() const;
-
-protected:
-    virtual void accept0(ASTVisitor *visitor);
-};
-
 class CPLUSPLUS_EXPORT TemplateDeclarationAST: public DeclarationAST
 {
 public:
diff --git a/src/shared/cplusplus/ASTVisit.cpp b/src/shared/cplusplus/ASTVisit.cpp
index 605e1538de4..f6b0bfb9b8c 100644
--- a/src/shared/cplusplus/ASTVisit.cpp
+++ b/src/shared/cplusplus/ASTVisit.cpp
@@ -781,14 +781,6 @@ void SwitchStatementAST::accept0(ASTVisitor *visitor)
     visitor->endVisit(this);
 }
 
-void TemplateArgumentListAST::accept0(ASTVisitor *visitor)
-{
-    if (visitor->visit(this)) {
-        accept(template_argument, visitor);
-    }
-    visitor->endVisit(this);
-}
-
 void TemplateDeclarationAST::accept0(ASTVisitor *visitor)
 {
     if (visitor->visit(this)) {
diff --git a/src/shared/cplusplus/ASTVisitor.h b/src/shared/cplusplus/ASTVisitor.h
index 29703a44a7e..ed61ea2a142 100644
--- a/src/shared/cplusplus/ASTVisitor.h
+++ b/src/shared/cplusplus/ASTVisitor.h
@@ -172,7 +172,6 @@ public:
     virtual bool visit(SizeofExpressionAST *) { return true; }
     virtual bool visit(StringLiteralAST *) { return true; }
     virtual bool visit(SwitchStatementAST *) { return true; }
-    virtual bool visit(TemplateArgumentListAST *) { return true; }
     virtual bool visit(TemplateDeclarationAST *) { return true; }
     virtual bool visit(TemplateIdAST *) { return true; }
     virtual bool visit(TemplateTypeParameterAST *) { return true; }
@@ -304,7 +303,6 @@ public:
     virtual void endVisit(SizeofExpressionAST *) { }
     virtual void endVisit(StringLiteralAST *) { }
     virtual void endVisit(SwitchStatementAST *) { }
-    virtual void endVisit(TemplateArgumentListAST *) { }
     virtual void endVisit(TemplateDeclarationAST *) { }
     virtual void endVisit(TemplateIdAST *) { }
     virtual void endVisit(TemplateTypeParameterAST *) { }
diff --git a/src/shared/cplusplus/ASTfwd.h b/src/shared/cplusplus/ASTfwd.h
index 906e188891d..50ab749ee5c 100644
--- a/src/shared/cplusplus/ASTfwd.h
+++ b/src/shared/cplusplus/ASTfwd.h
@@ -179,7 +179,6 @@ class SpecifierAST;
 class StatementAST;
 class StringLiteralAST;
 class SwitchStatementAST;
-class TemplateArgumentListAST;
 class TemplateDeclarationAST;
 class TemplateIdAST;
 class TemplateTypeParameterAST;
@@ -202,6 +201,7 @@ typedef List<ExpressionAST *> ExpressionListAST;
 typedef List<DeclarationAST *> DeclarationListAST;
 typedef List<StatementAST *> StatementListAST;
 typedef List<DeclaratorAST *> DeclaratorListAST;
+typedef ExpressionListAST TemplateArgumentListAST;
 
 } // end of namespace CPlusPlus
 
diff --git a/src/shared/cplusplus/CheckName.cpp b/src/shared/cplusplus/CheckName.cpp
index 19e2eedf98c..bcd8b3f1806 100644
--- a/src/shared/cplusplus/CheckName.cpp
+++ b/src/shared/cplusplus/CheckName.cpp
@@ -361,7 +361,7 @@ bool CheckName::visit(TemplateIdAST *ast)
     std::vector<FullySpecifiedType> templateArguments;
     for (TemplateArgumentListAST *it = ast->template_arguments; it;
             it = it->next) {
-        ExpressionAST *arg = it->template_argument;
+        ExpressionAST *arg = it->value;
         FullySpecifiedType exprTy = semantic()->check(arg, _scope);
         templateArguments.push_back(exprTy);
     }
diff --git a/src/shared/cplusplus/Parser.cpp b/src/shared/cplusplus/Parser.cpp
index 6a4222024c1..d52431e01c0 100644
--- a/src/shared/cplusplus/Parser.cpp
+++ b/src/shared/cplusplus/Parser.cpp
@@ -716,14 +716,14 @@ bool Parser::parseTemplateArgumentList(TemplateArgumentListAST *&node)
     ExpressionAST *template_argument = 0;
     if (parseTemplateArgument(template_argument)) {
         *template_argument_ptr = new (_pool) TemplateArgumentListAST;
-        (*template_argument_ptr)->template_argument = template_argument;
+        (*template_argument_ptr)->value = template_argument;
         template_argument_ptr = &(*template_argument_ptr)->next;
         while (LA() == T_COMMA) {
             consumeToken(); // consume T_COMMA
 
             if (parseTemplateArgument(template_argument)) {
                 *template_argument_ptr = new (_pool) TemplateArgumentListAST;
-                (*template_argument_ptr)->template_argument = template_argument;
+                (*template_argument_ptr)->value = template_argument;
                 template_argument_ptr = &(*template_argument_ptr)->next;
             }
         }
@@ -3365,8 +3365,8 @@ bool Parser::parseNameId(NameAST *&name)
     else if (LA() == T_LPAREN) {
         // a template-id followed by a T_LPAREN
         if (TemplateArgumentListAST *template_arguments = template_id->template_arguments) {
-            if (! template_arguments->next && template_arguments->template_argument &&
-                    template_arguments->template_argument->asBinaryExpression()) {
+            if (! template_arguments->next && template_arguments->value &&
+                    template_arguments->value->asBinaryExpression()) {
 
                 unsigned saved = cursor();
                 ExpressionAST *expr = 0;
-- 
GitLab