From 526fd1eb5517e9e5891d784f8fd4f33310fdddfa Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Fri, 14 Mar 2014 11:02:17 -0700 Subject: [PATCH] Bug 430230. Fixed loss of EvalTypeId arguments during serialization/deserialization. --- .../tests/IndexCPPTemplateResolutionTest.java | 19 +++++- .../cpp/semantics/EvalFunctionCall.java | 12 +--- .../dom/parser/cpp/semantics/EvalTypeId.java | 59 +++++++++---------- .../eclipse/cdt/internal/core/pdom/PDOM.java | 11 ++-- 4 files changed, 53 insertions(+), 48 deletions(-) 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 74e1c6332c1..46342aa7ce3 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 @@ -2053,7 +2053,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa // }; // // typedef A type; - public void testSFINAE_a() throws Exception { + public void testSfinae_a() throws Exception { checkBindings(); } @@ -2085,7 +2085,22 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa // A::get(); // A::get(); // } - public void testSFINAE_b() throws Exception { + public void testSfinae_b() throws Exception { + checkBindings(); + } + + // template + // static void test(int); + // + // template + // static int test(...); + + // struct A {}; + // + // int waldo(int p); + // + // int x = waldo(test(0)); + public void testSfinaeInNewExpression_430230() throws Exception { checkBindings(); } 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 5a791eb818c..b74633bb40a 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 @@ -76,20 +76,12 @@ public class EvalFunctionCall extends CPPDependentEvaluation { @Override public boolean isTypeDependent() { - for (ICPPEvaluation arg : fArguments) { - if (arg.isTypeDependent()) - return true; - } - return false; + return containsDependentType(fArguments); } @Override public boolean isValueDependent() { - for (ICPPEvaluation arg : fArguments) { - if (arg.isValueDependent()) - return true; - } - return false; + return containsDependentValue(fArguments); } public ICPPFunction getOverload(IASTNode point) { 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 2975dd9e059..1104628ec59 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 @@ -144,18 +144,14 @@ public class EvalTypeId extends CPPDependentEvaluation { @Override public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException { short firstBytes = ITypeMarshalBuffer.EVAL_TYPE_ID; - if (includeValue) - firstBytes |= ITypeMarshalBuffer.FLAG1; if (fRepresentsNewExpression) - firstBytes |= ITypeMarshalBuffer.FLAG2; + firstBytes |= ITypeMarshalBuffer.FLAG1; buffer.putShort(firstBytes); buffer.marshalType(fInputType); - if (includeValue) { - buffer.putInt(fArguments.length); - for (ICPPEvaluation arg : fArguments) { - buffer.marshalEvaluation(arg, includeValue); - } + buffer.putInt(fArguments.length); + for (ICPPEvaluation arg : fArguments) { + buffer.marshalEvaluation(arg, includeValue); } marshalTemplateDefinition(buffer); } @@ -164,17 +160,13 @@ public class EvalTypeId extends CPPDependentEvaluation { throws CoreException { IType type= buffer.unmarshalType(); ICPPEvaluation[] args= null; - if ((firstBytes & ITypeMarshalBuffer.FLAG1) != 0) { - int len= buffer.getInt(); - args = new ICPPEvaluation[len]; - for (int i = 0; i < args.length; i++) { - args[i]= (ICPPEvaluation) buffer.unmarshalEvaluation(); - } - } else { - args = ICPPEvaluation.EMPTY_ARRAY; // Arguments must not be null + int len= buffer.getInt(); + args = new ICPPEvaluation[len]; + for (int i = 0; i < args.length; i++) { + args[i]= (ICPPEvaluation) buffer.unmarshalEvaluation(); } IBinding templateDefinition= buffer.unmarshalBinding(); - boolean forNewExpression = (firstBytes & ITypeMarshalBuffer.FLAG2) != 0; + boolean forNewExpression = (firstBytes & ITypeMarshalBuffer.FLAG1) != 0; return new EvalTypeId(type, templateDefinition, forNewExpression, args); } @@ -186,23 +178,26 @@ public class EvalTypeId extends CPPDependentEvaluation { if (args == fArguments && type == fInputType) return this; - if (!CPPTemplates.isDependentType(type) && !containsDependentType(args) && type instanceof ICPPClassType) { - // Check the constructor call and return EvalFixed.INCOMPLETE to indicate a substitution - // failure if the call cannot be resolved. - ICPPClassType classType = (ICPPClassType) type; - LookupData data = new LookupData(classType.getNameCharArray(), null, point); - ICPPConstructor[] constructors = ClassTypeHelper.getConstructors(classType, point); - data.foundItems = constructors; - data.setFunctionArguments(false, args); - try { - IBinding binding = CPPSemantics.resolveFunction(data, constructors, true); - if (binding == null || binding instanceof IProblemBinding || - binding instanceof ICPPFunction && ((ICPPFunction) binding).isDeleted()) { + if (!CPPTemplates.isDependentType(type) && !containsDependentType(args)) { + IType simplifiedType = SemanticUtil.getNestedType(type, SemanticUtil.TDEF); + if (simplifiedType instanceof ICPPClassType) { + // Check the constructor call and return EvalFixed.INCOMPLETE to indicate a substitution + // failure if the call cannot be resolved. + ICPPClassType classType = (ICPPClassType) type; + LookupData data = new LookupData(classType.getNameCharArray(), null, point); + ICPPConstructor[] constructors = ClassTypeHelper.getConstructors(classType, point); + data.foundItems = constructors; + data.setFunctionArguments(false, args); + try { + IBinding binding = CPPSemantics.resolveFunction(data, constructors, true); + if (binding == null || binding instanceof IProblemBinding || + binding instanceof ICPPFunction && ((ICPPFunction) binding).isDeleted()) { + return EvalFixed.INCOMPLETE; + } + } catch (DOMException e) { + CCorePlugin.log(e); return EvalFixed.INCOMPLETE; } - } catch (DOMException e) { - CCorePlugin.log(e); - return EvalFixed.INCOMPLETE; } } return new EvalTypeId(type, getTemplateDefinition(), fRepresentsNewExpression, args); 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 ef743880d95..444ecc90df3 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 @@ -245,11 +245,14 @@ public class PDOM extends PlatformObject implements IPDOM { * 160.0 - Store specialized template parameters of class/function template specializations, bug 407497. * 161.0 - Allow reference to PDOMBinding from other PDOMLinkages, bug 422681. * 162.0 - PDOMNode now stores the factoryId for loading, bug 422681. - * 163.0 - QtLinkage changed storage format of QObject to accommodate QGadget. + * #163.0# - QtLinkage changed storage format of QObject to accommodate QGadget. <> + * + * CDT 8.4 development (versions not supported on the 8.3.x branch) + * 170.0 - Unconditionally store arguments of EvalTypeId, bug 430230. */ - private static final int MIN_SUPPORTED_VERSION= version(163, 0); - private static final int MAX_SUPPORTED_VERSION= version(163, Short.MAX_VALUE); - private static final int DEFAULT_VERSION = version(163, 0); + private static final int MIN_SUPPORTED_VERSION= version(170, 0); + private static final int MAX_SUPPORTED_VERSION= version(170, Short.MAX_VALUE); + private static final int DEFAULT_VERSION = version(170, 0); private static int version(int major, int minor) { return (major << 16) + minor;