mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-10 10:35:23 +02:00
[272995] - fixed f.p. and f.n
This commit is contained in:
parent
eaf73307bc
commit
d02fb6433d
1 changed files with 24 additions and 1 deletions
|
@ -15,9 +15,14 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IBasicType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTBinaryExpression;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checker that detects statements without effect such as
|
* Checker that detects statements without effect such as
|
||||||
|
@ -66,7 +71,21 @@ public class StatementHasNoEffectChecker extends AbstractIndexAstChecker {
|
||||||
private boolean hasNoEffect(IASTExpression e) {
|
private boolean hasNoEffect(IASTExpression e) {
|
||||||
if (e instanceof IASTBinaryExpression) {
|
if (e instanceof IASTBinaryExpression) {
|
||||||
IASTBinaryExpression binExpr = (IASTBinaryExpression) e;
|
IASTBinaryExpression binExpr = (IASTBinaryExpression) e;
|
||||||
return binExpr.getOperator() != IASTBinaryExpression.op_assign;
|
if (binExpr.getOperator() == IASTBinaryExpression.op_assign)
|
||||||
|
return false;
|
||||||
|
if (binExpr instanceof CPPASTBinaryExpression) {
|
||||||
|
CPPASTBinaryExpression cppBin = (CPPASTBinaryExpression) binExpr;
|
||||||
|
ICPPFunction overload = cppBin.getOverload();
|
||||||
|
if (overload != null)
|
||||||
|
return false;
|
||||||
|
IType expressionType = binExpr.getOperand1()
|
||||||
|
.getExpressionType();
|
||||||
|
if (!(expressionType instanceof IBasicType)) {
|
||||||
|
return false; // must be overloaded but parser could not
|
||||||
|
// find it
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
if (e instanceof IASTUnaryExpression) {
|
if (e instanceof IASTUnaryExpression) {
|
||||||
IASTUnaryExpression unaryExpr = (IASTUnaryExpression) e;
|
IASTUnaryExpression unaryExpr = (IASTUnaryExpression) e;
|
||||||
|
@ -80,6 +99,10 @@ public class StatementHasNoEffectChecker extends AbstractIndexAstChecker {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (e instanceof IASTIdExpression) {
|
||||||
|
// simply a;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue