forked from github/codeql-coding-standards
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArgumentToForwardSubsequentlyUsed.ql
More file actions
27 lines (25 loc) · 1.02 KB
/
ArgumentToForwardSubsequentlyUsed.ql
File metadata and controls
27 lines (25 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/**
* @id cpp/autosar/argument-to-forward-subsequently-used
* @name A18-9-4: An argument to std::forward shall not be subsequently used
* @description An argument to std::forward shall not be subsequently used.
* @kind problem
* @precision very-high
* @problem.severity error
* @tags external/autosar/id/a18-9-4
* external/autosar/allocated-target/implementation
* external/autosar/enforcement/automated
* external/autosar/obligation/required
*/
import cpp
import codingstandards.cpp.autosar
import codingstandards.cpp.standardlibrary.Utility
import semmle.code.cpp.dataflow.new.DataFlow
from StdForwardCall f, Access a
where
not isExcluded(a, MoveForwardPackage::movedFromObjectReadAccessedQuery()) and
exists(DataFlow::DefinitionByReferenceNode def |
def.asDefiningArgument() = f.getArgument(0) and
DataFlow::localFlow(def, DataFlow::exprNode(a))
)
select a, "The argument $@ of `std::forward` may be indeterminate when accessed at this location.",
f.getArgument(0), f.getArgument(0).toString()