summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanny Ferreira2013-05-21 20:37:43 (EDT)
committer Sergey Prigogin2013-05-24 14:10:54 (EDT)
commit2740141e2e3fbf8a31a43bbd004ed7d5633d3e7c (patch)
treeb96c0f40d1a726cc7fc982507425c9922ae2ff07
parentecb373f340957bc9c382bea6f1868af11d70a96b (diff)
downloadorg.eclipse.cdt-2740141e2e3fbf8a31a43bbd004ed7d5633d3e7c.zip
org.eclipse.cdt-2740141e2e3fbf8a31a43bbd004ed7d5633d3e7c.tar.gz
org.eclipse.cdt-2740141e2e3fbf8a31a43bbd004ed7d5633d3e7c.tar.bz2
Bug 408314 - Failure of dependent base lookuprefs/changes/42/13042/4
Change-Id: Ib689ed08b14fedc88893b406a552df6adeb546f9 Reviewed-on: https://git.eclipse.org/r/13042 Reviewed-by: Sergey Prigogin <eclipse.sprigogin@gmail.com> IP-Clean: Sergey Prigogin <eclipse.sprigogin@gmail.com> Tested-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java64
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java32
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IRecursionResolvingBinding.java19
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNameBase.java3
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecialization.java3
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplatePartialSpecialization.java22
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplateSpecialization.java4
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownMember.java5
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java25
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java10
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java11
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java6
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassTemplatePartialSpecialization.java27
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassTemplatePartialSpecialization.java30
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassTemplatePartialSpecializationSpecialization.java2
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassTemplateSpecialization.java3
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java31
17 files changed, 185 insertions, 112 deletions
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java
index 77330a4..6286425 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java
@@ -13,6 +13,7 @@
* Sergey Prigogin (Google)
* Thomas Corbat (IFS)
* Nathan Ridge
+ * Danny Ferreira
*******************************************************************************/
package org.eclipse.cdt.core.parser.tests.ast2;
@@ -1968,7 +1969,8 @@ public class AST2TemplateTests extends AST2TestBase {
ITypedef myType = (ITypedef) col.getName(31).resolveBinding();
ICPPClassType A = (ICPPClassType) myType.getType();
- ICPPSpecialization Aspec = (ICPPSpecialization) col.getName(10).resolveBinding();
+ ICPPClassTemplatePartialSpecialization Aspec =
+ (ICPPClassTemplatePartialSpecialization) col.getName(10).resolveBinding();
assertTrue(A instanceof ICPPTemplateInstance);
assertSame(((ICPPTemplateInstance)A).getTemplateDefinition(), Aspec);
@@ -3224,7 +3226,67 @@ public class AST2TemplateTests extends AST2TestBase {
BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), CPP);
ba.assertNonProblem("foo(s", 3);
}
+
+ // template<typename U>
+ // struct result : U {
+ // typedef typename result::result_type type;
+ // };
+ //
+ // struct B {
+ // typedef int result_type;
+ // };
+ //
+ // typedef result<B>::type waldo;
+ public void testDependentBaseLookup_408314a() throws Exception {
+ BindingAssertionHelper bh = getAssertionHelper();
+ ITypedef waldo = bh.assertNonProblem("waldo");
+ assertSameType(waldo.getType(), CommonTypes.int_);
+ }
+
+ // template <typename T>
+ // struct A {
+ // template <typename U>
+ // struct result;
+ //
+ // template <typename V>
+ // struct result<V*> : T {
+ // typedef typename result::result_type type;
+ // };
+ // };
+ //
+ // struct B {
+ // typedef int result_type;
+ // };
+ //
+ // typedef A<B>::result<int*>::type waldo;
+ public void testDependentBaseLookup_408314b() throws Exception {
+ BindingAssertionHelper bh = getAssertionHelper();
+ ITypedef waldo = bh.assertNonProblem("waldo");
+ assertSameType(waldo.getType(), CommonTypes.int_);
+ }
+ // template <typename T>
+ // struct A {
+ // template <typename U>
+ // struct result;
+ //
+ // template <typename V>
+ // struct result<V*> : T {
+ // typedef typename result::result_type type;
+ // };
+ // };
+ //
+ // struct B {
+ // typedef int result_type;
+ // };
+ //
+ // typedef A<B>::result<B*>::type waldo;
+ public void testDependentBaseLookup_408314c() throws Exception {
+ BindingAssertionHelper bh = getAssertionHelper();
+ ITypedef waldo = bh.assertNonProblem("waldo");
+ assertSameType(waldo.getType(), CommonTypes.int_);
+ }
+
// template <class T>
// class A {
// public:
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java
index dd55f8f..5eb0bbe 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java
@@ -599,17 +599,14 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
IBinding b3= getBindingFromASTName("D<B", 1);
List spBindings= new ArrayList();
- assertInstance(b0, ICPPSpecialization.class);
- assertInstance(b0, ICPPClassTemplate.class);
- spBindings.add(((ICPPSpecialization)b0).getSpecializedBinding());
+ assertInstance(b0, ICPPClassTemplatePartialSpecialization.class);
+ spBindings.add(((ICPPClassTemplatePartialSpecialization)b0).getPrimaryClassTemplate());
- assertInstance(b1, ICPPSpecialization.class);
- assertInstance(b1, ICPPClassTemplate.class);
- spBindings.add(((ICPPSpecialization)b1).getSpecializedBinding());
+ assertInstance(b1, ICPPClassTemplatePartialSpecialization.class);
+ spBindings.add(((ICPPClassTemplatePartialSpecialization)b1).getPrimaryClassTemplate());
- assertInstance(b2, ICPPSpecialization.class);
- assertInstance(b2, ICPPClassTemplate.class);
- spBindings.add(((ICPPSpecialization)b2).getSpecializedBinding());
+ assertInstance(b2, ICPPClassTemplatePartialSpecialization.class);
+ spBindings.add(((ICPPClassTemplatePartialSpecialization)b2).getPrimaryClassTemplate());
for(int i=0; i<spBindings.size(); i++) {
for(int j=0; j<spBindings.size(); j++) {
@@ -2299,6 +2296,23 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
public void testADLForQualifiedName_408296() throws Exception {
checkBindings();
}
+
+ // template <typename>
+ // struct waldo {
+ // };
+ //
+ // struct outer {
+ // template <typename>
+ // struct inner;
+ // };
+ //
+ // template <typename T>
+ // struct outer::inner<waldo<T>> {};
+
+ // int main() {}
+ public void testRegression_408314() throws Exception {
+ checkBindings();
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IRecursionResolvingBinding.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IRecursionResolvingBinding.java
new file mode 100644
index 0000000..a0d4841
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/IRecursionResolvingBinding.java
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Nathan Ridge.
+ * 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
+ *
+ * Contributors:
+ * Nathan Ridge - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.dom.parser;
+
+import org.eclipse.cdt.core.dom.ast.IProblemBinding;
+
+/**
+ * Interface for problem bindings created to avoid infinite recursion.
+ */
+public interface IRecursionResolvingBinding extends IProblemBinding {
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNameBase.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNameBase.java
index 53bf884..ccf5847 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNameBase.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNameBase.java
@@ -23,6 +23,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.IASTInternalNameOwner;
+import org.eclipse.cdt.internal.core.dom.parser.IRecursionResolvingBinding;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
import org.eclipse.core.runtime.Assert;
@@ -40,7 +41,7 @@ public abstract class CPPASTNameBase extends ASTNode implements IASTName {
public static boolean sAllowNameComputation = true;
private static final byte MAX_RESOLUTION_DEPTH= 6;
- protected final static class RecursionResolvingBinding extends ProblemBinding {
+ protected final static class RecursionResolvingBinding extends ProblemBinding implements IRecursionResolvingBinding {
public RecursionResolvingBinding(IASTName node) {
super(node, IProblemBinding.SEMANTIC_RECURSION_IN_LOOKUP);
Assert.isTrue(sAllowRecursionBindings, getMessage());
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecialization.java
index 22376aa..ce9c7a1 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecialization.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecialization.java
@@ -44,6 +44,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.core.parser.util.ObjectMap;
+import org.eclipse.cdt.internal.core.dom.parser.IRecursionResolvingBinding;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
import org.eclipse.cdt.internal.core.dom.parser.ProblemFunctionType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
@@ -55,7 +56,7 @@ import org.eclipse.core.runtime.Assert;
public class CPPClassSpecialization extends CPPSpecialization
implements ICPPClassSpecialization, ICPPInternalClassTypeMixinHost {
- public static class RecursionResolvingBinding extends ProblemBinding implements ICPPMember {
+ public static class RecursionResolvingBinding extends ProblemBinding implements ICPPMember, IRecursionResolvingBinding {
public static RecursionResolvingBinding createFor(IBinding original, IASTNode point) {
if (original instanceof ICPPMethod)
return new RecursionResolvingMethod(point, original.getNameCharArray());
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplatePartialSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplatePartialSpecialization.java
index ca97cc3..066470d 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplatePartialSpecialization.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplatePartialSpecialization.java
@@ -13,25 +13,21 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
import org.eclipse.cdt.core.dom.ast.DOMException;
-import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
import org.eclipse.cdt.core.index.IIndexBinding;
-import org.eclipse.cdt.core.parser.util.ObjectMap;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
/**
* A partial class template specialization.
*/
public class CPPClassTemplatePartialSpecialization extends CPPClassTemplate
- implements ICPPClassTemplatePartialSpecialization, ICPPSpecialization {
+ implements ICPPClassTemplatePartialSpecialization {
private final ICPPTemplateArgument[] arguments;
@@ -55,28 +51,12 @@ public class CPPClassTemplatePartialSpecialization extends CPPClassTemplate
}
@Override
- public IBinding getSpecializedBinding() {
- return getPrimaryClassTemplate();
- }
-
- @Override
- public ICPPTemplateParameterMap getTemplateParameterMap() {
- return CPPTemplates.createParameterMap(getPrimaryClassTemplate(), getTemplateArguments());
- }
-
- @Override
public String toString() {
return super.toString() + ASTTypeUtil.getArgumentListString(getTemplateArguments(), true);
}
@Override
@Deprecated
- public ObjectMap getArgumentMap() {
- return CPPTemplates.getArgumentMap(getPrimaryClassTemplate(), getTemplateParameterMap());
- }
-
- @Override
- @Deprecated
public IType[] getArguments() throws DOMException {
return CPPTemplates.getArguments(getTemplateArguments());
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplateSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplateSpecialization.java
index 4bdd0ab..85b9aba 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplateSpecialization.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplateSpecialization.java
@@ -16,6 +16,7 @@ import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
@@ -47,8 +48,9 @@ public class CPPClassTemplateSpecialization extends CPPClassSpecialization
ICPPClassTemplate origTemplate= (ICPPClassTemplate) getSpecializedBinding();
ICPPClassTemplatePartialSpecialization[] orig = origTemplate.getPartialSpecializations();
ICPPClassTemplatePartialSpecialization[] spec = new ICPPClassTemplatePartialSpecialization[orig.length];
+ ICPPClassSpecialization owner = (ICPPClassSpecialization) getOwner();
for (int i = 0; i < orig.length; i++) {
- spec[i]= (ICPPClassTemplatePartialSpecialization) specializeMember(orig[i], point);
+ spec[i]= (ICPPClassTemplatePartialSpecialization) owner.specializeMember(orig[i], point);
}
fPartialSpecs = spec;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownMember.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownMember.java
index db6db9d..6f23c7b 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownMember.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownMember.java
@@ -14,10 +14,12 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IType;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.internal.core.dom.parser.ISerializableType;
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
import org.eclipse.cdt.internal.core.index.IIndexFragment;
import org.eclipse.cdt.internal.core.pdom.dom.cpp.PDOMCPPUnknownField;
import org.eclipse.cdt.internal.core.pdom.dom.cpp.PDOMCPPUnknownMemberClass;
@@ -32,6 +34,9 @@ public class CPPUnknownMember extends CPPUnknownBinding implements ICPPUnknownMe
protected CPPUnknownMember(IType owner, char[] name) {
super(name);
+ if (owner instanceof ICPPClassTemplate) {
+ owner= CPPTemplates.createDeferredInstance((ICPPClassTemplate) owner);
+ }
fOwner= owner;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java
index e7c5e70..c59ad4c 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java
@@ -184,6 +184,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguousDeclarator;
import org.eclipse.cdt.internal.core.dom.parser.IASTInternalScope;
+import org.eclipse.cdt.internal.core.dom.parser.IRecursionResolvingBinding;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
import org.eclipse.cdt.internal.core.dom.parser.Value;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTIdExpression;
@@ -1241,9 +1242,33 @@ public class CPPSemantics {
}
}
}
+
+ if (data.ignoreRecursionResolvingBindings()) {
+ bindings = filterOutRecursionResovingBindings(bindings);
+ }
+
return expandUsingDeclarationsAndRemoveObjects(bindings, data);
}
+ private static IBinding[] filterOutRecursionResovingBindings(IBinding[] bindings) {
+ IBinding[] result = bindings;
+ int resultIndex = 0;
+ for (int i = 0; i < bindings.length; ++i) {
+ if (bindings[i] instanceof IRecursionResolvingBinding) {
+ if (result == bindings) {
+ result = new IBinding[bindings.length - 1];
+ System.arraycopy(bindings, 0, result, 0, i);
+ }
+ } else {
+ if (result != bindings) {
+ result[resultIndex] = bindings[i];
+ }
+ ++resultIndex;
+ }
+ }
+ return ArrayUtil.trim(result);
+ }
+
private static IBinding[] expandUsingDeclarationsAndRemoveObjects(final IBinding[] bindings,
LookupData data) {
if (bindings == null || bindings.length == 0)
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java
index bf88ee2..a844d5c 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java
@@ -2638,15 +2638,7 @@ public class CPPTemplates {
}
if (changed) {
- IBinding inst= null;
- if (classTemplate instanceof ICPPClassTemplatePartialSpecialization) {
- try {
- inst= instantiatePartialSpecialization((ICPPClassTemplatePartialSpecialization) classTemplate, newArgs, false, null, point);
- } catch (DOMException e) {
- }
- } else {
- inst= instantiate(classTemplate, newArgs, point);
- }
+ IBinding inst= instantiate(classTemplate, newArgs, point);
if (inst != null)
return inst;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java
index 586e8f6..6769b58 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java
@@ -551,4 +551,15 @@ public class LookupData extends ScopeLookupData {
}
return IBinding.EMPTY_BINDING_ARRAY;
}
+
+ public boolean ignoreRecursionResolvingBindings() {
+ // When name lookup is performed during template instantiation
+ // rather than for an AST name, infinite recursion can sometimes
+ // result when a binding with a given name uses the same name
+ // in its definition (e.g. "typedef C::name name" where C is
+ // the current (template) class). In such cases, we want to
+ // ignore the resulting IRecursionResolvingBindings and allow
+ // name lookup to proceed to outer (or base class) scopes.
+ return getLookupName() == null;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java
index 4abe2b3..95753c0 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java
@@ -518,9 +518,7 @@ public class CPPCompositesFactory extends AbstractCompositeFactory {
}
} else if (binding instanceof ICPPTemplateDefinition) {
if (binding instanceof ICPPClassTemplatePartialSpecialization) {
- if (binding instanceof ICPPClassTemplatePartialSpecializationSpecialization)
- return new CompositeCPPClassTemplatePartialSpecializationSpecialization(this, (ICPPClassTemplatePartialSpecializationSpecialization) binding);
- return new CompositeCPPClassTemplatePartialSpecialization(this, (ICPPClassTemplatePartialSpecialization) findOneBinding(binding));
+ return new CompositeCPPClassTemplatePartialSpecializationSpecialization(this, (ICPPClassTemplatePartialSpecializationSpecialization) binding);
} else if (binding instanceof ICPPClassType) {
return new CompositeCPPClassTemplateSpecialization(this, (ICPPClassType) binding);
} else if (binding instanceof ICPPConstructor) {
@@ -557,6 +555,8 @@ public class CPPCompositesFactory extends AbstractCompositeFactory {
throw new CompositingNotImplementedError("Composite binding unavailable for " + binding + " " + binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$
}
}
+ } else if (binding instanceof ICPPClassTemplatePartialSpecialization) {
+ return new CompositeCPPClassTemplatePartialSpecialization(this, (ICPPClassTemplatePartialSpecialization) findOneBinding(binding));
} else if (binding instanceof ICPPTemplateParameter) {
if (binding instanceof ICPPTemplateTypeParameter) {
result = new CompositeCPPTemplateTypeParameter(this, (ICPPTemplateTypeParameter) binding);
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassTemplatePartialSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassTemplatePartialSpecialization.java
index 5420ca2..179a41f 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassTemplatePartialSpecialization.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassTemplatePartialSpecialization.java
@@ -11,21 +11,16 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.index.composite.cpp;
-import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
-import org.eclipse.cdt.core.parser.util.ObjectMap;
-import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateParameterMap;
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMOverloader;
import org.eclipse.core.runtime.CoreException;
-public class CompositeCPPClassTemplatePartialSpecialization extends CompositeCPPClassTemplate implements ICPPClassTemplatePartialSpecialization, ICPPSpecialization, IPDOMOverloader {
+public class CompositeCPPClassTemplatePartialSpecialization extends CompositeCPPClassTemplate implements ICPPClassTemplatePartialSpecialization, IPDOMOverloader {
public CompositeCPPClassTemplatePartialSpecialization(ICompositesFactory cf, ICPPClassTemplatePartialSpecialization delegate) {
super(cf, delegate);
}
@@ -37,37 +32,17 @@ public class CompositeCPPClassTemplatePartialSpecialization extends CompositeCPP
}
@Override
- public IBinding getSpecializedBinding() {
- return TemplateInstanceUtil.getSpecializedBinding(cf, rbinding);
- }
-
- @Override
public int getSignatureHash() throws CoreException {
return ((IPDOMOverloader) rbinding).getSignatureHash();
}
@Override
- public ICPPTemplateParameterMap getTemplateParameterMap() {
- IBinding owner= getOwner();
- if (owner instanceof ICPPSpecialization) {
- return ((ICPPSpecialization) owner).getTemplateParameterMap();
- }
- return CPPTemplateParameterMap.EMPTY;
- }
-
- @Override
public ICPPTemplateArgument[] getTemplateArguments() {
return TemplateInstanceUtil.getTemplateArguments(cf, (ICPPClassTemplatePartialSpecialization) rbinding);
}
@Override
@Deprecated
- public ObjectMap getArgumentMap() {
- return TemplateInstanceUtil.getArgumentMap(cf, rbinding);
- }
-
- @Override
- @Deprecated
public IType[] getArguments() {
return TemplateInstanceUtil.getArguments(cf, (ICPPClassTemplatePartialSpecialization) rbinding);
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassTemplatePartialSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassTemplatePartialSpecialization.java
index 4a7a9c4..1536bd3 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassTemplatePartialSpecialization.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassTemplatePartialSpecialization.java
@@ -13,16 +13,11 @@ package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.DOMException;
-import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
-import org.eclipse.cdt.core.parser.util.ObjectMap;
import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassTemplatePartialSpecialization;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
@@ -39,7 +34,7 @@ import org.eclipse.core.runtime.CoreException;
* Partial specialization of a class template for the index.
*/
class PDOMCPPClassTemplatePartialSpecialization extends PDOMCPPClassTemplate
- implements IPDOMPartialSpecialization, ICPPSpecialization, IPDOMOverloader {
+ implements IPDOMPartialSpecialization, IPDOMOverloader {
private static final int ARGUMENTS = PDOMCPPClassTemplate.RECORD_SIZE + 0;
private static final int SIGNATURE_HASH = PDOMCPPClassTemplate.RECORD_SIZE + 4;
private static final int PRIMARY = PDOMCPPClassTemplate.RECORD_SIZE + 8;
@@ -108,11 +103,6 @@ class PDOMCPPClassTemplatePartialSpecialization extends PDOMCPPClassTemplate
}
@Override
- public IBinding getSpecializedBinding() {
- return getPrimaryClassTemplate();
- }
-
- @Override
public void setArguments(ICPPTemplateArgument[] templateArguments) throws CoreException {
final Database db = getPDOM().getDB();
long oldRec = db.getRecPtr(record + ARGUMENTS);
@@ -161,11 +151,6 @@ class PDOMCPPClassTemplatePartialSpecialization extends PDOMCPPClassTemplate
}
@Override
- public ICPPTemplateParameterMap getTemplateParameterMap() {
- return CPPTemplates.createParameterMap(getPrimaryClassTemplate(), getTemplateArguments());
- }
-
- @Override
public boolean isSameType(IType type) {
if (type instanceof ITypedef) {
return type.isSameType(this);
@@ -185,17 +170,4 @@ class PDOMCPPClassTemplatePartialSpecialization extends PDOMCPPClassTemplate
final ICPPClassTemplatePartialSpecialization rhs = (ICPPClassTemplatePartialSpecialization)type;
return CPPClassTemplatePartialSpecialization.isSamePartialClassSpecialization(this, rhs);
}
-
- @Override
- @Deprecated
- public ObjectMap getArgumentMap() {
- ICPPTemplateParameter[] params = getPrimaryClassTemplate().getTemplateParameters();
- ICPPTemplateArgument[] args= getTemplateArguments();
- int len= Math.min(params.length, args.length);
- ObjectMap result= new ObjectMap(len);
- for (int i = 0; i < len; i++) {
- result.put(params[i], args[i]);
- }
- return ObjectMap.EMPTY_MAP;
- }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassTemplatePartialSpecializationSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassTemplatePartialSpecializationSpecialization.java
index e5b72e3..ed8a17e 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassTemplatePartialSpecializationSpecialization.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassTemplatePartialSpecializationSpecialization.java
@@ -103,7 +103,7 @@ class PDOMCPPClassTemplatePartialSpecializationSpecialization extends PDOMCPPCla
public ICPPClassTemplate getPrimaryClassTemplate() {
if (fPrimaryTemplate == null) {
try {
- int specializedRec = getDB().getInt(record + PRIMARY_TEMPLATE);
+ long specializedRec = getDB().getRecPtr(record + PRIMARY_TEMPLATE);
fPrimaryTemplate= (ICPPClassTemplate) getLinkage().getNode(specializedRec);
} catch (CoreException e) {
CCorePlugin.log(e);
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassTemplateSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassTemplateSpecialization.java
index fd10f16..33a1d50 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassTemplateSpecialization.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassTemplateSpecialization.java
@@ -161,8 +161,9 @@ class PDOMCPPClassTemplateSpecialization extends PDOMCPPClassSpecialization
ICPPClassTemplate origTemplate= (ICPPClassTemplate) getSpecializedBinding();
ICPPClassTemplatePartialSpecialization[] orig = origTemplate.getPartialSpecializations();
ICPPClassTemplatePartialSpecialization[] spec = new ICPPClassTemplatePartialSpecialization[orig.length];
+ ICPPClassSpecialization owner = (ICPPClassSpecialization) getOwner();
for (int i = 0; i < orig.length; i++) {
- spec[i]= (ICPPClassTemplatePartialSpecialization) specializeMember(orig[i], point);
+ spec[i]= (ICPPClassTemplatePartialSpecialization) owner.specializeMember(orig[i], point);
}
return spec;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java
index d03f2a4..9dbfb06 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java
@@ -46,7 +46,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecializationSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPEnumeration;
@@ -435,6 +434,13 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
return null;
pdomBinding = createSpecialization(parent, pdomSpecialized, binding);
+ } else if (binding instanceof ICPPClassTemplatePartialSpecialization) {
+ ICPPClassTemplate primary = ((ICPPClassTemplatePartialSpecialization) binding).getPrimaryClassTemplate();
+ PDOMBinding pdomPrimary = addBinding(primary, null);
+ if (pdomPrimary instanceof PDOMCPPClassTemplate) {
+ pdomBinding = new PDOMCPPClassTemplatePartialSpecialization(
+ this, parent, (ICPPClassTemplatePartialSpecialization) binding, (PDOMCPPClassTemplate) pdomPrimary);
+ }
} else if (binding instanceof ICPPField) {
if (parent instanceof PDOMCPPClassType || parent instanceof PDOMCPPClassSpecialization) {
pdomBinding = new PDOMCPPField(this, parent, (ICPPField) binding);
@@ -509,6 +515,10 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
while (binding instanceof ICPPSpecialization) {
binding = ((ICPPSpecialization) binding).getSpecializedBinding();
}
+ if (binding instanceof ICPPClassTemplatePartialSpecialization) {
+ // A class template partial specialization inherits the visibility of its primary class template.
+ binding = ((ICPPClassTemplatePartialSpecialization) binding).getPrimaryClassTemplate();
+ }
if (binding instanceof CPPImplicitMethod)
return ICPPClassType.v_public;
@@ -559,11 +569,6 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
} else if (special instanceof ICPPClassType && orig instanceof ICPPClassType) {
result= new PDOMCPPClassInstance(this, parent, (ICPPClassType) special, orig);
}
- } else if (special instanceof ICPPClassTemplatePartialSpecialization) {
- if (orig instanceof PDOMCPPClassTemplate) {
- result= new PDOMCPPClassTemplatePartialSpecialization(
- this, parent, (ICPPClassTemplatePartialSpecialization) special, (PDOMCPPClassTemplate) orig);
- }
} else if (special instanceof ICPPField) {
result= new PDOMCPPFieldSpecialization(this, parent, (ICPPField) special, orig);
} else if (special instanceof ICPPFunctionTemplate) {
@@ -574,6 +579,14 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
} else if (special instanceof ICPPFunction) {
result= new PDOMCPPFunctionTemplateSpecialization(this, parent, (ICPPFunctionTemplate) special, orig);
}
+ } else if (special instanceof ICPPClassTemplatePartialSpecialization) {
+ ICPPClassTemplatePartialSpecialization partialSpecSpec = (ICPPClassTemplatePartialSpecialization) special;
+ ICPPClassTemplate primarySpec = partialSpecSpec.getPrimaryClassTemplate();
+ PDOMBinding pdomPrimarySpec = addBinding(primarySpec, null);
+ if (pdomPrimarySpec instanceof PDOMCPPClassTemplateSpecialization) {
+ result= new PDOMCPPClassTemplatePartialSpecializationSpecialization(this, parent, orig,
+ partialSpecSpec, (PDOMCPPClassTemplateSpecialization) pdomPrimarySpec);
+ }
} else if (special instanceof ICPPConstructor) {
result= new PDOMCPPConstructorSpecialization(this, parent, (ICPPConstructor) special, orig);
} else if (special instanceof ICPPMethod) {
@@ -649,9 +662,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
return CPP_CLASS_INSTANCE;
}
} else if (binding instanceof ICPPClassTemplatePartialSpecialization) {
- if (binding instanceof ICPPClassTemplatePartialSpecializationSpecialization)
- return CPP_CLASS_TEMPLATE_PARTIAL_SPEC_SPEC;
- return CPP_CLASS_TEMPLATE_PARTIAL_SPEC;
+ return CPP_CLASS_TEMPLATE_PARTIAL_SPEC_SPEC;
} else if (binding instanceof ICPPField) {
return CPP_FIELD_SPECIALIZATION;
} else if (binding instanceof ICPPFunctionTemplate) {
@@ -675,6 +686,8 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
} else if (binding instanceof ITypedef) {
return CPP_TYPEDEF_SPECIALIZATION;
}
+ } else if (binding instanceof ICPPClassTemplatePartialSpecialization) {
+ return CPP_CLASS_TEMPLATE_PARTIAL_SPEC;
} else if (binding instanceof ICPPTemplateParameter) {
if (binding instanceof ICPPTemplateTypeParameter) {
return CPP_TEMPLATE_TYPE_PARAMETER;