1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-13 03:55:22 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2013-07-21 19:30:00 -07:00
parent 2050fe2bfb
commit 9827378be6
16 changed files with 156 additions and 157 deletions

View file

@ -19,10 +19,10 @@
package org.eclipse.cdt.core.parser.tests.ast2;
import static org.eclipse.cdt.core.parser.ParserLanguage.CPP;
import static org.eclipse.cdt.core.parser.tests.VisibilityAsserts.assertVisibility;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getNestedType;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getUltimateType;
import static org.eclipse.cdt.core.parser.tests.VisibilityAsserts.assertVisibility;
import java.io.IOException;
@ -126,7 +126,7 @@ public class AST2TemplateTests extends AST2TestBase {
private IASTTranslationUnit parseAndCheckBindings(final String code) throws Exception {
return parseAndCheckBindings(code, CPP);
}
protected IASTTranslationUnit parseAndCheckImplicitNameBindings() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), CPP, false, true, false);
NameCollector col = new NameCollector(true /* visit implicit names */);
@ -1978,7 +1978,7 @@ public class AST2TemplateTests extends AST2TestBase {
ITypedef myType = (ITypedef) col.getName(31).resolveBinding();
ICPPClassType A = (ICPPClassType) myType.getType();
ICPPClassTemplatePartialSpecialization Aspec =
ICPPClassTemplatePartialSpecialization Aspec =
(ICPPClassTemplatePartialSpecialization) col.getName(10).resolveBinding();
assertTrue(A instanceof ICPPTemplateInstance);
@ -3235,7 +3235,7 @@ public class AST2TemplateTests extends AST2TestBase {
BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), CPP);
ba.assertNonProblem("foo(s", 3);
}
// template<typename U>
// struct result : U {
// typedef typename result::result_type type;
@ -3251,12 +3251,12 @@ public class AST2TemplateTests extends AST2TestBase {
ITypedef waldo = bh.assertNonProblem("waldo");
assertSameType(waldo.getType(), CommonTypes.int_);
}
// template <typename T>
// struct A {
// template <typename U>
// struct result;
//
// struct result;
//
// template <typename V>
// struct result<V*> : T {
// typedef typename result::result_type type;
@ -3277,8 +3277,8 @@ public class AST2TemplateTests extends AST2TestBase {
// template <typename T>
// struct A {
// template <typename U>
// struct result;
//
// struct result;
//
// template <typename V>
// struct result<V*> : T {
// typedef typename result::result_type type;
@ -3295,7 +3295,7 @@ public class AST2TemplateTests extends AST2TestBase {
ITypedef waldo = bh.assertNonProblem("waldo");
assertSameType(waldo.getType(), CommonTypes.int_);
}
// template <class T>
// class A {
// public:
@ -4507,7 +4507,7 @@ public class AST2TemplateTests extends AST2TestBase {
public void testFunctionTemplateOrdering_388805() throws Exception {
parseAndCheckBindings();
}
// template <typename T>
// struct identity {
// typedef T type;
@ -4527,8 +4527,8 @@ public class AST2TemplateTests extends AST2TestBase {
}
// template <typename T>
// struct identity {
// typedef T type;
// struct identity {
// typedef T type;
// };
//
// template <typename> struct W;
@ -4554,7 +4554,7 @@ public class AST2TemplateTests extends AST2TestBase {
public void testFunctionTemplateOrdering_409094b() throws Exception {
parseAndCheckBindings();
}
// template<typename T> class CT {};
// template<int I> class CTI {};
//
@ -6216,9 +6216,9 @@ public class AST2TemplateTests extends AST2TestBase {
// template <typename T>
// struct B {
// struct base : id<id<T>> {};
//
//
// typedef typename base::type base2;
//
//
// struct result : base2 {};
// };
//
@ -6410,7 +6410,7 @@ public class AST2TemplateTests extends AST2TestBase {
public void testPointerToMemberOfTemplateClass_402861() throws Exception {
parseAndCheckBindings();
}
// struct N {
// int node;
// };
@ -6425,7 +6425,7 @@ public class AST2TemplateTests extends AST2TestBase {
public void testDependentTemplateParameterInNestedTemplate_407497() throws Exception {
parseAndCheckBindings();
}
// template <typename T>
// struct enclosing {
// template <typename U = T>
@ -7235,7 +7235,7 @@ public class AST2TemplateTests extends AST2TestBase {
assertNotNull(val);
assertEquals(0 /* false */, val.longValue());
}
// struct S {
// S(int);
// };
@ -7247,7 +7247,7 @@ public class AST2TemplateTests extends AST2TestBase {
// struct meta<S> {
// typedef void type;
// };
//
//
// struct B {
// template <typename T, typename = typename meta<T>::type>
// operator T() const;
@ -7501,9 +7501,9 @@ public class AST2TemplateTests extends AST2TestBase {
// template <typename F>
// struct W {
// F f;
//
// auto operator()() const -> decltype(f()) {
// return f();
//
// auto operator()() const -> decltype(f()) {
// return f();
// }
// };
//
@ -7513,7 +7513,7 @@ public class AST2TemplateTests extends AST2TestBase {
IType waldo = bh.assertNonProblem("waldo");
assertSameType(waldo, CommonTypes.int_);
}
// template <typename _Tp>
// struct remove_reference {
// typedef _Tp type;

View file

@ -13,6 +13,9 @@
*******************************************************************************/
package org.eclipse.cdt.internal.index.tests;
import java.util.ArrayList;
import java.util.List;
import junit.framework.TestSuite;
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
@ -65,9 +68,6 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
import org.eclipse.cdt.internal.core.index.IIndexScope;
import org.eclipse.core.runtime.CoreException;
import java.util.ArrayList;
import java.util.List;
/**
* Tests for exercising resolution of template bindings against IIndex
*/
@ -2322,7 +2322,7 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
public void testSpecializationRedefinition_409444() throws Exception {
checkBindings();
}
// struct N {
// int node;
// };
@ -2332,12 +2332,12 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
// template <int T::*>
// struct Base {};
// };
// List<N>::Base<&N::node> base;
public void testDependentTemplateParameterInNestedTemplate_407497() throws Exception {
checkBindings();
}
// template <typename T>
// struct enclosing {
// template <typename U = T>
@ -2345,12 +2345,12 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
// typedef U type;
// };
// };
// typedef enclosing<int>::nested<>::type waldo;
public void testDependentTemplateParameterInNestedTemplate_399454() throws Exception {
checkBindings();
}
// void f(int);
//
// template <typename... Args>

View file

@ -32,17 +32,16 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
*/
public class CPPClassTemplateSpecialization extends CPPClassSpecialization
implements ICPPClassTemplate, ICPPInternalClassTemplate {
private ObjectMap instances = null;
private ObjectMap instances;
private ICPPDeferredClassInstance fDeferredInstance;
private ICPPClassTemplatePartialSpecialization[] fPartialSpecs;
private ICPPTemplateParameter[] fTemplateParameters;
public CPPClassTemplateSpecialization(ICPPClassTemplate orig, ICPPClassSpecialization owner,
public CPPClassTemplateSpecialization(ICPPClassTemplate orig, ICPPClassSpecialization owner,
ICPPTemplateParameterMap argumentMap) {
super(orig, owner, argumentMap);
}
public void setTemplateParameters(ICPPTemplateParameter[] templateParameters) {
fTemplateParameters = templateParameters;
}
@ -105,12 +104,12 @@ public class CPPClassTemplateSpecialization extends CPPClassSpecialization
public String toString() {
return getName();
}
@Override
public IBinding resolveTemplateParameter(ICPPTemplateParameter param) {
return param;
}
@Override
public final ICPPDeferredClassInstance asDeferredInstance() {
if (fDeferredInstance == null) {
@ -118,17 +117,17 @@ public class CPPClassTemplateSpecialization extends CPPClassSpecialization
}
return fDeferredInstance;
}
@Override
public ICPPTemplateArgument getDefaultArgFromIndex(int paramPos) throws DOMException {
return null;
}
@Override
public ICPPClassSpecialization getOwner() {
return (ICPPClassSpecialization) super.getOwner();
}
@Override
public ICPPClassTemplate getSpecializedBinding() {
return (ICPPClassTemplate) super.getSpecializedBinding();

View file

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
* Markus Schorn (Wind River Systems)
* IBM Corporation - initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -20,9 +20,9 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
/**
* Specialization of a constructor template
*/
public class CPPConstructorTemplateSpecialization extends CPPMethodTemplateSpecialization
public class CPPConstructorTemplateSpecialization extends CPPMethodTemplateSpecialization
implements ICPPConstructor {
public CPPConstructorTemplateSpecialization(ICPPConstructor original,
ICPPClassSpecialization owner, ICPPTemplateParameterMap tpmap, ICPPFunctionType type, IType[] exceptionSpecs) {
super(original, owner, tpmap, type, exceptionSpecs);

View file

@ -25,16 +25,15 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
/**
* The specialization of a method template in the context of a class specialization.
*/
public class CPPMethodTemplateSpecialization extends CPPFunctionTemplateSpecialization
public class CPPMethodTemplateSpecialization extends CPPFunctionTemplateSpecialization
implements ICPPMethod {
private ICPPTemplateParameter[] fTemplateParameters;
public CPPMethodTemplateSpecialization(ICPPMethod specialized, ICPPClassSpecialization owner,
public CPPMethodTemplateSpecialization(ICPPMethod specialized, ICPPClassSpecialization owner,
ICPPTemplateParameterMap ctmap, ICPPFunctionType type, IType[] exceptionSpecs) {
super(specialized, owner, ctmap, type, exceptionSpecs);
}
public void setTemplateParameters(ICPPTemplateParameter[] templateParameters) {
fTemplateParameters = templateParameters;
}
@ -59,7 +58,7 @@ public class CPPMethodTemplateSpecialization extends CPPFunctionTemplateSpeciali
return ((ICPPMethod) m).getVisibility();
return 0;
}
@Override
public ICPPClassType getClassOwner() {
return getOwner();
@ -70,7 +69,7 @@ public class CPPMethodTemplateSpecialization extends CPPFunctionTemplateSpeciali
char[] name = getNameCharArray();
if (name.length > 1 && name[0] == '~')
return true;
return false;
}
@ -81,7 +80,7 @@ public class CPPMethodTemplateSpecialization extends CPPFunctionTemplateSpeciali
return ((ICPPMethod) m).isImplicit();
return false;
}
@Override
public boolean isExplicit() {
IBinding m = getSpecializedBinding();
@ -107,7 +106,7 @@ public class CPPMethodTemplateSpecialization extends CPPFunctionTemplateSpeciali
public boolean isFinal() {
return false;
}
@Override
public ICPPClassSpecialization getOwner() {
return (ICPPClassSpecialization) super.getOwner();

View file

@ -22,21 +22,20 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
* A specialization of a non-type template parameter. This is needed when a nested template
* has a non-type template parameter whose type or default value is dependent on a template
* parameter of an enclosing template.
*
*
* This class can represent a specialization of either an AST or a PDOM template parameter.
*/
public class CPPTemplateNonTypeParameterSpecialization extends CPPTemplateParameterSpecialization
implements ICPPTemplateNonTypeParameter {
private final IType fType;
public CPPTemplateNonTypeParameterSpecialization(ICPPSpecialization owner, ICPPScope scope,
ICPPTemplateNonTypeParameter specialized, ICPPTemplateArgument defaultValue, IType type) {
super(owner, scope, specialized, defaultValue);
this.fType = type;
}
@Override
public ICPPTemplateNonTypeParameter getSpecializedBinding() {
return (ICPPTemplateNonTypeParameter) super.getSpecializedBinding();
@ -56,22 +55,22 @@ public class CPPTemplateNonTypeParameterSpecialization extends CPPTemplateParame
public boolean isStatic() {
return false;
}
@Override
public boolean isExtern() {
return false;
}
@Override
public boolean isRegister() {
return false;
}
@Override
public boolean isAuto() {
return false;
}
@Override
public IType getType() {
return fType;

View file

@ -24,20 +24,19 @@ import org.eclipse.core.runtime.PlatformObject;
/**
* A specialization of a template parameter.
*
*
* This class provides common implementation for CPPTemplateNonTypeParameterSpecialization,
* CPPTemplateTypeParameterSpecialization, and CPPTemplateTemplateParameterSpecialization.
*/
public abstract class CPPTemplateParameterSpecialization extends PlatformObject
implements ICPPTemplateParameter, ICPPSpecialization {
private final ICPPSpecialization fOwner;
private final ICPPScope fScope;
private final ICPPTemplateParameter fSpecialized;
private final ICPPTemplateParameterMap fTemplateParameterMap;
private final ICPPTemplateArgument fDefaultValue;
public CPPTemplateParameterSpecialization(ICPPSpecialization owner, ICPPScope scope, ICPPTemplateParameter specialized,
public CPPTemplateParameterSpecialization(ICPPSpecialization owner, ICPPScope scope, ICPPTemplateParameter specialized,
ICPPTemplateArgument defaultValue) {
fOwner = owner;
fScope = scope;
@ -126,5 +125,4 @@ public abstract class CPPTemplateParameterSpecialization extends PlatformObject
public boolean isParameterPack() {
return fSpecialized.isParameterPack();
}
}

View file

@ -33,7 +33,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTemplateParameter;
* A specialization of a template template parameter. This is needed when a nested template
* has a template template parameter whose default value is dependent on a template
* parameter of an enclosing template.
*
*
* This class can represent a specialization of either an AST or a PDOM template parameter.
*/
public class CPPTemplateTemplateParameterSpecialization extends CPPTemplateParameterSpecialization
@ -43,7 +43,7 @@ public class CPPTemplateTemplateParameterSpecialization extends CPPTemplateParam
ICPPTemplateTemplateParameter specialized, ICPPTemplateArgument defaultValue) {
super(owner, scope, specialized, defaultValue);
}
@Override
public ICPPTemplateTemplateParameter getSpecializedBinding() {
return (ICPPTemplateTemplateParameter) super.getSpecializedBinding();
@ -63,47 +63,47 @@ public class CPPTemplateTemplateParameterSpecialization extends CPPTemplateParam
public ICPPBase[] getBases() {
return ICPPBase.EMPTY_BASE_ARRAY;
}
@Override
public IField[] getFields() {
return IField.EMPTY_FIELD_ARRAY;
}
@Override
public IField findField(String name) {
return null;
}
@Override
public ICPPField[] getDeclaredFields() {
return ICPPField.EMPTY_CPPFIELD_ARRAY;
}
@Override
public ICPPMethod[] getMethods() {
return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
}
@Override
public ICPPMethod[] getAllDeclaredMethods() {
return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
}
@Override
public ICPPMethod[] getDeclaredMethods() {
return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
}
@Override
public ICPPConstructor[] getConstructors() {
return ICPPConstructor.EMPTY_CONSTRUCTOR_ARRAY;
}
@Override
public IBinding[] getFriends() {
return IBinding.EMPTY_BINDING_ARRAY;
}
@Override
public ICPPClassType[] getNestedClasses() {
return ICPPClassType.EMPTY_CLASS_ARRAY;

View file

@ -23,12 +23,12 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
* A specialization of a type template parameter. This is needed when a nested template
* has a type template parameter whose default value is dependent on a template
* parameter of an enclosing template.
*
*
* This class can represent a specialization of either an AST or a PDOM template parameter.
*/
public class CPPTemplateTypeParameterSpecialization extends CPPTemplateParameterSpecialization
implements ICPPTemplateTypeParameter {
public CPPTemplateTypeParameterSpecialization(ICPPSpecialization owner, ICPPScope scope,
ICPPTemplateTypeParameter specialized, ICPPTemplateArgument defaultValue) {
super(owner, scope, specialized, defaultValue);
@ -52,7 +52,7 @@ public class CPPTemplateTypeParameterSpecialization extends CPPTemplateParameter
return type.isSameType(this);
if (!(type instanceof ICPPTemplateTypeParameter))
return false;
return getParameterID() == ((ICPPTemplateParameter) type).getParameterID();
}

View file

@ -26,6 +26,8 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPFunctionParamet
* Assists in evaluating expressions.
*/
public interface ICPPEvaluation extends ISerializableEvaluation {
public static final ICPPEvaluation[] EMPTY_ARRAY = {};
boolean isInitializerList();
boolean isFunctionSet();

View file

@ -172,7 +172,7 @@ public class CPPTemplates {
// The three constants below are used as special return values for the various overloads
// of CPPTemplates.determinePackSize() and for ICPPEvaluation.determinePackSize(), which
// search a type, template argument, or value for a usage of a template parameter pack
// and return the number of arguments bound to that parameter pack in an
// and return the number of arguments bound to that parameter pack in an
// ICPPTemplateParameterMap.
// Used to indicate that the parameter pack is not bound to any arguments in the
@ -820,9 +820,9 @@ public class CPPTemplates {
} else if (decl instanceof ICPPClassTemplate) {
ICPPClassTemplate template = (ICPPClassTemplate) decl;
CPPClassTemplateSpecialization classTemplateSpec = new CPPClassTemplateSpecialization(template, owner, tpMap);
classTemplateSpec.setTemplateParameters(CPPTemplates.specializeTemplateParameters(classTemplateSpec,
classTemplateSpec.setTemplateParameters(CPPTemplates.specializeTemplateParameters(classTemplateSpec,
(ICPPScope) classTemplateSpec.getScope(), template.getTemplateParameters(), owner, point));
spec = classTemplateSpec;
spec = classTemplateSpec;
} else if (decl instanceof ICPPClassType) {
IBinding oldOwner = decl.getOwner();
if (oldOwner instanceof IType && owner.getSpecializedBinding().isSameType((IType) oldOwner)) {
@ -841,7 +841,7 @@ public class CPPTemplates {
ICPPClassSpecialization within = getSpecializationContext(owner);
ICPPFunctionType type= (ICPPFunctionType) instantiateType(func.getType(), tpMap, -1, within, point);
IType[] exceptionSpecs= instantiateTypes(func.getExceptionSpecification(), tpMap, -1, within, point);
if (decl instanceof ICPPFunctionTemplate) {
if (decl instanceof ICPPMethod) {
CPPMethodTemplateSpecialization methodSpec;
@ -849,8 +849,8 @@ public class CPPTemplates {
methodSpec = new CPPConstructorTemplateSpecialization((ICPPConstructor) decl, owner, tpMap, type, exceptionSpecs);
} else {
methodSpec = new CPPMethodTemplateSpecialization((ICPPMethod) decl, owner, tpMap, type, exceptionSpecs);
}
methodSpec.setTemplateParameters(CPPTemplates.specializeTemplateParameters(methodSpec,
}
methodSpec.setTemplateParameters(CPPTemplates.specializeTemplateParameters(methodSpec,
(ICPPScope) methodSpec.getScope(), ((ICPPFunctionTemplate) decl).getTemplateParameters(), owner, point));
spec = methodSpec;
} else {
@ -1354,7 +1354,7 @@ public class CPPTemplates {
* Specialize a template parameter of a nested template by subtituting values for the template
* parameters of enclosing templates into the template parameter's default value and, in the
* case of a non-type template parameter, type.
*
*
* @param owner the specialization of the nested template. This will be the owner of the
* specialized template parameter.
* @param scope the scope of the nested template specialization
@ -1374,38 +1374,38 @@ public class CPPTemplates {
IType type = instantiateType(spec.getType(), tpMap, 0, within, point);
return new CPPTemplateNonTypeParameterSpecialization(owner, scope, spec, defaultValue, type);
} else if (specialized instanceof ICPPTemplateTypeParameter) {
return new CPPTemplateTypeParameterSpecialization(owner, scope, (ICPPTemplateTypeParameter) specialized,
return new CPPTemplateTypeParameterSpecialization(owner, scope, (ICPPTemplateTypeParameter) specialized,
defaultValue);
} else if (specialized instanceof ICPPTemplateTemplateParameter) {
return new CPPTemplateTemplateParameterSpecialization(owner, scope, (ICPPTemplateTemplateParameter) specialized,
return new CPPTemplateTemplateParameterSpecialization(owner, scope, (ICPPTemplateTemplateParameter) specialized,
defaultValue);
}
return null;
}
/**
* Convenience method for specializing all template parameters in an array.
* See specializeTemplateParameter().
* See specializeTemplateParameter().
*/
public static ICPPTemplateParameter[] specializeTemplateParameters(ICPPSpecialization owner, ICPPScope scope,
public static ICPPTemplateParameter[] specializeTemplateParameters(ICPPSpecialization owner, ICPPScope scope,
ICPPTemplateParameter[] specialized, ICPPClassSpecialization within, IASTNode point) {
ICPPTemplateParameter[] result = new ICPPTemplateParameter[specialized.length];
for (int i = 0; i < specialized.length; ++i)
result[i] = specializeTemplateParameter(owner, scope, specialized[i], within, point);
return result;
}
public static IBinding instantiateBinding(IBinding binding, ICPPTemplateParameterMap tpMap, int packOffset,
ICPPClassSpecialization within, int maxdepth, IASTNode point) throws DOMException {
if (binding instanceof ICPPClassTemplate) {
binding = createDeferredInstance((ICPPClassTemplate) binding);
}
if (binding instanceof ICPPUnknownBinding) {
return resolveUnknown((ICPPUnknownBinding) binding, tpMap, packOffset, within, point);
} else if (binding instanceof IEnumerator
|| binding instanceof ICPPMethod
|| binding instanceof ICPPField
|| binding instanceof ICPPMethod
|| binding instanceof ICPPField
|| binding instanceof ICPPEnumeration
|| binding instanceof ICPPClassType) {
IBinding owner = binding.getOwner();
@ -1422,20 +1422,20 @@ public class CPPTemplates {
}
}
} else if (binding instanceof CPPFunctionInstance) {
// TODO(nathanridge):
// Maybe we should introduce a CPPDeferredFunctionInstance and have things that can return
// TODO(nathanridge):
// Maybe we should introduce a CPPDeferredFunctionInstance and have things that can return
// a dependent CPPFunctionInstance (like instantiateForAddressOfFunction) return that when
// appropriate?
CPPFunctionInstance origInstance = (CPPFunctionInstance) binding;
ICPPTemplateArgument[] origArgs = origInstance.getTemplateArguments();
ICPPTemplateArgument[] newArgs = instantiateArguments(origArgs, tpMap, packOffset, within, point, false);
if (origArgs != newArgs) {
CPPTemplateParameterMap newMap = instantiateArgumentMap(origInstance.getTemplateParameterMap(),
CPPTemplateParameterMap newMap = instantiateArgumentMap(origInstance.getTemplateParameterMap(),
tpMap, packOffset, within, point);
IType newType = instantiateType(origInstance.getType(), tpMap, packOffset, within, point);
IType[] newExceptionSpecs = instantiateTypes(origInstance.getExceptionSpecification(),
IType[] newExceptionSpecs = instantiateTypes(origInstance.getExceptionSpecification(),
tpMap, packOffset, within, point);
return new CPPFunctionInstance((ICPPFunction) origInstance.getTemplateDefinition(), origInstance.getOwner(),
return new CPPFunctionInstance((ICPPFunction) origInstance.getTemplateDefinition(), origInstance.getOwner(),
newMap, newArgs, (ICPPFunctionType) newType, newExceptionSpecs);
}
}
@ -2341,7 +2341,7 @@ public class CPPTemplates {
return arg != null && isValidType(arg.isTypeValue() ? arg.getTypeValue() : arg.getTypeOfNonTypeValue());
}
static ICPPTemplateArgument matchTemplateParameterAndArgument(ICPPTemplateDefinition template,
static ICPPTemplateArgument matchTemplateParameterAndArgument(ICPPTemplateDefinition template,
ICPPTemplateParameter param, ICPPTemplateArgument arg, CPPTemplateParameterMap map, IASTNode point) {
if (arg == null || !isValidType(arg.getTypeValue())) {
return null;
@ -2461,12 +2461,12 @@ public class CPPTemplates {
}
/**
* Converts the template argument <code>arg</code> to match the parameter type
* <code>paramType</code> or returns <code>null</code>, if this violates the rules
* specified in 14.3.2 - 5.
* Converts the template argument {@code arg} to match the parameter type {@code paramType}
* or returns {@code null}, if this violates the rules specified in 14.3.2 - 5.
*
* @throws DOMException
*/
private static ICPPTemplateArgument convertNonTypeTemplateArgument(ICPPTemplateDefinition template,
private static ICPPTemplateArgument convertNonTypeTemplateArgument(ICPPTemplateDefinition template,
final IType paramType, ICPPTemplateArgument arg, IASTNode point) throws DOMException {
//14.1s8 function to pointer and array to pointer conversions
IType a= arg.getTypeOfNonTypeValue();

View file

@ -39,6 +39,7 @@ public class EvalTypeId extends CPPDependentEvaluation {
public EvalTypeId(IType type, IASTNode pointOfDefinition, ICPPEvaluation... arguments) {
this(type, findEnclosingTemplate(pointOfDefinition), arguments);
}
public EvalTypeId(IType type, IBinding templateDefinition, ICPPEvaluation... arguments) {
super(templateDefinition);
fInputType= type;
@ -83,7 +84,7 @@ public class EvalTypeId extends CPPDependentEvaluation {
return Value.create(this);
if (fArguments == null)
return Value.UNKNOWN;
if (isTypeDependent())
return Value.create(this);
if (fOutputType instanceof ICPPClassType) {
@ -136,7 +137,8 @@ public class EvalTypeId extends CPPDependentEvaluation {
marshalTemplateDefinition(buffer);
}
public static ISerializableEvaluation unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
public static ISerializableEvaluation unmarshal(short firstBytes, ITypeMarshalBuffer buffer)
throws CoreException {
IType type= buffer.unmarshalType();
ICPPEvaluation[] args= null;
if ((firstBytes & ITypeMarshalBuffer.FLAG1) != 0) {
@ -146,7 +148,7 @@ public class EvalTypeId extends CPPDependentEvaluation {
args[i]= (ICPPEvaluation) buffer.unmarshalEvaluation();
}
} else {
args = new ICPPEvaluation[0]; // arguments must not be null
args = ICPPEvaluation.EMPTY_ARRAY; // arguments must not be null
}
IBinding templateDefinition= buffer.unmarshalBinding();
return new EvalTypeId(type, templateDefinition, args);

View file

@ -104,7 +104,7 @@ public class PDOM extends PlatformObject implements IPDOM {
private static final int BLOCKED_WRITE_LOCK_OUTPUT_INTERVAL = 30000;
private static final int LONG_WRITE_LOCK_REPORT_THRESHOLD = 1000;
private static final int LONG_READ_LOCK_WAIT_REPORT_THRESHOLD = 1000;
static boolean sDEBUG_LOCKS= false; // initialized in the PDOMManager, because IBM needs PDOM independent of runtime plugin.
static boolean sDEBUG_LOCKS= false; // Initialized in the PDOMManager, because IBM needs PDOM independent of runtime plugin.
/**
* Identifier for PDOM format
@ -236,9 +236,11 @@ public class PDOM extends PlatformObject implements IPDOM {
* 142.0 - Changed marshalling of evaluations to allow more than 15 evaluation kinds, bug 401479.
* 143.0 - Store implied object type in EvalFunctionSet, bug 402409.
* 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.
* 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. <<CDT 8.2>>
*
* CDT 8.3 development (versions not supported on the 8.2.x branch)
* 148.0 - Store specialized template parameters of class/function template specializations, bug 407497.
*/
private static final int MIN_SUPPORTED_VERSION= version(148, 0);

View file

@ -42,18 +42,17 @@ import org.eclipse.core.runtime.CoreException;
/**
* Specialization of a class template.
*/
class PDOMCPPClassTemplateSpecialization extends PDOMCPPClassSpecialization
class PDOMCPPClassTemplateSpecialization extends PDOMCPPClassSpecialization
implements ICPPClassTemplate, ICPPInstanceCache {
private static final int TEMPLATE_PARAMS = PDOMCPPClassSpecialization.RECORD_SIZE;
@SuppressWarnings("hiding")
protected static final int RECORD_SIZE = TEMPLATE_PARAMS + Database.PTR_SIZE;
private volatile IPDOMCPPTemplateParameter[] fTemplateParameters;
public PDOMCPPClassTemplateSpecialization(PDOMCPPLinkage linkage, PDOMNode parent, ICPPClassTemplate template, PDOMBinding specialized)
throws CoreException {
public PDOMCPPClassTemplateSpecialization(PDOMCPPLinkage linkage, PDOMNode parent,
ICPPClassTemplate template, PDOMBinding specialized) throws CoreException {
super(linkage, parent, template, specialized);
computeTemplateParameters(template); // sets fTemplateParameters
final Database db = getDB();
@ -65,7 +64,7 @@ class PDOMCPPClassTemplateSpecialization extends PDOMCPPClassSpecialization
public PDOMCPPClassTemplateSpecialization(PDOMLinkage linkage, long bindingRecord) {
super(linkage, bindingRecord);
}
@Override
protected int getRecordSize() {
return RECORD_SIZE;
@ -75,7 +74,7 @@ class PDOMCPPClassTemplateSpecialization extends PDOMCPPClassSpecialization
public int getNodeType() {
return IIndexCPPBindingConstants.CPP_CLASS_TEMPLATE_SPECIALIZATION;
}
@Override
public ICPPTemplateParameter[] getTemplateParameters() {
if (fTemplateParameters == null) {
@ -96,19 +95,19 @@ class PDOMCPPClassTemplateSpecialization extends PDOMCPPClassSpecialization
@Override
public ICPPTemplateInstance getInstance(ICPPTemplateArgument[] arguments) {
return PDOMInstanceCache.getCache(this).getInstance(arguments);
return PDOMInstanceCache.getCache(this).getInstance(arguments);
}
@Override
public void addInstance(ICPPTemplateArgument[] arguments, ICPPTemplateInstance instance) {
PDOMInstanceCache.getCache(this).addInstance(arguments, instance);
PDOMInstanceCache.getCache(this).addInstance(arguments, instance);
}
@Override
public ICPPTemplateInstance[] getAllInstances() {
return PDOMInstanceCache.getCache(this).getAllInstances();
return PDOMInstanceCache.getCache(this).getAllInstances();
}
@Override
public boolean isSameType(IType type) {
if( type == this )
@ -125,15 +124,15 @@ class PDOMCPPClassTemplateSpecialization extends PDOMCPPClassSpecialization
}
// require a class template specialization
if (type instanceof ICPPClassSpecialization == false ||
if (type instanceof ICPPClassSpecialization == false ||
type instanceof ICPPTemplateDefinition == false || type instanceof IProblemBinding)
return false;
final ICPPClassSpecialization classSpec2 = (ICPPClassSpecialization) type;
if (getKey() != classSpec2.getKey())
if (getKey() != classSpec2.getKey())
return false;
if (!CharArrayUtils.equals(getNameCharArray(), classSpec2.getNameCharArray()))
return false;
@ -180,7 +179,7 @@ class PDOMCPPClassTemplateSpecialization extends PDOMCPPClassSpecialization
return ((ICPPClassType) owner1).isSameType((ICPPClassType) owner2);
}
@Override
public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() {
IASTNode point= null; // Instantiation of dependent expressions may not work.
@ -193,7 +192,7 @@ class PDOMCPPClassTemplateSpecialization extends PDOMCPPClassSpecialization
}
return spec;
}
@Override
public final ICPPDeferredClassInstance asDeferredInstance() {
PDOMInstanceCache cache= PDOMInstanceCache.getCache(this);
@ -206,11 +205,11 @@ class PDOMCPPClassTemplateSpecialization extends PDOMCPPClassSpecialization
return dci;
}
}
private void computeTemplateParameters(ICPPClassTemplate originalTemplate) {
try {
fTemplateParameters = PDOMTemplateParameterArray.createPDOMTemplateParameters(getLinkage(), this,
originalTemplate.getTemplateParameters());
fTemplateParameters = PDOMTemplateParameterArray.createPDOMTemplateParameters(getLinkage(),
this, originalTemplate.getTemplateParameters());
} catch (DOMException e) {
CCorePlugin.log(e);
fTemplateParameters = IPDOMCPPTemplateParameter.EMPTY_ARRAY;

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* QNX - Initial API and implementation
* QNX - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
@ -27,16 +27,16 @@ class PDOMCPPConstructorTemplateSpecialization extends PDOMCPPMethodTemplateSpec
*/
@SuppressWarnings("hiding")
protected static final int RECORD_SIZE = PDOMCPPFunctionSpecialization.RECORD_SIZE + 0;
public PDOMCPPConstructorTemplateSpecialization(PDOMCPPLinkage linkage, PDOMNode parent, ICPPConstructor constructor, PDOMBinding specialized)
throws CoreException {
public PDOMCPPConstructorTemplateSpecialization(PDOMCPPLinkage linkage, PDOMNode parent,
ICPPConstructor constructor, PDOMBinding specialized) throws CoreException {
super(linkage, parent, constructor, specialized);
}
public PDOMCPPConstructorTemplateSpecialization(PDOMLinkage linkage, long bindingRecord) {
super(linkage, bindingRecord);
}
@Override
protected int getRecordSize() {
return RECORD_SIZE;

View file

@ -29,32 +29,31 @@ import org.eclipse.core.runtime.CoreException;
/**
* @author Bryan Wilkinson
*
*/
class PDOMCPPMethodTemplateSpecialization extends
PDOMCPPFunctionTemplateSpecialization implements ICPPMethod {
class PDOMCPPMethodTemplateSpecialization extends PDOMCPPFunctionTemplateSpecialization
implements ICPPMethod {
private static final int TEMPLATE_PARAMS = PDOMCPPFunctionTemplateSpecialization.RECORD_SIZE;
@SuppressWarnings("hiding")
protected static final int RECORD_SIZE = TEMPLATE_PARAMS + Database.PTR_SIZE;
private volatile IPDOMCPPTemplateParameter[] fTemplateParameters;
public PDOMCPPMethodTemplateSpecialization(PDOMCPPLinkage linkage, PDOMNode parent, ICPPMethod method, PDOMBinding specialized)
throws CoreException {
public PDOMCPPMethodTemplateSpecialization(PDOMCPPLinkage linkage, PDOMNode parent,
ICPPMethod method, PDOMBinding specialized) throws CoreException {
super(linkage, parent, (ICPPFunctionTemplate) method, specialized);
computeTemplateParameters((ICPPFunctionTemplate) method); // sets fTemplateParameters
computeTemplateParameters((ICPPFunctionTemplate) method); // Sets fTemplateParameters
final Database db = getDB();
long rec = PDOMTemplateParameterArray.putArray(db, fTemplateParameters);
db.putRecPtr(record + TEMPLATE_PARAMS, rec);
linkage.new ConfigureTemplateParameters(((ICPPFunctionTemplate) method).getTemplateParameters(), fTemplateParameters);
linkage.new ConfigureTemplateParameters(((ICPPFunctionTemplate) method).getTemplateParameters(),
fTemplateParameters);
}
public PDOMCPPMethodTemplateSpecialization(PDOMLinkage linkage, long bindingRecord) {
super(linkage, bindingRecord);
}
@Override
protected int getRecordSize() {
return RECORD_SIZE;
@ -82,7 +81,7 @@ class PDOMCPPMethodTemplateSpecialization extends
public int getNodeType() {
return IIndexCPPBindingConstants.CPP_METHOD_TEMPLATE_SPECIALIZATION;
}
@Override
public boolean isDestructor() {
IBinding spec = getSpecializedBinding();
@ -100,7 +99,7 @@ class PDOMCPPMethodTemplateSpecialization extends
}
return false;
}
@Override
public boolean isExplicit() {
IBinding spec = getSpecializedBinding();
@ -132,7 +131,7 @@ class PDOMCPPMethodTemplateSpecialization extends
}
return 0;
}
@Override
public boolean isExternC() {
return false;
@ -152,11 +151,11 @@ class PDOMCPPMethodTemplateSpecialization extends
public boolean isFinal() {
return false;
}
private void computeTemplateParameters(ICPPFunctionTemplate originalMethodTemplate) {
try {
fTemplateParameters = PDOMTemplateParameterArray.createPDOMTemplateParameters(getLinkage(), this,
originalMethodTemplate.getTemplateParameters());
fTemplateParameters = PDOMTemplateParameterArray.createPDOMTemplateParameters(getLinkage(),
this, originalMethodTemplate.getTemplateParameters());
} catch (DOMException e) {
CCorePlugin.log(e);
fTemplateParameters = IPDOMCPPTemplateParameter.EMPTY_ARRAY;