~ubuntu-branches/debian/sid/eclipse-cdt/sid

« back to all changes in this revision

Viewing changes to codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/AssignmentToItselfChecker.java

  • Committer: Package Import Robot
  • Author(s): Jakub Adam
  • Date: 2013-10-03 20:30:16 UTC
  • mfrom: (1.1.11)
  • Revision ID: package-import@ubuntu.com-20131003203016-d4ug6l0xgosasumq
Tags: 8.2.1-1
* New upstream release.
* Updated autotools documentation sources.

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
                                return PROCESS_CONTINUE;
42
42
                        }
43
43
 
44
 
                        private boolean isAssignmentToItself(IASTExpression e) {
45
 
                                if (e instanceof IASTBinaryExpression) {
46
 
                                        IASTBinaryExpression binExpr = (IASTBinaryExpression) e;
 
44
                        private boolean isAssignmentToItself(IASTExpression expr) {
 
45
                                if (expr instanceof IASTBinaryExpression) {
 
46
                                        IASTBinaryExpression binExpr = (IASTBinaryExpression) expr;
47
47
                                        if (binExpr.getOperator() == IASTBinaryExpression.op_assign) {
48
 
                                                String op1 = binExpr.getOperand1().getRawSignature();
49
 
                                                String op2 = binExpr.getOperand2().getRawSignature();
50
 
                                                String expr = binExpr.getRawSignature();
51
 
                                                return op1.equals(op2)
52
 
                                                                // When macro is used, RawSignature returns macro name, see bug 321933
53
 
                                                                && !op1.equals(expr);
 
48
                                                IASTExpression operand1 = binExpr.getOperand1();
 
49
                                                IASTExpression operand2 = binExpr.getOperand2();
 
50
                                                if (operand1 != null && operand2 != null) {
 
51
                                                        String op1 = operand1.getRawSignature();
 
52
                                                        String op2 = operand2.getRawSignature();
 
53
                                                        String exprImage = binExpr.getRawSignature();
 
54
                                                        return op1.equals(op2)
 
55
                                                                        // When macro is used, RawSignature returns macro name, see bug 321933
 
56
                                                                        && !op1.equals(exprImage);
 
57
                                                }
54
58
                                        }
55
59
                                }
56
60
                                return false;