mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-04 14:55:41 +02:00
Restore the code that makes it work in CDT 6.0
This commit is contained in:
parent
173caf76de
commit
a491012509
1 changed files with 13 additions and 8 deletions
|
@ -13,7 +13,6 @@ package org.eclipse.cdt.codan.internal.checkers;
|
||||||
import org.eclipse.cdt.codan.core.cxx.model.AbstractIndexAstChecker;
|
import org.eclipse.cdt.codan.core.cxx.model.AbstractIndexAstChecker;
|
||||||
import org.eclipse.cdt.codan.core.model.IProblemWorkingCopy;
|
import org.eclipse.cdt.codan.core.model.IProblemWorkingCopy;
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||||
|
@ -23,10 +22,11 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
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.core.dom.ast.cpp.ICPPFunction;
|
||||||
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression;
|
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTBinaryExpression;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTBinaryExpression;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checker that detects statements without effect such as
|
* Checker that detects statements without effect such as
|
||||||
|
@ -118,12 +118,17 @@ public class StatementHasNoEffectChecker extends AbstractIndexAstChecker {
|
||||||
@SuppressWarnings("restriction")
|
@SuppressWarnings("restriction")
|
||||||
public boolean isLValue(IASTBinaryExpression expr) {
|
public boolean isLValue(IASTBinaryExpression expr) {
|
||||||
if (expr instanceof CPPASTBinaryExpression) {
|
if (expr instanceof CPPASTBinaryExpression) {
|
||||||
ICPPFunction op = ((CPPASTBinaryExpression) expr).getOverload();
|
// unfortunately ICPPASTBinaryExpression does not have
|
||||||
if (op != null) {
|
// getOverload public method
|
||||||
try {
|
CPPASTBinaryExpression cppBin = (CPPASTBinaryExpression) expr;
|
||||||
return CPPVisitor.isLValueReference(op.getType().getReturnType());
|
ICPPFunction overload = cppBin.getOverload();
|
||||||
} catch (DOMException e) {
|
if (overload != null)
|
||||||
}
|
return false;
|
||||||
|
IType expressionType = cppBin.getOperand1()
|
||||||
|
.getExpressionType();
|
||||||
|
if (!(expressionType instanceof IBasicType)) {
|
||||||
|
return false; // must be overloaded but parser could not
|
||||||
|
// find it
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch (expr.getOperator()) {
|
switch (expr.getOperator()) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue