mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-04 23:05:47 +02:00
Patch for Bryan - 182719 - Prevents a potential stack overflow error with virtual base classes.
This commit is contained in:
parent
a59c16a63a
commit
fce61429ce
1 changed files with 27 additions and 23 deletions
|
@ -1294,33 +1294,37 @@ public class CPPSemantics {
|
|||
return result;
|
||||
}
|
||||
|
||||
public static void visitVirtualBaseClasses( LookupData data, ICPPClassType cls ){
|
||||
ICPPBase [] bases = null;
|
||||
try {
|
||||
bases = cls.getBases();
|
||||
} catch ( DOMException e ) {
|
||||
return;
|
||||
}
|
||||
public static void visitVirtualBaseClasses( LookupData data, ICPPClassType cls ) throws DOMException {
|
||||
if( data.inheritanceChain == null )
|
||||
data.inheritanceChain = new ObjectSet( 2 );
|
||||
|
||||
IScope scope = cls.getCompositeScope();
|
||||
if (scope != null)
|
||||
data.inheritanceChain.put( scope );
|
||||
|
||||
ICPPBase [] bases = cls.getBases();
|
||||
|
||||
for( int i = 0; i < bases.length; i++ ){
|
||||
try {
|
||||
if( bases[i].isVirtual() ){
|
||||
if( data.visited == ObjectSet.EMPTY_SET )
|
||||
data.visited = new ObjectSet(2);
|
||||
IBinding b = bases[i].getBaseClass();
|
||||
if( b instanceof ICPPClassType ) {
|
||||
IScope bScope = ((ICPPClassType)b).getCompositeScope();
|
||||
if (bScope != null)
|
||||
data.visited.put(bScope);
|
||||
}
|
||||
} else {
|
||||
IBinding b = bases[i].getBaseClass();
|
||||
if( b instanceof ICPPClassType )
|
||||
visitVirtualBaseClasses( data, (ICPPClassType) b );
|
||||
}
|
||||
} catch ( DOMException e1 ) {
|
||||
IBinding b = bases[i].getBaseClass();
|
||||
if (b instanceof ICPPClassType) {
|
||||
IScope bScope = ((ICPPClassType)b).getCompositeScope();
|
||||
if( bases[i].isVirtual() ){
|
||||
if( data.visited == ObjectSet.EMPTY_SET )
|
||||
data.visited = new ObjectSet(2);
|
||||
if (bScope != null)
|
||||
data.visited.put(bScope);
|
||||
} else if ( !data.inheritanceChain.containsKey(bScope) ) {
|
||||
visitVirtualBaseClasses( data, (ICPPClassType) b );
|
||||
} else {
|
||||
data.problem = new ProblemBinding( null, IProblemBinding.SEMANTIC_CIRCULAR_INHERITANCE, cls.getNameCharArray() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (scope != null)
|
||||
data.inheritanceChain.remove( scope );
|
||||
}
|
||||
|
||||
private static boolean checkForAmbiguity( LookupData data, Object n, Object names ) throws DOMException{
|
||||
if( names instanceof Object[] ) {
|
||||
names = ArrayUtil.trim( Object.class, (Object[]) names );
|
||||
|
|
Loading…
Add table
Reference in a new issue