Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit da73a03

Browse files
committed
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.
1 parent 786377d commit da73a03

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ predicate assignOperatorWithWrongType(Operator op, string msg) {
8383
predicate assignOperatorWithWrongResult(Operator op, string msg) {
8484
op.hasName("operator=")
8585
and not returnsDereferenceThis(op)
86+
and exists(op.getBlock())
8687
and not op.getType() instanceof VoidType
8788
and not assignOperatorWithWrongType(op, _)
8889
and msg = "Assignment operator in class " + op.getDeclaringType().getName() + " does not return a reference to *this."

0 commit comments

Comments
 (0)