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 7433239e515..6faf3af4167 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 @@ -2626,25 +2626,6 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa checkBindings(); } - // // Empty header file - - // typedef unsigned long size_t; - // - // template struct int_pack { typedef int_pack type; }; - // - // template struct append; - // - // template - // struct append, I> : int_pack {}; - // - // template - // struct make_int_pack : append::type, C - 1> {}; - // - // template <> struct make_int_pack<0> : int_pack<> {}; - public void testRecursiveInheritance_466362() throws Exception { - checkBindings(); - } - // template // struct Bar {}; // diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPFunctionInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPFunctionInstance.java index 06506eacb5c..fd214832252 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPFunctionInstance.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPFunctionInstance.java @@ -11,7 +11,7 @@ package org.eclipse.cdt.core.dom.ast.cpp; /** - * This interface represents an instantiation or an explicit specialization of a function template. + * 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. diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateInstance.java index eba7477da1f..654a57f3478 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateInstance.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPTemplateInstance.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2015 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 @@ -14,17 +14,20 @@ package org.eclipse.cdt.core.dom.ast.cpp; import org.eclipse.cdt.core.dom.ast.IType; /** - * This interface represents an instantiation or an explicit specialization of a class or a function template. - * The {@link #isExplicitSpecialization()} method is used to distinguish between the two cases. + * This interface represents an instantiation of a class or function template. + * An instantiated template is a specialization of that template. * - * An instance of a class template will also implement ICPPClassType and similarly a function template - * instance will also implement ICPPFunction (or even ICPPMethod or ICPPConstructor as appropriate). + * An instance of a class template will also implement ICPPClassType and similarly + * a function template instance will also implement ICPPFunction (or even ICPPMethod + * or ICPPConstructor as appropriate) * * @noimplement This interface is not intended to be implemented by clients. * @noextend This interface is not intended to be extended by clients. */ public interface ICPPTemplateInstance extends ICPPSpecialization { - /** @since 5.1 */ + /** + * @since 5.1 + */ ICPPTemplateInstance[] EMPTY_TEMPLATE_INSTANCE_ARRAY = {}; /** diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstance.java index e69df84b1dd..35538ad31a2 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstance.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstance.java @@ -28,7 +28,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates; /** - * The result of instantiating a class template or an explicit specialization of a class template. + * The result of instantiating a class template. */ public class CPPClassInstance extends CPPClassSpecialization implements ICPPTemplateInstance { private final ICPPTemplateArgument[] arguments; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionInstance.java index 41ad1ddf980..da4855390f5 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionInstance.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionInstance.java @@ -25,7 +25,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates; /** - * An instantiation or an explicit specialization of a function template. + * The instantiation of a function template. */ public class CPPFunctionInstance extends CPPFunctionSpecialization implements ICPPFunctionInstance { private final ICPPTemplateArgument[] fArguments; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassInstance.java index 0b7636ba93c..1e2f71a1266 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassInstance.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassInstance.java @@ -19,9 +19,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap; import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory; -/** - * The result of instantiating a class template or an explicit specialization of a class template. - */ public class CompositeCPPClassInstance extends CompositeCPPClassSpecialization implements ICPPTemplateInstance { public CompositeCPPClassInstance(ICompositesFactory cf, ICPPClassType rbinding) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPFunctionInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPFunctionInstance.java index 898deb69113..9cdf57d0571 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPFunctionInstance.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPFunctionInstance.java @@ -23,9 +23,6 @@ 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; -/** - * An instantiation or an explicit specialization of a function template. - */ public class CompositeCPPFunctionInstance extends CompositeCPPFunction implements ICPPFunctionInstance { public CompositeCPPFunctionInstance(ICompositesFactory cf, 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 31e60c12767..1f23c6022f9 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 @@ -257,15 +257,14 @@ public class PDOM extends PlatformObject implements IPDOM { * CDT 8.6 development (versions not supported on the 8.5.x branch) * 180.0 - Internal types of enumerators, bug 446711. * 180.1 - Storing types of unknown members, bug 447728. - * 180.2 - Do not apply significant macros to source files, bug 450888. <> + * 180.2 - Do not apply significant macros to source files, bug 450888. * * CDT 8.7 development (versions not supported on the 8.6.x branch) * 181.0 - C function type with varargs, bug 452416. - * 182.0 - A flag added to PDOMCPPClassSpecialization, bug 466362. */ - private static final int MIN_SUPPORTED_VERSION= version(182, 0); - private static final int MAX_SUPPORTED_VERSION= version(182, Short.MAX_VALUE); - private static final int DEFAULT_VERSION = version(182, 0); + private static final int MIN_SUPPORTED_VERSION= version(181, 0); + private static final int MAX_SUPPORTED_VERSION= version(181, Short.MAX_VALUE); + private static final int DEFAULT_VERSION = version(181, 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/dom/cpp/PDOMCPPClassInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassInstance.java index 0c341179ad0..82565470ca2 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassInstance.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassInstance.java @@ -29,7 +29,7 @@ import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode; import org.eclipse.core.runtime.CoreException; /** - * The result of instantiating a class template or an explicit specialization of a class template. + * Result of instantiating a class template. */ class PDOMCPPClassInstance extends PDOMCPPClassSpecialization implements ICPPTemplateInstance { private static final int ARGUMENTS = PDOMCPPClassSpecialization.RECORD_SIZE + 0; @@ -101,6 +101,12 @@ class PDOMCPPClassInstance extends PDOMCPPClassSpecialization implements ICPPTem } } + @Override + protected boolean hasOwnScope() throws CoreException { + // An instance with a declaration does not use the original template. + return hasDeclaration(); + } + @Override public boolean isExplicitSpecialization() { return !(getCompositeScope() instanceof ICPPClassSpecializationScope); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassSpecialization.java index 7b22be2eb19..0e3b70491c4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassSpecialization.java @@ -36,13 +36,11 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor; import org.eclipse.cdt.core.dom.ast.cpp.ICPPField; import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance; import org.eclipse.cdt.core.parser.util.ObjectMap; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassSpecialization; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassSpecialization.RecursionResolvingBinding; import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPClassSpecializationScope; -import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates; import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants; import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner; @@ -59,16 +57,13 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements ICPPClassSpecialization, IPDOMMemberOwner, IPDOMCPPClassType { private static final int FIRST_BASE = PDOMCPPSpecialization.RECORD_SIZE + 0; private static final int MEMBERLIST = FIRST_BASE + 4; - private static final int FLAGS = MEMBERLIST + PDOMCPPMemberBlock.RECORD_SIZE; // byte + private static final int FINAL = MEMBERLIST + PDOMCPPMemberBlock.RECORD_SIZE; // byte /** * The size in bytes of a PDOMCPPClassSpecialization record in the database. */ @SuppressWarnings("hiding") - protected static final int RECORD_SIZE = FLAGS + 1; - - private static final byte FLAGS_FINAL = 0x01; - private static final byte FLAGS_HAS_OWN_SCOPE = 0x02; + protected static final int RECORD_SIZE = FINAL + 1; private volatile ICPPClassScope fScope; private ObjectMap specializationMap; // Obtained from the synchronized PDOM cache. @@ -82,7 +77,7 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization public PDOMCPPClassSpecialization(PDOMCPPLinkage linkage, PDOMNode parent, ICPPClassType classType, PDOMBinding specialized) throws CoreException { super(linkage, parent, (ICPPSpecialization) classType, specialized); - setFlags(classType); + setFinal(classType); } public PDOMCPPClassSpecialization(PDOMLinkage linkage, long bindingRecord) { @@ -92,8 +87,8 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization @Override public void update(PDOMLinkage linkage, IBinding newBinding) throws CoreException { if (newBinding instanceof ICPPClassType) { - ICPPClassType classType= (ICPPClassType) newBinding; - setFlags(classType); + ICPPClassType ct= (ICPPClassType) newBinding; + setFinal(ct); super.update(linkage, newBinding); } } @@ -184,6 +179,10 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization return fScope; } + protected boolean hasOwnScope() throws CoreException { + return hasDefinition(); + } + public PDOMCPPBase getFirstBase() throws CoreException { long rec = getDB().getRecPtr(record + FIRST_BASE); return rec != 0 ? new PDOMCPPBase(getLinkage(), rec) : null; @@ -472,43 +471,15 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization @Override public boolean isFinal() { try { - return (getFlags() & FLAGS_FINAL) != 0; - } catch (CoreException e) { + return getDB().getByte(record + FINAL) != 0; + } catch (CoreException e){ CCorePlugin.log(e); return false; } } - private boolean hasOwnScope() throws CoreException { - try { - return (getFlags() & FLAGS_HAS_OWN_SCOPE) != 0; - } catch (CoreException e) { - CCorePlugin.log(e); - return false; - } - } - - private byte getFlags() throws CoreException { - return getDB().getByte(record + FLAGS); - } - - private void setFlags(ICPPClassType classType) throws CoreException { - byte flags = (byte) ((classType.isFinal() ? FLAGS_FINAL : 0) | (hasOwnScope(classType) ? FLAGS_HAS_OWN_SCOPE : 0)); - getDB().putByte(record + FLAGS, flags); - } - - /** - * Returns true if the given class is an explicit template specialization that has its own definition. - */ - private static boolean hasOwnScope(ICPPClassType classType) { - if (!(classType instanceof ICPPInternalBinding)) - return false; - - ICPPInternalBinding binding = (ICPPInternalBinding) classType; - if (binding.getDefinition() != null) - return true; - // An instance with a declaration does not use the original template. - return binding instanceof ICPPTemplateInstance && binding.getDeclarations() != null; + private void setFinal(ICPPClassType ct) throws CoreException { + getDB().putByte(record + FINAL, (byte) (ct.isFinal() ? 1 : 0)); } @Override diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunctionInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunctionInstance.java index 7df19bdb4c1..800298190f1 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunctionInstance.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunctionInstance.java @@ -29,7 +29,7 @@ import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode; import org.eclipse.core.runtime.CoreException; /** - * An instantiation or an explicit specialization of a function template. + * Result of instantiating a function template. */ class PDOMCPPFunctionInstance extends PDOMCPPFunctionSpecialization implements ICPPFunctionInstance { private static final int ARGUMENTS = PDOMCPPFunctionSpecialization.RECORD_SIZE + 0;