mirror of
https://github.com/github/codeql.git
synced 2026-04-27 01:35:13 +02:00
C++: Restore exists(getBlock()) in AV Rule 82
I removed this condition in #362, thinking it was covered by the new conditions on return statements, but it turns out it wasn't in at least the following cases. 1. Assignment operators that are deleted or marked private in order to make them inaccessible. 2. Templates whose body was not extracted. While some of these results are technically valid, they are not nearly as interesting as the results that this query was designed to produce.
This commit is contained in:
@@ -83,6 +83,7 @@ predicate assignOperatorWithWrongType(Operator op, string msg) {
|
||||
predicate assignOperatorWithWrongResult(Operator op, string msg) {
|
||||
op.hasName("operator=")
|
||||
and not returnsDereferenceThis(op)
|
||||
and exists(op.getBlock())
|
||||
and not op.getType() instanceof VoidType
|
||||
and not assignOperatorWithWrongType(op, _)
|
||||
and msg = "Assignment operator in class " + op.getDeclaringType().getName() + " does not return a reference to *this."
|
||||
|
||||
Reference in New Issue
Block a user