mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-05 16:15:25 +02:00
Bug 299911. Improved propagation of template instantiation context.
This commit is contained in:
parent
273f7ce331
commit
ec941362f4
2 changed files with 15 additions and 11 deletions
|
@ -46,6 +46,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
|
||||||
import org.eclipse.cdt.core.index.IIndex;
|
import org.eclipse.cdt.core.index.IIndex;
|
||||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVariableReadWriteFlags;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVariableReadWriteFlags;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
|
||||||
|
|
||||||
|
@ -84,7 +85,7 @@ public class ClassMembersInitializationChecker extends AbstractIndexAstChecker {
|
||||||
Set<IField> fieldsInConstructor = constructorsStack.push(new HashSet<IField>());
|
Set<IField> fieldsInConstructor = constructorsStack.push(new HashSet<IField>());
|
||||||
|
|
||||||
// Add all class fields
|
// Add all class fields
|
||||||
for (IField field : constructor.getClassOwner().getDeclaredFields()) {
|
for (IField field : ClassTypeHelper.getDeclaredFields(constructor.getClassOwner(), declaration)) {
|
||||||
if (isSimpleType(field.getType()) && !field.isStatic()) {
|
if (isSimpleType(field.getType()) && !field.isStatic()) {
|
||||||
fieldsInConstructor.add(field);
|
fieldsInConstructor.add(field);
|
||||||
}
|
}
|
||||||
|
|
|
@ -241,7 +241,8 @@ public class OverrideIndicatorManager implements ICReconcilingListener {
|
||||||
|
|
||||||
overridenMethods.clear();
|
overridenMethods.clear();
|
||||||
shadowedMethods.clear();
|
shadowedMethods.clear();
|
||||||
handleBaseClass(testedClass, testedOverride, overridenMethods, shadowedMethods, alreadyTestedBases);
|
handleBaseClass(testedClass, testedOverride, overridenMethods, shadowedMethods,
|
||||||
|
alreadyTestedBases, node);
|
||||||
|
|
||||||
for (ICPPMethod overriddenMethod : overridenMethods) {
|
for (ICPPMethod overriddenMethod : overridenMethods) {
|
||||||
if (sb.length() > 0) {
|
if (sb.length() > 0) {
|
||||||
|
@ -296,25 +297,26 @@ public class OverrideIndicatorManager implements ICReconcilingListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the class directly has a valid override for testedOverride, it is added to foundBindings. Otherwise
|
* If the class directly has a valid override for testedOverride, it is added to foundBindings.
|
||||||
* each base class is added to handleBaseClass.
|
* Otherwise each base class is added to handleBaseClass.
|
||||||
*
|
*
|
||||||
* @param shadowedMethods
|
* @param shadowedMethods
|
||||||
* @param alreadyTestedBases
|
* @param alreadyTestedBases
|
||||||
|
* @param point
|
||||||
*
|
*
|
||||||
* @throws DOMException
|
* @throws DOMException
|
||||||
*/
|
*/
|
||||||
private static void handleBaseClass(ICPPClassType aClass, ICPPMethod testedOverride,
|
private static void handleBaseClass(ICPPClassType classType, ICPPMethod testedOverride,
|
||||||
Set<ICPPMethod> foundMethods, Set<ICPPMethod> shadowedMethods,
|
Set<ICPPMethod> foundMethods, Set<ICPPMethod> shadowedMethods,
|
||||||
Set<ICPPClassType> alreadyTestedBases) throws DOMException {
|
Set<ICPPClassType> alreadyTestedBases, IASTNode point) throws DOMException {
|
||||||
if (alreadyTestedBases.contains(aClass)) {
|
if (alreadyTestedBases.contains(classType)) {
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
alreadyTestedBases.add(aClass);
|
alreadyTestedBases.add(classType);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector<ICPPMethod> validOverrides = new Vector<ICPPMethod>();
|
Vector<ICPPMethod> validOverrides = new Vector<ICPPMethod>();
|
||||||
for (ICPPMethod method : aClass.getDeclaredMethods()) {
|
for (ICPPMethod method : ClassTypeHelper.getDeclaredMethods(classType, point)) {
|
||||||
if (testedOverride.getName().equals(method.getName())) {
|
if (testedOverride.getName().equals(method.getName())) {
|
||||||
if (ClassTypeHelper.isOverrider(testedOverride, method)) {
|
if (ClassTypeHelper.isOverrider(testedOverride, method)) {
|
||||||
validOverrides.add(method);
|
validOverrides.add(method);
|
||||||
|
@ -331,12 +333,13 @@ public class OverrideIndicatorManager implements ICReconcilingListener {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ICPPBase b : aClass.getBases()) {
|
for (ICPPBase b : ClassTypeHelper.getBases(classType, point)) {
|
||||||
if (!(b.getBaseClass() instanceof ICPPClassType)) {
|
if (!(b.getBaseClass() instanceof ICPPClassType)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ICPPClassType baseClass = (ICPPClassType) b.getBaseClass();
|
ICPPClassType baseClass = (ICPPClassType) b.getBaseClass();
|
||||||
handleBaseClass(baseClass, testedOverride, foundMethods, shadowedMethods, alreadyTestedBases);
|
handleBaseClass(baseClass, testedOverride, foundMethods, shadowedMethods,
|
||||||
|
alreadyTestedBases, point);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue