Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Ridge2019-03-26 06:07:31 +0000
committerNathan Ridge2019-03-26 23:32:25 +0000
commit2243afbb74da1b440c03c44b4f86375ec5eb1900 (patch)
tree0b3f70d022de8e0bb3d8537978000b9793878fd1
parent825423c1e3b2c94d628fbfc5de3c179a647ca51b (diff)
downloadorg.eclipse.cdt-2243afbb74da1b440c03c44b4f86375ec5eb1900.tar.gz
org.eclipse.cdt-2243afbb74da1b440c03c44b4f86375ec5eb1900.tar.xz
org.eclipse.cdt-2243afbb74da1b440c03c44b4f86375ec5eb1900.zip
Bug 545751 - NPE in EvalTypeId.getValue()
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalTypeId.java20
1 files changed, 12 insertions, 8 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalTypeId.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalTypeId.java
index 1d56670dd2..fad9747c5c 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalTypeId.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalTypeId.java
@@ -42,6 +42,7 @@ import org.eclipse.cdt.internal.core.dom.parser.DependentValue;
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
import org.eclipse.cdt.internal.core.dom.parser.IntegralValue;
import org.eclipse.cdt.internal.core.dom.parser.SizeofCalculator;
+import org.eclipse.cdt.internal.core.dom.parser.SizeofCalculator.SizeAndAlignment;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunction;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
@@ -195,15 +196,18 @@ public class EvalTypeId extends CPPDependentEvaluation {
// Cast signed integer to unsigned.
Long val = argVal.numberValue().longValue();
if (val < 0 && inputType instanceof ICPPBasicType && ((ICPPBasicType) inputType).isUnsigned()) {
- long sizeof = SizeofCalculator.getSizeAndAlignment(inputType).size;
- if (sizeof > 4) {
- // Java's "long" can't represent the full range of an 64-bit unsigned integer
- // in C++.
- sizeof = 4;
+ SizeAndAlignment sizeAndAlignment = SizeofCalculator.getSizeAndAlignment(inputType);
+ if (sizeAndAlignment != null) {
+ long sizeof = sizeAndAlignment.size;
+ if (sizeof > 4) {
+ // Java's "long" can't represent the full range of an 64-bit unsigned integer
+ // in C++.
+ sizeof = 4;
+ }
+ long range = (1L << (sizeof * 8 - 1));
+ val += range;
+ return IntegralValue.create(val);
}
- long range = (1L << (sizeof * 8 - 1));
- val += range;
- return IntegralValue.create(val);
}
}
return argVal;

Back to the top