Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++: Add an interprocedural control-flow library #149

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

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, ""

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.

1 participant