Skip to content

Commit 3bfaf5b

Browse files
committed
Convert M9-3-1 to the new dataflow library
1 parent 8a672b1 commit 3bfaf5b

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

cpp/autosar/src/rules/M9-3-1/ConstMemberFunctionReturnsNonConstPointer.ql

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
import cpp
2020
import codingstandards.cpp.autosar
21-
import semmle.code.cpp.dataflow.DataFlow
21+
import semmle.code.cpp.dataflow.new.DataFlow
2222

2323
class ReferenceTypeWithNonConstBaseType extends ReferenceType {
2424
ReferenceTypeWithNonConstBaseType() { not this.getBaseType().isConst() }
@@ -46,14 +46,16 @@ class ConstMemberFunctionWithRetNonConst extends ConstMemberFunction {
4646
from ConstMemberFunctionWithRetNonConst fun, Locatable f
4747
where
4848
not isExcluded(fun, ConstPackage::constMemberFunctionReturnsNonConstPointerQuery()) and
49-
exists(ReturnStmt ret |
49+
exists(ReturnStmt ret, DataFlow::Node vaNode, DataFlow::Node retNode |
5050
ret.getEnclosingFunction() = fun and
51+
retNode.asIndirectExpr() = ret.getExpr() and
5152
(
52-
f.(MemberVariable).getDeclaringType() = fun.getDeclaringType() and
53-
DataFlow::localExprFlow(f.(MemberVariable).getAnAccess(), ret.getExpr())
53+
vaNode.asIndirectExpr() = f.(MemberVariable).getAnAccess() and
54+
f.(MemberVariable).getDeclaringType() = fun.getDeclaringType()
5455
or
55-
DataFlow::localExprFlow(f.(ThisExpr), ret.getExpr())
56-
)
56+
vaNode.asIndirectExpr() = f.(ThisExpr)
57+
) and
58+
DataFlow::localFlow(vaNode, retNode)
5759
)
5860
select fun, "Const member function returns a " + fun.getReturnTypeCategory() + " to class data $@.",
5961
f, f.toString()
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
WARNING: module 'DataFlow' has been deprecated and may be removed in future (ConstMemberFunctionReturnsNonConstPointer.ql:53,7-15)
2-
WARNING: module 'DataFlow' has been deprecated and may be removed in future (ConstMemberFunctionReturnsNonConstPointer.ql:55,7-15)
31
| test.cpp:8:8:8:11 | getA | Const member function returns a pointer to class data $@. | test.cpp:3:8:3:8 | a | a |
42
| test.cpp:9:8:9:11 | getB | Const member function returns a pointer to class data $@. | test.cpp:4:8:4:8 | b | b |
53
| test.cpp:11:6:11:12 | getThis | Const member function returns a pointer to class data $@. | test.cpp:11:36:11:39 | this | this |

0 commit comments

Comments
 (0)