diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java index c3faee08cc9..2a88ba5a8de 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java @@ -6774,105 +6774,4 @@ public class AST2TemplateTests extends AST2BaseTest { public void testAliasTemplate_395026_2() throws Exception { parseAndCheckBindings(); } - - // template - // struct A { - // typedef U type1; - // - // template - // struct rebind { - // typedef A other; - // }; - // }; - // - // template - // struct B { - // template - // static constexpr bool test(typename T2::template rebind::other*) { - // return true; - // } - // - // template - // static constexpr bool test(...) { - // return false; - // } - // - // static const bool value = test(nullptr); - // }; - // - // template::value> - // struct C; - // - // template - // struct C { - // typedef typename T::template rebind::other type2; - // }; - // - // template - // struct D { - // typedef typename T::type1 type3; - // - // template - // using rebind2 = typename C::type2; - // }; - // - // template - // struct E : D { - // typedef D Base; - // typedef typename Base::type3& type4; - // - // template - // struct rebind { - // typedef typename Base::template rebind2 other; - // }; - // }; - // - // template> - // struct F { - // typedef typename E::template rebind::other type5; - // typedef typename E::type4 type6; - // type6 operator[](int n); - // }; - // - // void f(int); - // - // void test() { - // F a; - // f(*a[0]); - // } - public void testConstexprFunction_395238_1() throws Exception { - parseAndCheckBindings(); - } - - // template - // struct A { - // template - // static constexpr U test(U v) { - // return v; - // } - // - // template - // static constexpr bool test(...) { - // return false; - // } - // - // static const bool value = test(true); - // }; - // - // template::value> - // struct B; - // - // template - // struct B { - // typedef T type; - // }; - // - // B::type x; - // B::type y; - public void testConstexprFunction_395238_2() throws Exception { - BindingAssertionHelper ah = getAssertionHelper(); - ITypedef td = ah.assertNonProblem("B::type", "type", ITypedef.class); - assertEquals("bool", ASTTypeUtil.getType(td.getType())); - ah.assertProblem("B::type", "type"); - } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java index cc4715284cc..682f164ebd9 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java @@ -2061,104 +2061,4 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa public void testAliasTemplate() throws Exception { checkBindings(); } - - // template - // struct A { - // typedef U type1; - // - // template - // struct rebind { - // typedef A other; - // }; - // }; - // - // template - // struct B { - // template - // static constexpr bool test(typename T2::template rebind::other*) { - // return true; - // } - // - // template - // static constexpr bool test(...) { - // return false; - // } - // - // static const bool value = test(nullptr); - // }; - // - // template::value> - // struct C; - // - // template - // struct C { - // typedef typename T::template rebind::other type2; - // }; - // - // template - // struct D { - // typedef typename T1::type1 type3; - // - // template - // using rebind2 = typename C::type2; - // }; - // - // template - // struct E : D { - // typedef D Base; - // typedef typename Base::type3& type4; - // - // template - // struct rebind { - // typedef typename Base::template rebind2 other; - // }; - // }; - // - // template> - // struct F { - // typedef typename E::template rebind::other type5; - // typedef typename E::type4 type6; - // type6 operator[](int n); - // }; - // - // void f(int); - - // void test() { - // F a; - // f(*a[0]); - // } - public void testConstexprFunction_395238_1() throws Exception { - checkBindings(); - } - - // template - // struct A { - // template - // static constexpr U test(U v) { - // return v; - // } - // - // template - // static constexpr bool test(...) { - // return false; - // } - // - // static const bool value = test(true); - // }; - // - // template::value> - // struct B; - // - // template - // struct B { - // typedef T type; - // }; - - // B::type x; - // B::type y; - public void testConstexprFunction_395238_2() throws Exception { - ITypedef td = getBindingFromASTName("type x", 4, ITypedef.class); - assertEquals("bool", ASTTypeUtil.getType(td.getType())); - getProblemFromASTName("type y", 4); - } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPFunction.java index 32b486443bb..b0b38f935a5 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPFunction.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPFunction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2012 IBM Corporation and others. + * Copyright (c) 2005, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -8,7 +8,6 @@ * Contributors: * Andrew Niefer (IBM Corporation) - initial API and implementation * Markus Schorn (Wind River Systems) - * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.core.dom.ast.cpp; @@ -39,12 +38,6 @@ public interface ICPPFunction extends IFunction, ICPPBinding { */ public boolean isExternC(); - /** - * Returns whether this function is declared constexpr. - * @since 5.5 - */ - public boolean isConstexpr(); - /** * Returns the exception specification for this function or null if there * is no exception specification. diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPAliasTemplate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPAliasTemplate.java index 4bb16be6183..4d8257a99bf 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPAliasTemplate.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPAliasTemplate.java @@ -8,7 +8,6 @@ * * Contributors: * Thomas Corbat (IFS) - Initial API and implementation - * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -29,8 +28,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; import org.eclipse.core.runtime.PlatformObject; -public class CPPAliasTemplate extends PlatformObject - implements ICPPAliasTemplate, ICPPTemplateParameterOwner { +public class CPPAliasTemplate extends PlatformObject implements ICPPAliasTemplate { private final IASTName aliasName; private final IType aliasedType; private ICPPTemplateParameter[] templateParameters; @@ -130,16 +128,4 @@ public class CPPAliasTemplate extends PlatformObject public String toString() { return ASTTypeUtil.getQualifiedName(this) + " -> " + ASTTypeUtil.getType(aliasedType, true); //$NON-NLS-1$ } - - @Override - public IBinding resolveTemplateParameter(ICPPTemplateParameter templateParameter) { - int pos= templateParameter.getParameterPosition(); - - ICPPASTTemplateParameter[] params = CPPTemplates.getTemplateDeclaration(aliasName).getTemplateParameters(); - if (pos < params.length) { - final IASTName oName = CPPTemplates.getTemplateParameterName(params[pos]); - return oName.resolvePreBinding(); - } - return templateParameter; - } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecialization.java index 6aa3c0be5c7..468edd02551 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecialization.java @@ -135,11 +135,6 @@ public class CPPClassSpecialization extends CPPSpecialization public boolean isFinal() { return false; } - - @Override - public boolean isConstexpr() { - return false; - } } private ICPPClassSpecializationScope specScope; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPDeferredFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPDeferredFunction.java index daf282b6106..1e3fccf39e3 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPDeferredFunction.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPDeferredFunction.java @@ -7,7 +7,6 @@ * * Contributors: * Markus Schorn - initial API and implementation - * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -26,7 +25,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ProblemType; * Represents a reference to a (member) function (instance), which cannot be resolved because * an argument depends on a template parameter. A compiler would resolve it during instantiation. */ -public class CPPDeferredFunction extends CPPUnknownBinding implements ICPPFunction, ICPPComputableFunction { +public class CPPDeferredFunction extends CPPUnknownBinding implements ICPPFunction { private static final ICPPFunctionType FUNCTION_TYPE= new CPPFunctionType(ProblemType.UNKNOWN_FOR_EXPRESSION, IType.EMPTY_TYPE_ARRAY); @@ -70,11 +69,6 @@ public class CPPDeferredFunction extends CPPUnknownBinding implements ICPPFuncti return false; } - @Override - public boolean isConstexpr() { - return false; - } - @Override public IScope getFunctionScope() { return asScope(); @@ -134,9 +128,4 @@ public class CPPDeferredFunction extends CPPUnknownBinding implements ICPPFuncti public IBinding getOwner() { return fOwner; } - - @Override - public ICPPEvaluation getReturnExpression() { - return null; - } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunction.java index acd531befc0..cd8d776018d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunction.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunction.java @@ -18,19 +18,15 @@ import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUti import org.eclipse.cdt.core.dom.ILinkage; import org.eclipse.cdt.core.dom.ast.ASTTypeUtil; import org.eclipse.cdt.core.dom.ast.DOMException; -import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement; import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.IASTDeclaration; import org.eclipse.cdt.core.dom.ast.IASTDeclarator; import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition; -import org.eclipse.cdt.core.dom.ast.IASTInitializerClause; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration; -import org.eclipse.cdt.core.dom.ast.IASTReturnStatement; import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration; import org.eclipse.cdt.core.dom.ast.IASTStandardFunctionDeclarator; -import org.eclipse.cdt.core.dom.ast.IASTStatement; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.core.dom.ast.IASTTypeId; import org.eclipse.cdt.core.dom.ast.IBinding; @@ -42,7 +38,6 @@ import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier; 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.ICPPASTInitializerClause; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope; @@ -57,7 +52,6 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.ASTQueries; import org.eclipse.cdt.internal.core.dom.parser.ProblemFunctionType; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; -import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalFixed; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil; import org.eclipse.core.runtime.PlatformObject; @@ -236,8 +230,17 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt IASTName n = getASTName(); IScope scope = CPPVisitor.getContainingScope(n); if (scope instanceof ICPPClassScope) { - ICPPASTDeclSpecifier declSpec = getDeclSpecifier(); - if (declSpec != null && declSpec.isFriend()) { + ICPPASTDeclSpecifier declSpec = null; + if (definition != null) { + IASTNode node = ASTQueries.findOutermostDeclarator(definition).getParent(); + IASTFunctionDefinition def = (IASTFunctionDefinition) node; + declSpec = (ICPPASTDeclSpecifier) def.getDeclSpecifier(); + } else { + IASTNode node = ASTQueries.findOutermostDeclarator(declarations[0]).getParent(); + IASTSimpleDeclaration decl = (IASTSimpleDeclaration)node; + declSpec = (ICPPASTDeclSpecifier) decl.getDeclSpecifier(); + } + if (declSpec.isFriend()) { try { while (scope instanceof ICPPClassScope) { scope = scope.getParent(); @@ -249,19 +252,6 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt return scope; } - private ICPPASTDeclSpecifier getDeclSpecifier() { - if (definition != null) { - IASTNode node = ASTQueries.findOutermostDeclarator(definition).getParent(); - IASTFunctionDefinition def = (IASTFunctionDefinition) node; - return (ICPPASTDeclSpecifier) def.getDeclSpecifier(); - } else if (declarations != null && declarations.length != 0) { - IASTNode node = ASTQueries.findOutermostDeclarator(declarations[0]).getParent(); - IASTSimpleDeclaration decl = (IASTSimpleDeclaration) node; - return (ICPPASTDeclSpecifier) decl.getDeclSpecifier(); - } - return null; - } - @Override public ICPPFunctionType getType() { if (type == null) { @@ -430,9 +420,9 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt IASTDeclSpecifier declSpec = null; if (parent instanceof IASTSimpleDeclaration) { - declSpec = ((IASTSimpleDeclaration) parent).getDeclSpecifier(); + declSpec = ((IASTSimpleDeclaration)parent).getDeclSpecifier(); } else if (parent instanceof IASTFunctionDefinition) { - declSpec = ((IASTFunctionDefinition) parent).getDeclSpecifier(); + declSpec = ((IASTFunctionDefinition)parent).getDeclSpecifier(); } if (declSpec != null && declSpec.getStorageClass() == storage) { return true; @@ -447,14 +437,19 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt return false; } - static ICPPASTFunctionDefinition getFunctionDefinition(IASTNode def) { + @Override + public boolean isDeleted() { + return isDeletedDefinition(getDefinition()); + } + + public static boolean isDeletedDefinition(IASTNode def) { while (def != null && !(def instanceof IASTDeclaration)) { def= def.getParent(); } if (def instanceof ICPPASTFunctionDefinition) { - return (ICPPASTFunctionDefinition) def; + return ((ICPPASTFunctionDefinition) def).isDeleted(); } - return null; + return false; } @Override @@ -516,26 +511,6 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt return hasStorageClass(this, IASTDeclSpecifier.sc_auto); } - @Override - public boolean isConstexpr() { - ICPPASTDeclSpecifier declSpec = getDeclSpecifier(); - if (declSpec == null) - return false; - return declSpec.isConstexpr(); - } - - @Override - public boolean isDeleted() { - return isDeletedDefinition(getDefinition()); - } - - static boolean isDeletedDefinition(IASTNode def) { - ICPPASTFunctionDefinition functionDefinition = getFunctionDefinition(def); - if (functionDefinition != null) - return functionDefinition.isDeleted(); - return false; - } - @Override public boolean isRegister() { return hasStorageClass(this, IASTDeclSpecifier.sc_register); @@ -633,46 +608,4 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt ICPPASTFunctionDeclarator dtor = getPreferredDtor(); return dtor != null && AttributeUtil.hasNoreturnAttribute(dtor); } - - @Override - public ICPPEvaluation getReturnExpression() { - if (!isConstexpr()) - return null; - if (definition == null) - return EvalFixed.INCOMPLETE; - - IASTNode node = ASTQueries.findOutermostDeclarator(definition).getParent(); - return getReturnExpression((IASTFunctionDefinition) node); - } - - static ICPPEvaluation getReturnExpression(IASTFunctionDefinition functionDefinition) { - IASTReturnStatement returnStatement = null; - IASTStatement body = functionDefinition.getBody(); - if (body instanceof IASTReturnStatement) { - returnStatement = (IASTReturnStatement) body; - } else if (body instanceof IASTCompoundStatement) { - for (IASTStatement statement : ((IASTCompoundStatement) body).getStatements()) { - if (statement instanceof IASTReturnStatement) { - if (returnStatement != null) - return EvalFixed.INCOMPLETE; - returnStatement = (IASTReturnStatement) statement; - } - } - } - if (returnStatement == null) - return EvalFixed.INCOMPLETE; // constexpr constructors are not supported yet. - - IASTInitializerClause returnExpression = returnStatement.getReturnArgument(); - if (returnExpression instanceof ICPPASTInitializerClause) - return ((ICPPASTInitializerClause) returnExpression).getEvaluation(); - - return EvalFixed.INCOMPLETE; - } - - public static ICPPEvaluation getReturnExpression(ICPPFunction function) { - if (function instanceof ICPPComputableFunction) { - return ((ICPPComputableFunction) function).getReturnExpression(); - } - return null; - } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionSpecialization.java index f0d4e6f27aa..6fa49ac16f6 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionSpecialization.java @@ -24,9 +24,7 @@ import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IFunctionType; import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IType; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier; 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.ICPPFunction; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter; @@ -45,8 +43,7 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP private ICPPParameter[] fParams; private final IType[] fExceptionSpecs; - public CPPFunctionSpecialization(ICPPFunction orig, IBinding owner, ICPPTemplateParameterMap argMap, - ICPPFunctionType type, IType[] exceptionSpecs) { + public CPPFunctionSpecialization(ICPPFunction orig, IBinding owner, ICPPTemplateParameterMap argMap, ICPPFunctionType type, IType[] exceptionSpecs) { super(orig, owner, argMap); fType= type; fExceptionSpecs= exceptionSpecs; @@ -106,6 +103,19 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP return false; } + @Override + public boolean isDeleted() { + IASTNode def = getDefinition(); + if (def != null) + return CPPFunction.isDeletedDefinition(def); + + IBinding f = getSpecializedBinding(); + if (f instanceof ICPPFunction) { + return ((ICPPFunction) f).isDeleted(); + } + return false; + } + @Override public boolean isInline() { if (getDefinition() != null) { @@ -158,33 +168,6 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP return CPPFunction.hasStorageClass(this, IASTDeclSpecifier.sc_auto); } - @Override - public boolean isConstexpr() { - IASTNode def = getDefinition(); - if (def != null) { - ICPPASTFunctionDefinition functionDefinition = CPPFunction.getFunctionDefinition(def); - return ((ICPPASTDeclSpecifier) functionDefinition.getDeclSpecifier()).isConstexpr(); - } - IBinding f = getSpecializedBinding(); - if (f instanceof ICPPFunction) { - return ((ICPPFunction) f).isConstexpr(); - } - return false; - } - - @Override - public boolean isDeleted() { - IASTNode def = getDefinition(); - if (def != null) - return CPPFunction.isDeletedDefinition(def); - - IBinding f = getSpecializedBinding(); - if (f instanceof ICPPFunction) { - return ((ICPPFunction) f).isDeleted(); - } - return false; - } - @Override public boolean isRegister() { ICPPFunction f = (ICPPFunction) getSpecializedBinding(); @@ -331,21 +314,4 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP public IType[] getExceptionSpecification() { return fExceptionSpecs; } - - @Override - public ICPPEvaluation getReturnExpression() { - if (!isConstexpr()) - return null; - - IASTNode def = getDefinition(); - if (def != null) { - ICPPASTFunctionDefinition functionDefinition = CPPFunction.getFunctionDefinition(def); - return CPPFunction.getReturnExpression(functionDefinition); - } - IBinding f = getSpecializedBinding(); - if (f instanceof ICPPComputableFunction) { - return ((ICPPComputableFunction) f).getReturnExpression(); - } - return null; - } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionTemplate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionTemplate.java index 3e44f6fca1f..fee12ee72c3 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionTemplate.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionTemplate.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2012 IBM Corporation and others. + * Copyright (c) 2005, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -33,7 +33,6 @@ import org.eclipse.cdt.core.dom.ast.ISemanticProblem; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier; 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.ICPPFunctionTemplate; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter; @@ -42,7 +41,6 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTInternal; import org.eclipse.cdt.internal.core.dom.parser.ASTQueries; import org.eclipse.cdt.internal.core.dom.parser.ProblemFunctionType; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; -import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalFixed; /** * Implementation of function templates @@ -318,24 +316,16 @@ public class CPPFunctionTemplate extends CPPTemplateDefinition return hasStorageClass(IASTDeclSpecifier.sc_extern); } - @Override - public boolean isAuto() { - return hasStorageClass(IASTDeclSpecifier.sc_auto); - } - - @Override - public boolean isConstexpr() { - ICPPASTFunctionDefinition functionDefinition = CPPFunction.getFunctionDefinition(getDefinition()); - if (functionDefinition == null) - return false; - return ((ICPPASTDeclSpecifier) functionDefinition.getDeclSpecifier()).isConstexpr(); - } - @Override public boolean isDeleted() { return CPPFunction.isDeletedDefinition(getDefinition()); } + @Override + public boolean isAuto() { + return hasStorageClass(IASTDeclSpecifier.sc_auto); + } + @Override public boolean isRegister() { return hasStorageClass(IASTDeclSpecifier.sc_register); @@ -404,14 +394,4 @@ public class CPPFunctionTemplate extends CPPTemplateDefinition } return null; } - - @Override - public ICPPEvaluation getReturnExpression() { - if (!isConstexpr()) - return null; - ICPPASTFunctionDefinition functionDefinition = CPPFunction.getFunctionDefinition(getDefinition()); - if (functionDefinition == null) - return EvalFixed.INCOMPLETE; - return CPPFunction.getReturnExpression(functionDefinition); - } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateParameter.java index 0ea75eb79d3..444d85a0316 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateParameter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateParameter.java @@ -255,8 +255,8 @@ public abstract class CPPTemplateParameter extends PlatformObject return current; ICPPTemplateDefinition template= CPPTemplates.getContainingTemplate(getASTTemplateParameter()); - if (template instanceof ICPPTemplateParameterOwner) { - return ((ICPPTemplateParameterOwner) template).resolveTemplateParameter(this); + if (template instanceof ICPPInternalTemplate) { + return ((ICPPInternalTemplate) template).resolveTemplateParameter(this); } // problem finding the containing template diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownMethod.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownMethod.java index 0219cb9c5b0..761461b1881 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownMethod.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownMethod.java @@ -156,9 +156,4 @@ public class CPPUnknownMethod extends CPPUnknownMember implements ICPPMethod { public boolean isFinal() { return false; } - - @Override - public boolean isConstexpr() { - return false; - } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPComputableFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPComputableFunction.java deleted file mode 100644 index 9d4cef2b01b..00000000000 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPComputableFunction.java +++ /dev/null @@ -1,22 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012 Google, Inc and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sergey Prigogin (Google) - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.internal.core.dom.parser.cpp; - -/** - * Represents a function the return value of which may potentially be calculated at parsing time. - */ -public interface ICPPComputableFunction { - /** - * For a constexpr function returns the return statement expression. Otherwise returns - * {@code null}. - */ - public ICPPEvaluation getReturnExpression(); -} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPEvaluation.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPEvaluation.java index 0ed1f673f48..aed832e59a4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPEvaluation.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPEvaluation.java @@ -7,7 +7,6 @@ * * Contributors: * Markus Schorn - initial API and implementation - * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -18,7 +17,6 @@ import org.eclipse.cdt.core.dom.ast.IValue; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap; import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation; -import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPFunctionParameterMap; /** * Assists in evaluating expressions. @@ -72,17 +70,6 @@ public interface ICPPEvaluation extends ISerializableEvaluation { ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset, ICPPClassSpecialization within, int maxdepth, IASTNode point); - /** - * Computes the evaluation produced by substituting function parameters by their values. - * - * @param parameterMap maps function parameters to their values - * @param maxdepth allowed recursion depth - * @param point determines the scope for name lookups - * @return the computed evaluation - */ - ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap, int maxdepth, - IASTNode point); - /** * Determines size of the template parameter pack. * diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPInternalFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPInternalFunction.java index b5c2d5f40a2..4f4d4be7701 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPInternalFunction.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPInternalFunction.java @@ -8,7 +8,6 @@ * Contributors: * IBM Corporation - initial API and implementation * Markus Schorn (Wind River Systems) - * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -17,7 +16,7 @@ import org.eclipse.cdt.core.dom.ast.IBinding; /** * Interface for ast-internal implementations of function bindings. */ -public interface ICPPInternalFunction extends ICPPInternalBinding, ICPPComputableFunction { +public interface ICPPInternalFunction extends ICPPInternalBinding { /** * Called to resolve the parameter in the second phase. */ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPInternalTemplate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPInternalTemplate.java index 221e455a9ca..68a64cdec60 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPInternalTemplate.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPInternalTemplate.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2012 IBM Corporation and others. + * Copyright (c) 2005, 2008 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -10,9 +10,13 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; +import org.eclipse.cdt.core.dom.ast.IBinding; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter; + /** - * Interface for templates from the AST. + * Interface for templates from the ast. */ -public interface ICPPInternalTemplate - extends ICPPTemplateParameterOwner, ICPPInternalBinding, ICPPInstanceCache { +public interface ICPPInternalTemplate extends ICPPInternalBinding, ICPPInstanceCache { + + IBinding resolveTemplateParameter(ICPPTemplateParameter param); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPTemplateParameterOwner.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPTemplateParameterOwner.java deleted file mode 100644 index 189ae6b3ef2..00000000000 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPTemplateParameterOwner.java +++ /dev/null @@ -1,22 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012 Google, Inc and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sergey Prigogin (Google) - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.internal.core.dom.parser.cpp; - -import org.eclipse.cdt.core.dom.ast.IBinding; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter; - -/** - * Interface for templates from the AST. - */ -public interface ICPPTemplateParameterOwner { - - IBinding resolveTemplateParameter(ICPPTemplateParameter param); -} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/AutoTypeResolver.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/AutoTypeResolver.java index 0114bc9beb3..1a4a168efef 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/AutoTypeResolver.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/AutoTypeResolver.java @@ -72,11 +72,6 @@ class AutoTypeResolver implements ICPPFunctionTemplate { return false; } - @Override - public boolean isConstexpr() { - return false; - } - @Override public IType[] getExceptionSpecification() { return null; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPFunctionParameterMap.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPFunctionParameterMap.java deleted file mode 100644 index 053a9ea3d63..00000000000 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPFunctionParameterMap.java +++ /dev/null @@ -1,110 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012 Google, Inc and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Sergey Prigogin (Google) - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; - -import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization; -import org.eclipse.cdt.core.parser.util.ObjectMap; -import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation; - -/** - * Maps function parameters to values. - */ -public class CPPFunctionParameterMap { - public static final CPPFunctionParameterMap EMPTY = new CPPFunctionParameterMap(0); - - private final ObjectMap fMap; - - /** - * Constructs an empty parameter map. - */ - public CPPFunctionParameterMap(int initialSize) { - fMap= new ObjectMap(initialSize); - } - - public CPPFunctionParameterMap(CPPFunctionParameterMap other) { - fMap= (ObjectMap) other.fMap.clone(); - } - - /** - * Returns whether the map contains the given parameter - */ - public boolean contains(ICPPParameter param) { - return fMap.containsKey(canonicalize(param)); - } - - /** - * Adds the mapping. - */ - public void put(ICPPParameter param, ICPPEvaluation value) { - fMap.put(canonicalize(param), value); - } - - /** - * Adds the mapping. - */ - public void put(ICPPParameter param, ICPPEvaluation[] packExpansion) { - fMap.put(canonicalize(param), packExpansion); - } - - /** - * Returns the value for the given parameter. - */ - public ICPPEvaluation getArgument(ICPPParameter param) { - final Object object = fMap.get(canonicalize(param)); - if (object instanceof ICPPEvaluation) { - return (ICPPEvaluation) object; - } - return null; - } - - /** - * Returns the values for the given function parameter pack. - */ - public ICPPEvaluation[] getPackExpansion(ICPPParameter param) { - final Object object = fMap.get(canonicalize(param)); - if (object instanceof ICPPEvaluation[]) { - return (ICPPEvaluation[]) object; - } - return null; - } - - /** - * Returns the argument at the given position - */ - public ICPPEvaluation getArgument(ICPPParameter param, int packOffset) { - final Object object = fMap.get(canonicalize(param)); - if (object instanceof ICPPEvaluation) - return (ICPPEvaluation) object; - if (object instanceof ICPPEvaluation[]) { - ICPPEvaluation[] args = (ICPPEvaluation[]) object; - if (packOffset < args.length && packOffset >= 0) - return args[packOffset]; - } - return null; - } - - /** - * Puts all mappings from the supplied map into this map. - */ - public void putAll(CPPFunctionParameterMap map) { - final ObjectMap otherMap= map.fMap; - for (int i = 0; i < otherMap.size(); i++) { - fMap.put(otherMap.keyAt(i), otherMap.getAt(i)); - } - } - - private ICPPParameter canonicalize(ICPPParameter param) { - while (param instanceof ICPPSpecialization) - param = (ICPPParameter) ((ICPPSpecialization) param).getSpecializedBinding(); - return param; - } -} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java index 877e605ba48..0636d2829cb 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java @@ -51,7 +51,6 @@ import org.eclipse.cdt.core.dom.ast.ISemanticProblem; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.IValue; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAliasDeclaration; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAmbiguousTemplateArgument; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier; @@ -559,8 +558,6 @@ public class CPPTemplates { IASTDeclarator dtor = ((IASTFunctionDefinition) decl).getDeclarator(); dtor= ASTQueries.findInnermostDeclarator(dtor); name = dtor.getName(); - } else if (decl instanceof ICPPASTAliasDeclaration) { - name = ((ICPPASTAliasDeclaration) decl).getAlias(); } if (name == null) return null; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinary.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinary.java index b80e21c6f32..7eb375ebeb2 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinary.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinary.java @@ -347,16 +347,6 @@ public class EvalBinary extends CPPEvaluation { return new EvalBinary(fOperator, arg1, arg2); } - @Override - public ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap, - int maxdepth, IASTNode point) { - ICPPEvaluation arg1 = fArg1.computeForFunctionCall(parameterMap, maxdepth, point); - ICPPEvaluation arg2 = fArg2.computeForFunctionCall(parameterMap, maxdepth, point); - if (arg1 == fArg1 && arg2 == fArg2) - return this; - return new EvalBinary(fOperator, arg1, arg2); - } - @Override public int determinePackSize(ICPPTemplateParameterMap tpMap) { return CPPTemplates.combinePackSize(fArg1.determinePackSize(tpMap), fArg2.determinePackSize(tpMap)); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinaryTypeId.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinaryTypeId.java index 98dac57bcd6..c9a0aa44f93 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinaryTypeId.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinaryTypeId.java @@ -127,12 +127,6 @@ public class EvalBinaryTypeId extends CPPEvaluation { return new EvalBinaryTypeId(fOperator, type1, type2); } - @Override - public ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap, - int maxdepth, IASTNode point) { - return this; - } - @Override public int determinePackSize(ICPPTemplateParameterMap tpMap) { return CPPTemplates.combinePackSize(CPPTemplates.determinePackSize(fType1, tpMap), diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinding.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinding.java index a8ce7e62314..dbd8c1296a8 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinding.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinding.java @@ -26,7 +26,6 @@ import org.eclipse.cdt.core.dom.ast.IVariable; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate; import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition; @@ -246,18 +245,6 @@ public class EvalBinding extends CPPEvaluation { return new EvalBinding(binding, getFixedType()); } - - @Override - public ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap, - int maxdepth, IASTNode point) { - if (fBinding instanceof ICPPParameter) { - ICPPEvaluation eval = parameterMap.getArgument((ICPPParameter) fBinding); - if (eval != null) - return eval; - } - return this; - } - @Override public int determinePackSize(ICPPTemplateParameterMap tpMap) { if (fBinding instanceof IEnumerator) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalComma.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalComma.java index ea8d2a1ed97..9328c13ddcf 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalComma.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalComma.java @@ -189,25 +189,6 @@ public class EvalComma extends CPPEvaluation { return new EvalComma(args); } - @Override - public ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap, - int maxdepth, IASTNode point) { - ICPPEvaluation[] args = fArguments; - for (int i = 0; i < fArguments.length; i++) { - ICPPEvaluation arg = fArguments[i].computeForFunctionCall(parameterMap, maxdepth, point); - if (arg != fArguments[i]) { - if (args == fArguments) { - args = new ICPPEvaluation[fArguments.length]; - System.arraycopy(fArguments, 0, args, 0, fArguments.length); - } - args[i] = arg; - } - } - if (args == fArguments) - return this; - return new EvalComma(args); - } - @Override public int determinePackSize(ICPPTemplateParameterMap tpMap) { int r = CPPTemplates.PACK_SIZE_NOT_FOUND; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalCompound.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalCompound.java index 280e0f05d4b..dcc6c627d06 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalCompound.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalCompound.java @@ -94,15 +94,6 @@ public class EvalCompound extends CPPEvaluation { return new EvalCompound(delegate); } - @Override - public ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap, - int maxdepth, IASTNode point) { - ICPPEvaluation delegate = fDelegate.computeForFunctionCall(parameterMap, maxdepth, point); - if (delegate == fDelegate) - return this; - return new EvalCompound(delegate); - } - @Override public int determinePackSize(ICPPTemplateParameterMap tpMap) { return fDelegate.determinePackSize(tpMap); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalConditional.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalConditional.java index 393c1f7c372..f2a2370eba3 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalConditional.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalConditional.java @@ -336,18 +336,6 @@ public class EvalConditional extends CPPEvaluation { return new EvalConditional(condition, positive, negative, fPositiveThrows, fNegativeThrows); } - @Override - public ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap, - int maxdepth, IASTNode point) { - ICPPEvaluation condition = fCondition.computeForFunctionCall(parameterMap, maxdepth, point); - ICPPEvaluation positive = fPositive == null ? - null : fPositive.computeForFunctionCall(parameterMap, maxdepth, point); - ICPPEvaluation negative = fNegative.computeForFunctionCall(parameterMap, maxdepth, point); - if (condition == fCondition && positive == fPositive && negative == fNegative) - return this; - return new EvalConditional(condition, positive, negative, fPositiveThrows, fNegativeThrows); - } - @Override public int determinePackSize(ICPPTemplateParameterMap tpMap) { int r = fCondition.determinePackSize(tpMap); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFixed.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFixed.java index 343a7621f18..22d07d9238a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFixed.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFixed.java @@ -168,18 +168,6 @@ public class EvalFixed extends CPPEvaluation { return new EvalFixed(type, fValueCategory, value); } - @Override - public ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap, - int maxdepth, IASTNode point) { - ICPPEvaluation eval = fValue.getEvaluation(); - if (eval == null) - return this; - eval = eval.computeForFunctionCall(parameterMap, maxdepth, point); - if (eval == fValue.getEvaluation()) - return this; - return new EvalFixed(fType, fValueCategory, Value.create(eval)); - } - @Override public int determinePackSize(ICPPTemplateParameterMap tpMap) { return CPPTemplates.determinePackSize(fValue, tpMap); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFunctionCall.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFunctionCall.java index 77d05af9517..5ca58c483d2 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFunctionCall.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFunctionCall.java @@ -11,7 +11,6 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; -import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.PRVALUE; import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.typeFromReturnType; import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.valueCategoryFromFunctionCall; import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.valueCategoryFromReturnType; @@ -23,7 +22,6 @@ import java.util.Arrays; import org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory; import org.eclipse.cdt.core.dom.ast.IASTNode; -import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IFunctionType; import org.eclipse.cdt.core.dom.ast.IPointerType; import org.eclipse.cdt.core.dom.ast.IType; @@ -31,7 +29,6 @@ import org.eclipse.cdt.core.dom.ast.IValue; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap; import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation; import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer; @@ -142,11 +139,8 @@ public class EvalFunctionCall extends CPPEvaluation { @Override public IValue getValue(IASTNode point) { - ICPPEvaluation eval = computeForFunctionCall(Value.MAX_RECURSION_DEPTH, point); - if (eval instanceof EvalFixed) - return ((EvalFixed) eval).getValue(); - eval = new EvalFixed(getTypeOrFunctionSet(point), PRVALUE, eval.getValue(point)); - return Value.create(eval); + // TODO(sprigogin): Simulate execution of a function call if the value is not dependent. + return Value.create(this); } @Override @@ -207,70 +201,6 @@ public class EvalFunctionCall extends CPPEvaluation { return new EvalFunctionCall(args); } - @Override - public ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap, - int maxdepth, IASTNode point) { - if (maxdepth == 0) - return EvalFixed.INCOMPLETE; - - ICPPEvaluation[] args = fArguments; - for (int i = 0; i < fArguments.length; i++) { - ICPPEvaluation arg = fArguments[i].computeForFunctionCall(parameterMap, maxdepth, point); - if (arg != fArguments[i]) { - if (args == fArguments) { - args = new ICPPEvaluation[fArguments.length]; - System.arraycopy(fArguments, 0, args, 0, fArguments.length); - } - args[i] = arg; - } - } - EvalFunctionCall eval = this; - if (args != fArguments) - eval = new EvalFunctionCall(args); - return eval.computeForFunctionCall(maxdepth - 1, point); - } - - private ICPPEvaluation computeForFunctionCall(int maxdepth, IASTNode point) { - if (isValueDependent()) - return this; - ICPPFunction function = getOverload(point); - if (function == null) { - if (fArguments[0] instanceof EvalBinding) { - IBinding binding = ((EvalBinding) fArguments[0]).getBinding(); - if (binding instanceof ICPPFunction) - function = (ICPPFunction) binding; - } - } - if (function == null) - return this; - ICPPEvaluation eval = CPPFunction.getReturnExpression(function); - if (eval == null) - return EvalFixed.INCOMPLETE; - CPPFunctionParameterMap parameterMap = buildParameterMap(function); - return eval.computeForFunctionCall(parameterMap, maxdepth, point); - } - - private CPPFunctionParameterMap buildParameterMap(ICPPFunction function) { - ICPPParameter[] parameters = function.getParameters(); - CPPFunctionParameterMap map = new CPPFunctionParameterMap(parameters.length); - int j = 1; - for (int i = 0; i < parameters.length; i++) { - ICPPParameter param = parameters[i]; - if (param.isParameterPack()) { - // The parameter pack consumes all remaining arguments. - j = fArguments.length; - } else { - if (j < fArguments.length) { - map.put(param, fArguments[j++]); - } else if (param.hasDefaultValue()) { - IValue value = param.getInitialValue(); - map.put(param, value.getEvaluation()); - } - } - } - return map; - } - @Override public int determinePackSize(ICPPTemplateParameterMap tpMap) { int r = CPPTemplates.PACK_SIZE_NOT_FOUND; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFunctionSet.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFunctionSet.java index 4e16f5a0751..881db03f857 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFunctionSet.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFunctionSet.java @@ -170,12 +170,6 @@ public class EvalFunctionSet extends CPPEvaluation { return new EvalFunctionSet(new CPPFunctionSet(functions, arguments, null), fAddressOf); } - @Override - public ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap, - int maxdepth, IASTNode point) { - return this; - } - /** * Attempts to resolve the function using the parameters of a function call. * diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalID.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalID.java index 501189404f1..4cbea3195e5 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalID.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalID.java @@ -309,17 +309,6 @@ public class EvalID extends CPPEvaluation { return new EvalID(fieldOwner, nameOwner, fName, fAddressOf, fQualified, templateArgs); } - @Override - public ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap, - int maxdepth, IASTNode point) { - if (fFieldOwner == null) - return this; - ICPPEvaluation fieldOwner = fFieldOwner.computeForFunctionCall(parameterMap, maxdepth, point); - if (fieldOwner == fFieldOwner) - return this; - return new EvalID(fieldOwner, fNameOwner, fName, fAddressOf, fQualified, fTemplateArgs); - } - private ICPPEvaluation resolveName(ICPPClassType nameOwner, ICPPTemplateArgument[] templateArgs, IASTNode point) { LookupData data = new LookupData(fName, templateArgs, point); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalInitList.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalInitList.java index 996f71a9e62..02eb709506e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalInitList.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalInitList.java @@ -121,25 +121,6 @@ public class EvalInitList extends CPPEvaluation { return new EvalInitList(clauses); } - @Override - public ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap, - int maxdepth, IASTNode point) { - ICPPEvaluation[] clauses = fClauses; - for (int i = 0; i < fClauses.length; i++) { - ICPPEvaluation clause = fClauses[i].computeForFunctionCall(parameterMap, maxdepth, point); - if (clause != fClauses[i]) { - if (clauses == fClauses) { - clauses = new ICPPEvaluation[fClauses.length]; - System.arraycopy(fClauses, 0, clauses, 0, fClauses.length); - } - clauses[i] = clause; - } - } - if (clauses == fClauses) - return this; - return new EvalInitList(clauses); - } - @Override public int determinePackSize(ICPPTemplateParameterMap tpMap) { int r = CPPTemplates.PACK_SIZE_NOT_FOUND; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalMemberAccess.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalMemberAccess.java index 88d935356fb..61652be2b55 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalMemberAccess.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalMemberAccess.java @@ -334,12 +334,6 @@ public class EvalMemberAccess extends CPPEvaluation { return new EvalMemberAccess(ownerType, fOwnerValueCategory, member, fIsPointerDeref); } - @Override - public ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap, - int maxdepth, IASTNode point) { - return this; - } - @Override public int determinePackSize(ICPPTemplateParameterMap tpMap) { return CPPTemplates.determinePackSize(fOwnerType, tpMap); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalTypeId.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalTypeId.java index 62f713dc1b9..41a0fce27aa 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalTypeId.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalTypeId.java @@ -165,27 +165,6 @@ public class EvalTypeId extends CPPEvaluation { return new EvalTypeId(type, args); } - @Override - public ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap, - int maxdepth, IASTNode point) { - ICPPEvaluation[] args = fArguments; - if (fArguments != null) { - for (int i = 0; i < fArguments.length; i++) { - ICPPEvaluation arg = fArguments[i].computeForFunctionCall(parameterMap, maxdepth, point); - if (arg != fArguments[i]) { - if (args == fArguments) { - args = new ICPPEvaluation[fArguments.length]; - System.arraycopy(fArguments, 0, args, 0, fArguments.length); - } - args[i] = arg; - } - } - } - if (args == fArguments) - return this; - return new EvalTypeId(fInputType, args); - } - @Override public int determinePackSize(ICPPTemplateParameterMap tpMap) { int r = CPPTemplates.determinePackSize(fInputType, tpMap); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnary.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnary.java index a2d61ae8497..d7b56564e80 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnary.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnary.java @@ -324,16 +324,6 @@ public class EvalUnary extends CPPEvaluation { return new EvalUnary(fOperator, argument, aoqn); } - @Override - public ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap, - int maxdepth, IASTNode point) { - ICPPEvaluation argument = fArgument.computeForFunctionCall(parameterMap, maxdepth, point); - if (argument == fArgument) - return this; - - return new EvalUnary(fOperator, argument, fAddressOfQualifiedNameBinding); - } - @Override public int determinePackSize(ICPPTemplateParameterMap tpMap) { return fArgument.determinePackSize(tpMap); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnaryTypeID.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnaryTypeID.java index 9d2e39b7e52..06eb32de63f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnaryTypeID.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalUnaryTypeID.java @@ -190,12 +190,6 @@ public class EvalUnaryTypeID extends CPPEvaluation { return new EvalUnaryTypeID(fOperator, type); } - @Override - public ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap, - int maxdepth, IASTNode point) { - return this; - } - @Override public int determinePackSize(ICPPTemplateParameterMap tpMap) { return CPPTemplates.determinePackSize(fOrigType, tpMap); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPFunction.java index c560bf398e0..2e5a3d68f34 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPFunction.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPFunction.java @@ -18,13 +18,10 @@ import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunction; -import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPComputableFunction; -import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation; import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding; import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory; -class CompositeCPPFunction extends CompositeCPPBinding implements ICPPFunction, ICPPComputableFunction { +class CompositeCPPFunction extends CompositeCPPBinding implements ICPPFunction { public CompositeCPPFunction(ICompositesFactory cf, ICPPFunction rbinding) { super(cf, rbinding); @@ -45,11 +42,6 @@ class CompositeCPPFunction extends CompositeCPPBinding implements ICPPFunction, return ((ICPPFunction) rbinding).isMutable(); } - @Override - public boolean isConstexpr() { - return ((ICPPFunction) rbinding).isConstexpr(); - } - @Override public IScope getFunctionScope() { return null; @@ -137,9 +129,4 @@ class CompositeCPPFunction extends CompositeCPPBinding implements ICPPFunction, } return result; } - - @Override - public ICPPEvaluation getReturnExpression() { - return CPPFunction.getReturnExpression((ICPPFunction) rbinding); - } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java index 86abd1ed1d6..30ba6a2ac00 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java @@ -227,11 +227,10 @@ public class PDOM extends PlatformObject implements IPDOM { * 135.0 - Changed marshalling of EvalUnary, bug 391001. * 136.0 - Extended CPPTemplateTypeArgument to include the original type, bug 392278. * 137.0 - Fixed serialization of very large types and template arguments, bug 392278. - * 138.0 - Constexpr functions, bug 395238. */ - private static final int MIN_SUPPORTED_VERSION= version(138, 0); - private static final int MAX_SUPPORTED_VERSION= version(138, Short.MAX_VALUE); - private static final int DEFAULT_VERSION = version(138, 0); + private static final int MIN_SUPPORTED_VERSION= version(137, 0); + private static final int MAX_SUPPORTED_VERSION= version(137, Short.MAX_VALUE); + private static final int DEFAULT_VERSION = version(137, 0); private static int version(int major, int minor) { return (major << 16) + minor; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/Database.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/Database.java index 86870f1e5cc..4963a86f84e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/Database.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/Database.java @@ -78,7 +78,6 @@ public class Database { public static final int PTR_SIZE = 4; // size of a pointer in the database in bytes public static final int TYPE_SIZE = 2 + PTR_SIZE; // size of a type in the database in bytes public static final int VALUE_SIZE = TYPE_SIZE; // size of a value in the database in bytes - public static final int EVALUATION_SIZE = TYPE_SIZE; // size of an evaluation in the database in bytes public static final int ARGUMENT_SIZE = TYPE_SIZE; // size of a template argument in the database in bytes public static final long MAX_DB_SIZE= ((long) 1 << (Integer.SIZE + BLOCK_SIZE_DELTA_BITS)); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/TypeMarshalBuffer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/TypeMarshalBuffer.java index 958b75d004f..d5294c33b68 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/TypeMarshalBuffer.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/TypeMarshalBuffer.java @@ -17,8 +17,6 @@ import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.ISemanticProblem; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IValue; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument; import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation; import org.eclipse.cdt.internal.core.dom.parser.ISerializableType; @@ -28,8 +26,8 @@ import org.eclipse.cdt.internal.core.dom.parser.Value; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateNonTypeArgument; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateTypeArgument; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation; +import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding; import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage; -import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode; import org.eclipse.core.runtime.CoreException; /** @@ -40,8 +38,7 @@ public class TypeMarshalBuffer implements ITypeMarshalBuffer { public static final byte NULL_TYPE= 0; public static final byte INDIRECT_TYPE= (byte) -1; public static final byte BINDING_TYPE= (byte) -2; - public static final byte PARAMETER_TYPE= (byte) -3; - public static final byte UNSTORABLE_TYPE= (byte) -4; + public static final byte UNSTORABLE_TYPE= (byte) -3; public static final IType UNSTORABLE_TYPE_PROBLEM = new ProblemType(ISemanticProblem.TYPE_NOT_PERSISTED); @@ -82,39 +79,18 @@ public class TypeMarshalBuffer implements ITypeMarshalBuffer { ((ISerializableType) binding).marshal(this); } else if (binding == null) { putByte(NULL_TYPE); - } else if (binding instanceof ICPPParameter) { - // A function parameter cannot be stored in PDOM by itself. We are storing a reference - // to the containing function and the position of the parameter in the parameter list. - ICPPFunction function = (ICPPFunction) binding.getOwner(); - int pos = findInArray(function.getParameters(), binding); - PDOMNode pb= fLinkage.addTypeBinding(function); - if (pb == null) { - putByte(UNSTORABLE_TYPE); - } else { - putByte(PARAMETER_TYPE); - putRecordPointer(pb.getRecord()); - putShort((short) pos); - } } else { - PDOMNode pb= fLinkage.addTypeBinding(binding); + PDOMBinding pb= fLinkage.addTypeBinding(binding); if (pb == null) { putByte(UNSTORABLE_TYPE); } else { putByte(BINDING_TYPE); - putByte((byte) 0); // TODO(sprigogin): Do we need this padding? + putByte((byte) 0); putRecordPointer(pb.getRecord()); } } } - private int findInArray(Object[] array, Object obj) { - for (int i = 0; i < array.length; i++) { - if (obj == array[i]) - return i; - } - return -1; - } - @Override public IBinding unmarshalBinding() throws CoreException { if (fPos >= fBuffer.length) @@ -125,12 +101,6 @@ public class TypeMarshalBuffer implements ITypeMarshalBuffer { fPos += 2; long rec= getRecordPointer(); return (IBinding) fLinkage.getNode(rec); - } else if (firstByte == PARAMETER_TYPE) { - fPos++; - long rec= getRecordPointer(); - ICPPFunction function = (ICPPFunction) fLinkage.getNode(rec); - int pos = getShort(); - return function.getParameters()[pos]; } else if (firstByte == NULL_TYPE || firstByte == UNSTORABLE_TYPE) { fPos++; return null; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMLinkage.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMLinkage.java index 7c699dfc9b3..2bdfc076faf 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMLinkage.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMLinkage.java @@ -423,7 +423,7 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage return map; } - public abstract PDOMBinding addTypeBinding(IBinding binding) throws CoreException; + public abstract PDOMBinding addTypeBinding(IBinding type) throws CoreException; public abstract IType unmarshalType(ITypeMarshalBuffer buffer) throws CoreException; public abstract IBinding unmarshalBinding(ITypeMarshalBuffer buffer) throws CoreException; public abstract ISerializableEvaluation unmarshalEvaluation(ITypeMarshalBuffer typeMarshalBuffer) throws CoreException; @@ -633,41 +633,9 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage } public IValue loadValue(long offset) throws CoreException { - TypeMarshalBuffer buffer = loadBuffer(offset, Database.VALUE_SIZE); - if (buffer == null) - return null; - return buffer.unmarshalValue(); - } - - public void storeEvaluation(long offset, ISerializableEvaluation eval) throws CoreException { - final Database db= getDB(); - deleteEvaluation(db, offset); - storeEvaluation(db, offset, eval); - } - - private void storeEvaluation(Database db, long offset, ISerializableEvaluation eval) throws CoreException { - if (eval != null) { - TypeMarshalBuffer bc= new TypeMarshalBuffer(this); - bc.marshalEvaluation(eval, true); - storeBuffer(db, offset, bc, Database.EVALUATION_SIZE); - } - } - - private void deleteEvaluation(Database db, long offset) throws CoreException { - deleteSerializedData(db, offset, Database.EVALUATION_SIZE); - } - - public ISerializableEvaluation loadEvaluation(long offset) throws CoreException { - TypeMarshalBuffer buffer = loadBuffer(offset, Database.EVALUATION_SIZE); - if (buffer == null) - return null; - return buffer.unmarshalEvaluation(); - } - - private TypeMarshalBuffer loadBuffer(long offset, int size) throws CoreException { final Database db= getDB(); final byte firstByte= db.getByte(offset); - byte[] data; + byte[] data= null; switch (firstByte) { case TypeMarshalBuffer.INDIRECT_TYPE: data = loadLinkedSerializedData(db, offset + 1); @@ -675,13 +643,13 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage case TypeMarshalBuffer.NULL_TYPE: return null; default: - data= new byte[size]; + data= new byte[Database.VALUE_SIZE]; db.getBytes(offset, data); break; } - return new TypeMarshalBuffer(this, data); + return new TypeMarshalBuffer(this, data).unmarshalValue(); } - + public IIndexScope[] getInlineNamespaces() { return IIndexScope.EMPTY_INDEX_SCOPE_ARRAY; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPAliasTemplate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPAliasTemplate.java index 2383af9629a..7cf0c3c4971 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPAliasTemplate.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPAliasTemplate.java @@ -8,7 +8,6 @@ * * Contributors: * Thomas Corbat (IFS) - Initial API and implementation - * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.core.pdom.dom.cpp; @@ -16,10 +15,7 @@ import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplate; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTemplateParameter; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter; import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants; import org.eclipse.cdt.internal.core.pdom.db.Database; import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode; @@ -28,38 +24,39 @@ import org.eclipse.core.runtime.CoreException; /** * PDOM binding for alias template. */ -class PDOMCPPAliasTemplate extends PDOMCPPBinding implements ICPPAliasTemplate, IPDOMCPPTemplateParameterOwner { +class PDOMCPPAliasTemplate extends PDOMCPPBinding implements ICPPAliasTemplate { private static final int ALIASED_TYPE_SIZE = Database.TYPE_SIZE; private static final int TEMPLATE_PARAMS_SIZE = PDOMCPPTemplateTemplateParameter.RECORD_SIZE; @SuppressWarnings("hiding") protected static final int RECORD_SIZE = PDOMCPPBinding.RECORD_SIZE + ALIASED_TYPE_SIZE + TEMPLATE_PARAMS_SIZE; - private static final int ALIASED_TYPE = PDOMCPPBinding.RECORD_SIZE + 0; - private static final int TEMPLATE_PARAMS = ALIASED_TYPE + ALIASED_TYPE_SIZE; + private static final int ALIASED_TYPE_OFFSET = PDOMCPPBinding.RECORD_SIZE + 0; + private static final int TEMPLATE_PARAMS_OFFSET = ALIASED_TYPE_OFFSET + ALIASED_TYPE_SIZE; private volatile IPDOMCPPTemplateParameter[] parameters; - public PDOMCPPAliasTemplate(PDOMCPPLinkage linkage, PDOMNode parent, ICPPAliasTemplate template) - throws CoreException, DOMException { - super(linkage, parent, template.getNameCharArray()); - final ICPPTemplateParameter[] origParams= template.getTemplateParameters(); - parameters = PDOMTemplateParameterArray.createPDOMTemplateParameters(linkage, this, origParams); - final Database db = getDB(); - long rec= PDOMTemplateParameterArray.putArray(db, parameters); - db.putRecPtr(record + TEMPLATE_PARAMS, rec); - linkage.new ConfigureAliasTemplate(template, this); + public PDOMCPPAliasTemplate(PDOMCPPLinkage linkage, PDOMNode parent, + ICPPAliasTemplate templateAlias) throws CoreException, DOMException { + super(linkage, parent, templateAlias.getNameCharArray()); + setTemplateParameters(linkage, templateAlias.getTemplateParameters()); + setType(linkage, templateAlias.getType()); } public PDOMCPPAliasTemplate(PDOMCPPLinkage linkage, long record) { super(linkage, record); } - public void initData(IType aliasedType) { - try { - getLinkage().storeType(record + ALIASED_TYPE, aliasedType); - } catch (CoreException e) { - CCorePlugin.log(e); - } + private void setTemplateParameters(PDOMCPPLinkage linkage, + final ICPPTemplateParameter[] origParams) throws CoreException, DOMException { + parameters = PDOMTemplateParameterArray.createPDOMTemplateParameters(linkage, this, origParams); + final Database db = getDB(); + long rec= PDOMTemplateParameterArray.putArray(db, parameters); + db.putRecPtr(record + TEMPLATE_PARAMS_OFFSET, rec); + linkage.new ConfigureTemplateParameters(origParams, parameters); + } + + private void setType(PDOMCPPLinkage linkage, IType aliasedType) throws CoreException { + linkage.storeType(record + ALIASED_TYPE_OFFSET, aliasedType); } @Override @@ -77,11 +74,11 @@ class PDOMCPPAliasTemplate extends PDOMCPPBinding implements ICPPAliasTemplate, } @Override - public IPDOMCPPTemplateParameter[] getTemplateParameters() { + public ICPPTemplateParameter[] getTemplateParameters() { if (parameters == null) { try { Database db = getDB(); - long rec= db.getRecPtr(record + TEMPLATE_PARAMS); + long rec= db.getRecPtr(record + TEMPLATE_PARAMS_OFFSET); if (rec == 0) { parameters= IPDOMCPPTemplateParameter.EMPTY_ARRAY; } else { @@ -98,7 +95,7 @@ class PDOMCPPAliasTemplate extends PDOMCPPBinding implements ICPPAliasTemplate, @Override public IType getType() { try { - return getLinkage().loadType(record + ALIASED_TYPE); + return getLinkage().loadType(record + ALIASED_TYPE_OFFSET); } catch (CoreException e) { CCorePlugin.log(e); return null; @@ -118,27 +115,4 @@ class PDOMCPPAliasTemplate extends PDOMCPPBinding implements ICPPAliasTemplate, } return null; } - - @Override - public ICPPTemplateParameter adaptTemplateParameter(ICPPTemplateParameter param) { - // Template parameters are identified by their position in the parameter list. - int pos = param.getParameterPosition(); - ICPPTemplateParameter[] pars = getTemplateParameters(); - - if (pars == null || pos >= pars.length) - return null; - - ICPPTemplateParameter result= pars[pos]; - if (param instanceof ICPPTemplateTypeParameter) { - if (result instanceof ICPPTemplateTypeParameter) - return result; - } else if (param instanceof ICPPTemplateNonTypeParameter) { - if (result instanceof ICPPTemplateNonTypeParameter) - return result; - } else if (param instanceof ICPPTemplateTemplateParameter) { - if (result instanceof ICPPTemplateTemplateParameter) - return result; - } - return null; - } } \ No newline at end of file diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunction.java index 22bb4fd7547..9edcbf37948 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunction.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunction.java @@ -24,9 +24,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter; import org.eclipse.cdt.internal.core.dom.parser.ProblemFunctionType; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunction; -import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPComputableFunction; -import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation; import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants; import org.eclipse.cdt.internal.core.index.IndexCPPSignatureUtil; import org.eclipse.cdt.internal.core.pdom.db.Database; @@ -40,10 +37,9 @@ import org.eclipse.core.runtime.CoreException; /** * Binding for c++ functions in the index. */ -class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverloader, ICPPComputableFunction { +class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverloader { private static final short ANNOT_PARAMETER_PACK = 8; private static final short ANNOT_IS_DELETED = 9; - private static final short ANNOT_IS_CONSTEXPR = 10; /** * Offset of total number of function parameters (relative to the beginning of the record). @@ -76,16 +72,13 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl */ private static final int ANNOTATION = EXCEPTION_SPEC + Database.PTR_SIZE; // short - /** Offset of the number of the required arguments. */ - private static final int REQUIRED_ARG_COUNT = ANNOTATION + 2; // short + private static final int REQUIRED_ARG_COUNT = ANNOTATION + 2; - /** Offset of the return expression for constexpr functions. */ - private static final int RETURN_EXPRESSION = REQUIRED_ARG_COUNT + 2; // Database.EVALUATION_SIZE /** * The size in bytes of a PDOMCPPFunction record in the database. */ @SuppressWarnings("hiding") - protected static final int RECORD_SIZE = RETURN_EXPRESSION + Database.EVALUATION_SIZE; + protected static final int RECORD_SIZE = REQUIRED_ARG_COUNT + 4; private short fAnnotation = -1; private int fRequiredArgCount = -1; @@ -98,10 +91,9 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl Integer sigHash = IndexCPPSignatureUtil.getSignatureHash(function); getDB().putInt(record + SIGNATURE_HASH, sigHash != null ? sigHash.intValue() : 0); db.putShort(record + ANNOTATION, getAnnotation(function)); - db.putShort(record + REQUIRED_ARG_COUNT, (short) function.getRequiredArgumentCount()); + db.putInt(record + REQUIRED_ARG_COUNT, function.getRequiredArgumentCount()); if (setTypes) { - initData(function.getType(), function.getParameters(), extractExceptionSpec(function), - CPPFunction.getReturnExpression(function)); + initData(function.getType(), function.getParameters(), extractExceptionSpec(function)); } } @@ -113,19 +105,14 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl if (function.isDeleted()) { annot |= (1 << ANNOT_IS_DELETED); } - if (function.isConstexpr()) { - annot |= (1 << ANNOT_IS_CONSTEXPR); - } return (short) annot; } - public void initData(ICPPFunctionType ftype, ICPPParameter[] params, IType[] exceptionSpec, - ICPPEvaluation returnExpression) { + public void initData(ICPPFunctionType ftype, ICPPParameter[] params, IType[] exceptionSpec) { try { setType(ftype); setParameters(params); storeExceptionSpec(exceptionSpec); - getLinkage().storeEvaluation(record + RETURN_EXPRESSION, returnExpression); } catch (CoreException e) { CCorePlugin.log(e); } @@ -133,59 +120,57 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl @Override public void update(final PDOMLinkage linkage, IBinding newBinding) throws CoreException { - if (!(newBinding instanceof ICPPFunction)) - return; + if (newBinding instanceof ICPPFunction) { + ICPPFunction func = (ICPPFunction) newBinding; + ICPPFunctionType newType; + ICPPParameter[] newParams; + short newAnnotation; + int newBindingRequiredArgCount; + newType = func.getType(); + newParams = func.getParameters(); + newAnnotation = getAnnotation(func); + newBindingRequiredArgCount = func.getRequiredArgumentCount(); - ICPPFunction func = (ICPPFunction) newBinding; - ICPPFunctionType newType; - ICPPParameter[] newParams; - short newAnnotation; - int newBindingRequiredArgCount; - newType = func.getType(); - newParams = func.getParameters(); - newAnnotation = getAnnotation(func); - newBindingRequiredArgCount = func.getRequiredArgumentCount(); + fType = null; + linkage.storeType(record + FUNCTION_TYPE, newType); - fType = null; - linkage.storeType(record + FUNCTION_TYPE, newType); - - PDOMCPPParameter oldParams = getFirstParameter(null); - int requiredCount; - if (oldParams != null && hasDeclaration()) { - int parCount = 0; - requiredCount = 0; - for (ICPPParameter newPar : newParams) { - parCount++; - if (parCount <= newBindingRequiredArgCount && !oldParams.hasDefaultValue()) - requiredCount = parCount; - oldParams.update(newPar); - long next = oldParams.getNextPtr(); - if (next == 0) - break; - oldParams = new PDOMCPPParameter(linkage, next, null); - } - if (parCount < newBindingRequiredArgCount) { + PDOMCPPParameter oldParams = getFirstParameter(null); + int requiredCount; + if (oldParams != null && hasDeclaration()) { + int parCount = 0; + requiredCount = 0; + for (ICPPParameter newPar : newParams) { + parCount++; + if (parCount <= newBindingRequiredArgCount && !oldParams.hasDefaultValue()) + requiredCount = parCount; + oldParams.update(newPar); + long next = oldParams.getNextPtr(); + if (next == 0) + break; + oldParams = new PDOMCPPParameter(linkage, next, null); + } + if (parCount < newBindingRequiredArgCount) { + requiredCount = newBindingRequiredArgCount; + } + } else { requiredCount = newBindingRequiredArgCount; + setParameters(newParams); + if (oldParams != null) { + oldParams.delete(linkage); + } } - } else { - requiredCount = newBindingRequiredArgCount; - setParameters(newParams); - if (oldParams != null) { - oldParams.delete(linkage); - } - } - final Database db = getDB(); - db.putShort(record + ANNOTATION, newAnnotation); - fAnnotation = newAnnotation; - db.putShort(record + REQUIRED_ARG_COUNT, (short) requiredCount); - fRequiredArgCount = requiredCount; + final Database db = getDB(); + db.putShort(record + ANNOTATION, newAnnotation); + fAnnotation = newAnnotation; + db.putInt(record + REQUIRED_ARG_COUNT, requiredCount); + fRequiredArgCount = requiredCount; - long oldRec = db.getRecPtr(record + EXCEPTION_SPEC); - storeExceptionSpec(extractExceptionSpec(func)); - if (oldRec != 0) { - PDOMCPPTypeList.clearTypes(this, oldRec); + long oldRec = db.getRecPtr(record + EXCEPTION_SPEC); + storeExceptionSpec(extractExceptionSpec(func)); + if (oldRec != 0) { + PDOMCPPTypeList.clearTypes(this, oldRec); + } } - linkage.storeEvaluation(record + RETURN_EXPRESSION, CPPFunction.getReturnExpression(func)); } private void storeExceptionSpec(IType[] exceptionSpec) throws CoreException { @@ -258,7 +243,7 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl public int getRequiredArgumentCount() { if (fRequiredArgCount == -1) { try { - fRequiredArgCount = getDB().getShort(record + REQUIRED_ARG_COUNT); + fRequiredArgCount = getDB().getInt(record + REQUIRED_ARG_COUNT); } catch (CoreException e) { fRequiredArgCount = 0; } @@ -336,11 +321,6 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl return false; } - @Override - public boolean isConstexpr() { - return getBit(getAnnotation(), ANNOT_IS_CONSTEXPR); - } - @Override public boolean isDeleted() { return getBit(getAnnotation(), ANNOT_IS_DELETED); @@ -414,17 +394,4 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl return null; } } - - @Override - public ICPPEvaluation getReturnExpression() { - if (!isConstexpr()) - return null; - - try { - return (ICPPEvaluation) getLinkage().loadEvaluation(record + RETURN_EXPRESSION); - } catch (CoreException e) { - CCorePlugin.log(e); - return null; - } - } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunctionSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunctionSpecialization.java index 8698367b01b..947ed44409d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunctionSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunctionSpecialization.java @@ -23,9 +23,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization; import org.eclipse.cdt.internal.core.dom.parser.ProblemFunctionType; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunction; -import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPComputableFunction; -import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation; import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants; import org.eclipse.cdt.internal.core.pdom.db.Database; import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding; @@ -37,8 +34,7 @@ import org.eclipse.core.runtime.CoreException; /** * Binding for function specialization in the index. */ -class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization - implements ICPPFunction, ICPPComputableFunction { +class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICPPFunction { /** * Offset of total number of function parameters (relative to the beginning of the record). */ @@ -63,29 +59,24 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization /** * Offset of annotation information (relative to the beginning of the record). */ - protected static final int ANNOTATION = EXCEPTION_SPEC + Database.PTR_SIZE; // short + protected static final int ANNOTATION_OFFSET = EXCEPTION_SPEC + Database.PTR_SIZE; // short + + private static final int REQUIRED_ARG_COUNT_OFFSET= ANNOTATION_OFFSET + 2; - /** Offset of the number of the required arguments. */ - private static final int REQUIRED_ARG_COUNT = ANNOTATION + 2; // short - - /** Offset of the return expression for constexpr functions. */ - private static final int RETURN_EXPRESSION = REQUIRED_ARG_COUNT + 2; // Database.EVALUATION_SIZE /** - * The size in bytes of a PDOMCPPFunctionSpecialization record in the database. + * The size in bytes of a PDOMCPPFunction record in the database. */ @SuppressWarnings("hiding") - protected static final int RECORD_SIZE = RETURN_EXPRESSION + Database.EVALUATION_SIZE; + protected static final int RECORD_SIZE = REQUIRED_ARG_COUNT_OFFSET + 4; private static final short ANNOT_PARAMETER_PACK = 8; private static final short ANNOT_IS_DELETED = 9; - private static final short ANNOT_IS_CONSTEXPR = 10; private ICPPFunctionType fType; // No need for volatile, all fields of ICPPFunctionTypes are final. private short fAnnotation= -1; private int fRequiredArgCount= -1; - public PDOMCPPFunctionSpecialization(PDOMLinkage linkage, PDOMNode parent, ICPPFunction astFunction, - PDOMBinding specialized) throws CoreException { + public PDOMCPPFunctionSpecialization(PDOMLinkage linkage, PDOMNode parent, ICPPFunction astFunction, PDOMBinding specialized) throws CoreException { super(linkage, parent, (ICPPSpecialization) astFunction, specialized); Database db = getDB(); @@ -121,12 +112,8 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization db.putRecPtr(record + FIRST_PARAM, next == null ? 0 : next.getRecord()); } fAnnotation = getAnnotation(astFunction); - db.putShort(record + ANNOTATION, fAnnotation); - db.putShort(record + REQUIRED_ARG_COUNT , (short) astFunction.getRequiredArgumentCount()); - ICPPEvaluation returnExpression = CPPFunction.getReturnExpression(astFunction); - if (returnExpression != null) { - linkage.storeEvaluation(record + RETURN_EXPRESSION, returnExpression); - } + db.putShort(record + ANNOTATION_OFFSET, fAnnotation); + db.putInt(record + REQUIRED_ARG_COUNT_OFFSET, astFunction.getRequiredArgumentCount()); long typelist= 0; if (astFunction instanceof ICPPMethod && ((ICPPMethod) astFunction).isImplicit()) { // Don't store the exception specification, it is computed on demand. @@ -144,9 +131,6 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization if (astFunction.isDeleted()) { annot |= (1 << ANNOT_IS_DELETED); } - if (astFunction.isConstexpr()) { - annot |= (1 << ANNOT_IS_CONSTEXPR); - } return (short) annot; } @@ -172,7 +156,7 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization private short readAnnotation() { if (fAnnotation == -1) { try { - fAnnotation= getDB().getShort(record + ANNOTATION); + fAnnotation= getDB().getShort(record + ANNOTATION_OFFSET); } catch (CoreException e) { fAnnotation= 0; } @@ -235,11 +219,6 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization return false; } - @Override - public boolean isConstexpr() { - return getBit(readAnnotation(), ANNOT_IS_CONSTEXPR); - } - @Override public boolean isExtern() { return getBit(readAnnotation(), PDOMCAnnotation.EXTERN_OFFSET); @@ -275,7 +254,7 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization public int getRequiredArgumentCount() { if (fRequiredArgCount == -1) { try { - fRequiredArgCount= getDB().getShort(record + REQUIRED_ARG_COUNT ); + fRequiredArgCount= getDB().getInt(record + REQUIRED_ARG_COUNT_OFFSET); } catch (CoreException e) { fRequiredArgCount= 0; } @@ -321,17 +300,4 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization return null; } } - - @Override - public ICPPEvaluation getReturnExpression() { - if (!isConstexpr()) - return null; - - try { - return (ICPPEvaluation) getLinkage().loadEvaluation(record + RETURN_EXPRESSION); - } catch (CoreException e) { - CCorePlugin.log(e); - return null; - } - } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java index abd6696a899..920b06a2789 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java @@ -42,8 +42,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDirective; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplate; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplateInstance; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization; @@ -63,6 +61,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace; import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceAlias; import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter; import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplate; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplateInstance; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter; @@ -79,23 +79,21 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTInternal; import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation; import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer; import org.eclipse.cdt.internal.core.dom.parser.ProblemType; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPAliasTemplateInstance; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPArrayType; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClosureType; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPDeferredClassInstance; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunction; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunctionType; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPParameterPackType; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerToMemberType; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerType; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPQualifierType; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPReferenceType; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPAliasTemplateInstance; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownClassInstance; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownMember; import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance; -import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalBinary; @@ -228,7 +226,6 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { private final ICPPFunctionType fOriginalFunctionType; private final ICPPParameter[] fOriginalParameters; private final IType[] fOriginalExceptionSpec; - private final ICPPEvaluation fReturnExpression; public ConfigureFunctionTemplate(ICPPFunctionTemplate original, PDOMCPPFunctionTemplate template) throws DOMException { fTemplate = template; @@ -237,7 +234,6 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { fOriginalFunctionType= original.getType(); fOriginalParameters= original.getParameters(); fOriginalExceptionSpec= template.extractExceptionSpec(original); - fReturnExpression= CPPFunction.getReturnExpression(original); postProcesses.add(this); } @@ -248,33 +244,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { if (tp != null) tp.configure(fOriginalTemplateParameters[i]); } - fTemplate.initData(fOriginalFunctionType, fOriginalParameters, fOriginalExceptionSpec, - fReturnExpression); - } - } - - class ConfigureAliasTemplate implements Runnable { - private final PDOMCPPAliasTemplate fTemplate; - private final IPDOMCPPTemplateParameter[] fTemplateParameters; - private final ICPPTemplateParameter[] fOriginalTemplateParameters; - private final IType fOriginalAliasedType; - - public ConfigureAliasTemplate(ICPPAliasTemplate original, PDOMCPPAliasTemplate template) throws DOMException { - fTemplate = template; - fTemplateParameters= template.getTemplateParameters(); - fOriginalTemplateParameters= original.getTemplateParameters(); - fOriginalAliasedType= original.getType(); - postProcesses.add(this); - } - - @Override - public void run() { - for (int i = 0; i < fOriginalTemplateParameters.length; i++) { - final IPDOMCPPTemplateParameter tp = fTemplateParameters[i]; - if (tp != null) - tp.configure(fOriginalTemplateParameters[i]); - } - fTemplate.initData(fOriginalAliasedType); + fTemplate.initData(fOriginalFunctionType, fOriginalParameters, fOriginalExceptionSpec); } } @@ -300,7 +270,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { } /** - * Adds or returns existing binding for the given one. If {@code fromName} is not {@code null}, + * Adds or returns existing binding for the given one. If fromName is not null * then an existing binding is updated with the properties of the name. */ private PDOMBinding addBinding(IBinding inputBinding, IASTName fromName) throws CoreException { @@ -654,8 +624,8 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { return adaptBinding(null, inputBinding, includeLocal ? FILE_LOCAL_REC_DUMMY : null); } - private final PDOMBinding adaptBinding(final PDOMNode parent, IBinding inputBinding, - long[] fileLocalRecHolder) throws CoreException { + private final PDOMBinding adaptBinding(final PDOMNode parent, IBinding inputBinding, long[] fileLocalRecHolder) + throws CoreException { if (cannotAdapt(inputBinding)) { return null; } @@ -664,8 +634,8 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { if (result != null) { return result; } - - // Assign names to anonymous types. + + // assign names to anonymous types. IBinding binding= PDOMASTAdapter.getAdapterForAnonymousASTBinding(inputBinding); if (binding == null) { return null; @@ -1052,8 +1022,8 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { } @Override - public PDOMBinding addTypeBinding(IBinding binding) throws CoreException { - return addBinding(binding, null); + public PDOMBinding addTypeBinding(IBinding type) throws CoreException { + return addBinding(type, null); } @Override diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethodSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethodSpecialization.java index 397fdddfcaa..3262f7a77c3 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethodSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethodSpecialization.java @@ -123,7 +123,7 @@ class PDOMCPPMethodSpecialization extends PDOMCPPFunctionSpecialization @Override public int getVisibility() { - return PDOMCPPAnnotation.getVisibility(getByte(record + ANNOTATION)); + return PDOMCPPAnnotation.getVisibility(getByte(record + ANNOTATION_OFFSET)); } @Override