Skip to content

Commit f4d7e9f

Browse files
committed
Convert A20-8-4 to use the new dataflow library
1 parent ba9ebc6 commit f4d7e9f

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

cpp/autosar/src/rules/A20-8-4/SharedPointerUsedWithNoOwnershipSharing.ql

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import cpp
1717
import codingstandards.cpp.autosar
1818
import codingstandards.cpp.SmartPointers
19-
import semmle.code.cpp.dataflow.DataFlow
19+
import semmle.code.cpp.dataflow.new.DataFlow
2020

2121
/*
2222
* Finds `std::shared_ptr` local variables which are not copy or move initialized, and are not used in
@@ -44,7 +44,11 @@ from AutosarSharedPointerLocalScopeVariable var, SharedPointerLocalAllocInitiali
4444
where
4545
not isExcluded(var, SmartPointers1Package::sharedPointerUsedWithNoOwnershipSharingQuery()) and
4646
var.getAnAssignedValue() = src and
47-
not DataFlow::localExprFlow(src, varOwnershipSharingExpr(var.getType(), var.getFunction()))
47+
not exists(DataFlow::Node n |
48+
n.asIndirectExpr() = varOwnershipSharingExpr(var.getType(), var.getFunction())
49+
|
50+
DataFlow::localFlow(DataFlow::exprNode(src), n)
51+
)
4852
select var,
4953
"The ownership of shared_ptr $@ is not shared within or passed out of the local scope of function $@.",
5054
var, var.getName(), var.getFunction(), var.getFunction().getQualifiedName()
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
WARNING: module 'DataFlow' has been deprecated and may be removed in future (SharedPointerUsedWithNoOwnershipSharing.ql:47,7-15)
21
| test.cpp:14:24:14:26 | sp3 | The ownership of shared_ptr $@ is not shared within or passed out of the local scope of function $@. | test.cpp:14:24:14:26 | sp3 | sp3 | test.cpp:11:22:11:23 | f1 | f1 |
32
| test.cpp:16:24:16:26 | sp5 | The ownership of shared_ptr $@ is not shared within or passed out of the local scope of function $@. | test.cpp:16:24:16:26 | sp5 | sp5 | test.cpp:11:22:11:23 | f1 | f1 |
43
| test.cpp:17:24:17:26 | sp6 | The ownership of shared_ptr $@ is not shared within or passed out of the local scope of function $@. | test.cpp:17:24:17:26 | sp6 | sp6 | test.cpp:11:22:11:23 | f1 | f1 |

0 commit comments

Comments
 (0)