Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/codan
diff options
context:
space:
mode:
Diffstat (limited to 'codan')
-rw-r--r--codan/org.eclipse.cdt.codan.checkers/plugin.xml4
-rw-r--r--codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/AbstractClassInstantiationChecker.java34
2 files changed, 18 insertions, 20 deletions
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">
</problem>
-
-
</checker>
+
<checker
class="org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectChecker"
id="org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectChecker"
diff --git a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/AbstractClassInstantiationChecker.java b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/AbstractClassInstantiationChecker.java
index 96b25e05e4a..6554b9ed9d4 100644
--- a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/AbstractClassInstantiationChecker.java
+++ b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/AbstractClassInstantiationChecker.java
@@ -15,6 +15,8 @@ import java.util.HashMap;
import org.eclipse.cdt.codan.checkers.CodanCheckersActivator;
import org.eclipse.cdt.codan.core.cxx.CxxAstUtils;
import org.eclipse.cdt.codan.core.cxx.model.AbstractIndexAstChecker;
+import org.eclipse.cdt.codan.core.model.CheckerLaunchMode;
+import org.eclipse.cdt.codan.core.model.IProblemWorkingCopy;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
@@ -44,12 +46,19 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
* functions).
*
* @author Anton Gorenkov
- *
*/
public class AbstractClassInstantiationChecker extends AbstractIndexAstChecker {
public static final String ER_ID = "org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation"; //$NON-NLS-1$
private HashMap<ICPPClassType, ICPPMethod[]> pureVirtualMethodsCache = new HashMap<ICPPClassType, ICPPMethod[]>();
+ @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) {
@@ -152,17 +161,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.
*/
private String resolveName(ICPPBinding binding) {

Back to the top