1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-22 22:22:11 +02:00

Bug 421900 - NPE in StatementHasNoEffectChecker.usesOverloadOperator()

Change-Id: I9099f3600cfdac492784087ef5993b353111eab8
Signed-off-by: Nathan Ridge <zeratul976@hotmail.com>
Reviewed-on: https://git.eclipse.org/r/18468
Tested-by: Hudson CI
Reviewed-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
IP-Clean: Sergey Prigogin <eclipse.sprigogin@gmail.com>
Tested-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
This commit is contained in:
Nathan Ridge 2013-11-17 03:12:47 -05:00 committed by Sergey Prigogin
parent c8b535a52c
commit 08293b3f58

View file

@ -26,7 +26,6 @@ import org.eclipse.cdt.core.dom.ast.IASTStatement;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
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.gnu.IGNUASTCompoundStatementExpression;
/**
@ -169,9 +168,13 @@ public class StatementHasNoEffectChecker extends AbstractIndexAstChecker {
IASTImplicitName[] implicitNames = ((IASTImplicitNameOwner) expr).getImplicitNames();
if (implicitNames.length > 0)
return true;
IType operand1Type = expr.getOperand1().getExpressionType();
IType operand2Type = expr.getOperand2().getExpressionType();
if (!(operand1Type instanceof IBasicType && operand2Type instanceof IBasicType)) {
IASTExpression operand1 = expr.getOperand1();
IASTExpression operand2 = expr.getOperand2();
// This shouldn't happen, but if it does, it's better to have a
// false negative than a false positive warning.
if (operand1 == null || operand2 == null)
return true;
if (!(operand1.getExpressionType() instanceof IBasicType && operand2.getExpressionType() instanceof IBasicType)) {
return true; // must be overloaded but parser could not find it
}
}
@ -183,8 +186,12 @@ public class StatementHasNoEffectChecker extends AbstractIndexAstChecker {
IASTImplicitName[] implicitNames = ((IASTImplicitNameOwner) expr).getImplicitNames();
if (implicitNames.length > 0)
return true;
IType operandType = expr.getOperand().getExpressionType();
if (!(operandType instanceof IBasicType)) {
IASTExpression operand = expr.getOperand();
// This shouldn't happen, but if it does, it's better to have a
// false negative than a false positive warning.
if (operand == null)
return true;
if (!(operand.getExpressionType() instanceof IBasicType)) {
return true; // must be overloaded but parser could not find it
}
}