1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-13 19:25:38 +02:00

Follow-up for 169860, fix regression in type hierarchy, inheritance via typedefs

This commit is contained in:
Markus Schorn 2007-01-29 11:51:44 +00:00
parent 5af2db4d4c
commit f405ef7559
7 changed files with 32 additions and 8 deletions

View file

@ -10,6 +10,7 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp; package org.eclipse.cdt.core.dom.ast.cpp;
import org.eclipse.cdt.core.dom.IName;
import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
@ -31,6 +32,12 @@ public interface ICPPBase {
*/ */
public IBinding getBaseClass() throws DOMException; public IBinding getBaseClass() throws DOMException;
/**
* Returns the name that specifies the base class.
* @since 4.0
*/
public IName getBaseClassSpecifierName();
/** /**
* The visibility qualifier applied to the base class. * The visibility qualifier applied to the base class.
* *

View file

@ -14,8 +14,9 @@
*/ */
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.IName;
import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
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;
@ -32,7 +33,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
public class CPPBaseClause implements ICPPBase { public class CPPBaseClause implements ICPPBase {
static public class CPPBaseProblem extends ProblemBinding implements ICPPBase { static public class CPPBaseProblem extends ProblemBinding implements ICPPBase {
private ICPPClassType classProblem = null; private ICPPClassType classProblem = null;
public CPPBaseProblem( IASTNode node, int id, char[] arg ) { public CPPBaseProblem( IASTName node, int id, char[] arg ) {
super( node, id, arg ); super( node, id, arg );
} }
public IBinding getBaseClass() { public IBinding getBaseClass() {
@ -49,6 +50,9 @@ public class CPPBaseClause implements ICPPBase {
public boolean isVirtual() throws DOMException { public boolean isVirtual() throws DOMException {
throw new DOMException( this ); throw new DOMException( this );
} }
public IName getBaseClassSpecifierName() {
return (IName) node;
}
} }
private ICPPASTBaseSpecifier base = null; private ICPPASTBaseSpecifier base = null;
private IBinding baseClass = null; private IBinding baseClass = null;
@ -57,6 +61,7 @@ public class CPPBaseClause implements ICPPBase {
this.base = base; this.base = base;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBase#getBaseClass() * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBase#getBaseClass()
*/ */
@ -106,4 +111,8 @@ public class CPPBaseClause implements ICPPBase {
baseClass = cls; baseClass = cls;
} }
public IName getBaseClassSpecifierName() {
return base.getName();
}
} }

View file

@ -195,7 +195,7 @@ public class CPPClassTemplate extends CPPTemplateDefinition implements
if( definition == null ){ if( definition == null ){
checkForDefinition(); checkForDefinition();
if( definition == null ){ if( definition == null ){
IASTNode node = (declarations != null && declarations.length > 0) ? declarations[0] : null; IASTName node = (declarations != null && declarations.length > 0) ? declarations[0] : null;
return new ICPPBase [] { new CPPBaseClause.CPPBaseProblem( node, IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, getNameCharArray() ) }; return new ICPPBase [] { new CPPBaseClause.CPPBaseProblem( node, IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, getNameCharArray() ) };
} }
} }

View file

@ -452,7 +452,7 @@ public class CPPClassType extends PlatformObject implements ICPPClassType, ICPPI
if( definition == null ){ if( definition == null ){
checkForDefinition(); checkForDefinition();
if( definition == null ){ if( definition == null ){
IASTNode node = (declarations != null && declarations.length > 0) ? declarations[0] : null; IASTName node = (declarations != null && declarations.length > 0) ? declarations[0] : null;
return new ICPPBase [] { new CPPBaseClause.CPPBaseProblem( node, IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, getNameCharArray() ) }; return new ICPPBase [] { new CPPBaseClause.CPPBaseProblem( node, IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, getNameCharArray() ) };
} }
} }

View file

@ -12,6 +12,7 @@
package org.eclipse.cdt.internal.core.pdom.dom.cpp; package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IName;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
import org.eclipse.cdt.internal.core.pdom.PDOM; import org.eclipse.cdt.internal.core.pdom.PDOM;
@ -69,7 +70,7 @@ class PDOMCPPBase implements ICPPBase {
return pdom.getDB().getByte(record + FLAGS); return pdom.getDB().getByte(record + FLAGS);
} }
public PDOMName getBaseClassSpecifierImpl() { public PDOMName getBaseClassSpecifierNameImpl() {
try { try {
int rec = pdom.getDB().getInt(record + BASECLASS_SPECIFIER); int rec = pdom.getDB().getInt(record + BASECLASS_SPECIFIER);
if (rec != 0) { if (rec != 0) {
@ -81,9 +82,13 @@ class PDOMCPPBase implements ICPPBase {
return null; return null;
} }
public IName getBaseClassSpecifierName() {
return getBaseClassSpecifierNameImpl();
}
public IBinding getBaseClass() { public IBinding getBaseClass() {
try { try {
PDOMName name= getBaseClassSpecifierImpl(); PDOMName name= getBaseClassSpecifierNameImpl();
if (name != null) { if (name != null) {
PDOMBinding b = name.getPDOMBinding(); PDOMBinding b = name.getPDOMBinding();
while( b instanceof PDOMCPPTypedef && ((PDOMCPPTypedef)b).getType() instanceof PDOMBinding ){ while( b instanceof PDOMCPPTypedef && ((PDOMCPPTypedef)b).getType() instanceof PDOMBinding ){

View file

@ -474,7 +474,8 @@ ICPPClassScope, IPDOMMemberOwner, IIndexType {
PDOMCPPBase predecessor= null; PDOMCPPBase predecessor= null;
int nameRec= pdomName.getRecord(); int nameRec= pdomName.getRecord();
while (base != null) { while (base != null) {
if (base.getBaseClassSpecifierImpl().getRecord() == nameRec) { PDOMName name = base.getBaseClassSpecifierNameImpl();
if (name != null && name.getRecord() == nameRec) {
break; break;
} }
predecessor= base; predecessor= base;

View file

@ -21,6 +21,7 @@ import java.util.List;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.cdt.core.dom.IName;
import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.ICompositeType; import org.eclipse.cdt.core.dom.ast.ICompositeType;
@ -164,7 +165,8 @@ class THGraph {
return; return;
} }
ICPPBase base= bases[i]; ICPPBase base= bases[i];
IBinding basecl= base.getBaseClass(); IName name= base.getBaseClassSpecifierName();
IBinding basecl= name != null ? index.findBinding(name) : base.getBaseClass();
ICElementHandle[] baseElems= IndexUI.findRepresentative(index, basecl); ICElementHandle[] baseElems= IndexUI.findRepresentative(index, basecl);
if (baseElems.length > 0) { if (baseElems.length > 0) {
ICElementHandle baseElem= baseElems[0]; ICElementHandle baseElem= baseElems[0];