~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/StatementHasNoEffectChecker.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:
82
82
                                IASTBinaryExpression binExpr = (IASTBinaryExpression) e;
83
83
                                if (isPossibleAssignment(binExpr))
84
84
                                        return false;
 
85
                                if (usesOverloadedOperator(binExpr))
 
86
                                        return false;
85
87
                                switch (binExpr.getOperator()) {
86
88
                                        case IASTBinaryExpression.op_logicalOr:
87
89
                                        case IASTBinaryExpression.op_logicalAnd:
91
93
                        }
92
94
                        if (e instanceof IASTUnaryExpression) {
93
95
                                IASTUnaryExpression unaryExpr = (IASTUnaryExpression) e;
 
96
                                if (usesOverloadedOperator(unaryExpr))
 
97
                                        return false;
94
98
                                int operator = unaryExpr.getOperator();
95
99
                                switch (operator) {
96
100
                                        case IASTUnaryExpression.op_postFixDecr:
131
135
                                CheckersMessages.GenericParameter_ParameterExceptionsItem);
132
136
        }
133
137
 
134
 
        public boolean isFilteredArg(String arg) {
 
138
        private boolean isFilteredArg(String arg) {
135
139
                return isFilteredArg(arg, getProblemById(ER_ID, getFile()), PARAM_EXCEPT_ARG_LIST);
136
140
        }
137
141
 
138
142
        /**
139
143
         * @return
140
144
         */
141
 
        public boolean shouldReportInMacro() {
 
145
        private boolean shouldReportInMacro() {
142
146
                return (Boolean) getPreference(getProblemById(ER_ID, getFile()), PARAM_MACRO_ID);
143
147
        }
144
148
 
157
161
                        case IASTBinaryExpression.op_shiftRightAssign:
158
162
                                return true;
159
163
                }
160
 
                if (expr instanceof IASTImplicitNameOwner) {
161
 
                        // Check whether the operator is overloaded
162
 
                        IASTImplicitName[] implicitNames = ((IASTImplicitNameOwner) expr).getImplicitNames();
163
 
                        if (implicitNames.length > 0)
164
 
                                return true;
165
 
                        IType expressionType = expr.getOperand1().getExpressionType();
166
 
                        if (!(expressionType instanceof IBasicType)) {
167
 
                                return true; // must be overloaded but parser could not
168
 
                                // find it
 
164
                return false;
 
165
        }
 
166
        
 
167
        private boolean usesOverloadedOperator(IASTBinaryExpression expr) {
 
168
                if (expr instanceof IASTImplicitNameOwner) {
 
169
                        IASTImplicitName[] implicitNames = ((IASTImplicitNameOwner) expr).getImplicitNames();
 
170
                        if (implicitNames.length > 0)
 
171
                                return true;
 
172
                        IType operand1Type = expr.getOperand1().getExpressionType();
 
173
                        IType operand2Type = expr.getOperand2().getExpressionType();
 
174
                        if (!(operand1Type instanceof IBasicType && operand2Type instanceof IBasicType)) {
 
175
                                return true; // must be overloaded but parser could not find it
 
176
                        }
 
177
                }
 
178
                return false;
 
179
        }
 
180
        
 
181
        private boolean usesOverloadedOperator(IASTUnaryExpression expr) {
 
182
                if (expr instanceof IASTImplicitNameOwner) {
 
183
                        IASTImplicitName[] implicitNames = ((IASTImplicitNameOwner) expr).getImplicitNames();
 
184
                        if (implicitNames.length > 0)
 
185
                                return true;
 
186
                        IType operandType = expr.getOperand().getExpressionType();
 
187
                        if (!(operandType instanceof IBasicType)) {
 
188
                                return true; // must be overloaded but parser could not find it
169
189
                        }
170
190
                }
171
191
                return false;