Skip to content

Commit 527d29b

Browse files
committed
CPP: Exclude template classes from the query.
1 parent d527dbe commit 527d29b

3 files changed

Lines changed: 7 additions & 5 deletions

File tree

cpp/ql/src/jsf/4.10 Classes/AV Rule 82.ql

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ predicate assignOperatorWithWrongResult(Operator op, string msg) {
9393

9494
from Operator op, string msg
9595
where
96-
assignOperatorWithWrongType(op, msg) or
97-
assignOperatorWithWrongResult(op, msg)
96+
(
97+
assignOperatorWithWrongType(op, msg) or
98+
assignOperatorWithWrongResult(op, msg)
99+
) and
100+
// exclude template classes which may have incomplete function bodies
101+
not op.getDeclaringType() instanceof TemplateClass
98102
select op, msg

cpp/ql/test/query-tests/jsf/4.10 Classes/AV Rule 82/AV Rule 82.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ class Obj3 {
209209
}
210210

211211
Obj3<T> &operator=(const Obj3<T> &other) {
212-
return subFunc(other); // GOOD (returns *this) [FALSE POSITIVE]
212+
return subFunc(other); // GOOD (returns *this)
213213
}
214214
};
215215

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
| AV Rule 82.cpp:18:9:18:17 | operator= | Assignment operator in class Bad1 does not return a reference to *this. |
22
| AV Rule 82.cpp:24:8:24:16 | operator= | Assignment operator in class Bad2 should have return type Bad2&. Otherwise a copy is created at each call. |
33
| AV Rule 82.cpp:63:29:63:29 | operator= | Assignment operator in class TemplateReturnAssignment<int> does not return a reference to *this. |
4-
| AV Rule 82.cpp:63:29:63:37 | operator= | Assignment operator in class TemplateReturnAssignment<T> does not return a reference to *this. |
54
| AV Rule 82.cpp:199:52:199:52 | operator= | Assignment operator in class TemplatedAssignmentBad should have return type TemplatedAssignmentBad&. Otherwise a copy is created at each call. |
6-
| AV Rule 82.cpp:211:12:211:20 | operator= | Assignment operator in class Obj3<T> does not return a reference to *this. |

0 commit comments

Comments
 (0)