mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-24 09:25:31 +02:00
Bug 531172 - Avoid ClassCastException in CPPSemantics.declaredBefore()
Change-Id: Iddda8bab86e9567b8e0c877562b48defb187656f
This commit is contained in:
parent
af73a4ed1a
commit
bdc212ec05
3 changed files with 29 additions and 2 deletions
|
@ -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;
|
||||
|
||||
|
@ -2028,7 +2029,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.
|
||||
|
|
|
@ -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();
|
||||
}
|
|
@ -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 {
|
||||
|
|
Loading…
Add table
Reference in a new issue