Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Ridge2018-02-24 06:44:05 +0000
committerNathan Ridge2018-02-25 23:46:00 +0000
commit1150af56bb0cae0aea704bebb3f8630352e0b2d3 (patch)
treeb1eddbda4f17d3f267c0220c8087c70362a662c5
parentcf308662d24b1285133222d27f12dd9f4adff81b (diff)
downloadorg.eclipse.cdt-1150af56bb0cae0aea704bebb3f8630352e0b2d3.tar.gz
org.eclipse.cdt-1150af56bb0cae0aea704bebb3f8630352e0b2d3.tar.xz
org.eclipse.cdt-1150af56bb0cae0aea704bebb3f8630352e0b2d3.zip
Bug 531172 - Avoid ClassCastException in CPPSemantics.declaredBefore()
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java7
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/IPDOMAdaptedASTNode.java17
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMASTAdapter.java7
3 files changed, 29 insertions, 2 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java
index 84f7b656cb..ea74553801 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java
@@ -244,6 +244,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates.TypeS
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.Conversions.Context;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.Conversions.UDCMode;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.Cost.Rank;
+import org.eclipse.cdt.internal.core.pdom.dom.IPDOMAdaptedASTNode;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
@@ -2014,7 +2015,11 @@ public class CPPSemantics {
}
public static boolean declaredBefore(Object obj, IASTNode node, boolean indexBased) {
- if (node == null)
+ if (node instanceof IPDOMAdaptedASTNode) {
+ // Get the underlying ASTNode.
+ node = ((IPDOMAdaptedASTNode) node).getDelegate();
+ }
+ if (!(node instanceof ASTNode))
return true;
// The pointOfRef and pointOfDecl variables contain node offsets scaled by a factor of two.
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/IPDOMAdaptedASTNode.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/IPDOMAdaptedASTNode.java
new file mode 100644
index 0000000000..fad015b9f1
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/IPDOMAdaptedASTNode.java
@@ -0,0 +1,17 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Nathan Ridge.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.pdom.dom;
+
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+
+/**
+ * Interface for AST nodes created by PDOMASTAdapter.
+ */
+public interface IPDOMAdaptedASTNode extends IASTNode {
+ IASTNode getDelegate();
+} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMASTAdapter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMASTAdapter.java
index bcacba875f..f2f4386c39 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMASTAdapter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMASTAdapter.java
@@ -51,7 +51,7 @@ import org.eclipse.cdt.core.parser.IToken;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding;
public class PDOMASTAdapter {
- private static class AnonymousASTName implements IASTName {
+ private static class AnonymousASTName implements IASTName, IPDOMAdaptedASTNode {
private IASTName fDelegate;
private IASTFileLocation fLocation;
@@ -292,6 +292,11 @@ public class PDOMASTAdapter {
public IASTNode getOriginalNode() {
return this;
}
+
+ @Override
+ public IASTNode getDelegate() {
+ return fDelegate;
+ }
}
private static class AnonymousEnumeration implements IEnumeration {

Back to the top