CPP: Exclude template classes from the query.

This commit is contained in:
Geoffrey White
2020-01-08 13:16:38 +00:00
parent d527dbe47a
commit 527d29ba23
3 changed files with 7 additions and 5 deletions

View File

@@ -93,6 +93,10 @@ predicate assignOperatorWithWrongResult(Operator op, string msg) {
from Operator op, string msg
where
assignOperatorWithWrongType(op, msg) or
assignOperatorWithWrongResult(op, msg)
(
assignOperatorWithWrongType(op, msg) or
assignOperatorWithWrongResult(op, msg)
) and
// exclude template classes which may have incomplete function bodies
not op.getDeclaringType() instanceof TemplateClass
select op, msg

View File

@@ -209,7 +209,7 @@ public:
}
Obj3<T> &operator=(const Obj3<T> &other) {
return subFunc(other); // GOOD (returns *this) [FALSE POSITIVE]
return subFunc(other); // GOOD (returns *this)
}
};

View File

@@ -1,6 +1,4 @@
| AV Rule 82.cpp:18:9:18:17 | operator= | Assignment operator in class Bad1 does not return a reference to *this. |
| 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. |
| AV Rule 82.cpp:63:29:63:29 | operator= | Assignment operator in class TemplateReturnAssignment<int> does not return a reference to *this. |
| AV Rule 82.cpp:63:29:63:37 | operator= | Assignment operator in class TemplateReturnAssignment<T> does not return a reference to *this. |
| 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. |
| AV Rule 82.cpp:211:12:211:20 | operator= | Assignment operator in class Obj3<T> does not return a reference to *this. |