mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-08 02:53:12 +02:00
Fixed a potential NPE.
Change-Id: I274242b74a27f17eeb3a6d7841b1107be22cd096
This commit is contained in:
parent
61ac21daa0
commit
17a5ba8361
2 changed files with 6 additions and 6 deletions
|
@ -186,7 +186,7 @@ public final class CStringValue implements IValue {
|
|||
IValue val = IntegralValue.create(c);
|
||||
return new EvalFixed(CPPBasicType.CHAR, ValueCategory.PRVALUE, val);
|
||||
}
|
||||
return null;
|
||||
return EvalFixed.INCOMPLETE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -81,18 +81,18 @@ public final class CompositeValue implements IValue {
|
|||
|
||||
@Override
|
||||
public ICPPEvaluation getSubValue(final int index) {
|
||||
return rangeIsValid(index) ? values[index] : EvalFixed.INCOMPLETE;
|
||||
return rangeIsValid(index) && values[index] != null ? values[index] : EvalFixed.INCOMPLETE;
|
||||
}
|
||||
|
||||
private boolean rangeIsValid(final int index) {
|
||||
return numberOfSubValues() > index && index >= 0;
|
||||
private boolean rangeIsValid(int index) {
|
||||
return 0 <= index && index < values.length;
|
||||
}
|
||||
|
||||
public static IValue create(EvalInitList initList) {
|
||||
ICPPEvaluation[] values = new ICPPEvaluation[initList.getClauses().length];
|
||||
for (int i = 0; i < initList.getClauses().length; i++) {
|
||||
ICPPEvaluation eval = initList.getClauses()[i];
|
||||
values[i] = new EvalFixed(eval.getType(null), eval.getValueCategory(null), eval.getValue(null));
|
||||
values[i] = new EvalFixed(eval.getType(null), eval.getValueCategory(null), eval.getValue(null));
|
||||
}
|
||||
return new CompositeValue(initList, values);
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ public final class CompositeValue implements IValue {
|
|||
ActivationRecord record = new ActivationRecord();
|
||||
ICPPEvaluation[] values = new ICPPEvaluation[ClassTypeHelper.getFields(classType, null).length];
|
||||
|
||||
// recursively create all the base class member variables
|
||||
// Recursively create all the base class member variables.
|
||||
ICPPBase[] bases = ClassTypeHelper.getBases(classType, null);
|
||||
for (ICPPBase base : bases) {
|
||||
IBinding baseClass = base.getBaseClass();
|
||||
|
|
Loading…
Add table
Reference in a new issue