From f88c1e14b60e1c7ea8db28cc95c110e381eeed25 Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Mon, 2 May 2011 18:40:24 +0000 Subject: Bug 326269. A follow up patch by Anton Gorenkov. --- codan/org.eclipse.cdt.codan.checkers/plugin.xml | 4 +-- .../AbstractClassInstantiationChecker.java | 34 ++++++++++------------ 2 files changed, 18 insertions(+), 20 deletions(-) (limited to 'codan') diff --git a/codan/org.eclipse.cdt.codan.checkers/plugin.xml b/codan/org.eclipse.cdt.codan.checkers/plugin.xml index f1afe2bd9e6..91a6de728a9 100644 --- a/codan/org.eclipse.cdt.codan.checkers/plugin.xml +++ b/codan/org.eclipse.cdt.codan.checkers/plugin.xml @@ -13,12 +13,12 @@ defaultSeverity="Warning" description="%problem.description.AssignmentInCondition" id="org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem" + markerType="org.eclipse.cdt.codan.core.codanSemanticProblem" messagePattern="%problem.messagePattern.AssignmentInCondition" name="%problem.name.AssignmentInCondition"> - - + pureVirtualMethodsCache = new HashMap(); + @Override + public void initPreferences(IProblemWorkingCopy problem) { + super.initPreferences(problem); + // These checkers should not run on full or incremental build. + getLaunchModePreference(problem).enableInLaunchModes(CheckerLaunchMode.RUN_AS_YOU_TYPE, + CheckerLaunchMode.RUN_ON_DEMAND); + } + public void processAst(IASTTranslationUnit ast) { try { ast.accept(new OnEachClass()); @@ -67,7 +76,7 @@ public class AbstractClassInstantiationChecker extends AbstractIndexAstChecker { } public int visit(IASTDeclaration declaration) { - // Looking for the variables declarations + // Looking for the variables declarations. if (declaration instanceof IASTSimpleDeclaration) { // If there is at least one non-pointer and non-reference type... IASTSimpleDeclaration simpleDecl = (IASTSimpleDeclaration)declaration; @@ -75,7 +84,7 @@ public class AbstractClassInstantiationChecker extends AbstractIndexAstChecker { if (declSpec.getStorageClass() != IASTDeclSpecifier.sc_typedef) { for (IASTDeclarator declarator : simpleDecl.getDeclarators()) { if (!hasPointerOrReference(declarator)) { - // ... check whether type is an abstract class + // ... check whether type is an abstract class. checkClass(declSpec); break; } @@ -103,7 +112,7 @@ public class AbstractClassInstantiationChecker extends AbstractIndexAstChecker { private void checkClass(IASTDeclSpecifier declSpec) { if (declSpec instanceof ICPPASTNamedTypeSpecifier) { IASTName className = ((ICPPASTNamedTypeSpecifier)declSpec).getName(); - IBinding binding = getOrResolveBinding(className); + IBinding binding = className.resolveBinding(); if (binding instanceof IType) { // Resolve class and check whether it is abstract reportProblemsIfAbstract((IType)binding, className); @@ -124,7 +133,7 @@ public class AbstractClassInstantiationChecker extends AbstractIndexAstChecker { } } } - // Looking for direct class constructor call and check it + // Looking for direct class constructor call and check it. else if (expression instanceof ICPPASTFunctionCallExpression) { ICPPASTFunctionCallExpression functionCall = (ICPPASTFunctionCallExpression)expression; IASTExpression functionName = functionCall.getFunctionNameExpression(); @@ -141,9 +150,9 @@ public class AbstractClassInstantiationChecker extends AbstractIndexAstChecker { * and check whether it is abstract. If it is - report problems */ private void checkClassConstructor(IASTName constructorName) { - IBinding binding = getOrResolveBinding(constructorName); + IBinding binding = constructorName.resolveBinding(); if (binding instanceof ICPPConstructor) { - // Resolve class and check whether it is abstract + // Resolve class and check whether it is abstract. reportProblemsIfAbstract(((ICPPConstructor)binding).getClassOwner(), constructorName); } else if (binding instanceof IType) { @@ -151,17 +160,6 @@ public class AbstractClassInstantiationChecker extends AbstractIndexAstChecker { } } - /** - * Tries to get binding by AST Name. If it is not available - tries to resolve it - */ - private IBinding getOrResolveBinding(IASTName name) { - IBinding binding = name.getBinding(); - if (binding == null) { - binding = name.resolveBinding(); - } - return binding; - } - /** * Tries to resolve qualified name. If it is not available returns simple name. */ -- cgit v1.2.3