Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorNathan Ridge2018-09-28 05:45:23 +0000
committerNathan Ridge2018-09-30 23:06:01 +0000
commit956ce6b2dc371d3f899bb9b5fe16b5d12fd3ec3c (patch)
tree4074c4dd6f86603e6e0dce9a63796c287ade42c0 /core
parentdcc09f1975db6916f09a3ae5dd800040bed5e3b2 (diff)
downloadorg.eclipse.cdt-956ce6b2dc371d3f899bb9b5fe16b5d12fd3ec3c.tar.gz
org.eclipse.cdt-956ce6b2dc371d3f899bb9b5fe16b5d12fd3ec3c.tar.xz
org.eclipse.cdt-956ce6b2dc371d3f899bb9b5fe16b5d12fd3ec3c.zip
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
Diffstat (limited to 'core')
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java63
1 files changed, 40 insertions, 23 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java
index 246cbe9630c..28da07be9de 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java
@@ -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;

Back to the top