mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-09 10:46:02 +02:00
Bug 257818.
This commit is contained in:
parent
2bfba6efb0
commit
a8a55aa932
2 changed files with 18 additions and 13 deletions
|
@ -722,7 +722,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
// void test(B<int>::value_type x) {
|
// void test(B<int>::value_type x) {
|
||||||
// f(x); // problem on f
|
// f(x); // problem on f
|
||||||
// }
|
// }
|
||||||
public void _test257818_1() throws Exception {
|
public void test257818_1() throws Exception {
|
||||||
waitForIndexer();
|
waitForIndexer();
|
||||||
|
|
||||||
String[] testData = getContentsForTest(4);
|
String[] testData = getContentsForTest(4);
|
||||||
|
@ -763,7 +763,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
// void test(B<C> x, C y) {
|
// void test(B<C> x, C y) {
|
||||||
// x.m(&y);
|
// x.m(&y);
|
||||||
// }
|
// }
|
||||||
public void _test257818_2() throws Exception {
|
public void test257818_2() throws Exception {
|
||||||
waitForIndexer();
|
waitForIndexer();
|
||||||
|
|
||||||
String[] testData = getContentsForTest(4);
|
String[] testData = getContentsForTest(4);
|
||||||
|
|
|
@ -32,16 +32,14 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
/**
|
/**
|
||||||
* @author Doug Schaefer
|
* @author Doug Schaefer
|
||||||
*/
|
*/
|
||||||
class PDOMCPPTypedef extends PDOMCPPBinding
|
class PDOMCPPTypedef extends PDOMCPPBinding implements ITypedef, ITypeContainer, IIndexType {
|
||||||
implements ITypedef, ITypeContainer, IIndexType {
|
|
||||||
|
|
||||||
private static final int TYPE = PDOMBinding.RECORD_SIZE + 0;
|
private static final int TYPE = PDOMBinding.RECORD_SIZE + 0;
|
||||||
|
|
||||||
@SuppressWarnings("hiding")
|
@SuppressWarnings("hiding")
|
||||||
protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 4;
|
protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 4;
|
||||||
|
|
||||||
public PDOMCPPTypedef(PDOM pdom, PDOMNode parent, ITypedef typedef)
|
public PDOMCPPTypedef(PDOM pdom, PDOMNode parent, ITypedef typedef) throws CoreException {
|
||||||
throws CoreException {
|
|
||||||
super(pdom, parent, typedef.getNameCharArray());
|
super(pdom, parent, typedef.getNameCharArray());
|
||||||
try {
|
try {
|
||||||
setType(parent.getLinkageImpl(), typedef.getType());
|
setType(parent.getLinkageImpl(), typedef.getType());
|
||||||
|
@ -73,31 +71,39 @@ class PDOMCPPTypedef extends PDOMCPPBinding
|
||||||
|
|
||||||
private void setType(final PDOMLinkage linkage, IType newType) throws CoreException, DOMException {
|
private void setType(final PDOMLinkage linkage, IType newType) throws CoreException, DOMException {
|
||||||
PDOMNode typeNode = linkage.addType(this, newType);
|
PDOMNode typeNode = linkage.addType(this, newType);
|
||||||
if (introducesRecursion((IType) typeNode, getNameCharArray())) {
|
if (introducesRecursion((IType) typeNode, getParentNodeRec(), getNameCharArray())) {
|
||||||
linkage.deleteType((IType) typeNode, record);
|
linkage.deleteType((IType) typeNode, record);
|
||||||
typeNode= null;
|
typeNode= null;
|
||||||
}
|
}
|
||||||
pdom.getDB().putInt(record + TYPE, typeNode != null ? typeNode.getRecord() : 0);
|
pdom.getDB().putInt(record + TYPE, typeNode != null ? typeNode.getRecord() : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean introducesRecursion(IType type, char[] tdname) throws DOMException {
|
private boolean introducesRecursion(IType type, int parentRec, char[] tdname) throws DOMException {
|
||||||
int maxDepth= 50;
|
int maxDepth= 50;
|
||||||
while (--maxDepth > 0) {
|
while (--maxDepth > 0) {
|
||||||
if (type instanceof ITypedef && CharArrayUtils.equals(((ITypedef) type).getNameCharArray(), tdname)) {
|
if (type instanceof ITypedef) {
|
||||||
return true;
|
try {
|
||||||
|
if ((!(type instanceof PDOMNode) || // this should not be the case anyhow
|
||||||
|
((PDOMNode) type).getParentNodeRec() == parentRec) &&
|
||||||
|
CharArrayUtils.equals(((ITypedef) type).getNameCharArray(), tdname)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} catch (CoreException e) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (type instanceof ITypeContainer) {
|
if (type instanceof ITypeContainer) {
|
||||||
type= ((ITypeContainer) type).getType();
|
type= ((ITypeContainer) type).getType();
|
||||||
}
|
}
|
||||||
else if (type instanceof IFunctionType) {
|
else if (type instanceof IFunctionType) {
|
||||||
IFunctionType ft= (IFunctionType) type;
|
IFunctionType ft= (IFunctionType) type;
|
||||||
if (introducesRecursion(ft.getReturnType(), tdname)) {
|
if (introducesRecursion(ft.getReturnType(), parentRec, tdname)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
IType[] params= ft.getParameterTypes();
|
IType[] params= ft.getParameterTypes();
|
||||||
for (int i = 0; i < params.length; i++) {
|
for (int i = 0; i < params.length; i++) {
|
||||||
IType param = params[i];
|
IType param = params[i];
|
||||||
if (introducesRecursion(param, tdname)) {
|
if (introducesRecursion(param, parentRec, tdname)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -110,7 +116,6 @@ class PDOMCPPTypedef extends PDOMCPPBinding
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getRecordSize() {
|
protected int getRecordSize() {
|
||||||
return RECORD_SIZE;
|
return RECORD_SIZE;
|
||||||
|
|
Loading…
Add table
Reference in a new issue