mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-30 04:15:35 +02:00
Class instance as base class, bug 258745.
This commit is contained in:
parent
48ad5e5042
commit
0ce1436bdc
3 changed files with 45 additions and 23 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
|
* Copyright (c) 2006, 2009 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -41,6 +41,7 @@ import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||||
|
@ -1622,4 +1623,32 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
fIndex.releaseReadLock();
|
fIndex.releaseReadLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// namespace ns {
|
||||||
|
// template<typename T> class X {};
|
||||||
|
// }
|
||||||
|
// class Y : public ns::X<int> {
|
||||||
|
// };
|
||||||
|
public void testInstanceInheritance_258745() throws Exception {
|
||||||
|
String code= getContentsForTest(1)[0];
|
||||||
|
final IIndexManager indexManager = CCorePlugin.getIndexManager();
|
||||||
|
IFile file= TestSourceReader.createFile(fCProject.getProject(), "test.cpp", code);
|
||||||
|
waitUntilFileIsIndexed(file, 4000);
|
||||||
|
fIndex.acquireReadLock();
|
||||||
|
try {
|
||||||
|
IIndexBinding[] bindings = fIndex.findBindings("Y".toCharArray(), false, IndexFilter.ALL_DECLARED, NPM);
|
||||||
|
assertEquals(1, bindings.length);
|
||||||
|
ICPPClassType ct= (ICPPClassType) bindings[0];
|
||||||
|
final ICPPBase[] bases = ct.getBases();
|
||||||
|
assertEquals(1, bases.length);
|
||||||
|
IBinding inst = bases[0].getBaseClass();
|
||||||
|
assertTrue(inst instanceof ICPPTemplateInstance);
|
||||||
|
|
||||||
|
IIndexName name= (IIndexName) bases[0].getBaseClassSpecifierName();
|
||||||
|
IBinding inst2= fIndex.findBinding(name);
|
||||||
|
assertEquals(inst, inst2);
|
||||||
|
} finally {
|
||||||
|
fIndex.releaseReadLock();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
|
* Copyright (c) 2007, 2009 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -36,6 +36,7 @@ import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDirective;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDirective;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
|
||||||
|
@ -388,14 +389,17 @@ abstract public class PDOMWriter {
|
||||||
|
|
||||||
protected final boolean isRequiredReference(IASTName name) {
|
protected final boolean isRequiredReference(IASTName name) {
|
||||||
IASTNode parentNode= name.getParent();
|
IASTNode parentNode= name.getParent();
|
||||||
|
if (parentNode instanceof ICPPASTQualifiedName) {
|
||||||
|
if (name != ((ICPPASTQualifiedName) parentNode).getLastName())
|
||||||
|
return false;
|
||||||
|
parentNode= parentNode.getParent();
|
||||||
|
}
|
||||||
if (parentNode instanceof ICPPASTBaseSpecifier) {
|
if (parentNode instanceof ICPPASTBaseSpecifier) {
|
||||||
return true;
|
return true;
|
||||||
}
|
} else if (parentNode instanceof IASTDeclSpecifier) {
|
||||||
else if (parentNode instanceof IASTDeclSpecifier) {
|
|
||||||
IASTDeclSpecifier ds= (IASTDeclSpecifier) parentNode;
|
IASTDeclSpecifier ds= (IASTDeclSpecifier) parentNode;
|
||||||
return ds.getStorageClass() == IASTDeclSpecifier.sc_typedef;
|
return ds.getStorageClass() == IASTDeclSpecifier.sc_typedef;
|
||||||
}
|
} else if (parentNode instanceof ICPPASTUsingDirective) {
|
||||||
else if (parentNode instanceof ICPPASTUsingDirective) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2008 QNX Software Systems and others.
|
* Copyright (c) 2005, 2009 QNX Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -36,7 +36,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDirective;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDirective;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
|
||||||
|
@ -830,16 +829,9 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
||||||
super.onCreateName(file, name, pdomName);
|
super.onCreateName(file, name, pdomName);
|
||||||
|
|
||||||
IASTNode parentNode= name.getParent();
|
IASTNode parentNode= name.getParent();
|
||||||
IASTNode nameNode = name;
|
|
||||||
if (name.getPropertyInParent() == ICPPASTTemplateId.TEMPLATE_NAME &&
|
|
||||||
parentNode.getParent() instanceof ICPPASTQualifiedName) {
|
|
||||||
nameNode = parentNode;
|
|
||||||
parentNode = parentNode.getParent();
|
|
||||||
}
|
|
||||||
if (parentNode instanceof ICPPASTQualifiedName) {
|
if (parentNode instanceof ICPPASTQualifiedName) {
|
||||||
if (nameNode != ((ICPPASTQualifiedName) parentNode).getLastName()) {
|
if (name != ((ICPPASTQualifiedName) parentNode).getLastName())
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
parentNode = parentNode.getParent();
|
parentNode = parentNode.getParent();
|
||||||
}
|
}
|
||||||
if (parentNode instanceof ICPPASTBaseSpecifier) {
|
if (parentNode instanceof ICPPASTBaseSpecifier) {
|
||||||
|
@ -861,8 +853,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
||||||
pdomName.setIsBaseSpecifier(true);
|
pdomName.setIsBaseSpecifier(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if (parentNode instanceof ICPPASTUsingDirective) {
|
||||||
else if (parentNode instanceof ICPPASTUsingDirective) {
|
|
||||||
IScope container= CPPVisitor.getContainingScope(name);
|
IScope container= CPPVisitor.getContainingScope(name);
|
||||||
try {
|
try {
|
||||||
boolean doit= false;
|
boolean doit= false;
|
||||||
|
@ -892,8 +883,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
||||||
} catch (DOMException e) {
|
} catch (DOMException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
}
|
}
|
||||||
}
|
} else if (parentNode instanceof ICPPASTElaboratedTypeSpecifier) {
|
||||||
else if (parentNode instanceof ICPPASTElaboratedTypeSpecifier) {
|
|
||||||
ICPPASTElaboratedTypeSpecifier elaboratedSpecifier = (ICPPASTElaboratedTypeSpecifier)parentNode;
|
ICPPASTElaboratedTypeSpecifier elaboratedSpecifier = (ICPPASTElaboratedTypeSpecifier)parentNode;
|
||||||
if (elaboratedSpecifier.isFriend()) {
|
if (elaboratedSpecifier.isFriend()) {
|
||||||
pdomName.setIsFriendSpecifier(true);
|
pdomName.setIsFriendSpecifier(true);
|
||||||
|
@ -903,8 +893,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
||||||
((PDOMCPPClassType)enclClassBinding).addFriend(new PDOMCPPFriend(pdom, pdomName));
|
((PDOMCPPClassType)enclClassBinding).addFriend(new PDOMCPPFriend(pdom, pdomName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if (parentNode instanceof ICPPASTFunctionDeclarator) {
|
||||||
else if (parentNode instanceof ICPPASTFunctionDeclarator) {
|
|
||||||
if (parentNode.getParent() instanceof IASTSimpleDeclaration) {
|
if (parentNode.getParent() instanceof IASTSimpleDeclaration) {
|
||||||
IASTSimpleDeclaration grandparentNode = (IASTSimpleDeclaration) parentNode.getParent();
|
IASTSimpleDeclaration grandparentNode = (IASTSimpleDeclaration) parentNode.getParent();
|
||||||
if (grandparentNode.getDeclSpecifier() instanceof ICPPASTDeclSpecifier) {
|
if (grandparentNode.getDeclSpecifier() instanceof ICPPASTDeclSpecifier) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue