mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Bug 437675 - Handle PDOM function instances in
CPPTemplates.instantiateBinding() Change-Id: I3bf9ee9f5db0521e60c302b96db39513873aeb1b Signed-off-by: Nathan Ridge <zeratul976@hotmail.com> Reviewed-on: https://git.eclipse.org/r/31347 Reviewed-by: Sergey Prigogin <eclipse.sprigogin@gmail.com> Tested-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
This commit is contained in:
parent
3e540156b6
commit
de6b33924c
6 changed files with 67 additions and 10 deletions
|
@ -2551,4 +2551,33 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
public void testEnumerationWithMultipleEnumerators_434467() throws Exception {
|
||||
checkBindings();
|
||||
}
|
||||
|
||||
// template <typename ResultT, ResultT (*Func)()>
|
||||
// struct Base {
|
||||
// ResultT operator()() const;
|
||||
// };
|
||||
//
|
||||
// struct S {};
|
||||
//
|
||||
// template <typename T>
|
||||
// class B {};
|
||||
//
|
||||
// template<typename T>
|
||||
// B<T> f();
|
||||
//
|
||||
// template <typename T>
|
||||
// class Derived : public Base<B<S>, f<T> > {};
|
||||
|
||||
// #include "header.h"
|
||||
// const Derived<S> decl;
|
||||
//
|
||||
// void bar(const B<S>&);
|
||||
//
|
||||
// void foo()
|
||||
// {
|
||||
// bar(decl()); // ERROR HERE: Invalid arguments
|
||||
// }
|
||||
public void testInstantiationOfFunctionInstance_437675() throws Exception {
|
||||
checkBindings();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Nathan Ridge.
|
||||
* 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:
|
||||
* Nathan Ridge - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
|
||||
/**
|
||||
* This interface represents an instantiation of a function template.
|
||||
*
|
||||
* @noimplement This interface is not intended to be implemented by clients.
|
||||
* @noextend This interface is not intended to be extended by clients.
|
||||
* @since 5.8
|
||||
*/
|
||||
public interface ICPPFunctionInstance extends ICPPTemplateInstance, ICPPFunction {
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 2010 IBM Corporation and others.
|
||||
* Copyright (c) 2005, 2014 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,6 +8,7 @@
|
|||
* Contributors:
|
||||
* Andrew Niefer (IBM) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Nathan Ridge
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
|
@ -16,6 +17,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
|
|||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
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.ICPPFunctionInstance;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||
|
@ -25,7 +27,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
|||
/**
|
||||
* The instantiation of a function template.
|
||||
*/
|
||||
public class CPPFunctionInstance extends CPPFunctionSpecialization implements ICPPTemplateInstance {
|
||||
public class CPPFunctionInstance extends CPPFunctionSpecialization implements ICPPFunctionInstance {
|
||||
private final ICPPTemplateArgument[] fArguments;
|
||||
|
||||
public CPPFunctionInstance(ICPPFunction orig, IBinding owner, CPPTemplateParameterMap argMap,
|
||||
|
|
|
@ -82,6 +82,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPEnumeration;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPEnumerationSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionInstance;
|
||||
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.ICPPMethod;
|
||||
|
@ -1507,12 +1508,12 @@ public class CPPTemplates {
|
|||
return ((ICPPClassSpecialization) owner).specializeMember(binding, point);
|
||||
}
|
||||
}
|
||||
} else if (binding instanceof CPPFunctionInstance) {
|
||||
} else if (binding instanceof ICPPFunctionInstance) {
|
||||
// TODO(nathanridge):
|
||||
// Maybe we should introduce a CPPDeferredFunctionInstance and have things that can return
|
||||
// a dependent CPPFunctionInstance (like instantiateForAddressOfFunction) return that when
|
||||
// Maybe we should introduce an ICPPDeferredFunctionInstance and have things that can return
|
||||
// a dependent ICPPFunctionInstance (like instantiateForAddressOfFunction) return that when
|
||||
// appropriate?
|
||||
CPPFunctionInstance origInstance = (CPPFunctionInstance) binding;
|
||||
ICPPFunctionInstance origInstance = (ICPPFunctionInstance) binding;
|
||||
ICPPTemplateArgument[] origArgs = origInstance.getTemplateArguments();
|
||||
ICPPTemplateArgument[] newArgs = instantiateArguments(origArgs, tpMap, packOffset, within, point, false);
|
||||
if (origArgs != newArgs) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007, 2010 Symbian Software Systems and others.
|
||||
* Copyright (c) 2007, 2014 Symbian Software Systems 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,12 +8,14 @@
|
|||
* Contributors:
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Nathan Ridge
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
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.ICPPFunctionInstance;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||
|
@ -21,7 +23,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
|||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||
|
||||
public class CompositeCPPFunctionInstance extends CompositeCPPFunction implements ICPPTemplateInstance {
|
||||
public class CompositeCPPFunctionInstance extends CompositeCPPFunction implements ICPPFunctionInstance {
|
||||
|
||||
public CompositeCPPFunctionInstance(ICompositesFactory cf, ICPPFunction rbinding) {
|
||||
super(cf, rbinding);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007, 2010 QNX Software Systems and others.
|
||||
* Copyright (c) 2007, 2014 QNX Software Systems 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
|
||||
|
@ -9,12 +9,14 @@
|
|||
* Bryan Wilkinson (QNX) - Initial API and implementation
|
||||
* Andrew Ferguson (Symbian)
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Nathan Ridge
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
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.ICPPFunctionInstance;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||
|
@ -29,7 +31,7 @@ import org.eclipse.core.runtime.CoreException;
|
|||
/**
|
||||
* Result of instantiating a function template.
|
||||
*/
|
||||
class PDOMCPPFunctionInstance extends PDOMCPPFunctionSpecialization implements ICPPTemplateInstance {
|
||||
class PDOMCPPFunctionInstance extends PDOMCPPFunctionSpecialization implements ICPPFunctionInstance {
|
||||
private static final int ARGUMENTS = PDOMCPPFunctionSpecialization.RECORD_SIZE + 0;
|
||||
|
||||
@SuppressWarnings("hiding")
|
||||
|
|
Loading…
Add table
Reference in a new issue