mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-18 14:35:23 +02:00
Bug 511726 - Handle unresolved field owner type in CPPASTFieldReference.getFieldPosition()
Change-Id: I0ded6f44f8aad69d54c361432afcb423ed6601b2
This commit is contained in:
parent
e6b9bee424
commit
63ed21e194
2 changed files with 9 additions and 0 deletions
|
@ -205,6 +205,9 @@ public final class CompositeValue implements IValue {
|
||||||
IValue compValue = CompositeValue.create(baseClassType);
|
IValue compValue = CompositeValue.create(baseClassType);
|
||||||
for (ICPPField baseField : baseFields) {
|
for (ICPPField baseField : baseFields) {
|
||||||
int fieldPos = CPPASTFieldReference.getFieldPosition(baseField);
|
int fieldPos = CPPASTFieldReference.getFieldPosition(baseField);
|
||||||
|
if (fieldPos == -1) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
record.update(baseField, compValue.getSubValue(fieldPos));
|
record.update(baseField, compValue.getSubValue(fieldPos));
|
||||||
// TODO(nathanridge): This won't work with multiple inheritance, since 'fieldPos'
|
// TODO(nathanridge): This won't work with multiple inheritance, since 'fieldPos'
|
||||||
// is a field position in the base class' hierarchy, while values[] expects
|
// is a field position in the base class' hierarchy, while values[] expects
|
||||||
|
@ -220,6 +223,9 @@ public final class CompositeValue implements IValue {
|
||||||
continue;
|
continue;
|
||||||
final ICPPEvaluation value = EvalUtil.getVariableValue(field, record);
|
final ICPPEvaluation value = EvalUtil.getVariableValue(field, record);
|
||||||
int fieldPos = CPPASTFieldReference.getFieldPosition(field);
|
int fieldPos = CPPASTFieldReference.getFieldPosition(field);
|
||||||
|
if (fieldPos == -1) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
record.update(field, value);
|
record.update(field, value);
|
||||||
values[fieldPos] = value;
|
values[fieldPos] = value;
|
||||||
}
|
}
|
||||||
|
|
|
@ -322,6 +322,9 @@ public class CPPASTFieldReference extends ASTNode
|
||||||
|
|
||||||
public static int getFieldPosition(ICPPField field) {
|
public static int getFieldPosition(ICPPField field) {
|
||||||
final ICPPClassType ownerType = field.getClassOwner();
|
final ICPPClassType ownerType = field.getClassOwner();
|
||||||
|
if (ownerType == null) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
final ICPPClassType[] baseClasses = ClassTypeHelper.getAllBases(ownerType, null);
|
final ICPPClassType[] baseClasses = ClassTypeHelper.getAllBases(ownerType, null);
|
||||||
int baseFields = 0;
|
int baseFields = 0;
|
||||||
for (ICPPClassType baseClass : baseClasses) {
|
for (ICPPClassType baseClass : baseClasses) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue