Skip to content

Conversation

@MathiasVP
Copy link
Collaborator

This adds a "shared" (i.e., language-independent) interprocedural control-flow library to the repository and instantiates it for C++.

Normally these things should be put under the shared folder, but I didn't do that as this would be the first "Microsoft-only" shared library in that folder. So let's just keep even the language-independent parts in the C++ folder for now.

Using this library is a lot like using the global dataflow library. Here's an example of how to use it:

/**
 * @kind path-problem
 */
import cpp
import semmle.code.cpp.interproccontrolflow.ControlFlow
import Flow::PathGraph

module Config implements ControlFlow::ConfigSig {
  predicate isSource(ControlFlow::Node source) {
    source.asParameter().hasName("argv") // start control-flow at the argv declaration
  }

  predicate isSink(ControlFlow::Node sink) {
    sink.getEnclosingFunction().hasName("foo") // and end at any node inside the "foo" function
  }
}

module Flow = ControlFlow::Global<Config>;

from Flow::PathNode source, Flow::PathNode sink
where Flow::flowPath(source, sink)
select sink.getNode(), source, sink, ""

@MathiasVP MathiasVP merged commit 198a594 into main May 19, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants