Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Ridge2014-08-17 06:57:21 +0000
committerSergey Prigogin2014-08-17 17:33:59 +0000
commit82f3bca7d069e3af01a7e51ad636ad8440dd4cc5 (patch)
treec7eab6a796bdba6f7294bbb3bc86a98634e02137
parent4e692170166550c666f0dc1cda6e1fd713f6b217 (diff)
downloadorg.eclipse.cdt-82f3bca7d069e3af01a7e51ad636ad8440dd4cc5.tar.gz
org.eclipse.cdt-82f3bca7d069e3af01a7e51ad636ad8440dd4cc5.tar.xz
org.eclipse.cdt-82f3bca7d069e3af01a7e51ad636ad8440dd4cc5.zip
Bug 441701 - Add ICPPASTFunctionCallExpression.getOverload()
Change-Id: I42e2180c28db135d5d7d135cccde44f839720bbd Signed-off-by: Nathan Ridge <zeratul976@hotmail.com> Reviewed-on: https://git.eclipse.org/r/31799 Reviewed-by: Sergey Prigogin <eclipse.sprigogin@gmail.com> Tested-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java20
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionCallExpression.java7
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionCallExpression.java1
3 files changed, 28 insertions, 0 deletions
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java
index 4e1eaafe4a6..ab4ab50e37b 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java
@@ -97,6 +97,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeleteExpression;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionCallExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDefinition;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLinkageSpecification;
@@ -10701,4 +10702,23 @@ public class AST2CPPTests extends AST2TestBase {
IVariable waldo = helper.assertNonProblem("waldo");
assertEquals(42, waldo.getInitialValue().numericalValue().longValue());
}
+
+ // struct S1 { S1(int); };
+ // struct S2 { void operator()(int); };
+ // S2 s2;
+ // int main() {
+ // S1(42);
+ // s2(43);
+ // }
+ public void testICPPASTFunctionCallExpression_getOverload_441701() throws Exception {
+ BindingAssertionHelper helper = getAssertionHelper();
+
+ ICPPASTFunctionCallExpression call1 = helper.assertNode("S1(42)");
+ ICPPFunction constructor = helper.assertNonProblem("S1(int)", "S1");
+ assertEquals(constructor, call1.getOverload());
+
+ ICPPASTFunctionCallExpression call2 = helper.assertNode("s2(43)");
+ ICPPFunction operator = helper.assertNonProblem("operator()");
+ assertEquals(operator, call2.getOverload());
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionCallExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionCallExpression.java
index ea0636b2e8d..dad3526b7b8 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionCallExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFunctionCallExpression.java
@@ -29,4 +29,11 @@ public interface ICPPASTFunctionCallExpression
*/
@Override
ICPPASTFunctionCallExpression copy(CopyStyle style);
+
+ /**
+ * Returns the function binding for the overloaded operator() invoked by
+ * the function call, or <code>null</code> if the operator() is not overloaded.
+ * @since 5.8
+ */
+ public ICPPFunction getOverload();
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionCallExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionCallExpression.java
index c95dc72e566..67144bd24a1 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionCallExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionCallExpression.java
@@ -259,6 +259,7 @@ public class CPPASTFunctionCallExpression extends ASTNode
}
}
+ @Override
public ICPPFunction getOverload() {
ICPPEvaluation eval = getEvaluation();
if (eval instanceof EvalFunctionCall)

Back to the top