mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 17:05:26 +02:00
Revert "Bug 466362 - StackOverflowError involving self-referencing template definition"
This reverts commit 74292d661b
.
This commit is contained in:
parent
74292d661b
commit
5067760a91
11 changed files with 37 additions and 83 deletions
|
@ -2626,25 +2626,6 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
checkBindings();
|
||||
}
|
||||
|
||||
// // Empty header file
|
||||
|
||||
// typedef unsigned long size_t;
|
||||
//
|
||||
// template <size_t... Is> struct int_pack { typedef int_pack type; };
|
||||
//
|
||||
// template <class Pack, size_t I> struct append;
|
||||
//
|
||||
// template <size_t... Is, size_t I>
|
||||
// struct append<int_pack<Is...>, I> : int_pack<Is..., I> {};
|
||||
//
|
||||
// template <size_t C>
|
||||
// struct make_int_pack : append<typename make_int_pack<C - 1>::type, C - 1> {};
|
||||
//
|
||||
// template <> struct make_int_pack<0> : int_pack<> {};
|
||||
public void testRecursiveInheritance_466362() throws Exception {
|
||||
checkBindings();
|
||||
}
|
||||
|
||||
// template <typename T>
|
||||
// struct Bar {};
|
||||
//
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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 = {};
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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. <<CDT 8.6>>
|
||||
* 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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue