1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Bug 539535 - Refactor CPPSemantics.findOverloadedOperator() so that if something goes wrong during one of the member or non-member lookups, the other is still performed

Change-Id: I34c1321a0aa943ee82d1e6c45cf33d97e2f5b5ca
This commit is contained in:
Nathan Ridge 2018-09-28 01:45:23 -04:00
parent dcc09f1975
commit 956ce6b2dc

View file

@ -3851,21 +3851,9 @@ public class CPPSemantics {
static enum LookupMode {NO_GLOBALS, GLOBALS_IF_NO_MEMBERS, LIMITED_GLOBALS, ALL_GLOBALS}
static ICPPFunction findOverloadedOperator(IScope pointOfDefinition, ICPPEvaluation[] args,
IType methodLookupType, OverloadableOperator operator, LookupMode mode) {
IASTNode pointOfInstantiation = CPPSemantics.getCurrentLookupPoint();
while (pointOfInstantiation instanceof IASTName) {
pointOfInstantiation= pointOfInstantiation.getParent();
}
ICPPClassType callToObjectOfClassType= null;
IType type2= null;
if (args.length >= 2) {
type2 = args[1].getType();
type2= getNestedType(type2, TDEF | REF | CVTYPE);
}
// Find a method
static LookupData findOverloadedMemberOperator(IType methodLookupType, OverloadableOperator operator,
ICPPEvaluation[] args, IASTNode pointOfInstantiation) {
LookupData methodData = null;
if (methodLookupType instanceof ISemanticProblem)
return null;
@ -3881,15 +3869,16 @@ public class CPPSemantics {
return null;
lookup(methodData, scope);
if (operator == OverloadableOperator.PAREN) {
callToObjectOfClassType= classType;
}
} catch (DOMException e) {
return null;
}
}
// Find a function
return methodData;
}
static LookupData findOverloadedNonmemberOperator(IType methodLookupType, OverloadableOperator operator,
ICPPEvaluation[] args, IASTNode pointOfInstantiation, IScope pointOfDefinition,
LookupData methodData, LookupMode mode, IType type2, ICPPClassType callToObjectOfClassType) {
LookupData funcData = new LookupData(operator.toCharArray(), null, pointOfInstantiation);
// Global new and delete operators do not take an argument for the this pointer.
@ -3909,7 +3898,7 @@ public class CPPSemantics {
try {
IScope scope = CPPVisitor.getContainingScope(pointOfInstantiation);
if (scope == null)
return null;
return funcData;
lookup(funcData, scope);
try {
doArgumentDependentLookup(funcData);
@ -3947,7 +3936,7 @@ public class CPPSemantics {
}
}
} catch (DOMException e) {
return null;
return funcData;
}
if (operator == OverloadableOperator.NEW || operator == OverloadableOperator.DELETE
@ -4021,7 +4010,7 @@ public class CPPSemantics {
}
}
} catch (DOMException e) {
return null;
return funcData;
}
}
@ -4029,6 +4018,34 @@ public class CPPSemantics {
ICPPFunction[] builtins= BuiltinOperators.create(operator, args, (Object[]) funcData.foundItems);
mergeResults(funcData, builtins, false);
}
return funcData;
}
static ICPPFunction findOverloadedOperator(IScope pointOfDefinition, ICPPEvaluation[] args,
IType methodLookupType, OverloadableOperator operator, LookupMode mode) {
IASTNode pointOfInstantiation = CPPSemantics.getCurrentLookupPoint();
while (pointOfInstantiation instanceof IASTName) {
pointOfInstantiation= pointOfInstantiation.getParent();
}
ICPPClassType callToObjectOfClassType= null;
IType type2= null;
if (args.length >= 2) {
type2 = args[1].getType();
type2= getNestedType(type2, TDEF | REF | CVTYPE);
}
// Find a method
LookupData methodData = findOverloadedMemberOperator(methodLookupType, operator, args,
pointOfInstantiation);
if (methodData != null && operator == OverloadableOperator.PAREN) {
callToObjectOfClassType = (ICPPClassType) methodLookupType;
}
// Find a function
LookupData funcData = findOverloadedNonmemberOperator(methodLookupType, operator, args,
pointOfInstantiation, pointOfDefinition, methodData, mode, type2, callToObjectOfClassType);
try {
IBinding binding = null;