Skip to content

Commit f4a39b4

Browse files
committed
Remove duplicate predicate result and mark FN
1 parent 3365b5a commit f4a39b4

3 files changed

Lines changed: 6 additions & 11 deletions

File tree

cpp/common/src/codingstandards/cpp/lifetimes/CppObjects.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ Expr getASubobjectAccessOf(Expr e) {
159159
*
160160
* For `e` this will be subobject accesses of `*e`.
161161
* Or for `e->x` the subobject access is `x`.
162+
*
163+
* This predicate is not used/tested extensively so
164+
* verify it before use.
162165
*/
163166
Expr getASubobjectAccessOfPointee(Expr e) {
164167
e.getParent() instanceof PointerDereferenceExpr and

cpp/misra/src/rules/RULE-6-8-4/MemberFunctionsRefqualified.ql

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,8 @@ class MembersReturningObject extends MembersReturningObjectOrSubobject {
3535
MembersReturningObject() {
3636
exists(ReturnStmt r, ThisExpr t |
3737
r.getEnclosingFunction() = this and
38-
(
39-
//return `this`
40-
r.getAChild() = t
41-
or
42-
//accesses of subobjects through the `this` pointer
43-
r.getAChild() = getASubobjectAccessOf(t)
44-
) and
38+
//return `this`
39+
r.getAChild() = t and
4540
t.getActualType().stripType() = this.getDeclaringType()
4641
)
4742
}
@@ -114,6 +109,3 @@ where
114109
not f instanceof AppropriatelyQualified and
115110
not f instanceof DefaultedAssignmentOperator
116111
select f, "Member function is not properly ref qualified."
117-
// from Expr e, PointerFieldAccess p
118-
// where e.getParent() = p
119-
// select e, p, p.getTarget(), p.getQualifier(), p.getParent()

cpp/misra/test/rules/RULE-6-8-4/test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ struct A {
2525
return this;
2626
}
2727

28-
A &getstructbad2() { return *this; } // NON_COMPLIANT
28+
A &getstructbad2() { return *this; } // NON_COMPLIANT[FALSE_NEGATIVE]
2929
};
3030

3131
class C {

0 commit comments

Comments
 (0)