diff options
5 files changed, 62 insertions, 19 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 4579f58225e..dd55f8fb57c 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 @@ -2277,4 +2277,28 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa public void testIntNullPointerConstant_407808() throws Exception { checkBindings(); } + + // namespace bar { + // template<class T> + // void join(T); + // } + // + // namespace foo { + // template<typename T> + // void join(T); + // + // struct cat {}; + // } + + // template <typename T> + // auto waldo(T t) -> decltype(bar::join(t)); + // + // int main() { + // waldo(foo::cat{}); + // } + public void testADLForQualifiedName_408296() throws Exception { + checkBindings(); + } } + + 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 501ba428afe..6bea4d370ce 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 @@ -41,6 +41,7 @@ import org.eclipse.core.runtime.CoreException; */ public class EvalFunctionSet extends CPPDependentEvaluation { private final CPPFunctionSet fFunctionSet; + private final boolean fQualified; private final boolean fAddressOf; // Where an EvalFunctionSet is created for an expression of the form 'obj.member_function', @@ -54,25 +55,29 @@ public class EvalFunctionSet extends CPPDependentEvaluation { // Exactly one of fFunctionSet and fName should be non-null. private final char[] fName; - public EvalFunctionSet(CPPFunctionSet set, boolean addressOf, IType impliedObjectType, IASTNode pointOfDefinition) { - this(set, addressOf, impliedObjectType, findEnclosingTemplate(pointOfDefinition)); + public EvalFunctionSet(CPPFunctionSet set, boolean qualified, boolean addressOf, IType impliedObjectType, + IASTNode pointOfDefinition) { + this(set, qualified, addressOf, impliedObjectType, findEnclosingTemplate(pointOfDefinition)); } - public EvalFunctionSet(CPPFunctionSet set, boolean addressOf, IType impliedObjectType, IBinding templateDefinition) { + public EvalFunctionSet(CPPFunctionSet set, boolean qualified, boolean addressOf, IType impliedObjectType, + IBinding templateDefinition) { super(templateDefinition); fFunctionSet= set; + fQualified= qualified; fAddressOf= addressOf; fImpliedObjectType= impliedObjectType; fName= null; } - public EvalFunctionSet(char[] name, boolean addressOf, IASTNode pointOfDefinition) { - this(name, addressOf, findEnclosingTemplate(pointOfDefinition)); + public EvalFunctionSet(char[] name, boolean qualified, boolean addressOf, IASTNode pointOfDefinition) { + this(name, qualified, addressOf, findEnclosingTemplate(pointOfDefinition)); } - public EvalFunctionSet(char[] name, boolean addressOf, IBinding templateDefinition) { + public EvalFunctionSet(char[] name, boolean qualified, boolean addressOf, IBinding templateDefinition) { super(templateDefinition); fFunctionSet= null; + fQualified= qualified; fAddressOf= addressOf; fImpliedObjectType= null; fName= name; @@ -82,6 +87,10 @@ public class EvalFunctionSet extends CPPDependentEvaluation { return fFunctionSet; } + public boolean isQualified() { + return fQualified; + } + public boolean isAddressOf() { return fAddressOf; } @@ -142,10 +151,13 @@ public class EvalFunctionSet extends CPPDependentEvaluation { private final static short FLAG_ADDRESS_OF = ITypeMarshalBuffer.FLAG1; private final static short FLAG_HAS_FUNCTION_SET = ITypeMarshalBuffer.FLAG2; private final static short FLAG_HAS_TEMPLATE_ARGS = ITypeMarshalBuffer.FLAG3; + private final static short FLAG_QUALIFIED = ITypeMarshalBuffer.FLAG4; @Override public void marshal(ITypeMarshalBuffer buffer, boolean includeValue) throws CoreException { short firstBytes = ITypeMarshalBuffer.EVAL_FUNCTION_SET; + if (fQualified) + firstBytes |= FLAG_QUALIFIED; if (fAddressOf) firstBytes |= FLAG_ADDRESS_OF; if (fFunctionSet != null) { @@ -175,6 +187,7 @@ public class EvalFunctionSet extends CPPDependentEvaluation { } public static ISerializableEvaluation unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException { + final boolean qualified= (firstBytes & FLAG_QUALIFIED) != 0; final boolean addressOf= (firstBytes & FLAG_ADDRESS_OF) != 0; if ((firstBytes & FLAG_HAS_FUNCTION_SET) != 0) { int bindingCount= buffer.getInt(); @@ -192,11 +205,12 @@ public class EvalFunctionSet extends CPPDependentEvaluation { } IType impliedObjectType= buffer.unmarshalType(); IBinding templateDefinition= buffer.unmarshalBinding(); - return new EvalFunctionSet(new CPPFunctionSet(bindings, args, null), addressOf, impliedObjectType, templateDefinition); + return new EvalFunctionSet(new CPPFunctionSet(bindings, args, null), qualified, addressOf, + impliedObjectType, templateDefinition); } else { char[] name = buffer.getCharArray(); IBinding templateDefinition= buffer.unmarshalBinding(); - return new EvalFunctionSet(name, addressOf, templateDefinition); + return new EvalFunctionSet(name, qualified, addressOf, templateDefinition); } } @@ -236,7 +250,8 @@ public class EvalFunctionSet extends CPPDependentEvaluation { // with an implied object type when that type is not dependent. if (Arrays.equals(arguments, originalArguments) && functions == originalFunctions) return this; - return new EvalFunctionSet(new CPPFunctionSet(functions, arguments, null), fAddressOf, fImpliedObjectType, getTemplateDefinition()); + return new EvalFunctionSet(new CPPFunctionSet(functions, arguments, null), fQualified, fAddressOf, + fImpliedObjectType, getTemplateDefinition()); } @Override @@ -271,7 +286,7 @@ public class EvalFunctionSet extends CPPDependentEvaluation { try { // Perform ADL if appropriate. - if (fImpliedObjectType == null && !data.hasTypeOrMemberFunctionOrVariableResult()) { + if (!fQualified && fImpliedObjectType == null && !data.hasTypeOrMemberFunctionOrVariableResult()) { CPPSemantics.doKoenigLookup(data); Object[] foundItems = (Object[]) data.foundItems; 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 3e4996d1847..a069e4d17c0 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 @@ -189,10 +189,11 @@ public class EvalID extends CPPDependentEvaluation { public static ICPPEvaluation create(IASTIdExpression expr) { final IASTName name = expr.getName(); IBinding binding = name.resolvePreBinding(); + boolean qualified = name instanceof ICPPASTQualifiedName; if (binding instanceof IProblemBinding || binding instanceof IType || binding instanceof ICPPConstructor) return EvalFixed.INCOMPLETE; if (binding instanceof CPPFunctionSet) { - return new EvalFunctionSet((CPPFunctionSet) binding, isAddressOf(expr), null, expr); + return new EvalFunctionSet((CPPFunctionSet) binding, qualified, isAddressOf(expr), null, expr); } if (binding instanceof ICPPUnknownBinding) { ICPPTemplateArgument[] templateArgs = null; @@ -209,10 +210,10 @@ public class EvalID extends CPPDependentEvaluation { ICPPFunction[] candidates = ((CPPDeferredFunction) binding).getCandidates(); if (candidates != null) { CPPFunctionSet functionSet = new CPPFunctionSet(candidates, templateArgs, null); - return new EvalFunctionSet(functionSet, isAddressOf(expr), null, expr); + return new EvalFunctionSet(functionSet, qualified, isAddressOf(expr), null, expr); } else { // Just store the name. ADL at the time of instantiation might come up with bindings. - return new EvalFunctionSet(name.getSimpleID(), isAddressOf(expr), expr); + return new EvalFunctionSet(name.getSimpleID(), qualified, isAddressOf(expr), expr); } } @@ -367,7 +368,7 @@ public class EvalID extends CPPDependentEvaluation { if (bindings.length > 1 && bindings[0] instanceof ICPPFunction) { ICPPFunction[] functions = new ICPPFunction[bindings.length]; System.arraycopy(bindings, 0, functions, 0, bindings.length); - return new EvalFunctionSet(new CPPFunctionSet(functions, templateArgs, null), fAddressOf, + return new EvalFunctionSet(new CPPFunctionSet(functions, templateArgs, null), fQualified, fAddressOf, impliedObjectType, getTemplateDefinition()); } IBinding binding = bindings.length == 1 ? bindings[0] : null; @@ -376,7 +377,8 @@ public class EvalID extends CPPDependentEvaluation { } else if (binding instanceof ICPPMember) { return new EvalMemberAccess(nameOwner, ValueCategory.PRVALUE, binding, false, getTemplateDefinition()); } else if (binding instanceof CPPFunctionSet) { - return new EvalFunctionSet((CPPFunctionSet) binding, fAddressOf, impliedObjectType, getTemplateDefinition()); + return new EvalFunctionSet((CPPFunctionSet) binding, fQualified, fAddressOf, impliedObjectType, + getTemplateDefinition()); } return null; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java index 75575e0fb3b..4abe2b33678 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java @@ -339,7 +339,8 @@ public class CPPCompositesFactory extends AbstractCompositeFactory { ICPPTemplateArgument[] b2 = TemplateInstanceUtil.convert(this, b); IType c2 = getCompositeType(c); if (a != a2 || b != b2 || c != c2 || templateDefinition != templateDefinition2) - e= new EvalFunctionSet(new CPPFunctionSet(a2, b2, null), e.isAddressOf(), c2, templateDefinition2); + e= new EvalFunctionSet(new CPPFunctionSet(a2, b2, null), e.isQualified(), e.isAddressOf(), + c2, templateDefinition2); } return e; } 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 50b54057034..6ab47206add 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 @@ -238,10 +238,11 @@ public class PDOM extends PlatformObject implements IPDOM { * 144.0 - Add support for storing function sets with zero functions in EvalFunctionSet, bug 402498. * 145.0 - Changed marshalling of CPPBasicType to store the associated numerical value, bug 407808. * 146.0 - Added visibility support on class type level, bug 402878. + * 147.0 - Store whether function name is qualified in EvalFunctionSet, bug 408296. */ - private static final int MIN_SUPPORTED_VERSION= version(145, 0); - private static final int MAX_SUPPORTED_VERSION= version(145, Short.MAX_VALUE); - private static final int DEFAULT_VERSION = version(145, 0); + private static final int MIN_SUPPORTED_VERSION= version(147, 0); + private static final int MAX_SUPPORTED_VERSION= version(147, Short.MAX_VALUE); + private static final int DEFAULT_VERSION = version(147, 0); private static int version(int major, int minor) { return (major << 16) + minor; |