mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 02:06:01 +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:
parent
dcc09f1975
commit
956ce6b2dc
1 changed files with 40 additions and 23 deletions
|
@ -3851,21 +3851,9 @@ public class CPPSemantics {
|
||||||
|
|
||||||
|
|
||||||
static enum LookupMode {NO_GLOBALS, GLOBALS_IF_NO_MEMBERS, LIMITED_GLOBALS, ALL_GLOBALS}
|
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;
|
static LookupData findOverloadedMemberOperator(IType methodLookupType, OverloadableOperator operator,
|
||||||
IType type2= null;
|
ICPPEvaluation[] args, IASTNode pointOfInstantiation) {
|
||||||
if (args.length >= 2) {
|
|
||||||
type2 = args[1].getType();
|
|
||||||
type2= getNestedType(type2, TDEF | REF | CVTYPE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find a method
|
|
||||||
LookupData methodData = null;
|
LookupData methodData = null;
|
||||||
if (methodLookupType instanceof ISemanticProblem)
|
if (methodLookupType instanceof ISemanticProblem)
|
||||||
return null;
|
return null;
|
||||||
|
@ -3881,15 +3869,16 @@ public class CPPSemantics {
|
||||||
return null;
|
return null;
|
||||||
lookup(methodData, scope);
|
lookup(methodData, scope);
|
||||||
|
|
||||||
if (operator == OverloadableOperator.PAREN) {
|
|
||||||
callToObjectOfClassType= classType;
|
|
||||||
}
|
|
||||||
} catch (DOMException e) {
|
} catch (DOMException e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return methodData;
|
||||||
|
}
|
||||||
|
|
||||||
// Find a function
|
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);
|
LookupData funcData = new LookupData(operator.toCharArray(), null, pointOfInstantiation);
|
||||||
|
|
||||||
// Global new and delete operators do not take an argument for the this pointer.
|
// Global new and delete operators do not take an argument for the this pointer.
|
||||||
|
@ -3909,7 +3898,7 @@ public class CPPSemantics {
|
||||||
try {
|
try {
|
||||||
IScope scope = CPPVisitor.getContainingScope(pointOfInstantiation);
|
IScope scope = CPPVisitor.getContainingScope(pointOfInstantiation);
|
||||||
if (scope == null)
|
if (scope == null)
|
||||||
return null;
|
return funcData;
|
||||||
lookup(funcData, scope);
|
lookup(funcData, scope);
|
||||||
try {
|
try {
|
||||||
doArgumentDependentLookup(funcData);
|
doArgumentDependentLookup(funcData);
|
||||||
|
@ -3947,7 +3936,7 @@ public class CPPSemantics {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (DOMException e) {
|
} catch (DOMException e) {
|
||||||
return null;
|
return funcData;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (operator == OverloadableOperator.NEW || operator == OverloadableOperator.DELETE
|
if (operator == OverloadableOperator.NEW || operator == OverloadableOperator.DELETE
|
||||||
|
@ -4021,7 +4010,7 @@ public class CPPSemantics {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (DOMException e) {
|
} catch (DOMException e) {
|
||||||
return null;
|
return funcData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4030,6 +4019,34 @@ public class CPPSemantics {
|
||||||
mergeResults(funcData, builtins, false);
|
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 {
|
try {
|
||||||
IBinding binding = null;
|
IBinding binding = null;
|
||||||
if (methodData != null && funcData.hasResults()) {
|
if (methodData != null && funcData.hasResults()) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue