summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Ridge2013-11-17 03:12:47 (EST)
committerSergey Prigogin2013-11-30 22:57:04 (EST)
commit08293b3f584834b4cc7e911e42f9779500fc61b6 (patch)
tree7b6d6d30eabda21066a2d33a5c1b7f5983c95714
parentc8b535a52c342a65deb2adae88322f153821b859 (diff)
downloadorg.eclipse.cdt-08293b3f584834b4cc7e911e42f9779500fc61b6.zip
org.eclipse.cdt-08293b3f584834b4cc7e911e42f9779500fc61b6.tar.gz
org.eclipse.cdt-08293b3f584834b4cc7e911e42f9779500fc61b6.tar.bz2
Bug 421900 - NPE in StatementHasNoEffectChecker.usesOverloadOperator()refs/changes/68/18468/2
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>
-rw-r--r--codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/StatementHasNoEffectChecker.java19
1 files changed, 13 insertions, 6 deletions
diff --git a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/StatementHasNoEffectChecker.java b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/StatementHasNoEffectChecker.java
index c3f140e..91831ed 100644
--- a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/StatementHasNoEffectChecker.java
+++ b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/StatementHasNoEffectChecker.java
@@ -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
}
}