Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Ridge2018-04-05 19:54:50 +0000
committerNathan Ridge2018-04-13 05:46:10 +0000
commitfc8f2d6176d648a0d05c7131177e55edfbe607e0 (patch)
treef9c5abdc720fcdec25890cf8c6ebda82f92c1ef6 /core/org.eclipse.cdt.core/parser/org
parent72d90351736e74f0e2860fc10e3b6bcc67a5fbce (diff)
downloadorg.eclipse.cdt-fc8f2d6176d648a0d05c7131177e55edfbe607e0.tar.gz
org.eclipse.cdt-fc8f2d6176d648a0d05c7131177e55edfbe607e0.tar.xz
org.eclipse.cdt-fc8f2d6176d648a0d05c7131177e55edfbe607e0.zip
Bug 533216 - Avoid a ClassCastException in EvalBinding.unmarshal() if the parameter owner could not be stored in the index
Diffstat (limited to 'core/org.eclipse.cdt.core/parser/org')
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinding.java13
1 files changed, 12 insertions, 1 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinding.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinding.java
index 51eca0ef32f..078ed7d60ad 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinding.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinding.java
@@ -14,6 +14,7 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.ExpressionTypes.prvalueType;
+import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory;
import org.eclipse.cdt.core.dom.ast.IASTName;
@@ -24,6 +25,7 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IEnumerator;
import org.eclipse.cdt.core.dom.ast.IFunction;
import org.eclipse.cdt.core.dom.ast.IFunctionType;
+import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IValue;
import org.eclipse.cdt.core.dom.ast.IVariable;
@@ -377,7 +379,16 @@ public class EvalBinding extends CPPDependentEvaluation {
public static ICPPEvaluation unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException {
if ((firstBytes & ITypeMarshalBuffer.FLAG1) != 0) {
- ICPPFunction parameterOwner= (ICPPFunction) buffer.unmarshalBinding();
+ IBinding paramOwnerBinding = buffer.unmarshalBinding();
+ if (paramOwnerBinding instanceof IProblemBinding) {
+ // The parameter owner could not be stored in the index.
+ // If this happens, it's almost certainly a bug, but the severity
+ // is mitigated by returning a problem evaluation instead of just
+ // trying to cast to ICPPFunction and throwing a ClassCastException.
+ CCorePlugin.log("An EvalBinding had a parameter owner that could not be stored in the index"); //$NON-NLS-1$
+ return EvalFixed.INCOMPLETE;
+ }
+ ICPPFunction parameterOwner= (ICPPFunction) paramOwnerBinding;
int parameterPosition= buffer.getInt();
IType type= buffer.unmarshalType();
IBinding templateDefinition= buffer.unmarshalBinding();

Back to the top