mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Bug 356239 - ClassCastException in ClassTypeHelper.getOwnMethods.
This commit is contained in:
parent
97d0869a9a
commit
fb7d64098f
2 changed files with 19 additions and 15 deletions
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Anton Gorenkov - initial implementation
|
* Anton Gorenkov - initial implementation
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.codan.internal.checkers;
|
package org.eclipse.cdt.codan.internal.checkers;
|
||||||
|
|
||||||
|
@ -30,6 +31,7 @@ import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionCallExpression;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionCallExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier;
|
||||||
|
@ -179,12 +181,14 @@ public class AbstractClassInstantiationChecker extends AbstractIndexAstChecker {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether specified type (class or typedef to the class) is abstract class.
|
* Checks whether specified type (class or typedef to the class) is an abstract class.
|
||||||
* If it is - reports violations on each pure virtual method
|
* If it is, reports violations on each pure virtual method
|
||||||
*/
|
*/
|
||||||
private void reportProblemsIfAbstract(IType typeToCheck, IASTNode problemNode ) {
|
private void reportProblemsIfAbstract(IType typeToCheck, IASTNode problemNode ) {
|
||||||
IType unwindedType = CxxAstUtils.getInstance().unwindTypedef(typeToCheck);
|
IType unwindedType = CxxAstUtils.getInstance().unwindTypedef(typeToCheck);
|
||||||
if (unwindedType instanceof ICPPClassType) {
|
if (!(unwindedType instanceof ICPPClassType) || unwindedType instanceof IProblemBinding) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
ICPPClassType classType = (ICPPClassType) unwindedType;
|
ICPPClassType classType = (ICPPClassType) unwindedType;
|
||||||
ICPPMethod[] pureVirtualMethods = pureVirtualMethodsCache.get(classType);
|
ICPPMethod[] pureVirtualMethods = pureVirtualMethodsCache.get(classType);
|
||||||
if (pureVirtualMethods == null) {
|
if (pureVirtualMethods == null) {
|
||||||
|
@ -197,5 +201,4 @@ public class AbstractClassInstantiationChecker extends AbstractIndexAstChecker {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -310,12 +310,13 @@ public class ClassTypeHelper {
|
||||||
/**
|
/**
|
||||||
* Returns methods either declared by the given class or generated by the compiler. Does not
|
* Returns methods either declared by the given class or generated by the compiler. Does not
|
||||||
* include methods declared in base classes.
|
* include methods declared in base classes.
|
||||||
* @param classType
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
private static ObjectSet<ICPPMethod> getOwnMethods(ICPPClassType classType) {
|
private static ObjectSet<ICPPMethod> getOwnMethods(ICPPClassType classType) {
|
||||||
ObjectSet<ICPPMethod> set= new ObjectSet<ICPPMethod>(4);
|
ObjectSet<ICPPMethod> set= new ObjectSet<ICPPMethod>(4);
|
||||||
set.addAll(classType.getDeclaredMethods());
|
set.addAll(classType.getDeclaredMethods());
|
||||||
|
if (classType instanceof IProblemBinding) {
|
||||||
|
return set;
|
||||||
|
}
|
||||||
ICPPClassScope scope= (ICPPClassScope) classType.getCompositeScope();
|
ICPPClassScope scope= (ICPPClassScope) classType.getCompositeScope();
|
||||||
set.addAll(scope.getImplicitMethods());
|
set.addAll(scope.getImplicitMethods());
|
||||||
return set;
|
return set;
|
||||||
|
|
Loading…
Add table
Reference in a new issue