mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 299911. Added logging of methods that loose template instantiation
context.
This commit is contained in:
parent
dd039973ae
commit
f122365484
45 changed files with 577 additions and 365 deletions
|
@ -188,7 +188,7 @@ public class AbstractClassInstantiationChecker extends AbstractIndexAstChecker {
|
|||
* Checks whether specified type (class or typedef to the class) is an abstract class.
|
||||
* If it is, reports violations on each pure virtual method
|
||||
*/
|
||||
private void reportProblemsIfAbstract(IType typeToCheck, IASTNode problemNode ) {
|
||||
private void reportProblemsIfAbstract(IType typeToCheck, IASTNode problemNode) {
|
||||
IType unwindedType = CxxAstUtils.unwindTypedef(typeToCheck);
|
||||
if (!(unwindedType instanceof ICPPClassType) || unwindedType instanceof IProblemBinding) {
|
||||
return;
|
||||
|
@ -196,7 +196,7 @@ public class AbstractClassInstantiationChecker extends AbstractIndexAstChecker {
|
|||
ICPPClassType classType = (ICPPClassType) unwindedType;
|
||||
ICPPMethod[] pureVirtualMethods = pureVirtualMethodsCache.get(classType);
|
||||
if (pureVirtualMethods == null) {
|
||||
pureVirtualMethods = ClassTypeHelper.getPureVirtualMethods(classType);
|
||||
pureVirtualMethods = ClassTypeHelper.getPureVirtualMethods(classType, problemNode);
|
||||
pureVirtualMethodsCache.put(classType, pureVirtualMethods);
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisibilityLabel;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding;
|
||||
|
||||
/**
|
||||
|
@ -46,8 +47,8 @@ public class NonVirtualDestructor extends AbstractIndexAstChecker {
|
|||
ast.accept(new OnEachClass());
|
||||
}
|
||||
|
||||
private static ICPPMethod getDestructor(ICPPClassType classType) {
|
||||
for (ICPPMethod method : classType.getDeclaredMethods()) {
|
||||
private static ICPPMethod getDestructor(ICPPClassType classType, IASTNode point) {
|
||||
for (ICPPMethod method : ClassTypeHelper.getDeclaredMethods(classType, point)) {
|
||||
if (method.isDestructor()) {
|
||||
return method;
|
||||
}
|
||||
|
@ -55,18 +56,18 @@ public class NonVirtualDestructor extends AbstractIndexAstChecker {
|
|||
return null;
|
||||
}
|
||||
|
||||
private static boolean hasVirtualDestructor(ICPPClassType classType) {
|
||||
private static boolean hasVirtualDestructor(ICPPClassType classType, IASTNode point) {
|
||||
checkedClassTypes.add(classType);
|
||||
ICPPMethod destructor = getDestructor(classType);
|
||||
ICPPMethod destructor = getDestructor(classType, point);
|
||||
if (destructor != null && destructor.isVirtual()) {
|
||||
return true;
|
||||
}
|
||||
ICPPBase[] bases = classType.getBases();
|
||||
ICPPBase[] bases = ClassTypeHelper.getBases(classType, point);
|
||||
for (ICPPBase base : bases) {
|
||||
IBinding baseClass = base.getBaseClass();
|
||||
if (baseClass instanceof ICPPClassType) {
|
||||
ICPPClassType cppClassType = (ICPPClassType) baseClass;
|
||||
if (!checkedClassTypes.contains(cppClassType) && hasVirtualDestructor(cppClassType)) {
|
||||
if (!checkedClassTypes.contains(cppClassType) && hasVirtualDestructor(cppClassType, point)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -89,13 +90,13 @@ public class NonVirtualDestructor extends AbstractIndexAstChecker {
|
|||
return PROCESS_SKIP;
|
||||
}
|
||||
ICPPClassType classType = (ICPPClassType) binding;
|
||||
boolean hasVirtualDestructor = hasVirtualDestructor(classType);
|
||||
boolean hasVirtualDestructor = hasVirtualDestructor(classType, className);
|
||||
checkedClassTypes.clear();
|
||||
if (hasVirtualDestructor) {
|
||||
return PROCESS_SKIP;
|
||||
}
|
||||
ICPPMethod virtualMethod = null;
|
||||
for (ICPPMethod method : classType.getAllDeclaredMethods()) {
|
||||
for (ICPPMethod method : ClassTypeHelper.getAllDeclaredMethods(classType, className)) {
|
||||
if (!method.isDestructor() && method.isVirtual()) {
|
||||
virtualMethod = method;
|
||||
}
|
||||
|
@ -103,7 +104,7 @@ public class NonVirtualDestructor extends AbstractIndexAstChecker {
|
|||
if (virtualMethod == null) {
|
||||
return PROCESS_SKIP;
|
||||
}
|
||||
ICPPMethod destructor = getDestructor(classType);
|
||||
ICPPMethod destructor = getDestructor(classType, className);
|
||||
if (destructor != null &&
|
||||
destructor.getVisibility() != ICPPASTVisibilityLabel.v_public &&
|
||||
classType.getFriends().length == 0) {
|
||||
|
|
|
@ -6252,20 +6252,20 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
assertFalse(ClassTypeHelper.isOverrider(m5, m2));
|
||||
assertTrue(ClassTypeHelper.isOverrider(m4, m2));
|
||||
|
||||
ICPPMethod[] ors= ClassTypeHelper.findOverridden(m0);
|
||||
ICPPMethod[] ors= ClassTypeHelper.findOverridden(m0, null);
|
||||
assertEquals(0, ors.length);
|
||||
ors= ClassTypeHelper.findOverridden(m1);
|
||||
ors= ClassTypeHelper.findOverridden(m1, null);
|
||||
assertEquals(0, ors.length);
|
||||
ors= ClassTypeHelper.findOverridden(m2);
|
||||
ors= ClassTypeHelper.findOverridden(m2, null);
|
||||
assertEquals(1, ors.length);
|
||||
assertSame(ors[0], m1);
|
||||
ors= ClassTypeHelper.findOverridden(m3);
|
||||
ors= ClassTypeHelper.findOverridden(m3, null);
|
||||
assertEquals(0, ors.length);
|
||||
ors= ClassTypeHelper.findOverridden(m4);
|
||||
ors= ClassTypeHelper.findOverridden(m4, null);
|
||||
assertEquals(2, ors.length);
|
||||
assertSame(ors[0], m2);
|
||||
assertSame(ors[1], m1);
|
||||
ors= ClassTypeHelper.findOverridden(m5);
|
||||
ors= ClassTypeHelper.findOverridden(m5, null);
|
||||
assertEquals(1, ors.length);
|
||||
assertSame(ors[0], m1);
|
||||
}
|
||||
|
@ -8732,14 +8732,14 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
assertFalse(ClassTypeHelper.isOverrider(m3, m0));
|
||||
assertFalse(ClassTypeHelper.isOverrider(m3, m1));
|
||||
|
||||
ICPPMethod[] ors= ClassTypeHelper.findOverridden(m0);
|
||||
ICPPMethod[] ors= ClassTypeHelper.findOverridden(m0, null);
|
||||
assertEquals(0, ors.length);
|
||||
ors= ClassTypeHelper.findOverridden(m1);
|
||||
ors= ClassTypeHelper.findOverridden(m1, null);
|
||||
assertEquals(0, ors.length);
|
||||
ors= ClassTypeHelper.findOverridden(m2);
|
||||
ors= ClassTypeHelper.findOverridden(m2, null);
|
||||
assertEquals(1, ors.length);
|
||||
assertSame(ors[0], m0);
|
||||
ors= ClassTypeHelper.findOverridden(m3);
|
||||
ors= ClassTypeHelper.findOverridden(m3, null);
|
||||
assertEquals(0, ors.length);
|
||||
}
|
||||
|
||||
|
@ -9546,7 +9546,7 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
public void testRecursiveClassInheritance_Bug357256() throws Exception {
|
||||
BindingAssertionHelper bh= getAssertionHelper();
|
||||
ICPPClassType c= bh.assertNonProblem("A", 1);
|
||||
assertEquals(0, ClassTypeHelper.getPureVirtualMethods(c).length);
|
||||
assertEquals(0, ClassTypeHelper.getPureVirtualMethods(c, null).length);
|
||||
}
|
||||
|
||||
// template <typename T> struct CT1 {};
|
||||
|
|
|
@ -85,6 +85,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
|
|||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNameBase;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknownScope;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
||||
|
@ -1907,7 +1908,7 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
ICPPClassType B = (ICPPClassType) col.getName(3).resolveBinding();
|
||||
ICPPClassType A = (ICPPClassType) col.getName(6).resolveBinding();
|
||||
|
||||
ICPPBase[] bases = A.getBases();
|
||||
ICPPBase[] bases = ClassTypeHelper.getBases(A, tu);
|
||||
assertEquals(bases.length, 1);
|
||||
assertSame(bases[0].getBaseClass(), B);
|
||||
}
|
||||
|
@ -4368,19 +4369,19 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
BindingAssertionHelper bh= new BindingAssertionHelper(code, CPP);
|
||||
|
||||
ICPPClassType type= bh.assertNonProblem("X<int&>", 7);
|
||||
ICPPMethod[] ms= type.getMethods();
|
||||
ICPPMethod[] ms= ClassTypeHelper.getMethods(type, null);
|
||||
int i= ms[0].getName().equals("f") ? 0 : 1;
|
||||
ICPPMethod m= ms[i];
|
||||
assertEquals("int &", ASTTypeUtil.getType(m.getType().getParameterTypes()[0]));
|
||||
m= ms[1-i];
|
||||
m= ms[1 - i];
|
||||
assertEquals("int &", ASTTypeUtil.getType(m.getType().getParameterTypes()[0]));
|
||||
|
||||
type= bh.assertNonProblem("X<const int&&>", 14);
|
||||
ms= type.getMethods();
|
||||
ms= ClassTypeHelper.getMethods(type, null);
|
||||
i= ms[0].getName().equals("f") ? 0 : 1;
|
||||
m= ms[i];
|
||||
assertEquals("const int &", ASTTypeUtil.getType(m.getType().getParameterTypes()[0]));
|
||||
m= ms[1-i];
|
||||
m= ms[1 - i];
|
||||
assertEquals("const int &&", ASTTypeUtil.getType(m.getType().getParameterTypes()[0]));
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,9 @@ import org.eclipse.cdt.core.index.IIndexMacro;
|
|||
import org.eclipse.cdt.core.index.IndexFilter;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateTypeArgument;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInstanceCache;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
|
@ -229,7 +231,7 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
|
|||
ICPPSpecialization inst= ct.getInstance(new ICPPTemplateArgument[]{new CPPTemplateTypeArgument((IType)b0)});
|
||||
assertInstance(inst, ICPPClassType.class);
|
||||
ICPPClassType c2t= (ICPPClassType) inst;
|
||||
ICPPBase[] bases= c2t.getBases();
|
||||
ICPPBase[] bases= ClassTypeHelper.getBases(c2t, null);
|
||||
assertEquals(1, bases.length);
|
||||
assertInstance(bases[0].getBaseClass(), ICPPClassType.class);
|
||||
}
|
||||
|
@ -998,74 +1000,74 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
|
|||
// class template instance
|
||||
ct= getBindingFromASTName("CT<int>", 7);
|
||||
assertInstance(ct, ICPPTemplateInstance.class);
|
||||
assertBindings(new String[] {"B"}, ct.getBases());
|
||||
assertBindings(new String[] {"n", "m", "B", "CT"}, ct.getAllDeclaredMethods());
|
||||
assertBindings(new String[] {"CT", "CT"}, ct.getConstructors());
|
||||
assertBindings(new String[] {"g"}, ct.getDeclaredFields());
|
||||
assertBindings(new String[] {"n", "CT"}, ct.getDeclaredMethods());
|
||||
assertBindings(new String[] {"f", "g"}, ct.getFields());
|
||||
assertBindings(new String[] {"m", "n", "CT", "CT", "~CT", "B", "B", "~B", "operator =", "operator ="}, ct.getMethods());
|
||||
assertBindings(new String[] {"O"}, ct.getNestedClasses());
|
||||
assertBindings(new String[] {"B"}, ClassTypeHelper.getBases(ct, null));
|
||||
assertBindings(new String[] {"n", "m", "B", "CT"}, ClassTypeHelper.getAllDeclaredMethods(ct, null));
|
||||
assertBindings(new String[] {"CT", "CT"}, ClassTypeHelper.getConstructors(ct, null));
|
||||
assertBindings(new String[] {"g"}, ClassTypeHelper.getDeclaredFields(ct, null));
|
||||
assertBindings(new String[] {"n", "CT"}, ClassTypeHelper.getDeclaredMethods(ct, null));
|
||||
assertBindings(new String[] {"f", "g"}, ClassTypeHelper.getFields(ct, null));
|
||||
assertBindings(new String[] {"m", "n", "CT", "CT", "~CT", "B", "B", "~B", "operator =", "operator ="}, ClassTypeHelper.getMethods(ct, null));
|
||||
assertBindings(new String[] {"O"}, ClassTypeHelper.getNestedClasses(ct, null));
|
||||
|
||||
// explicit class template instance
|
||||
ct= getBindingFromASTName("CT<char>", 8);
|
||||
assertInstance(ct, ICPPTemplateInstance.class);
|
||||
assertBindings(new String[] {"A"}, ct.getBases());
|
||||
assertBindings(new String[] {"o", "l", "A", "CT", "CT"}, ct.getAllDeclaredMethods());
|
||||
assertBindings(new String[] {"CT", "CT", "CT"}, ct.getConstructors());
|
||||
assertBindings(new String[] {"h"}, ct.getDeclaredFields());
|
||||
assertBindings(new String[] {"o", "CT", "CT"}, ct.getDeclaredMethods());
|
||||
assertBindings(new String[] {"e", "h"}, ct.getFields());
|
||||
assertBindings(new String[] {"l", "o", "CT", "CT", "CT", "~CT", "A", "A", "~A", "operator =", "operator ="}, ct.getMethods());
|
||||
assertBindings(new String[] {"P"}, ct.getNestedClasses());
|
||||
assertBindings(new String[] {"A"}, ClassTypeHelper.getBases(ct, null));
|
||||
assertBindings(new String[] {"o", "l", "A", "CT", "CT"}, ClassTypeHelper.getAllDeclaredMethods(ct, null));
|
||||
assertBindings(new String[] {"CT", "CT", "CT"}, ClassTypeHelper.getConstructors(ct, null));
|
||||
assertBindings(new String[] {"h"}, ClassTypeHelper.getDeclaredFields(ct, null));
|
||||
assertBindings(new String[] {"o", "CT", "CT"}, ClassTypeHelper.getDeclaredMethods(ct, null));
|
||||
assertBindings(new String[] {"e", "h"}, ClassTypeHelper.getFields(ct, null));
|
||||
assertBindings(new String[] {"l", "o", "CT", "CT", "CT", "~CT", "A", "A", "~A", "operator =", "operator ="}, ClassTypeHelper.getMethods(ct, null));
|
||||
assertBindings(new String[] {"P"}, ClassTypeHelper.getNestedClasses(ct, null));
|
||||
|
||||
// class specialization
|
||||
ct= getBindingFromASTName("C spec", 1);
|
||||
assertInstance(ct, ICPPClassSpecialization.class);
|
||||
assertBindings(new String[] {"B"}, ct.getBases());
|
||||
assertBindings(new String[] {"n", "m", "B", "C"}, ct.getAllDeclaredMethods());
|
||||
assertBindings(new String[] {"C", "C"}, ct.getConstructors());
|
||||
assertBindings(new String[] {"g"}, ct.getDeclaredFields());
|
||||
assertBindings(new String[] {"n", "C"}, ct.getDeclaredMethods());
|
||||
assertBindings(new String[] {"f", "g"}, ct.getFields());
|
||||
assertBindings(new String[] {"m", "n", "C", "C", "~C", "B", "B", "~B", "operator =", "operator ="}, ct.getMethods());
|
||||
assertBindings(new String[] {"O"}, ct.getNestedClasses());
|
||||
assertBindings(new String[] {"B"}, ClassTypeHelper.getBases(ct, null));
|
||||
assertBindings(new String[] {"n", "m", "B", "C"}, ClassTypeHelper.getAllDeclaredMethods(ct, null));
|
||||
assertBindings(new String[] {"C", "C"}, ClassTypeHelper.getConstructors(ct, null));
|
||||
assertBindings(new String[] {"g"}, ClassTypeHelper.getDeclaredFields(ct, null));
|
||||
assertBindings(new String[] {"n", "C"}, ClassTypeHelper.getDeclaredMethods(ct, null));
|
||||
assertBindings(new String[] {"f", "g"}, ClassTypeHelper.getFields(ct, null));
|
||||
assertBindings(new String[] {"m", "n", "C", "C", "~C", "B", "B", "~B", "operator =", "operator ="}, ClassTypeHelper.getMethods(ct, null));
|
||||
assertBindings(new String[] {"O"}, ClassTypeHelper.getNestedClasses(ct, null));
|
||||
|
||||
// class template specialization
|
||||
ct= getBindingFromASTName("CT<int> spect", 2);
|
||||
assertInstance(ct, ICPPClassTemplate.class, ICPPClassSpecialization.class);
|
||||
assertBindings(new String[] {"B"}, ct.getBases());
|
||||
assertBindings(new String[] {"n", "m", "B", "CT"}, ct.getAllDeclaredMethods());
|
||||
assertBindings(new String[] {"CT", "CT"}, ct.getConstructors());
|
||||
assertBindings(new String[] {"g"}, ct.getDeclaredFields());
|
||||
assertBindings(new String[] {"n", "CT"}, ct.getDeclaredMethods());
|
||||
assertBindings(new String[] {"f", "g"}, ct.getFields());
|
||||
assertBindings(new String[] {"m", "n", "CT", "CT", "~CT", "B", "B", "~B", "operator =", "operator ="}, ct.getMethods());
|
||||
assertBindings(new String[] {"O"}, ct.getNestedClasses());
|
||||
assertBindings(new String[] {"B"}, ClassTypeHelper.getBases(ct, null));
|
||||
assertBindings(new String[] {"n", "m", "B", "CT"}, ClassTypeHelper.getAllDeclaredMethods(ct, null));
|
||||
assertBindings(new String[] {"CT", "CT"}, ClassTypeHelper.getConstructors(ct, null));
|
||||
assertBindings(new String[] {"g"}, ClassTypeHelper.getDeclaredFields(ct, null));
|
||||
assertBindings(new String[] {"n", "CT"}, ClassTypeHelper.getDeclaredMethods(ct, null));
|
||||
assertBindings(new String[] {"f", "g"}, ClassTypeHelper.getFields(ct, null));
|
||||
assertBindings(new String[] {"m", "n", "CT", "CT", "~CT", "B", "B", "~B", "operator =", "operator ="}, ClassTypeHelper.getMethods(ct, null));
|
||||
assertBindings(new String[] {"O"}, ClassTypeHelper.getNestedClasses(ct, null));
|
||||
|
||||
// explicit class specialization
|
||||
ct= getBindingFromASTName("C espec", 1);
|
||||
assertInstance(ct, ICPPClassSpecialization.class);
|
||||
assertBindings(new String[] {"A"}, ct.getBases());
|
||||
assertBindings(new String[] {"o", "l", "A", "C", "C"}, ct.getAllDeclaredMethods());
|
||||
assertBindings(new String[] {"C", "C", "C"}, ct.getConstructors());
|
||||
assertBindings(new String[] {"h"}, ct.getDeclaredFields());
|
||||
assertBindings(new String[] {"o", "C", "C"}, ct.getDeclaredMethods());
|
||||
assertBindings(new String[] {"e", "h"}, ct.getFields());
|
||||
assertBindings(new String[] {"l", "o", "C", "C", "C", "~C", "A", "A", "~A", "operator =", "operator ="}, ct.getMethods());
|
||||
assertBindings(new String[] {"P"}, ct.getNestedClasses());
|
||||
assertBindings(new String[] {"A"}, ClassTypeHelper.getBases(ct, null));
|
||||
assertBindings(new String[] {"o", "l", "A", "C", "C"}, ClassTypeHelper.getAllDeclaredMethods(ct, null));
|
||||
assertBindings(new String[] {"C", "C", "C"}, ClassTypeHelper.getConstructors(ct, null));
|
||||
assertBindings(new String[] {"h"}, ClassTypeHelper.getDeclaredFields(ct, null));
|
||||
assertBindings(new String[] {"o", "C", "C"}, ClassTypeHelper.getDeclaredMethods(ct, null));
|
||||
assertBindings(new String[] {"e", "h"}, ClassTypeHelper.getFields(ct, null));
|
||||
assertBindings(new String[] {"l", "o", "C", "C", "C", "~C", "A", "A", "~A", "operator =", "operator ="}, ClassTypeHelper.getMethods(ct, null));
|
||||
assertBindings(new String[] {"P"}, ClassTypeHelper.getNestedClasses(ct, null));
|
||||
|
||||
// explicit class template specialization
|
||||
ct= getBindingFromASTName("CT<int> espect", 7);
|
||||
assertInstance(ct, ICPPTemplateInstance.class);
|
||||
assertBindings(new String[] {"A"}, ct.getBases());
|
||||
assertBindings(new String[] {"o", "l", "A", "CT", "CT"}, ct.getAllDeclaredMethods());
|
||||
assertBindings(new String[] {"CT", "CT", "CT"}, ct.getConstructors());
|
||||
assertBindings(new String[] {"h"}, ct.getDeclaredFields());
|
||||
assertBindings(new String[] {"o", "CT", "CT"}, ct.getDeclaredMethods());
|
||||
assertBindings(new String[] {"e", "h"}, ct.getFields());
|
||||
assertBindings(new String[] {"l", "o", "CT", "CT", "CT", "~CT", "A", "A", "~A", "operator =", "operator ="}, ct.getMethods());
|
||||
assertBindings(new String[] {"P"}, ct.getNestedClasses());
|
||||
assertBindings(new String[] {"A"}, ClassTypeHelper.getBases(ct, null));
|
||||
assertBindings(new String[] {"o", "l", "A", "CT", "CT"}, ClassTypeHelper.getAllDeclaredMethods(ct, null));
|
||||
assertBindings(new String[] {"CT", "CT", "CT"}, ClassTypeHelper.getConstructors(ct, null));
|
||||
assertBindings(new String[] {"h"}, ClassTypeHelper.getDeclaredFields(ct, null));
|
||||
assertBindings(new String[] {"o", "CT", "CT"}, ClassTypeHelper.getDeclaredMethods(ct, null));
|
||||
assertBindings(new String[] {"e", "h"}, ClassTypeHelper.getFields(ct, null));
|
||||
assertBindings(new String[] {"l", "o", "CT", "CT", "CT", "~CT", "A", "A", "~A", "operator =", "operator ="}, ClassTypeHelper.getMethods(ct, null));
|
||||
assertBindings(new String[] {"P"}, ClassTypeHelper.getNestedClasses(ct, null));
|
||||
}
|
||||
|
||||
// void func(const int* x) {}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.index.tests;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -57,13 +58,13 @@ import org.eclipse.cdt.core.index.IndexFilter;
|
|||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateTypeArgument;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexScope;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
|
||||
/**
|
||||
* Tests for exercising resolution of template bindings against IIndex
|
||||
*/
|
||||
|
@ -629,7 +630,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
assertInstance(b2, ICPPClassType.class);
|
||||
assertInstance(b2, ICPPTemplateInstance.class);
|
||||
ICPPClassType ct2= (ICPPClassType) b2;
|
||||
ICPPBase[] bss2= ct2.getBases();
|
||||
ICPPBase[] bss2= ClassTypeHelper.getBases(ct2, null);
|
||||
assertEquals(1, bss2.length);
|
||||
assertInstance(bss2[0].getBaseClass(), ICPPClassType.class);
|
||||
ICPPClassType ct2b= (ICPPClassType) bss2[0].getBaseClass();
|
||||
|
@ -638,14 +639,14 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
IBinding b0= getBindingFromASTName("B<int>", 6);
|
||||
assertInstance(b0, ICPPClassType.class);
|
||||
ICPPClassType ct= (ICPPClassType) b0;
|
||||
ICPPBase[] bss= ct.getBases();
|
||||
ICPPBase[] bss= ClassTypeHelper.getBases(ct, null);
|
||||
assertEquals(1, bss.length);
|
||||
assertInstance(bss[0].getBaseClass(), ICPPClassType.class);
|
||||
|
||||
IBinding b1= getBindingFromASTName("B<long>", 7);
|
||||
assertInstance(b1, ICPPClassType.class);
|
||||
ICPPClassType ct1= (ICPPClassType) b1;
|
||||
ICPPBase[] bss1= ct1.getBases();
|
||||
ICPPBase[] bss1= ClassTypeHelper.getBases(ct1, null);
|
||||
assertEquals(1, bss1.length);
|
||||
assertInstance(bss1[0].getBaseClass(), ICPPClassType.class);
|
||||
}
|
||||
|
@ -674,11 +675,11 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
assertInstance(b0, ICPPSpecialization.class);
|
||||
|
||||
ICPPClassType ct= (ICPPClassType) b0;
|
||||
ICPPMethod[] dms= ct.getDeclaredMethods();
|
||||
ICPPMethod[] dms= ClassTypeHelper.getDeclaredMethods(ct, null);
|
||||
assertEquals(2, dms.length);
|
||||
|
||||
// if the specialization was used, we have 2 fields.
|
||||
ICPPField[] fs= ct.getDeclaredFields();
|
||||
ICPPField[] fs= ClassTypeHelper.getDeclaredFields(ct, null);
|
||||
assertEquals(2, fs.length);
|
||||
|
||||
ICPPMethod foo= dms[0].getName().equals("foo") ? dms[0] : dms[1];
|
||||
|
@ -1574,7 +1575,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
assertInstance(m, ICPPSpecialization.class);
|
||||
ICPPClassType ct= m.getClassOwner();
|
||||
assertInstance(ct, ICPPTemplateInstance.class);
|
||||
ICPPMethod[] ms= ct.getDeclaredMethods();
|
||||
ICPPMethod[] ms= ClassTypeHelper.getDeclaredMethods(ct, null);
|
||||
assertEquals(1, ms.length);
|
||||
assertEquals(m, ms[0]);
|
||||
}
|
||||
|
@ -1849,16 +1850,16 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
methods= ct.getMethods();
|
||||
assertEquals(14, methods.length);
|
||||
|
||||
ICPPBase[] bases = ct.getBases();
|
||||
ICPPBase[] bases = ClassTypeHelper.getBases(ct, null);
|
||||
assertEquals(1, bases.length);
|
||||
|
||||
IField field = ct.findField("bfield");
|
||||
assertNotNull(field);
|
||||
|
||||
IField[] fields = ct.getFields();
|
||||
IField[] fields = ClassTypeHelper.getFields(ct, null);
|
||||
assertEquals(2, fields.length);
|
||||
|
||||
IBinding[] friends = ct.getFriends();
|
||||
IBinding[] friends = ClassTypeHelper.getFriends(ct, null);
|
||||
assertEquals(0, friends.length); // not yet supported
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.eclipse.cdt.core.CCorePlugin;
|
|||
import org.eclipse.cdt.core.dom.IPDOMManager;
|
||||
import org.eclipse.cdt.core.dom.ast.IBasicType;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IField;
|
||||
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
||||
import org.eclipse.cdt.core.dom.ast.IPointerType;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
|
@ -34,6 +35,7 @@ import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
|||
import org.eclipse.cdt.core.testplugin.CTestPlugin;
|
||||
import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
|
||||
import org.eclipse.cdt.internal.core.CCoreInternals;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
|
||||
|
@ -237,9 +239,10 @@ public class CPPClassTemplateTests extends PDOMTestBase {
|
|||
ICPPVariable var= (ICPPVariable) bs[0];
|
||||
assertInstance(var.getType(), ICPPClassType.class);
|
||||
ICPPClassType ct= (ICPPClassType) var.getType();
|
||||
assertEquals(1, ct.getFields().length);
|
||||
assertInstance(ct.getFields()[0].getType(), IPointerType.class);
|
||||
IPointerType pt= (IPointerType) ct.getFields()[0].getType();
|
||||
IField[] fields = ClassTypeHelper.getFields(ct, null);
|
||||
assertEquals(1, fields.length);
|
||||
assertInstance(fields[0].getType(), IPointerType.class);
|
||||
IPointerType pt= (IPointerType) fields[0].getType();
|
||||
assertInstance(pt.getType(), IFunctionType.class);
|
||||
IFunctionType ft= (IFunctionType) pt.getType();
|
||||
assertInstance(ft.getReturnType(), ICPPClassType.class);
|
||||
|
|
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.core.dom.ast.cpp;
|
|||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IField;
|
||||
|
||||
/**
|
||||
* Specializations of all sorts of class types.
|
||||
|
@ -59,6 +60,20 @@ public interface ICPPClassSpecialization extends ICPPSpecialization, ICPPClassTy
|
|||
*/
|
||||
ICPPField[] getDeclaredFields(IASTNode point);
|
||||
|
||||
/**
|
||||
* Similar to {@link ICPPClassType#getMethods()} but a accepts a starting point
|
||||
* for template instantiation.
|
||||
* @since 5.5
|
||||
*/
|
||||
ICPPMethod[] getMethods(IASTNode point);
|
||||
|
||||
/**
|
||||
* Similar to {@link ICPPClassType#getAllDeclaredMethods()} but a accepts a starting point
|
||||
* for template instantiation.
|
||||
* @since 5.5
|
||||
*/
|
||||
ICPPMethod[] getAllDeclaredMethods(IASTNode point);
|
||||
|
||||
/**
|
||||
* Similar to {@link ICPPClassType#getDeclaredMethods()} but a accepts a starting point
|
||||
* for template instantiation.
|
||||
|
@ -73,6 +88,13 @@ public interface ICPPClassSpecialization extends ICPPSpecialization, ICPPClassTy
|
|||
*/
|
||||
IBinding[] getFriends(IASTNode point);
|
||||
|
||||
/**
|
||||
* Similar to {@link ICPPClassType#getFriends()} but a accepts a starting point
|
||||
* for template instantiation.
|
||||
* @since 5.5
|
||||
*/
|
||||
IField[] getFields(IASTNode point);
|
||||
|
||||
/**
|
||||
* Similar to {@link ICPPClassType#getNestedClasses()} but a accepts a starting point
|
||||
* for template instantiation.
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012 Google, Inc and others.
|
||||
* 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:
|
||||
* Sergey Prigogin (Google) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
|
||||
/**
|
||||
* Specialization of a method.
|
||||
* @since 5.5
|
||||
*
|
||||
* @noextend This interface is not intended to be extended by clients.
|
||||
* @noimplement This interface is not intended to be implemented by clients.
|
||||
*/
|
||||
public interface ICPPMethodSpecialization extends ICPPSpecialization, ICPPMethod {
|
||||
/**
|
||||
* Similar to {@link ICPPFunction#getExceptionSpecification()} but a accepts a starting point
|
||||
* for template instantiation.
|
||||
* @since 5.5
|
||||
*/
|
||||
IType[] getExceptionSpecification(IASTNode point);
|
||||
}
|
|
@ -49,6 +49,8 @@ public class SizeofCalculator {
|
|||
}
|
||||
}
|
||||
|
||||
private static final SizeofCalculator defaultInstance = new SizeofCalculator();
|
||||
|
||||
private static final SizeAndAlignment SIZE_1 = new SizeAndAlignment(1, 1);
|
||||
|
||||
public final SizeAndAlignment size_2;
|
||||
|
@ -68,6 +70,15 @@ public class SizeofCalculator {
|
|||
public final SizeAndAlignment sizeof_long_double;
|
||||
public final SizeAndAlignment sizeof_complex_long_double;
|
||||
|
||||
/**
|
||||
* Returns the default instance of sizeof calculator. The default instance is not aware
|
||||
* of the parser configuration and can only calculate sizes that are the same across all
|
||||
* C/C++ implementations.
|
||||
*/
|
||||
public static SizeofCalculator getDefault() {
|
||||
return defaultInstance;
|
||||
}
|
||||
|
||||
public SizeofCalculator(IASTTranslationUnit ast) {
|
||||
int maxAlignment = 32;
|
||||
Map<String, String> sizeofMacros = new HashMap<String, String>();
|
||||
|
@ -103,6 +114,25 @@ public class SizeofCalculator {
|
|||
sizeof_complex_long_double = getSizeOfPair(sizeof_long_double);
|
||||
}
|
||||
|
||||
private SizeofCalculator() {
|
||||
size_2 = new SizeAndAlignment(2, 2);
|
||||
size_4 = new SizeAndAlignment(4, 4);
|
||||
size_8 = new SizeAndAlignment(8, 8);
|
||||
sizeof_pointer = null;
|
||||
sizeof_int = null;
|
||||
sizeof_long = null;
|
||||
sizeof_long_long = null;
|
||||
sizeof_short = null;
|
||||
sizeof_bool = null;
|
||||
sizeof_wchar_t = null;
|
||||
sizeof_float = null;
|
||||
sizeof_complex_float = null;
|
||||
sizeof_double = null;
|
||||
sizeof_complex_double = null;
|
||||
sizeof_long_double = null;
|
||||
sizeof_complex_long_double = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates size and alignment for the given type.
|
||||
* @param type the type to get size and alignment for.
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.IName;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.EScopeKind;
|
||||
|
@ -128,7 +129,7 @@ public class AbstractCPPClassSpecializationScope implements ICPPClassSpecializat
|
|||
public ICPPBase[] getBases(IASTNode point) {
|
||||
if (fBases == null) {
|
||||
ICPPBase[] result = null;
|
||||
ICPPBase[] bases = specialClass.getSpecializedBinding().getBases();
|
||||
ICPPBase[] bases = ClassTypeHelper.getBases(specialClass.getSpecializedBinding(), point);
|
||||
if (bases.length == 0) {
|
||||
fBases= bases;
|
||||
} else {
|
||||
|
@ -136,7 +137,8 @@ public class AbstractCPPClassSpecializationScope implements ICPPClassSpecializat
|
|||
for (ICPPBase base : bases) {
|
||||
IBinding origClass = base.getBaseClass();
|
||||
if (origClass instanceof ICPPTemplateParameter && ((ICPPTemplateParameter) origClass).isParameterPack()) {
|
||||
IType[] specClasses= CPPTemplates.instantiateTypes(new IType[]{new CPPParameterPackType((IType) origClass)}, tpmap, -1, specialClass, point);
|
||||
IType[] specClasses= CPPTemplates.instantiateTypes(new IType[] { new CPPParameterPackType((IType) origClass) },
|
||||
tpmap, -1, specialClass, point);
|
||||
if (specClasses.length == 1 && specClasses[0] instanceof ICPPParameterPackType) {
|
||||
result= ArrayUtil.append(ICPPBase.class, result, base);
|
||||
} else {
|
||||
|
@ -183,13 +185,14 @@ public class AbstractCPPClassSpecializationScope implements ICPPClassSpecializat
|
|||
|
||||
@Override
|
||||
public ICPPField[] getDeclaredFields(IASTNode point) {
|
||||
ICPPField[] fields= specialClass.getSpecializedBinding().getDeclaredFields();
|
||||
ICPPField[] fields= ClassTypeHelper.getDeclaredFields(specialClass.getSpecializedBinding(), point);
|
||||
return specializeMembers(fields, point);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPMethod[] getImplicitMethods() {
|
||||
return getImplicitMethods(null); // Instantiation of dependent expression may not work.
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getImplicitMethods(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -211,30 +214,31 @@ public class AbstractCPPClassSpecializationScope implements ICPPClassSpecializat
|
|||
|
||||
@Override
|
||||
public ICPPConstructor[] getConstructors() {
|
||||
return getConstructors(null); // Instantiation of dependent expression may not work.
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getConstructors(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPConstructor[] getConstructors(IASTNode point) {
|
||||
ICPPConstructor[] ctors= specialClass.getSpecializedBinding().getConstructors();
|
||||
ICPPConstructor[] ctors= ClassTypeHelper.getConstructors(specialClass.getSpecializedBinding(), point);
|
||||
return specializeMembers(ctors, point);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPMethod[] getDeclaredMethods(IASTNode point) {
|
||||
ICPPMethod[] bindings = specialClass.getSpecializedBinding().getDeclaredMethods();
|
||||
ICPPMethod[] bindings = ClassTypeHelper.getDeclaredMethods(specialClass.getSpecializedBinding(), point);
|
||||
return specializeMembers(bindings, point);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPClassType[] getNestedClasses(IASTNode point) {
|
||||
ICPPClassType[] bindings = specialClass.getSpecializedBinding().getNestedClasses();
|
||||
ICPPClassType[] bindings = ClassTypeHelper.getNestedClasses(specialClass.getSpecializedBinding(), point);
|
||||
return specializeMembers(bindings, point);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinding[] getFriends(IASTNode point) {
|
||||
IBinding[] friends = specialClass.getSpecializedBinding().getFriends();
|
||||
IBinding[] friends = ClassTypeHelper.getFriends(specialClass.getSpecializedBinding(), point);
|
||||
return specializeMembers(friends, point);
|
||||
}
|
||||
|
||||
|
|
|
@ -175,7 +175,7 @@ public class CPPASTConstructorChainInitializer extends ASTNode implements
|
|||
IBinding method= fdef.getDeclarator().getName().resolveBinding();
|
||||
if (method instanceof ICPPMethod) {
|
||||
ICPPClassType cls= ((ICPPMethod) method).getClassOwner();
|
||||
for (ICPPBase base : SemanticUtil.getBases(cls, fdef)) {
|
||||
for (ICPPBase base : ClassTypeHelper.getBases(cls, fdef)) {
|
||||
result.put(base.getBaseClassSpecifierName().getSimpleID());
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -43,6 +43,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalFixed;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalFunctionCall;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalTypeId;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.LookupData;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
|
||||
|
||||
public class CPPASTFunctionCallExpression extends ASTNode
|
||||
implements ICPPASTFunctionCallExpression, IASTAmbiguityParent {
|
||||
|
@ -270,7 +271,7 @@ public class CPPASTFunctionCallExpression extends ASTNode
|
|||
ICPPClassType cls= (ICPPClassType) t;
|
||||
LookupData data= CPPSemantics.createLookupData(((IASTIdExpression) functionName).getName());
|
||||
try {
|
||||
IBinding b= CPPSemantics.resolveFunction(data, cls.getConstructors(), true);
|
||||
IBinding b= CPPSemantics.resolveFunction(data, ClassTypeHelper.getConstructors(cls, data.getLookupPoint()), true);
|
||||
if (b instanceof ICPPFunction)
|
||||
return (ICPPFunction) b;
|
||||
} catch (DOMException e) {
|
||||
|
|
|
@ -278,7 +278,7 @@ public class CPPASTQualifiedName extends CPPASTNameBase
|
|||
List<IBinding> filtered = filterClassScopeBindings(classType, bindings, isDeclaration);
|
||||
if (isDeclaration && nameMatches(classType.getNameCharArray(),
|
||||
n.getLookupKey(), isPrefix)) {
|
||||
ICPPConstructor[] constructors = SemanticUtil.getConstructors(classType, n);
|
||||
ICPPConstructor[] constructors = ClassTypeHelper.getConstructors(classType, n);
|
||||
for (int i = 0; i < constructors.length; i++) {
|
||||
if (!constructors[i].isImplicit()) {
|
||||
filtered.add(constructors[i]);
|
||||
|
|
|
@ -15,6 +15,7 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
|||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||
|
@ -122,7 +123,8 @@ public class CPPClassSpecialization extends CPPSpecialization
|
|||
|
||||
@Override
|
||||
public ICPPBase[] getBases() {
|
||||
return getBases(null); // Instantiation of dependent expression may not work.
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getBases(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -136,7 +138,8 @@ public class CPPClassSpecialization extends CPPSpecialization
|
|||
|
||||
@Override
|
||||
public ICPPField[] getDeclaredFields() {
|
||||
return getDeclaredFields(null); // Instantiation of dependent expression may not work.
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getDeclaredFields(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -150,7 +153,8 @@ public class CPPClassSpecialization extends CPPSpecialization
|
|||
|
||||
@Override
|
||||
public ICPPMethod[] getDeclaredMethods() {
|
||||
return getDeclaredMethods(null); // Instantiation of dependent expression may not work.
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getDeclaredMethods(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -164,7 +168,8 @@ public class CPPClassSpecialization extends CPPSpecialization
|
|||
|
||||
@Override
|
||||
public ICPPConstructor[] getConstructors() {
|
||||
return getConstructors(null); // Instantiation of dependent expression may not work.
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getConstructors(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -178,7 +183,8 @@ public class CPPClassSpecialization extends CPPSpecialization
|
|||
|
||||
@Override
|
||||
public IBinding[] getFriends() {
|
||||
return getFriends(null); // Instantiation of dependent expression may not work.
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getFriends(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -192,7 +198,8 @@ public class CPPClassSpecialization extends CPPSpecialization
|
|||
|
||||
@Override
|
||||
public ICPPClassType[] getNestedClasses() {
|
||||
return getNestedClasses(null); // Instantiation of dependent expression may not work.
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getNestedClasses(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -206,7 +213,13 @@ public class CPPClassSpecialization extends CPPSpecialization
|
|||
|
||||
@Override
|
||||
public IField[] getFields() {
|
||||
return ClassTypeHelper.getFields(this);
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getFields(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IField[] getFields(IASTNode point) {
|
||||
return ClassTypeHelper.getFields(this, point);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -216,12 +229,24 @@ public class CPPClassSpecialization extends CPPSpecialization
|
|||
|
||||
@Override
|
||||
public ICPPMethod[] getMethods() {
|
||||
return ClassTypeHelper.getMethods(this);
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getMethods(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPMethod[] getMethods(IASTNode point) {
|
||||
return ClassTypeHelper.getMethods(this, point);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPMethod[] getAllDeclaredMethods() {
|
||||
return ClassTypeHelper.getAllDeclaredMethods(this);
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getAllDeclaredMethods(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPMethod[] getAllDeclaredMethods(IASTNode point) {
|
||||
return ClassTypeHelper.getAllDeclaredMethods(this, point);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -159,7 +159,7 @@ public class CPPClassTemplate extends CPPTemplateDefinition implements ICPPClass
|
|||
|
||||
@Override
|
||||
public IField[] getFields() {
|
||||
return ClassTypeHelper.getFields(this);
|
||||
return ClassTypeHelper.getFields(this, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -169,12 +169,12 @@ public class CPPClassTemplate extends CPPTemplateDefinition implements ICPPClass
|
|||
|
||||
@Override
|
||||
public ICPPMethod[] getMethods() {
|
||||
return ClassTypeHelper.getMethods(this);
|
||||
return ClassTypeHelper.getMethods(this, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPMethod[] getAllDeclaredMethods() {
|
||||
return ClassTypeHelper.getAllDeclaredMethods(this);
|
||||
return ClassTypeHelper.getAllDeclaredMethods(this, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -43,7 +43,7 @@ public class CPPClassTemplateSpecialization extends CPPClassSpecialization
|
|||
@Override
|
||||
public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() {
|
||||
if (fPartialSpecs == null) {
|
||||
IASTNode point= null; // Instantiation of dependent expression may not work.
|
||||
IASTNode point= null; // Instantiation of dependent expressions may not work.
|
||||
ICPPClassTemplate origTemplate= (ICPPClassTemplate) getSpecializedBinding();
|
||||
ICPPClassTemplatePartialSpecialization[] orig = origTemplate.getPartialSpecializations();
|
||||
ICPPClassTemplatePartialSpecialization[] spec = new ICPPClassTemplatePartialSpecialization[orig.length];
|
||||
|
|
|
@ -309,7 +309,7 @@ public class CPPClassType extends PlatformObject implements ICPPInternalClassTyp
|
|||
|
||||
@Override
|
||||
public IField[] getFields() {
|
||||
return ClassTypeHelper.getFields(this);
|
||||
return ClassTypeHelper.getFields(this, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -319,12 +319,12 @@ public class CPPClassType extends PlatformObject implements ICPPInternalClassTyp
|
|||
|
||||
@Override
|
||||
public ICPPMethod[] getMethods() {
|
||||
return ClassTypeHelper.getMethods(this);
|
||||
return ClassTypeHelper.getMethods(this, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPMethod[] getAllDeclaredMethods() {
|
||||
return ClassTypeHelper.getAllDeclaredMethods(this);
|
||||
return ClassTypeHelper.getAllDeclaredMethods(this, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -194,6 +194,6 @@ public class CPPImplicitMethod extends CPPImplicitFunction implements ICPPMethod
|
|||
|
||||
@Override
|
||||
public IType[] getExceptionSpecification() {
|
||||
return ClassTypeHelper.getInheritedExceptionSpecification(this);
|
||||
return ClassTypeHelper.getInheritedExceptionSpecification(this, null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 2010 IBM Corporation and others.
|
||||
* Copyright (c) 2005, 2012 IBM Corporation and others.
|
||||
* 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
|
||||
|
@ -8,6 +8,7 @@
|
|||
* Contributors:
|
||||
* Andrew Niefer (IBM) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
|
@ -20,20 +21,27 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethodSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||
|
||||
/**
|
||||
* The specialization of a method in the context of a class-specialization.
|
||||
*/
|
||||
public class CPPMethodSpecialization extends CPPFunctionSpecialization implements ICPPMethod {
|
||||
public class CPPMethodSpecialization extends CPPFunctionSpecialization implements ICPPMethodSpecialization {
|
||||
|
||||
public CPPMethodSpecialization(ICPPMethod orig, ICPPClassType owner, ICPPTemplateParameterMap argMap, ICPPFunctionType type, IType[] exceptionSpec ) {
|
||||
super(orig, owner, argMap, type, exceptionSpec );
|
||||
public CPPMethodSpecialization(ICPPMethod orig, ICPPClassType owner, ICPPTemplateParameterMap argMap,
|
||||
ICPPFunctionType type, IType[] exceptionSpec) {
|
||||
super(orig, owner, argMap, type, exceptionSpec);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPMethod getSpecializedBinding() {
|
||||
return (ICPPMethod) super.getSpecializedBinding();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVirtual() {
|
||||
ICPPMethod f = (ICPPMethod) getSpecializedBinding();
|
||||
ICPPMethod f = getSpecializedBinding();
|
||||
if (f != null)
|
||||
return f.isVirtual();
|
||||
IASTNode definition = getDefinition();
|
||||
|
@ -58,7 +66,7 @@ public class CPPMethodSpecialization extends CPPFunctionSpecialization implement
|
|||
|
||||
@Override
|
||||
public int getVisibility() {
|
||||
ICPPMethod f = (ICPPMethod) getSpecializedBinding();
|
||||
ICPPMethod f = getSpecializedBinding();
|
||||
if (f != null)
|
||||
return f.getVisibility();
|
||||
return 0;
|
||||
|
@ -80,17 +88,17 @@ public class CPPMethodSpecialization extends CPPFunctionSpecialization implement
|
|||
|
||||
@Override
|
||||
public boolean isExplicit() {
|
||||
return ((ICPPMethod) getSpecializedBinding()).isExplicit();
|
||||
return getSpecializedBinding().isExplicit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isImplicit() {
|
||||
return ((ICPPMethod) getSpecializedBinding()).isImplicit();
|
||||
return getSpecializedBinding().isImplicit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPureVirtual() {
|
||||
ICPPMethod f = (ICPPMethod) getSpecializedBinding();
|
||||
ICPPMethod f = getSpecializedBinding();
|
||||
if (f != null)
|
||||
return f.isPureVirtual();
|
||||
|
||||
|
@ -98,9 +106,9 @@ public class CPPMethodSpecialization extends CPPFunctionSpecialization implement
|
|||
}
|
||||
|
||||
@Override
|
||||
public IType[] getExceptionSpecification() {
|
||||
public IType[] getExceptionSpecification(IASTNode point) {
|
||||
if (isImplicit()) {
|
||||
return ClassTypeHelper.getInheritedExceptionSpecification(this);
|
||||
return ClassTypeHelper.getInheritedExceptionSpecification(this, point);
|
||||
}
|
||||
return super.getExceptionSpecification();
|
||||
}
|
||||
|
|
|
@ -54,6 +54,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||
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.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
||||
|
@ -101,14 +102,14 @@ public class ClassTypeHelper {
|
|||
IASTDeclaration[] members = host.getCompositeTypeSpecifier().getMembers();
|
||||
for (IASTDeclaration decl : members) {
|
||||
while (decl instanceof ICPPASTTemplateDeclaration)
|
||||
decl = ((ICPPASTTemplateDeclaration)decl).getDeclaration();
|
||||
decl = ((ICPPASTTemplateDeclaration) decl).getDeclaration();
|
||||
|
||||
if (decl instanceof IASTSimpleDeclaration) {
|
||||
ICPPASTDeclSpecifier declSpec = (ICPPASTDeclSpecifier) ((IASTSimpleDeclaration)decl).getDeclSpecifier();
|
||||
ICPPASTDeclSpecifier declSpec = (ICPPASTDeclSpecifier) ((IASTSimpleDeclaration) decl).getDeclSpecifier();
|
||||
if (declSpec.isFriend()) {
|
||||
IASTDeclarator[] dtors = ((IASTSimpleDeclaration)decl).getDeclarators();
|
||||
IASTDeclarator[] dtors = ((IASTSimpleDeclaration) decl).getDeclarators();
|
||||
if (declSpec instanceof ICPPASTElaboratedTypeSpecifier && dtors.length == 0) {
|
||||
resultSet.put(((ICPPASTElaboratedTypeSpecifier)declSpec).getName().resolveBinding());
|
||||
resultSet.put(((ICPPASTElaboratedTypeSpecifier) declSpec).getName().resolveBinding());
|
||||
} else {
|
||||
for (IASTDeclarator dtor : dtors) {
|
||||
if (dtor == null) break;
|
||||
|
@ -118,9 +119,9 @@ public class ClassTypeHelper {
|
|||
}
|
||||
}
|
||||
} else if (decl instanceof IASTFunctionDefinition) {
|
||||
ICPPASTDeclSpecifier declSpec = (ICPPASTDeclSpecifier) ((IASTFunctionDefinition)decl).getDeclSpecifier();
|
||||
ICPPASTDeclSpecifier declSpec = (ICPPASTDeclSpecifier) ((IASTFunctionDefinition) decl).getDeclSpecifier();
|
||||
if (declSpec.isFriend()) {
|
||||
IASTDeclarator dtor = ((IASTFunctionDefinition)decl).getDeclarator();
|
||||
IASTDeclarator dtor = ((IASTFunctionDefinition) decl).getDeclarator();
|
||||
dtor= ASTQueries.findInnermostDeclarator(dtor);
|
||||
resultSet.put(dtor.getName().resolveBinding());
|
||||
}
|
||||
|
@ -144,7 +145,7 @@ public class ClassTypeHelper {
|
|||
if (type.isSameType(classType)) {
|
||||
return true;
|
||||
}
|
||||
for (IBinding friend : classType.getFriends()) {
|
||||
for (IBinding friend : getFriends(classType, null)) {
|
||||
if (friend instanceof ICPPClassType && type.isSameType((IType) friend)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -152,7 +153,7 @@ public class ClassTypeHelper {
|
|||
} else if (binding instanceof ICPPFunction) {
|
||||
type = ((ICPPFunction) binding).getType();
|
||||
char[] name = binding.getNameCharArray();
|
||||
for (IBinding friend : classType.getFriends()) {
|
||||
for (IBinding friend : getFriends(classType, null)) {
|
||||
if (friend instanceof ICPPFunction &&
|
||||
CharArrayUtils.equals(name, friend.getNameCharArray()) &&
|
||||
SemanticUtil.isSameOwner(binding.getOwner(), friend.getOwner()) &&
|
||||
|
@ -217,17 +218,17 @@ public class ClassTypeHelper {
|
|||
IASTDeclaration[] decls = host.getCompositeTypeSpecifier().getMembers();
|
||||
for (IASTDeclaration decl : decls) {
|
||||
if (decl instanceof IASTSimpleDeclaration) {
|
||||
IASTDeclarator[] dtors = ((IASTSimpleDeclaration)decl).getDeclarators();
|
||||
IASTDeclarator[] dtors = ((IASTSimpleDeclaration) decl).getDeclarators();
|
||||
for (IASTDeclarator dtor : dtors) {
|
||||
binding = ASTQueries.findInnermostDeclarator(dtor).getName().resolveBinding();
|
||||
if (binding instanceof ICPPField)
|
||||
result = ArrayUtil.append(ICPPField.class, result, (ICPPField) binding);
|
||||
}
|
||||
} else if (decl instanceof ICPPASTUsingDeclaration) {
|
||||
IASTName n = ((ICPPASTUsingDeclaration)decl).getName();
|
||||
IASTName n = ((ICPPASTUsingDeclaration) decl).getName();
|
||||
binding = n.resolveBinding();
|
||||
if (binding instanceof ICPPUsingDeclaration) {
|
||||
IBinding[] bs = ((ICPPUsingDeclaration)binding).getDelegates();
|
||||
IBinding[] bs = ((ICPPUsingDeclaration) binding).getDelegates();
|
||||
for (IBinding element : bs) {
|
||||
if (element instanceof ICPPField)
|
||||
result = ArrayUtil.append(ICPPField.class, result, (ICPPField) element);
|
||||
|
@ -240,27 +241,63 @@ public class ClassTypeHelper {
|
|||
return ArrayUtil.trim(ICPPField.class, result);
|
||||
}
|
||||
|
||||
public static ICPPBase[] getBases(ICPPClassType classType, IASTNode point) {
|
||||
if (classType instanceof ICPPClassSpecialization)
|
||||
return ((ICPPClassSpecialization) classType).getBases(point);
|
||||
return classType.getBases();
|
||||
}
|
||||
|
||||
public static ICPPConstructor[] getConstructors(ICPPClassType classType, IASTNode point) {
|
||||
if (classType instanceof ICPPClassSpecialization)
|
||||
return ((ICPPClassSpecialization) classType).getConstructors(point);
|
||||
return classType.getConstructors();
|
||||
}
|
||||
|
||||
public static ICPPField[] getDeclaredFields(ICPPClassType classType, IASTNode point) {
|
||||
if (classType instanceof ICPPClassSpecialization)
|
||||
return ((ICPPClassSpecialization) classType).getDeclaredFields(point);
|
||||
return classType.getDeclaredFields();
|
||||
}
|
||||
|
||||
public static ICPPMethod[] getDeclaredMethods(ICPPClassType classType, IASTNode point) {
|
||||
if (classType instanceof ICPPClassSpecialization)
|
||||
return ((ICPPClassSpecialization) classType).getDeclaredMethods(point);
|
||||
return classType.getDeclaredMethods();
|
||||
}
|
||||
|
||||
public static IBinding[] getFriends(ICPPClassType classType, IASTNode point) {
|
||||
if (classType instanceof ICPPClassSpecialization)
|
||||
return ((ICPPClassSpecialization) classType).getFriends(point);
|
||||
return classType.getFriends();
|
||||
}
|
||||
|
||||
public static ICPPClassType[] getNestedClasses(ICPPClassType classType, IASTNode point) {
|
||||
if (classType instanceof ICPPClassSpecialization)
|
||||
return ((ICPPClassSpecialization) classType).getNestedClasses(point);
|
||||
return classType.getNestedClasses();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all direct and indirect base classes.
|
||||
* @param classType a class
|
||||
* @return An array of visible base classes in arbitrary order.
|
||||
*/
|
||||
public static ICPPClassType[] getAllBases(ICPPClassType classType) {
|
||||
public static ICPPClassType[] getAllBases(ICPPClassType classType, IASTNode point) {
|
||||
HashSet<ICPPClassType> result= new HashSet<ICPPClassType>();
|
||||
result.add(classType);
|
||||
getAllBases(classType, result);
|
||||
getAllBases(classType, result, point);
|
||||
result.remove(classType);
|
||||
return result.toArray(new ICPPClassType[result.size()]);
|
||||
}
|
||||
|
||||
private static void getAllBases(ICPPClassType classType, HashSet<ICPPClassType> result) {
|
||||
ICPPBase[] bases= classType.getBases();
|
||||
private static void getAllBases(ICPPClassType classType, HashSet<ICPPClassType> result, IASTNode point) {
|
||||
ICPPBase[] bases= ClassTypeHelper.getBases(classType, point);
|
||||
for (ICPPBase base : bases) {
|
||||
IBinding b= base.getBaseClass();
|
||||
if (b instanceof ICPPClassType) {
|
||||
final ICPPClassType baseClass = (ICPPClassType) b;
|
||||
if (result.add(baseClass)) {
|
||||
getAllBases(baseClass, result);
|
||||
getAllBases(baseClass, result, point);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -287,25 +324,22 @@ public class ClassTypeHelper {
|
|||
return false;
|
||||
}
|
||||
|
||||
public static ICPPMethod[] getAllDeclaredMethods(ICPPClassType ct) {
|
||||
ICPPMethod[] methods= ct.getDeclaredMethods();
|
||||
ICPPClassType[] bases= getAllBases(ct);
|
||||
public static ICPPMethod[] getAllDeclaredMethods(ICPPClassType ct, IASTNode point) {
|
||||
ICPPMethod[] methods= getDeclaredMethods(ct, point);
|
||||
ICPPClassType[] bases= getAllBases(ct, point);
|
||||
for (ICPPClassType base : bases) {
|
||||
methods = ArrayUtil.addAll(ICPPMethod.class, methods, base.getDeclaredMethods());
|
||||
methods = ArrayUtil.addAll(ICPPMethod.class, methods, getDeclaredMethods(base, point));
|
||||
}
|
||||
return ArrayUtil.trim(ICPPMethod.class, methods);
|
||||
}
|
||||
|
||||
public static ICPPMethod[] getMethods(ICPPClassType ct) {
|
||||
ObjectSet<ICPPMethod> set = getOwnMethods(ct);
|
||||
public static ICPPMethod[] getMethods(ICPPClassType ct, IASTNode point) {
|
||||
ObjectSet<ICPPMethod> set = getOwnMethods(ct, point);
|
||||
|
||||
ICPPClassType[] bases= getAllBases(ct);
|
||||
ICPPClassType[] bases= getAllBases(ct, point);
|
||||
for (ICPPClassType base : bases) {
|
||||
set.addAll(base.getDeclaredMethods());
|
||||
final IScope compositeScope = base.getCompositeScope();
|
||||
if (compositeScope instanceof ICPPClassScope) {
|
||||
set.addAll(((ICPPClassScope) compositeScope).getImplicitMethods());
|
||||
}
|
||||
set.addAll(getDeclaredMethods(base, point));
|
||||
set.addAll(getImplicitMethods(base, point));
|
||||
}
|
||||
return set.keyArray(ICPPMethod.class);
|
||||
}
|
||||
|
@ -314,16 +348,23 @@ public class ClassTypeHelper {
|
|||
* Returns methods either declared by the given class or generated by the compiler. Does not
|
||||
* include methods declared in base classes.
|
||||
*/
|
||||
private static ObjectSet<ICPPMethod> getOwnMethods(ICPPClassType classType) {
|
||||
private static ObjectSet<ICPPMethod> getOwnMethods(ICPPClassType classType, IASTNode point) {
|
||||
ObjectSet<ICPPMethod> set= new ObjectSet<ICPPMethod>(4);
|
||||
set.addAll(classType.getDeclaredMethods());
|
||||
IScope scope = classType.getCompositeScope();
|
||||
if (scope instanceof ICPPClassScope) {
|
||||
set.addAll(((ICPPClassScope) scope).getImplicitMethods());
|
||||
}
|
||||
set.addAll(ClassTypeHelper.getDeclaredMethods(classType, point));
|
||||
set.addAll(getImplicitMethods(classType, point));
|
||||
return set;
|
||||
}
|
||||
|
||||
public static ICPPMethod[] getImplicitMethods(ICPPClassType classType, IASTNode point) {
|
||||
IScope scope = classType.getCompositeScope();
|
||||
if (scope instanceof ICPPClassSpecializationScope) {
|
||||
return ((ICPPClassSpecializationScope) scope).getImplicitMethods(point);
|
||||
} else if (scope instanceof ICPPClassScope) {
|
||||
return ((ICPPClassScope) scope).getImplicitMethods();
|
||||
}
|
||||
return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
|
||||
}
|
||||
|
||||
public static ICPPMethod[] getDeclaredMethods(ICPPInternalClassTypeMixinHost host) {
|
||||
if (host.getDefinition() == null) {
|
||||
host.checkForDefinition();
|
||||
|
@ -341,9 +382,9 @@ public class ClassTypeHelper {
|
|||
IASTDeclaration[] decls = host.getCompositeTypeSpecifier().getMembers();
|
||||
for (IASTDeclaration decl : decls) {
|
||||
while (decl instanceof ICPPASTTemplateDeclaration)
|
||||
decl = ((ICPPASTTemplateDeclaration)decl).getDeclaration();
|
||||
decl = ((ICPPASTTemplateDeclaration) decl).getDeclaration();
|
||||
if (decl instanceof IASTSimpleDeclaration) {
|
||||
final IASTSimpleDeclaration sdecl = (IASTSimpleDeclaration)decl;
|
||||
final IASTSimpleDeclaration sdecl = (IASTSimpleDeclaration) decl;
|
||||
if (!((ICPPASTDeclSpecifier) sdecl.getDeclSpecifier()).isFriend()) {
|
||||
IASTDeclarator[] dtors = sdecl.getDeclarators();
|
||||
for (IASTDeclarator dtor : dtors) {
|
||||
|
@ -353,7 +394,7 @@ public class ClassTypeHelper {
|
|||
}
|
||||
}
|
||||
} else if (decl instanceof IASTFunctionDefinition) {
|
||||
final IASTFunctionDefinition fdef = (IASTFunctionDefinition)decl;
|
||||
final IASTFunctionDefinition fdef = (IASTFunctionDefinition) decl;
|
||||
if (!((ICPPASTDeclSpecifier) fdef.getDeclSpecifier()).isFriend()) {
|
||||
IASTDeclarator dtor = fdef.getDeclarator();
|
||||
dtor = ASTQueries.findInnermostDeclarator(dtor);
|
||||
|
@ -363,10 +404,10 @@ public class ClassTypeHelper {
|
|||
}
|
||||
}
|
||||
} else if (decl instanceof ICPPASTUsingDeclaration) {
|
||||
IASTName n = ((ICPPASTUsingDeclaration)decl).getName();
|
||||
IASTName n = ((ICPPASTUsingDeclaration) decl).getName();
|
||||
binding = n.resolveBinding();
|
||||
if (binding instanceof ICPPUsingDeclaration) {
|
||||
IBinding[] bs = ((ICPPUsingDeclaration)binding).getDelegates();
|
||||
IBinding[] bs = ((ICPPUsingDeclaration) binding).getDelegates();
|
||||
for (IBinding element : bs) {
|
||||
if (element instanceof ICPPMethod)
|
||||
result = ArrayUtil.append(ICPPMethod.class, result, (ICPPMethod) element);
|
||||
|
@ -407,15 +448,15 @@ public class ClassTypeHelper {
|
|||
IASTDeclaration[] decls = host.getCompositeTypeSpecifier().getMembers();
|
||||
for (IASTDeclaration decl : decls) {
|
||||
while (decl instanceof ICPPASTTemplateDeclaration)
|
||||
decl = ((ICPPASTTemplateDeclaration)decl).getDeclaration();
|
||||
decl = ((ICPPASTTemplateDeclaration) decl).getDeclaration();
|
||||
if (decl instanceof IASTSimpleDeclaration) {
|
||||
IBinding binding = null;
|
||||
IASTDeclSpecifier declSpec = ((IASTSimpleDeclaration) decl).getDeclSpecifier();
|
||||
if (declSpec instanceof ICPPASTCompositeTypeSpecifier) {
|
||||
binding = ((ICPPASTCompositeTypeSpecifier)declSpec).getName().resolveBinding();
|
||||
binding = ((ICPPASTCompositeTypeSpecifier) declSpec).getName().resolveBinding();
|
||||
} else if (declSpec instanceof ICPPASTElaboratedTypeSpecifier &&
|
||||
((IASTSimpleDeclaration)decl).getDeclarators().length == 0) {
|
||||
binding = ((ICPPASTElaboratedTypeSpecifier)declSpec).getName().resolveBinding();
|
||||
((IASTSimpleDeclaration) decl).getDeclarators().length == 0) {
|
||||
binding = ((ICPPASTElaboratedTypeSpecifier) declSpec).getName().resolveBinding();
|
||||
}
|
||||
if (binding instanceof ICPPClassType)
|
||||
result = ArrayUtil.append(ICPPClassType.class, result, (ICPPClassType) binding);
|
||||
|
@ -424,11 +465,11 @@ public class ClassTypeHelper {
|
|||
return ArrayUtil.trim(ICPPClassType.class, result);
|
||||
}
|
||||
|
||||
public static IField[] getFields(ICPPClassType ct) {
|
||||
IField[] fields = ct.getDeclaredFields();
|
||||
ICPPClassType[] bases = getAllBases(ct);
|
||||
public static IField[] getFields(ICPPClassType ct, IASTNode point) {
|
||||
IField[] fields = getDeclaredFields(ct, point);
|
||||
ICPPClassType[] bases = getAllBases(ct, point);
|
||||
for (ICPPClassType base : bases) {
|
||||
fields = ArrayUtil.addAll(IField.class, fields, base.getDeclaredFields());
|
||||
fields = ArrayUtil.addAll(IField.class, fields, getDeclaredFields(base, point));
|
||||
}
|
||||
return ArrayUtil.trim(IField.class, fields);
|
||||
}
|
||||
|
@ -464,7 +505,8 @@ public class ClassTypeHelper {
|
|||
final ICPPClassType mcl= m.getClassOwner();
|
||||
if (mcl != null) {
|
||||
final ICPPFunctionType mft= m.getType();
|
||||
ICPPMethod[] allMethods= mcl.getMethods();
|
||||
IASTNode point = null; // Instantiation of dependent expressions may not work
|
||||
ICPPMethod[] allMethods= ClassTypeHelper.getMethods(mcl, point);
|
||||
for (ICPPMethod method : allMethods) {
|
||||
if (CharArrayUtils.equals(mname, method.getNameCharArray()) && functionTypesAllowOverride(mft, method.getType())) {
|
||||
if (method.isVirtual()) {
|
||||
|
@ -520,7 +562,7 @@ public class ClassTypeHelper {
|
|||
if (sourceClass == null || targetClass == null)
|
||||
return false;
|
||||
|
||||
ICPPClassType[] bases= getAllBases(sourceClass);
|
||||
ICPPClassType[] bases= getAllBases(sourceClass, null);
|
||||
for (ICPPClassType base : bases) {
|
||||
if (base.isSameType(targetClass))
|
||||
return true;
|
||||
|
@ -532,7 +574,7 @@ public class ClassTypeHelper {
|
|||
/**
|
||||
* Returns all methods that are overridden by the given {@code method}.
|
||||
*/
|
||||
public static ICPPMethod[] findOverridden(ICPPMethod method) {
|
||||
public static ICPPMethod[] findOverridden(ICPPMethod method, IASTNode point) {
|
||||
if (method instanceof ICPPConstructor)
|
||||
return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
|
||||
|
||||
|
@ -546,7 +588,7 @@ public class ClassTypeHelper {
|
|||
final ICPPFunctionType mft= method.getType();
|
||||
|
||||
virtualInClass.put(mcl, method.isVirtual());
|
||||
ICPPBase[] bases= mcl.getBases();
|
||||
ICPPBase[] bases= getBases(mcl, point);
|
||||
for (ICPPBase base : bases) {
|
||||
IBinding b= base.getBaseClass();
|
||||
if (b instanceof ICPPClassType) {
|
||||
|
@ -681,10 +723,10 @@ public class ClassTypeHelper {
|
|||
/**
|
||||
* For implicit methods the exception specification is inherited, search it
|
||||
*/
|
||||
public static IType[] getInheritedExceptionSpecification(ICPPMethod implicitMethod) {
|
||||
public static IType[] getInheritedExceptionSpecification(ICPPMethod implicitMethod, IASTNode point) {
|
||||
// See 15.4.13
|
||||
ICPPClassType owner= implicitMethod.getClassOwner();
|
||||
if (owner == null || owner.getBases().length == 0)
|
||||
if (owner == null || ClassTypeHelper.getBases(owner, point).length == 0)
|
||||
return null;
|
||||
|
||||
// we use a list as types aren't comparable, and can have duplicates (15.4.6)
|
||||
|
@ -693,7 +735,7 @@ public class ClassTypeHelper {
|
|||
return null;
|
||||
|
||||
List<IType> inheritedTypeids = new ArrayList<IType>();
|
||||
ICPPClassType[] bases= getAllBases(owner);
|
||||
ICPPClassType[] bases= getAllBases(owner, point);
|
||||
for (ICPPClassType base : bases) {
|
||||
if (!(base instanceof ICPPDeferredClassInstance)) {
|
||||
ICPPMethod baseMethod= getMethodInClass(base, kind);
|
||||
|
@ -792,10 +834,10 @@ public class ClassTypeHelper {
|
|||
* no private or protected non-static data members (Clause 11),
|
||||
* no base classes (Clause 10), and no virtual functions (10.3).
|
||||
*/
|
||||
public static boolean isAggregateClass(ICPPClassType classTarget) {
|
||||
if (classTarget.getBases().length > 0)
|
||||
public static boolean isAggregateClass(ICPPClassType classTarget, IASTNode point) {
|
||||
if (ClassTypeHelper.getBases(classTarget, point).length > 0)
|
||||
return false;
|
||||
ICPPMethod[] methods = classTarget.getDeclaredMethods();
|
||||
ICPPMethod[] methods = ClassTypeHelper.getDeclaredMethods(classTarget, point);
|
||||
for (ICPPMethod m : methods) {
|
||||
if (m instanceof ICPPConstructor)
|
||||
return false;
|
||||
|
@ -803,7 +845,7 @@ public class ClassTypeHelper {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
ICPPField[] fields = classTarget.getDeclaredFields();
|
||||
ICPPField[] fields = ClassTypeHelper.getDeclaredFields(classTarget, point);
|
||||
for (ICPPField field : fields) {
|
||||
if (!(field.getVisibility() == ICPPMember.v_public || field.isStatic())) {
|
||||
return false;
|
||||
|
@ -837,7 +879,7 @@ public class ClassTypeHelper {
|
|||
if (base.isVirtual())
|
||||
return false;
|
||||
}
|
||||
for (ICPPClassType baseClass : getAllBases(classTarget)) {
|
||||
for (ICPPClassType baseClass : getAllBases(classTarget, null)) {
|
||||
if (!classTarget.isSameType(baseClass) && !hasTrivialCopyCtor(baseClass))
|
||||
return false;
|
||||
}
|
||||
|
@ -889,7 +931,7 @@ public class ClassTypeHelper {
|
|||
if (!ctor.isImplicit() && ctor.getParameters().length == 0)
|
||||
return false;
|
||||
}
|
||||
for (ICPPClassType baseClass : getAllBases(classTarget)) {
|
||||
for (ICPPClassType baseClass : getAllBases(classTarget, null)) {
|
||||
if (!classTarget.isSameType(baseClass) && !hasTrivialDefaultConstructor(baseClass))
|
||||
return false;
|
||||
}
|
||||
|
@ -925,7 +967,7 @@ public class ClassTypeHelper {
|
|||
if (method.isDestructor())
|
||||
return false;
|
||||
}
|
||||
for (ICPPClassType baseClass : getAllBases(classTarget)) {
|
||||
for (ICPPClassType baseClass : getAllBases(classTarget, null)) {
|
||||
if (!classTarget.isSameType(baseClass) && !hasTrivialDestructor(baseClass))
|
||||
return false;
|
||||
}
|
||||
|
@ -952,7 +994,7 @@ public class ClassTypeHelper {
|
|||
public static boolean isPolymorphic(ICPPClassType classTarget) {
|
||||
if (hasDeclaredVirtualMethod(classTarget))
|
||||
return true;
|
||||
for (ICPPClassType baseClass : getAllBases(classTarget)) {
|
||||
for (ICPPClassType baseClass : getAllBases(classTarget, null)) {
|
||||
if (hasDeclaredVirtualMethod(baseClass))
|
||||
return true;
|
||||
}
|
||||
|
@ -976,9 +1018,9 @@ public class ClassTypeHelper {
|
|||
* but doesn't take into account base classes and methods dependent on unspecified
|
||||
* template parameters.
|
||||
*/
|
||||
public static ICPPMethod[] getPureVirtualMethods(ICPPClassType classType) {
|
||||
public static ICPPMethod[] getPureVirtualMethods(ICPPClassType classType, IASTNode point) {
|
||||
Map<String, List<ICPPMethod>> result= collectPureVirtualMethods(classType,
|
||||
new HashMap<ICPPClassType, Map<String, List<ICPPMethod>>>());
|
||||
new HashMap<ICPPClassType, Map<String, List<ICPPMethod>>>(), point);
|
||||
|
||||
int resultArraySize = 0;
|
||||
for (List<ICPPMethod> methods : result.values()) {
|
||||
|
@ -995,7 +1037,7 @@ public class ClassTypeHelper {
|
|||
}
|
||||
|
||||
private static Map<String, List<ICPPMethod>> collectPureVirtualMethods(ICPPClassType classType,
|
||||
Map<ICPPClassType, Map<String, List<ICPPMethod>>> cache) {
|
||||
Map<ICPPClassType, Map<String, List<ICPPMethod>>> cache, IASTNode point) {
|
||||
Map<String, List<ICPPMethod>> result = cache.get(classType);
|
||||
if (result != null)
|
||||
return result;
|
||||
|
@ -1005,10 +1047,10 @@ public class ClassTypeHelper {
|
|||
|
||||
// Look at the pure virtual methods of the base classes
|
||||
Set<IBinding> handledBaseClasses= new HashSet<IBinding>();
|
||||
for (ICPPBase base : classType.getBases()) {
|
||||
for (ICPPBase base : ClassTypeHelper.getBases(classType, point)) {
|
||||
final IBinding baseClass = base.getBaseClass();
|
||||
if (baseClass instanceof ICPPClassType && handledBaseClasses.add(baseClass)) {
|
||||
Map<String, List<ICPPMethod>> pureVirtuals = collectPureVirtualMethods((ICPPClassType) baseClass, cache);
|
||||
Map<String, List<ICPPMethod>> pureVirtuals = collectPureVirtualMethods((ICPPClassType) baseClass, cache, point);
|
||||
// Merge derived pure virtual methods
|
||||
for (String key : pureVirtuals.keySet()) {
|
||||
List<ICPPMethod> list = result.get(key);
|
||||
|
@ -1021,8 +1063,8 @@ public class ClassTypeHelper {
|
|||
}
|
||||
}
|
||||
|
||||
// Remove overridden pure-virtual methods and add in new pure virutals.
|
||||
final ObjectSet<ICPPMethod> methods = getOwnMethods(classType);
|
||||
// Remove overridden pure-virtual methods and add in new pure virtuals.
|
||||
final ObjectSet<ICPPMethod> methods = getOwnMethods(classType, point);
|
||||
for (ICPPMethod method : methods) {
|
||||
String key= getMethodNameForOverrideKey(method);
|
||||
List<ICPPMethod> list = result.get(key);
|
||||
|
|
|
@ -152,7 +152,7 @@ public class AccessContext {
|
|||
return isAccessible(bindingVisibility, accessLevel);
|
||||
}
|
||||
|
||||
ICPPBase[] bases = derivedClass.getBases();
|
||||
ICPPBase[] bases = ClassTypeHelper.getBases(derivedClass, name);
|
||||
if (bases != null) {
|
||||
for (ICPPBase base : bases) {
|
||||
IBinding baseBinding = base.getBaseClass();
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPMember;
|
|||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknownScope;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
||||
|
@ -181,7 +182,7 @@ class BaseClassLookup {
|
|||
// base-classes
|
||||
ICPPClassType baseClass= result.getClassType();
|
||||
if (baseClass != null) {
|
||||
ICPPBase[] grandBases= SemanticUtil.getBases(baseClass, data.getLookupPoint());
|
||||
ICPPBase[] grandBases= ClassTypeHelper.getBases(baseClass, data.getLookupPoint());
|
||||
if (grandBases != null && grandBases.length > 0) {
|
||||
HashSet<IBinding> grandBaseBindings= null;
|
||||
BitSet selectedBases= null;
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTTranslationUnit;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
||||
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.SizeofCalculator;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.SizeofCalculator.SizeAndAlignment;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateNonTypeArgument;
|
||||
|
@ -251,7 +252,9 @@ public abstract class CPPEvaluation implements ICPPEvaluation {
|
|||
}
|
||||
|
||||
protected static SizeAndAlignment getSizeAndAlignment(IType type, IASTNode point) {
|
||||
ASTTranslationUnit ast = (ASTTranslationUnit) point.getTranslationUnit();
|
||||
return ast.getSizeofCalculator().sizeAndAlignment(type);
|
||||
SizeofCalculator calc = point == null ?
|
||||
SizeofCalculator.getDefault() :
|
||||
((ASTTranslationUnit) point.getTranslationUnit()).getSizeofCalculator();
|
||||
return calc.sizeAndAlignment(type);
|
||||
}
|
||||
}
|
|
@ -203,6 +203,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownFunction;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUsingDeclaration;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUsingDirective;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVariable;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPASTInternalScope;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPClassSpecializationScope;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance;
|
||||
|
@ -414,7 +415,7 @@ public class CPPSemantics {
|
|||
if (cls instanceof ICPPUnknownBinding) {
|
||||
binding= new CPPUnknownConstructor(cls);
|
||||
} else {
|
||||
binding= CPPSemantics.resolveFunction(data, SemanticUtil.getConstructors(cls, lookupPoint), true);
|
||||
binding= CPPSemantics.resolveFunction(data, ClassTypeHelper.getConstructors(cls, lookupPoint), true);
|
||||
}
|
||||
} catch (DOMException e) {
|
||||
return e.getProblem();
|
||||
|
@ -714,7 +715,7 @@ public class CPPSemantics {
|
|||
}
|
||||
if (t instanceof ICPPClassType && !(t instanceof ICPPClassTemplate)) {
|
||||
ICPPClassType ct= (ICPPClassType) t;
|
||||
ICPPBase[] bases = SemanticUtil.getBases(ct, tu);
|
||||
ICPPBase[] bases = ClassTypeHelper.getBases(ct, tu);
|
||||
for (ICPPBase base : bases) {
|
||||
IBinding b = base.getBaseClass();
|
||||
if (b instanceof IType)
|
||||
|
@ -725,7 +726,7 @@ public class CPPSemantics {
|
|||
// (excluding template template parameters);
|
||||
// * ... owners of which any template template arguments are members;
|
||||
if (ct instanceof ICPPTemplateInstance) {
|
||||
for (IBinding friend : ct.getFriends()) {
|
||||
for (IBinding friend : ClassTypeHelper.getFriends(ct, tu)) {
|
||||
if (friend instanceof ICPPFunction) {
|
||||
friendFns.add((ICPPFunction) friend);
|
||||
}
|
||||
|
@ -2817,7 +2818,7 @@ public class CPPSemantics {
|
|||
LookupData data= new LookupData(name);
|
||||
data.setFunctionArguments(false, init.getArguments());
|
||||
try {
|
||||
IBinding ctor = CPPSemantics.resolveFunction(data, SemanticUtil.getConstructors((ICPPClassType) targetType, name), true);
|
||||
IBinding ctor = CPPSemantics.resolveFunction(data, ClassTypeHelper.getConstructors((ICPPClassType) targetType, name), true);
|
||||
if (ctor instanceof ICPPConstructor) {
|
||||
int i= 0;
|
||||
for (IASTNode arg : init.getArguments()) {
|
||||
|
@ -3124,13 +3125,13 @@ public class CPPSemantics {
|
|||
LookupData data = new LookupData(astName);
|
||||
data.setFunctionArguments(false, arguments);
|
||||
data.qualified = true;
|
||||
data.foundItems = SemanticUtil.getConstructors(classType, name);
|
||||
data.foundItems = ClassTypeHelper.getConstructors(classType, name);
|
||||
binding = resolveAmbiguities(data);
|
||||
if (binding instanceof ICPPConstructor)
|
||||
return (ICPPConstructor) binding;
|
||||
} else if (initializer == null) {
|
||||
// Default initialization
|
||||
ICPPConstructor[] ctors = SemanticUtil.getConstructors(classType, name);
|
||||
ICPPConstructor[] ctors = ClassTypeHelper.getConstructors(classType, name);
|
||||
for (ICPPConstructor ctor : ctors) {
|
||||
if (ctor.getRequiredArgumentCount() == 0)
|
||||
return ctor;
|
||||
|
|
|
@ -2241,6 +2241,8 @@ public class CPPVisitor extends ASTQueries {
|
|||
}
|
||||
|
||||
private static IType getStdType(final IASTNode node, char[] name) {
|
||||
if (node == null)
|
||||
return null;
|
||||
ASTTranslationUnit ast = (ASTTranslationUnit) node.getTranslationUnit();
|
||||
IBinding[] std= ast.getScope().find(STD);
|
||||
for (IBinding binding : std) {
|
||||
|
|
|
@ -371,7 +371,7 @@ public class Conversions {
|
|||
return Cost.NO_CONVERSION;
|
||||
|
||||
ICPPClassType classTarget= (ICPPClassType) noCVTarget;
|
||||
if (ClassTypeHelper.isAggregateClass(classTarget)) {
|
||||
if (ClassTypeHelper.isAggregateClass(classTarget, point)) {
|
||||
Cost cost= new Cost(arg.getTypeOrFunctionSet(point), target, Rank.IDENTITY);
|
||||
cost.setUserDefinedConversion(null);
|
||||
return cost;
|
||||
|
@ -546,7 +546,7 @@ public class Conversions {
|
|||
ICPPConstructor usedCtor= null;
|
||||
Cost bestCost= null;
|
||||
boolean hasInitListConstructor= false;
|
||||
final ICPPConstructor[] constructors = SemanticUtil.getConstructors(t, point);
|
||||
final ICPPConstructor[] constructors = ClassTypeHelper.getConstructors(t, point);
|
||||
ICPPConstructor[] ctors= constructors;
|
||||
for (ICPPConstructor ctor : ctors) {
|
||||
final int minArgCount = ctor.getRequiredArgumentCount();
|
||||
|
@ -640,7 +640,7 @@ public class Conversions {
|
|||
|
||||
FunctionCost cost1= null;
|
||||
Cost cost2= null;
|
||||
ICPPFunction[] ctors= SemanticUtil.getConstructors(t, point);
|
||||
ICPPFunction[] ctors= ClassTypeHelper.getConstructors(t, point);
|
||||
ctors = CPPTemplates.instantiateForFunctionCall(ctors, null,
|
||||
Collections.singletonList(source), Collections.singletonList(valueCat), false, point);
|
||||
|
||||
|
|
|
@ -40,10 +40,7 @@ import org.eclipse.cdt.core.dom.ast.IQualifierType;
|
|||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||
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.ICPPField;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
|
@ -66,6 +63,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerToMemberType;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPQualifierType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateTypeArgument;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator;
|
||||
|
||||
|
@ -108,7 +106,7 @@ public class SemanticUtil {
|
|||
if (clazz instanceof ICPPDeferredClassInstance) {
|
||||
clazz= (ICPPClassType) ((ICPPDeferredClassInstance) clazz).getTemplateDefinition();
|
||||
}
|
||||
ICPPMethod[] decs= getDeclaredMethods(clazz, point);
|
||||
ICPPMethod[] decs= ClassTypeHelper.getDeclaredMethods(clazz, point);
|
||||
if (decs != null) {
|
||||
for (ICPPMethod method : decs) {
|
||||
if (isConversionOperator(method)) {
|
||||
|
@ -152,7 +150,7 @@ public class SemanticUtil {
|
|||
ICPPClassType clazz= current.keyAt(i);
|
||||
done.put(clazz);
|
||||
|
||||
for (ICPPBase base : getBases(clazz, point)) {
|
||||
for (ICPPBase base : ClassTypeHelper.getBases(clazz, point)) {
|
||||
IBinding binding= base.getBaseClass();
|
||||
if (binding instanceof ICPPClassType && !(binding instanceof IProblemBinding)) {
|
||||
ICPPClassType ct= (ICPPClassType) binding;
|
||||
|
@ -169,42 +167,6 @@ public class SemanticUtil {
|
|||
return done;
|
||||
}
|
||||
|
||||
public static ICPPBase[] getBases(ICPPClassType classType, IASTNode point) {
|
||||
if (classType instanceof ICPPClassSpecialization)
|
||||
return ((ICPPClassSpecialization) classType).getBases(point);
|
||||
return classType.getBases();
|
||||
}
|
||||
|
||||
public static ICPPConstructor[] getConstructors(ICPPClassType classType, IASTNode point) {
|
||||
if (classType instanceof ICPPClassSpecialization)
|
||||
return ((ICPPClassSpecialization) classType).getConstructors(point);
|
||||
return classType.getConstructors();
|
||||
}
|
||||
|
||||
public static ICPPField[] getDeclaredFields(ICPPClassType classType, IASTNode point) {
|
||||
if (classType instanceof ICPPClassSpecialization)
|
||||
return ((ICPPClassSpecialization) classType).getDeclaredFields(point);
|
||||
return classType.getDeclaredFields();
|
||||
}
|
||||
|
||||
public static ICPPMethod[] getDeclaredMethods(ICPPClassType classType, IASTNode point) {
|
||||
if (classType instanceof ICPPClassSpecialization)
|
||||
return ((ICPPClassSpecialization) classType).getDeclaredMethods(point);
|
||||
return classType.getDeclaredMethods();
|
||||
}
|
||||
|
||||
public static IBinding[] getFriends(ICPPClassType classType, IASTNode point) {
|
||||
if (classType instanceof ICPPClassSpecialization)
|
||||
return ((ICPPClassSpecialization) classType).getFriends(point);
|
||||
return classType.getFriends();
|
||||
}
|
||||
|
||||
public static ICPPClassType[] getNestedClasses(ICPPClassType classType, IASTNode point) {
|
||||
if (classType instanceof ICPPClassSpecialization)
|
||||
return ((ICPPClassSpecialization) classType).getNestedClasses(point);
|
||||
return classType.getNestedClasses();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param method
|
||||
* @return true if the specified method is a conversion operator
|
||||
|
@ -676,7 +638,7 @@ public class SemanticUtil {
|
|||
clazz= (ICPPClassType) ((ICPPDeferredClassInstance) clazz).getSpecializedBinding();
|
||||
}
|
||||
|
||||
for (ICPPBase cppBase : getBases(clazz, point)) {
|
||||
for (ICPPBase cppBase : ClassTypeHelper.getBases(clazz, point)) {
|
||||
IBinding base= cppBase.getBaseClass();
|
||||
if (base instanceof IType && hashSet.add(base)) {
|
||||
IType tbase= (IType) base;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009, 2010 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2009, 2012 Wind River Systems, Inc. and others.
|
||||
* 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
|
||||
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
||||
|
||||
|
@ -63,6 +64,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPReferenceType;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateNonTypeArgument;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateTypeArgument;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
||||
|
||||
|
@ -71,9 +73,9 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
|||
*/
|
||||
public class TemplateArgumentDeduction {
|
||||
/**
|
||||
* Deduce arguments for a template function from the template id + the template function parameters.
|
||||
* Deduce arguments for a template function from the template id and the template function
|
||||
* parameters.
|
||||
* 14.8.2.1
|
||||
* @param point
|
||||
*/
|
||||
static ICPPTemplateArgument[] deduceForFunctionCall(ICPPFunctionTemplate template,
|
||||
ICPPTemplateArgument[] tmplArgs, List<IType> fnArgs, List<ValueCategory> argIsLValue,
|
||||
|
@ -236,7 +238,7 @@ public class TemplateArgumentDeduction {
|
|||
ICPPTemplateInstance pInst = (ICPPTemplateInstance) pcheck;
|
||||
ICPPClassTemplate pTemplate= getPrimaryTemplate(pInst);
|
||||
if (pTemplate != null) {
|
||||
ICPPClassType aInst= findBaseInstance((ICPPClassType) argcheck, pTemplate);
|
||||
ICPPClassType aInst= findBaseInstance((ICPPClassType) argcheck, pTemplate, point);
|
||||
if (aInst != null && aInst != argcheck) {
|
||||
par= pcheck;
|
||||
arg= aInst;
|
||||
|
@ -291,7 +293,6 @@ public class TemplateArgumentDeduction {
|
|||
/**
|
||||
* Deduce arguments for a user defined conversion template
|
||||
* 14.8.2.3
|
||||
* @param point
|
||||
*/
|
||||
static ICPPTemplateArgument[] deduceForConversion(ICPPFunctionTemplate template,
|
||||
IType conversionType, CPPTemplateParameterMap map, IASTNode point) throws DOMException {
|
||||
|
@ -326,7 +327,6 @@ public class TemplateArgumentDeduction {
|
|||
/**
|
||||
* Deduce arguments for a function declaration
|
||||
* 14.8.2.6
|
||||
* @param point
|
||||
*/
|
||||
static ICPPTemplateArgument[] deduceForDeclaration(ICPPFunctionTemplate template,
|
||||
ICPPTemplateArgument[] args, ICPPFunctionType ftype, CPPTemplateParameterMap map, IASTNode point) throws DOMException {
|
||||
|
@ -361,7 +361,6 @@ public class TemplateArgumentDeduction {
|
|||
/**
|
||||
* Deduces the mapping for the template parameters from the function parameters,
|
||||
* returns <code>false</code> if there is no mapping.
|
||||
* @param point
|
||||
*/
|
||||
static int deduceForPartialOrdering(ICPPTemplateParameter[] tmplPars, IType[] fnPars, IType[] fnArgs, IASTNode point) {
|
||||
try {
|
||||
|
@ -424,7 +423,6 @@ public class TemplateArgumentDeduction {
|
|||
|
||||
/**
|
||||
* Adds the explicit arguments to the map.
|
||||
* @param point
|
||||
*/
|
||||
private static boolean addExplicitArguments(final ICPPTemplateParameter[] tmplParams,
|
||||
ICPPTemplateArgument[] tmplArgs, CPPTemplateParameterMap map, IASTNode point) {
|
||||
|
@ -482,13 +480,14 @@ public class TemplateArgumentDeduction {
|
|||
}
|
||||
|
||||
/**
|
||||
* 14.8.2.1.3 If P is a class and has the form template-id, then A can be a derived class of the deduced A.
|
||||
* 14.8.2.1.3 If P is a class and has the form template-id, then A can be a derived class of
|
||||
* the deduced A.
|
||||
*/
|
||||
private static ICPPClassType findBaseInstance(ICPPClassType a, ICPPClassTemplate pTemplate) throws DOMException {
|
||||
return findBaseInstance(a, pTemplate, CPPSemantics.MAX_INHERITANCE_DEPTH, new HashSet<Object>());
|
||||
private static ICPPClassType findBaseInstance(ICPPClassType a, ICPPClassTemplate pTemplate, IASTNode point) throws DOMException {
|
||||
return findBaseInstance(a, pTemplate, CPPSemantics.MAX_INHERITANCE_DEPTH, new HashSet<Object>(), point);
|
||||
}
|
||||
|
||||
private static ICPPClassType findBaseInstance(ICPPClassType a, ICPPClassTemplate pTemplate, int maxdepth, HashSet<Object> handled) throws DOMException {
|
||||
private static ICPPClassType findBaseInstance(ICPPClassType a, ICPPClassTemplate pTemplate, int maxdepth, HashSet<Object> handled, IASTNode point) throws DOMException {
|
||||
if (a instanceof ICPPTemplateInstance) {
|
||||
final ICPPTemplateInstance inst = (ICPPTemplateInstance) a;
|
||||
ICPPClassTemplate tmpl= getPrimaryTemplate(inst);
|
||||
|
@ -496,10 +495,10 @@ public class TemplateArgumentDeduction {
|
|||
return a;
|
||||
}
|
||||
if (maxdepth-- > 0) {
|
||||
for (ICPPBase cppBase : a.getBases()) {
|
||||
for (ICPPBase cppBase : ClassTypeHelper.getBases(a, point)) {
|
||||
IBinding base= cppBase.getBaseClass();
|
||||
if (base instanceof ICPPClassType && handled.add(base)) {
|
||||
final ICPPClassType inst= findBaseInstance((ICPPClassType) base, pTemplate, maxdepth, handled);
|
||||
final ICPPClassType inst= findBaseInstance((ICPPClassType) base, pTemplate, maxdepth, handled, point);
|
||||
if (inst != null)
|
||||
return inst;
|
||||
}
|
||||
|
@ -547,7 +546,6 @@ public class TemplateArgumentDeduction {
|
|||
|
||||
/**
|
||||
* Deduces the template parameter mapping from pairs of template arguments.
|
||||
* @param point
|
||||
*/
|
||||
public static boolean fromTemplateArguments(final ICPPTemplateParameter[] pars,
|
||||
final ICPPTemplateArgument[] p, final ICPPTemplateArgument[] a, CPPTemplateParameterMap map,
|
||||
|
@ -640,7 +638,6 @@ public class TemplateArgumentDeduction {
|
|||
|
||||
/**
|
||||
* Deduces the template parameter mapping from one pair of template arguments.
|
||||
* @param point
|
||||
*/
|
||||
private boolean fromTemplateArgument(ICPPTemplateArgument p, ICPPTemplateArgument a, IASTNode point) throws DOMException {
|
||||
if (p.isNonTypeValue() != a.isNonTypeValue())
|
||||
|
|
|
@ -15,8 +15,10 @@ package org.eclipse.cdt.internal.core.index.composite.cpp;
|
|||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IField;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
|
||||
|
@ -30,6 +32,7 @@ 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.CPPClassSpecialization.RecursionResolvingBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateParameterMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPClassSpecializationScope;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexFragment;
|
||||
|
@ -79,11 +82,11 @@ public class CompositeCPPClassSpecialization extends CompositeCPPClassType imple
|
|||
specializationMap= (ObjectMap) cached;
|
||||
} else {
|
||||
final ObjectMap newMap= new ObjectMap(2);
|
||||
// in any fragment explicit specializations may be defined.
|
||||
// In any fragment explicit specializations may be defined.
|
||||
IIndexFragmentBinding[] frags= cf.findEquivalentBindings(rbinding);
|
||||
for (IIndexFragmentBinding fb : frags) {
|
||||
if (fb instanceof ICPPClassType) {
|
||||
final ICPPClassType[] nested = ((ICPPClassType)fb).getNestedClasses();
|
||||
final ICPPClassType[] nested = ClassTypeHelper.getNestedClasses((ICPPClassType) fb, point);
|
||||
if (nested.length > 0) {
|
||||
for (ICPPClassType ct : nested) {
|
||||
if (ct instanceof ICPPClassSpecialization &&
|
||||
|
@ -129,7 +132,8 @@ public class CompositeCPPClassSpecialization extends CompositeCPPClassType imple
|
|||
|
||||
@Override
|
||||
public final ICPPBase[] getBases() {
|
||||
return getBases(null); // Instantiation of dependent expression may not work.
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getBases(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -138,12 +142,14 @@ public class CompositeCPPClassSpecialization extends CompositeCPPClassType imple
|
|||
if (scope instanceof ICPPClassSpecializationScope) {
|
||||
return ((ICPPClassSpecializationScope) scope).getBases(point);
|
||||
}
|
||||
return super.getBases();
|
||||
ICPPBase[] bases = ClassTypeHelper.getBases((ICPPClassType) rbinding, point);
|
||||
return wrapBases(bases);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final ICPPConstructor[] getConstructors() {
|
||||
return getConstructors(null); // Instantiation of dependent expression may not work.
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getConstructors(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -152,12 +158,25 @@ public class CompositeCPPClassSpecialization extends CompositeCPPClassType imple
|
|||
if (scope instanceof ICPPClassSpecializationScope) {
|
||||
return ((ICPPClassSpecializationScope) scope).getConstructors(point);
|
||||
}
|
||||
return super.getConstructors();
|
||||
ICPPConstructor[] result = ClassTypeHelper.getConstructors((ICPPClassType) rbinding, point);
|
||||
return wrapBindings(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPMethod[] getMethods() {
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getMethods(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPMethod[] getMethods(IASTNode point) {
|
||||
return ClassTypeHelper.getMethods(this, point);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final ICPPMethod[] getDeclaredMethods() {
|
||||
return getDeclaredMethods(null); // Instantiation of dependent expression may not work.
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getDeclaredMethods(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -166,12 +185,25 @@ public class CompositeCPPClassSpecialization extends CompositeCPPClassType imple
|
|||
if (scope instanceof ICPPClassSpecializationScope) {
|
||||
return ((ICPPClassSpecializationScope) scope).getDeclaredMethods(point);
|
||||
}
|
||||
return super.getDeclaredMethods();
|
||||
ICPPMethod[] result = ClassTypeHelper.getDeclaredMethods((ICPPClassType) rbinding, point);
|
||||
return wrapBindings(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final ICPPMethod[] getAllDeclaredMethods() {
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getAllDeclaredMethods(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final ICPPMethod[] getAllDeclaredMethods(IASTNode point) {
|
||||
return ClassTypeHelper.getAllDeclaredMethods(this, point);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final ICPPField[] getDeclaredFields() {
|
||||
return getDeclaredFields(null); // Instantiation of dependent expression may not work.
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getDeclaredFields(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -180,12 +212,25 @@ public class CompositeCPPClassSpecialization extends CompositeCPPClassType imple
|
|||
if (scope instanceof ICPPClassSpecializationScope) {
|
||||
return ((ICPPClassSpecializationScope) scope).getDeclaredFields(point);
|
||||
}
|
||||
return super.getDeclaredFields();
|
||||
ICPPField[] result = ClassTypeHelper.getDeclaredFields((ICPPClassType) rbinding, point);
|
||||
return wrapBindings(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IField[] getFields() {
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getFields(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IField[] getFields(IASTNode point) {
|
||||
return ClassTypeHelper.getFields(this, point);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IBinding[] getFriends() {
|
||||
return getFriends(null); // Instantiation of dependent expression may not work.
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getFriends(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -194,12 +239,14 @@ public class CompositeCPPClassSpecialization extends CompositeCPPClassType imple
|
|||
if (scope instanceof ICPPClassSpecializationScope) {
|
||||
return ((ICPPClassSpecializationScope) scope).getFriends(point);
|
||||
}
|
||||
return super.getFriends();
|
||||
IBinding[] result = ClassTypeHelper.getFriends((ICPPClassType) rbinding, point);
|
||||
return wrapBindings(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final ICPPClassType[] getNestedClasses() {
|
||||
return getNestedClasses(null); // Instantiation of dependent expression may not work.
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getNestedClasses(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -208,7 +255,8 @@ public class CompositeCPPClassSpecialization extends CompositeCPPClassType imple
|
|||
if (scope instanceof ICPPClassSpecializationScope) {
|
||||
return ((ICPPClassSpecializationScope) scope).getNestedClasses(point);
|
||||
}
|
||||
return super.getNestedClasses();
|
||||
ICPPClassType[] result = ClassTypeHelper.getNestedClasses((ICPPClassType) rbinding, point);
|
||||
return wrapBindings(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ast.EScopeKind;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
|
@ -69,7 +70,8 @@ public class CompositeCPPClassSpecializationScope extends CompositeScope impleme
|
|||
|
||||
@Override
|
||||
public ICPPMethod[] getImplicitMethods() {
|
||||
return getImplicitMethods(null); // Instantiation of dependent expression may not work.
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getImplicitMethods(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -104,7 +106,8 @@ public class CompositeCPPClassSpecializationScope extends CompositeScope impleme
|
|||
|
||||
@Override
|
||||
public ICPPConstructor[] getConstructors() {
|
||||
return getConstructors(null); // Instantiation of dependent expression may not work.
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getConstructors(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007, 2010 Symbian Software Systems and others.
|
||||
* Copyright (c) 2007, 2012 Symbian Software Systems and others.
|
||||
* 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
|
||||
|
@ -8,9 +8,12 @@
|
|||
* Contributors:
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.eclipse.cdt.core.dom.IName;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IField;
|
||||
|
@ -42,8 +45,8 @@ class CompositeCPPClassType extends CompositeCPPBinding implements ICPPClassType
|
|||
}
|
||||
|
||||
@Override
|
||||
public final ICPPMethod[] getAllDeclaredMethods() {
|
||||
return ClassTypeHelper.getAllDeclaredMethods(this);
|
||||
public ICPPMethod[] getAllDeclaredMethods() {
|
||||
return ClassTypeHelper.getAllDeclaredMethods(this, null);
|
||||
}
|
||||
|
||||
private class CPPBaseDelegate implements ICPPBase {
|
||||
|
@ -101,68 +104,48 @@ class CompositeCPPClassType extends CompositeCPPBinding implements ICPPClassType
|
|||
|
||||
@Override
|
||||
public ICPPBase[] getBases() {
|
||||
final ICPPBase[] preresult = ((ICPPClassType) rbinding).getBases();
|
||||
ICPPBase[] result = new ICPPBase[preresult.length];
|
||||
for (int i= 0; i < preresult.length; i++) {
|
||||
result[i] = new CPPBaseDelegate(preresult[i]);
|
||||
}
|
||||
return result;
|
||||
ICPPBase[] bases = ((ICPPClassType) rbinding).getBases();
|
||||
return wrapBases(bases);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPConstructor[] getConstructors() {
|
||||
ICPPConstructor[] result = ((ICPPClassType) rbinding).getConstructors();
|
||||
for (int i= 0; i < result.length; i++) {
|
||||
result[i] = (ICPPConstructor) cf.getCompositeBinding((IIndexFragmentBinding) result[i]);
|
||||
}
|
||||
return result;
|
||||
return wrapBindings(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPField[] getDeclaredFields() {
|
||||
ICPPField[] result = ((ICPPClassType) rbinding).getDeclaredFields();
|
||||
for (int i= 0; i < result.length; i++) {
|
||||
result[i] = (ICPPField) cf.getCompositeBinding((IIndexFragmentBinding) result[i]);
|
||||
}
|
||||
return result;
|
||||
return wrapBindings(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPMethod[] getDeclaredMethods() {
|
||||
ICPPMethod[] result = ((ICPPClassType) rbinding).getDeclaredMethods();
|
||||
for (int i= 0; i < result.length; i++) {
|
||||
result[i]= (ICPPMethod) cf.getCompositeBinding((IIndexFragmentBinding) result[i]);
|
||||
}
|
||||
return result;
|
||||
return wrapBindings(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IField[] getFields() {
|
||||
return ClassTypeHelper.getFields(this);
|
||||
public IField[] getFields() {
|
||||
return ClassTypeHelper.getFields(this, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinding[] getFriends() {
|
||||
IBinding[] preResult = ((ICPPClassType) rbinding).getFriends();
|
||||
IBinding[] result = new IBinding[preResult.length];
|
||||
for (int i= 0; i < preResult.length; i++) {
|
||||
result[i] = cf.getCompositeBinding((IIndexFragmentBinding) preResult[i]);
|
||||
}
|
||||
return result;
|
||||
return wrapBindings(preResult);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final ICPPMethod[] getMethods() {
|
||||
return ClassTypeHelper.getMethods(this);
|
||||
public ICPPMethod[] getMethods() {
|
||||
return ClassTypeHelper.getMethods(this, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPClassType[] getNestedClasses() {
|
||||
ICPPClassType[] result = ((ICPPClassType) rbinding).getNestedClasses();
|
||||
for (int i= 0; i < result.length; i++) {
|
||||
result[i] = (ICPPClassType) cf.getCompositeBinding((IIndexFragmentBinding) result[i]);
|
||||
}
|
||||
return result;
|
||||
return wrapBindings(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -184,4 +167,21 @@ class CompositeCPPClassType extends CompositeCPPBinding implements ICPPClassType
|
|||
public boolean isAnonymous() {
|
||||
return ((ICPPClassType) rbinding).isAnonymous();
|
||||
}
|
||||
|
||||
protected ICPPBase[] wrapBases(final ICPPBase[] bases) {
|
||||
ICPPBase[] result = new ICPPBase[bases.length];
|
||||
for (int i= 0; i < bases.length; i++) {
|
||||
result[i] = new CPPBaseDelegate(bases[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected <T extends IBinding> T[] wrapBindings(T[] bindings) {
|
||||
T[] result = Arrays.copyOf(bindings, bindings.length);
|
||||
for (int i= 0; i < bindings.length; i++) {
|
||||
result[i] = (T) cf.getCompositeBinding((IIndexFragmentBinding) bindings[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -208,7 +208,8 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
|
|||
|
||||
@Override
|
||||
public ICPPBase[] getBases() {
|
||||
return getBases(null); // Instantiation of dependent expression may not work.
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getBases(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -241,7 +242,8 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
|
|||
|
||||
@Override
|
||||
public ICPPConstructor[] getConstructors() {
|
||||
return getConstructors(null); // Instantiation of dependent expression may not work.
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getConstructors(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -262,7 +264,8 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
|
|||
|
||||
@Override
|
||||
public ICPPMethod[] getDeclaredMethods() {
|
||||
return getDeclaredMethods(null); // Instantiation of dependent expression may not work.
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getDeclaredMethods(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -283,7 +286,8 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
|
|||
|
||||
@Override
|
||||
public ICPPField[] getDeclaredFields() {
|
||||
return getDeclaredFields(null); // Instantiation of dependent expression may not work.
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getDeclaredFields(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -304,7 +308,8 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
|
|||
|
||||
@Override
|
||||
public ICPPClassType[] getNestedClasses() {
|
||||
return getNestedClasses(null); // Instantiation of dependent expression may not work.
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getNestedClasses(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -325,7 +330,8 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
|
|||
|
||||
@Override
|
||||
public IBinding[] getFriends() {
|
||||
return getFriends(null); // Instantiation of dependent expression may not work.
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getFriends(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -336,17 +342,35 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
|
|||
|
||||
@Override
|
||||
public ICPPMethod[] getMethods() {
|
||||
return ClassTypeHelper.getMethods(this);
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getMethods(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPMethod[] getMethods(IASTNode point) {
|
||||
return ClassTypeHelper.getMethods(this, point);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPMethod[] getAllDeclaredMethods() {
|
||||
return ClassTypeHelper.getAllDeclaredMethods(this);
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getAllDeclaredMethods(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPMethod[] getAllDeclaredMethods(IASTNode point) {
|
||||
return ClassTypeHelper.getAllDeclaredMethods(this, point);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IField[] getFields() {
|
||||
return ClassTypeHelper.getFields(this);
|
||||
CCorePlugin.log(new Exception("Unsafe method call. Instantiation of dependent expressions may not work.")); //$NON-NLS-1$
|
||||
return getFields(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IField[] getFields(IASTNode point) {
|
||||
return ClassTypeHelper.getFields(this, point);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -158,7 +158,7 @@ class PDOMCPPClassTemplateSpecialization extends PDOMCPPClassSpecialization
|
|||
|
||||
@Override
|
||||
public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() {
|
||||
IASTNode point= null; // Instantiation of dependent expression may not work.
|
||||
IASTNode point= null; // Instantiation of dependent expressions may not work.
|
||||
ICPPClassTemplate origTemplate= (ICPPClassTemplate) getSpecializedBinding();
|
||||
ICPPClassTemplatePartialSpecialization[] orig = origTemplate.getPartialSpecializations();
|
||||
ICPPClassTemplatePartialSpecialization[] spec = new ICPPClassTemplatePartialSpecialization[orig.length];
|
||||
|
|
|
@ -351,17 +351,17 @@ class PDOMCPPClassType extends PDOMCPPBinding implements IPDOMCPPClassType, IPDO
|
|||
|
||||
@Override
|
||||
public ICPPMethod[] getMethods() {
|
||||
return ClassTypeHelper.getMethods(this);
|
||||
return ClassTypeHelper.getMethods(this, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPMethod[] getAllDeclaredMethods() {
|
||||
return ClassTypeHelper.getAllDeclaredMethods(this);
|
||||
return ClassTypeHelper.getAllDeclaredMethods(this, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IField[] getFields() {
|
||||
return ClassTypeHelper.getFields(this);
|
||||
return ClassTypeHelper.getFields(this, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -68,6 +67,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDirective;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
|
||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.internal.core.Util;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
||||
|
@ -82,6 +82,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerToMemberType;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPQualifierType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPReferenceType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownClassInstance;
|
||||
|
@ -252,7 +253,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
PDOMBinding pdomBinding = addBinding(binding, name);
|
||||
if (pdomBinding instanceof PDOMCPPClassType || pdomBinding instanceof PDOMCPPClassSpecialization) {
|
||||
if (binding instanceof ICPPClassType && name.isDefinition()) {
|
||||
addImplicitMethods(pdomBinding, (ICPPClassType) binding);
|
||||
addImplicitMethods(pdomBinding, (ICPPClassType) binding, name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -299,7 +300,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
if (pdomBinding != null) {
|
||||
getPDOM().putCachedResult(inputBinding, pdomBinding);
|
||||
if (inputBinding instanceof CPPClosureType) {
|
||||
addImplicitMethods(pdomBinding, (ICPPClassType) binding);
|
||||
addImplicitMethods(pdomBinding, (ICPPClassType) binding, fromName);
|
||||
}
|
||||
}
|
||||
} catch (DOMException e) {
|
||||
|
@ -490,17 +491,14 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
return result;
|
||||
}
|
||||
|
||||
private void addImplicitMethods(PDOMBinding type, ICPPClassType binding) throws CoreException {
|
||||
private void addImplicitMethods(PDOMBinding type, ICPPClassType binding, IASTNode point) throws CoreException {
|
||||
try {
|
||||
final long fileLocalRec= type.getLocalToFileRec();
|
||||
IScope scope = binding.getCompositeScope();
|
||||
if (scope instanceof ICPPClassScope) {
|
||||
List<ICPPMethod> old= new ArrayList<ICPPMethod>();
|
||||
if (type instanceof ICPPClassType) {
|
||||
IScope oldScope = ((ICPPClassType)type).getCompositeScope();
|
||||
if (oldScope instanceof ICPPClassScope) {
|
||||
old.addAll(Arrays.asList(((ICPPClassScope) oldScope).getImplicitMethods()));
|
||||
}
|
||||
ArrayUtil.addAll(old, ClassTypeHelper.getImplicitMethods((ICPPClassType) type, point));
|
||||
}
|
||||
ICPPMethod[] implicit= ((ICPPClassScope) scope).getImplicitMethods();
|
||||
for (ICPPMethod method : implicit) {
|
||||
|
|
|
@ -253,7 +253,7 @@ class PDOMCPPMethod extends PDOMCPPFunction implements ICPPMethod {
|
|||
@Override
|
||||
public IType[] getExceptionSpecification() {
|
||||
if (isImplicit()) {
|
||||
return ClassTypeHelper.getInheritedExceptionSpecification(this);
|
||||
return ClassTypeHelper.getInheritedExceptionSpecification(this, null);
|
||||
}
|
||||
return super.getExceptionSpecification();
|
||||
}
|
||||
|
|
|
@ -6,16 +6,18 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Bryan Wilkinson (QNX) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Bryan Wilkinson (QNX) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethodSpecialization;
|
||||
import org.eclipse.cdt.internal.core.Util;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
|
||||
|
@ -30,8 +32,7 @@ import org.eclipse.core.runtime.CoreException;
|
|||
* Specialization of a method
|
||||
*/
|
||||
class PDOMCPPMethodSpecialization extends PDOMCPPFunctionSpecialization
|
||||
implements ICPPMethod {
|
||||
|
||||
implements ICPPMethodSpecialization {
|
||||
/**
|
||||
* Offset of remaining annotation information (relative to the beginning of
|
||||
* the record).
|
||||
|
@ -135,9 +136,9 @@ class PDOMCPPMethodSpecialization extends PDOMCPPFunctionSpecialization
|
|||
}
|
||||
|
||||
@Override
|
||||
public IType[] getExceptionSpecification() {
|
||||
public IType[] getExceptionSpecification(IASTNode point) {
|
||||
if (isImplicit()) {
|
||||
return ClassTypeHelper.getInheritedExceptionSpecification(this);
|
||||
return ClassTypeHelper.getInheritedExceptionSpecification(this, point);
|
||||
}
|
||||
return super.getExceptionSpecification();
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ public class CHQueries {
|
|||
if (calleeBinding != null) {
|
||||
findCalledBy1(index, calleeBinding, true, project, result);
|
||||
if (calleeBinding instanceof ICPPMethod) {
|
||||
IBinding[] overriddenBindings= ClassTypeHelper.findOverridden((ICPPMethod) calleeBinding);
|
||||
IBinding[] overriddenBindings= ClassTypeHelper.findOverridden((ICPPMethod) calleeBinding, null);
|
||||
for (IBinding overriddenBinding : overriddenBindings) {
|
||||
findCalledBy1(index, overriddenBinding, false, project, result);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2010 Tomasz Wesolowski and others
|
||||
* Copyright (c) 2010, 2012 Tomasz Wesolowski and others
|
||||
* 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
|
||||
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Tomasz Wesolowski - initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.editor;
|
||||
|
||||
|
@ -218,7 +219,6 @@ public class OverrideIndicatorManager implements ICReconcilingListener {
|
|||
|
||||
private static OverrideInfo checkForOverride(ICPPMethod testedOverride, IASTNode node) throws DOMException {
|
||||
IASTFileLocation location = node.getFileLocation();
|
||||
testedOverride.getClassOwner().getBases();
|
||||
|
||||
boolean onlyPureVirtual = true;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
@ -227,7 +227,7 @@ public class OverrideIndicatorManager implements ICReconcilingListener {
|
|||
|
||||
Set<ICPPClassType> alreadyTestedBases = new HashSet<ICPPClassType>();
|
||||
|
||||
ICPPBase[] bases = testedOverride.getClassOwner().getBases();
|
||||
ICPPBase[] bases = ClassTypeHelper.getBases(testedOverride.getClassOwner(), node);
|
||||
|
||||
// Don't override 'self' in cyclic inheritance
|
||||
alreadyTestedBases.add(testedOverride.getClassOwner());
|
||||
|
@ -244,7 +244,6 @@ public class OverrideIndicatorManager implements ICReconcilingListener {
|
|||
handleBaseClass(testedClass, testedOverride, overridenMethods, shadowedMethods, alreadyTestedBases);
|
||||
|
||||
for (ICPPMethod overriddenMethod : overridenMethods) {
|
||||
|
||||
if (sb.length() > 0) {
|
||||
sb.append(MESSAGE_SEPARATOR);
|
||||
}
|
||||
|
@ -289,8 +288,8 @@ public class OverrideIndicatorManager implements ICReconcilingListener {
|
|||
}
|
||||
|
||||
if (sb.length() > 0) {
|
||||
OverrideInfo info = new OverrideInfo(location.getNodeOffset(), location.getNodeLength(), markerType,
|
||||
sb.toString(), bindingToOpen);
|
||||
OverrideInfo info = new OverrideInfo(location.getNodeOffset(), location.getNodeLength(),
|
||||
markerType, sb.toString(), bindingToOpen);
|
||||
return info;
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -31,7 +31,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
|
||||
|
||||
|
||||
/**
|
||||
* Rename processor for methods.
|
||||
*/
|
||||
|
@ -108,7 +107,7 @@ public class CRenameMethodProcessor extends CRenameGlobalProcessor {
|
|||
if (binding instanceof ICPPMethod) {
|
||||
ICPPMethod m= (ICPPMethod) binding;
|
||||
try {
|
||||
IBinding[] bs= ClassTypeHelper.findOverridden(m);
|
||||
IBinding[] bs= ClassTypeHelper.findOverridden(m, argument.getTranslationUnit());
|
||||
bindings.addAll(Arrays.asList(bs));
|
||||
bs= ClassTypeHelper.findOverriders(getIndex(), m);
|
||||
bindings.addAll(Arrays.asList(bs));
|
||||
|
|
|
@ -357,7 +357,8 @@ public abstract class CSearchQuery implements ISearchQuery {
|
|||
|
||||
if (binding instanceof ICPPMethod) {
|
||||
ICPPMethod m= (ICPPMethod) binding;
|
||||
ICPPMethod[] msInBases = ClassTypeHelper.findOverridden(m);
|
||||
IASTNode point = null; // Instantiation of dependent expressions may not work.
|
||||
ICPPMethod[] msInBases = ClassTypeHelper.findOverridden(m, point);
|
||||
if (msInBases.length > 0) {
|
||||
if (polymorphicNames == null) {
|
||||
polymorphicNames= new ArrayList<IIndexName>();
|
||||
|
|
|
@ -99,7 +99,7 @@ public class LinkedNamesFinder {
|
|||
}
|
||||
} else if (target instanceof ICPPMethod) {
|
||||
ICPPMethod method= (ICPPMethod) target;
|
||||
for (ICPPMethod m : ClassTypeHelper.findOverridden(method)) {
|
||||
for (ICPPMethod m : ClassTypeHelper.findOverridden(method, root)) {
|
||||
findBinding(m);
|
||||
}
|
||||
try {
|
||||
|
|
|
@ -36,6 +36,7 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorFunctionStyleMacroDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
||||
|
@ -78,6 +79,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBuiltinVariable;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPImplicitFunction;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPImplicitMethod;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPImplicitTypedef;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.AccessContext;
|
||||
import org.eclipse.cdt.internal.core.parser.util.ContentAssistMatcherFactory;
|
||||
|
||||
|
@ -309,7 +311,7 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
|
|||
if (binding instanceof ICPPClassType) {
|
||||
handleClass((ICPPClassType) binding, astContext, cContext, baseRelevance, proposals);
|
||||
} else if (binding instanceof IFunction) {
|
||||
handleFunction((IFunction)binding, cContext, baseRelevance, proposals);
|
||||
handleFunction((IFunction) binding, cContext, baseRelevance, proposals);
|
||||
} else if (binding instanceof IVariable) {
|
||||
handleVariable((IVariable) binding, cContext, baseRelevance, proposals);
|
||||
} else if (!cContext.isContextInformationStyle()) {
|
||||
|
@ -466,7 +468,8 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
|
|||
t= unwindTypedefs(t);
|
||||
if (t instanceof ICPPClassType) {
|
||||
ICPPClassType classType= (ICPPClassType) t;
|
||||
ICPPConstructor[] constructors = classType.getConstructors();
|
||||
IASTTranslationUnit ast = context.getCompletionNode().getTranslationUnit();
|
||||
ICPPConstructor[] constructors = ClassTypeHelper.getConstructors(classType, ast);
|
||||
for (ICPPConstructor constructor : constructors) {
|
||||
handleFunction(constructor, context, baseRelevance, proposals);
|
||||
}
|
||||
|
|
|
@ -511,7 +511,7 @@ public class IndexUI {
|
|||
// Check for specializations of the owner
|
||||
IBinding owner = binding.getOwner();
|
||||
if (owner != null) {
|
||||
IASTNode point= null; // Instantiation of dependent expression may not work.
|
||||
IASTNode point= null; // Instantiation of dependent expressions may not work.
|
||||
for (IBinding specOwner : findSpecializations(index, owner)) {
|
||||
if (specOwner instanceof ICPPClassSpecialization) {
|
||||
// Add the specialized member
|
||||
|
|
Loading…
Add table
Reference in a new issue