diff --git a/codan/org.eclipse.cdt.codan.checkers/plugin.xml b/codan/org.eclipse.cdt.codan.checkers/plugin.xml index d206032ecaa..961aa7a23b5 100644 --- a/codan/org.eclipse.cdt.codan.checkers/plugin.xml +++ b/codan/org.eclipse.cdt.codan.checkers/plugin.xml @@ -119,8 +119,19 @@ name="%problem.name.NoReturn"> - - - + + + + diff --git a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/NameResolutionChecker.java b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/NameResolutionChecker.java new file mode 100644 index 00000000000..1bf184be826 --- /dev/null +++ b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/NameResolutionChecker.java @@ -0,0 +1,51 @@ +/******************************************************************************* + * Copyright (c) 2010 Marc-Andre Laperle and others. + * 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 + * + * Contributors: + * Marc-Andre Laperle - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.codan.internal.checkers; + +import org.eclipse.cdt.codan.core.cxx.model.AbstractIndexAstChecker; +import org.eclipse.cdt.core.dom.ast.ASTVisitor; +import org.eclipse.cdt.core.dom.ast.IASTName; +import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; +import org.eclipse.cdt.core.dom.ast.IBinding; +import org.eclipse.cdt.core.dom.ast.IProblemBinding; + +public class NameResolutionChecker extends AbstractIndexAstChecker { + + static final String ERR_ID = "org.eclipse.cdt.codan.internal.checkers.NameResolutionChecker"; //$NON-NLS-1$ + + public void processAst(IASTTranslationUnit ast) { + try { + ast.accept(new ASTVisitor() { + { + shouldVisitNames = true; + } + + @Override + public int visit(IASTName name) { + IBinding binding = name.resolveBinding(); + if (binding instanceof IProblemBinding) { + reportProblem(ERR_ID, name, name.getRawSignature()); + } + return PROCESS_CONTINUE; + } + }); + } catch (Exception e) { + e.printStackTrace(); + } + + } + + @Override + public boolean runInEditor() { + return true; + } + +}