mirror of
https://github.com/github/codeql.git
synced 2026-04-29 02:35:15 +02:00
C++: Add FP dataflow test.
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
namespace std
|
||||
{
|
||||
struct ptrdiff_t;
|
||||
struct input_iterator_tag
|
||||
{
|
||||
};
|
||||
struct forward_iterator_tag : public input_iterator_tag
|
||||
{
|
||||
};
|
||||
}
|
||||
|
||||
struct A
|
||||
{
|
||||
using value_type = int;
|
||||
using difference_type = std::ptrdiff_t;
|
||||
using pointer = int*;
|
||||
using reference = int&;
|
||||
using iterator_category = std::forward_iterator_tag;
|
||||
};
|
||||
|
||||
A get();
|
||||
|
||||
void test()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
auto &&x = get();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
edges
|
||||
| test.cpp:27:16:27:18 | call to get | test.cpp:27:16:27:18 | call to get | provenance | |
|
||||
| test.cpp:27:16:27:18 | call to get | test.cpp:27:16:27:18 | call to get | provenance | |
|
||||
| test.cpp:27:16:27:20 | call to get | test.cpp:27:16:27:18 | call to get | provenance | |
|
||||
| test.cpp:27:16:27:20 | call to get | test.cpp:27:16:27:18 | call to get | provenance | |
|
||||
nodes
|
||||
| test.cpp:27:16:27:18 | call to get | semmle.label | call to get |
|
||||
| test.cpp:27:16:27:18 | call to get | semmle.label | call to get |
|
||||
| test.cpp:27:16:27:20 | call to get | semmle.label | call to get |
|
||||
subpaths
|
||||
#select
|
||||
| test.cpp:27:16:27:18 | call to get | test.cpp:27:16:27:20 | call to get | test.cpp:27:16:27:18 | call to get | |
|
||||
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* @kind path-problem
|
||||
*/
|
||||
|
||||
import semmle.code.cpp.ir.IR
|
||||
import semmle.code.cpp.dataflow.new.DataFlow
|
||||
import Flow::PathGraph
|
||||
|
||||
module Config implements DataFlow::ConfigSig {
|
||||
predicate isSource(DataFlow::Node source) {
|
||||
source.asInstruction().(VariableAddressInstruction).getIRVariable() instanceof IRTempVariable
|
||||
}
|
||||
|
||||
predicate isSink(DataFlow::Node sink) {
|
||||
sink.asInstruction().(CallInstruction).getStaticCallTarget().hasName("get")
|
||||
}
|
||||
}
|
||||
|
||||
module Flow = DataFlow::Global<Config>;
|
||||
|
||||
from Flow::PathNode source, Flow::PathNode sink
|
||||
where Flow::flowPath(source, sink)
|
||||
select sink.getNode(), source, sink, ""
|
||||
Reference in New Issue
Block a user