Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHannes Vogt2018-10-13 18:38:11 -0400
committerNathan Ridge2018-10-31 01:21:26 -0400
commitb33ebe2ee6e4603fa12033d954cd46d6122a2547 (patch)
tree6bbb4890ec4e5e2a7bf5f6deb5a770f162357168 /core/org.eclipse.cdt.core/parser/org
parent652602febd59f4c99d5edbead2f539bef7414fdc (diff)
downloadorg.eclipse.cdt-b33ebe2ee6e4603fa12033d954cd46d6122a2547.tar.gz
org.eclipse.cdt-b33ebe2ee6e4603fa12033d954cd46d6122a2547.tar.xz
org.eclipse.cdt-b33ebe2ee6e4603fa12033d954cd46d6122a2547.zip
Bug 540450 - Parsing dependent template name
Parse dependent template names as type. Change-Id: I35461b2e4a615f34749e6ff17b2a85406ec2cf12 Signed-off-by: Hannes Vogt <hannes@havogt.de>
Diffstat (limited to 'core/org.eclipse.cdt.core/parser/org')
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTemplateName.java21
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPNodeFactory.java5
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateName.java35
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNodeFactory.java6
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java19
5 files changed, 81 insertions, 5 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTemplateName.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTemplateName.java
new file mode 100644
index 0000000000..c26d13182c
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTemplateName.java
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2018
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.eclipse.cdt.core.dom.ast.cpp;
+
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTName;
+
+/**
+ * This interface represents template names which use the template disambiguator
+ * keyword.
+ *
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @noextend This interface is not intended to be extended by clients.
+ * @since 9.6
+ */
+public interface ICPPASTTemplateName extends ICPPASTName {
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPNodeFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPNodeFactory.java
index 132d0a9b4a..d81bed2e74 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPNodeFactory.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPNodeFactory.java
@@ -305,6 +305,11 @@ public interface ICPPNodeFactory extends INodeFactory {
public ICPPASTName newName(String name);
/**
+ * @since 9.6
+ */
+ public ICPPASTTemplateName newTemplateName(char[] templateName);
+
+ /**
* @since 5.11
*/
public ICPPASTNamedTypeSpecifier newNamedTypeSpecifier(IASTName name);
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateName.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateName.java
new file mode 100644
index 0000000000..2b6a5b5934
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateName.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2018
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.dom.parser.cpp;
+
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateName;
+
+/**
+ * Represents a template name.
+ */
+public class CPPASTTemplateName extends CPPASTName implements ICPPASTTemplateName {
+ public CPPASTTemplateName(char[] name) {
+ super(name);
+ }
+
+ public CPPASTTemplateName() {
+ super();
+ }
+
+ @Override
+ public CPPASTTemplateName copy() {
+ return copy(CopyStyle.withoutLocations);
+ }
+
+ @Override
+ public CPPASTTemplateName copy(CopyStyle style) {
+ CPPASTTemplateName copy = new CPPASTTemplateName(
+ toCharArray() == null ? null : toCharArray().clone());
+ return copy(copy, style);
+ }
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNodeFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNodeFactory.java
index 834f34a25c..11498eba58 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNodeFactory.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNodeFactory.java
@@ -65,6 +65,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTBinaryExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCapture;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCastExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCatchHandler;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTClassVirtSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
@@ -584,6 +585,11 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
}
@Override
+ public ICPPASTTemplateName newTemplateName(char[] templateName) {
+ return new CPPASTTemplateName(templateName);
+ }
+
+ @Override
public ICPPASTNamedTypeSpecifier newNamedTypeSpecifier(IASTName name) {
return new CPPASTNamedTypeSpecifier(name);
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java
index b330ed8b6f..08ea653ca0 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java
@@ -81,6 +81,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAttributeList;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCapture;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCastExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCatchHandler;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTClassVirtSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
@@ -269,7 +270,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
case IToken.tIDENTIFIER:
case IToken.tCOMPLETION:
case IToken.tEOC:
- return buildName(-1, consume());
+ return buildName(-1, consume(), false);
}
throw backtrack;
@@ -335,7 +336,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
case IToken.tCOMPLETION:
case IToken.tEOC:
IToken nt= consume();
- nameSpec = (ICPPASTName) buildName(destructorOffset, nt);
+ nameSpec = (ICPPASTName) buildName(destructorOffset, nt, keywordTemplate);
break;
case IToken.t_operator:
@@ -436,10 +437,14 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
qname.addNameSpecifier(nameSpec);
}
- private IASTName buildName(int destructorOffset, IToken nt) {
+ private IASTName buildName(int destructorOffset, IToken nt, boolean keywordTemplate) {
IASTName name;
if (destructorOffset < 0) {
- name= getNodeFactory().newName(nt.getCharImage());
+ if (keywordTemplate) {
+ name= getNodeFactory().newTemplateName(nt.getCharImage());
+ } else {
+ name= getNodeFactory().newName(nt.getCharImage());
+ }
setRange(name, nt.getOffset(), nt.getEndOffset());
} else {
char[] nchars= nt.getCharImage();
@@ -2266,7 +2271,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
private IASTDeclaration aliasDeclaration(final int offset) throws EndOfFileException,
BacktrackException {
IToken identifierToken = consume();
- IASTName aliasName = buildName(-1, identifierToken);
+ IASTName aliasName = buildName(-1, identifierToken, false);
List<IASTAttributeSpecifier> attributes = attributeSpecifierSeq();
@@ -3439,6 +3444,10 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
if (identifier.getLookupKey().length == 0 && LT(1) != IToken.tEOC)
throwBacktrack(LA(1));
+ if (identifier.getLastName() instanceof ICPPASTTemplateName) {
+ isTypename = true;
+ }
+
endOffset= calculateEndOffset(identifier);
encounteredTypename= true;
break;

Back to the top