summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJacek Sieka2013-08-15 20:57:16 (EDT)
committer Sergey Prigogin2013-08-27 21:16:46 (EDT)
commit3e0f5e9e44f4dbf2b04cb57bff01cc5f9de2713a (patch)
treeb566b65d2276220d9bd46579098d648e789d549d
parent06cea4bc3c13d2ba9b259734295b702769c07604 (diff)
downloadorg.eclipse.cdt-3e0f5e9e44f4dbf2b04cb57bff01cc5f9de2713a.zip
org.eclipse.cdt-3e0f5e9e44f4dbf2b04cb57bff01cc5f9de2713a.tar.gz
org.eclipse.cdt-3e0f5e9e44f4dbf2b04cb57bff01cc5f9de2713a.tar.bz2
Bug 402601. Don't allow EvalTypeId.fArguments to be null to avoid NPE:srefs/changes/22/15522/6
in dependent code. The most probable case of arguments being null was fixed in ea53c271c9de4bcec078ddecce89bb8b1b806a8d. Change-Id: I9d90bd0d4d09839ff9ed0cbc79e599485e878513 Signed-off-by: Jacek Sieka <arnetheduck@gmail.com> Reviewed-on: https://git.eclipse.org/r/15522 Reviewed-by: Sergey Prigogin <eclipse.sprigogin@gmail.com> IP-Clean: Sergey Prigogin <eclipse.sprigogin@gmail.com> Tested-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalTypeId.java29
1 files changed, 11 insertions, 18 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 1e49fbc..bd32c0f 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
@@ -39,9 +39,11 @@ public class EvalTypeId extends CPPDependentEvaluation {
public EvalTypeId(IType type, IASTNode pointOfDefinition, ICPPEvaluation... arguments) {
this(type, findEnclosingTemplate(pointOfDefinition), arguments);
}
-
public EvalTypeId(IType type, IBinding templateDefinition, ICPPEvaluation... arguments) {
super(templateDefinition);
+ if (arguments == null)
+ throw new NullPointerException("arguments"); //$NON-NLS-1$
+
fInputType= type;
fArguments= arguments;
}
@@ -82,9 +84,6 @@ public class EvalTypeId extends CPPDependentEvaluation {
public IValue getValue(IASTNode point) {
if (isValueDependent())
return Value.create(this);
- if (fArguments == null)
- return Value.UNKNOWN;
-
if (isTypeDependent())
return Value.create(this);
if (fOutputType instanceof ICPPClassType) {
@@ -106,8 +105,6 @@ public class EvalTypeId extends CPPDependentEvaluation {
@Override
public boolean isValueDependent() {
- if (fArguments == null)
- return false;
for (ICPPEvaluation arg : fArguments) {
if (arg.isValueDependent())
return true;
@@ -157,9 +154,7 @@ public class EvalTypeId extends CPPDependentEvaluation {
@Override
public ICPPEvaluation instantiate(ICPPTemplateParameterMap tpMap, int packOffset,
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
- ICPPEvaluation[] args = null;
- if (fArguments != null)
- args = instantiateCommaSeparatedSubexpressions(fArguments, tpMap, packOffset, within, maxdepth, point);
+ ICPPEvaluation[] args= instantiateCommaSeparatedSubexpressions(fArguments, tpMap, packOffset, within, maxdepth, point);
IType type = CPPTemplates.instantiateType(fInputType, tpMap, packOffset, within, point);
if (args == fArguments && type == fInputType)
return this;
@@ -170,16 +165,14 @@ public class EvalTypeId extends CPPDependentEvaluation {
public ICPPEvaluation computeForFunctionCall(CPPFunctionParameterMap parameterMap,
int maxdepth, IASTNode point) {
ICPPEvaluation[] args = fArguments;
- if (fArguments != null) {
- for (int i = 0; i < fArguments.length; i++) {
- ICPPEvaluation arg = fArguments[i].computeForFunctionCall(parameterMap, maxdepth, point);
- if (arg != fArguments[i]) {
- if (args == fArguments) {
- args = new ICPPEvaluation[fArguments.length];
- System.arraycopy(fArguments, 0, args, 0, fArguments.length);
- }
- args[i] = arg;
+ for (int i = 0; i < fArguments.length; i++) {
+ ICPPEvaluation arg = fArguments[i].computeForFunctionCall(parameterMap, maxdepth, point);
+ if (arg != fArguments[i]) {
+ if (args == fArguments) {
+ args = new ICPPEvaluation[fArguments.length];
+ System.arraycopy(fArguments, 0, args, 0, fArguments.length);
}
+ args[i] = arg;
}
}
if (args == fArguments)