Skip to content

Commit fd768ae

Browse files
committed
C++: Don't generate models for stuff we have modeled in Ql by hand.
1 parent 991658f commit fd768ae

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

cpp/ql/src/utils/modelgenerator/internal/CaptureModels.qll

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ private import semmle.code.cpp.ir.dataflow.internal.TaintTrackingImplSpecific
1313
private import semmle.code.cpp.dataflow.new.TaintTracking as Tt
1414
private import semmle.code.cpp.dataflow.new.DataFlow as Df
1515
private import codeql.mad.modelgenerator.internal.ModelGeneratorImpl
16+
private import semmle.code.cpp.models.interfaces.Taint as Taint
17+
private import semmle.code.cpp.models.interfaces.DataFlow as DataFlow
1618

1719
/**
1820
* Holds if `f` is a "private" function.
@@ -45,6 +47,19 @@ private predicate isUninterestingForModels(Callable api) {
4547
api = any(Cpp::LambdaExpression lambda).getLambdaFunction()
4648
or
4749
api.isFromUninstantiatedTemplate(_)
50+
or
51+
// No need to generate models for functions modeled by hand in QL
52+
api instanceof Taint::TaintFunction
53+
or
54+
api instanceof DataFlow::DataFlowFunction
55+
or
56+
// Don't generate models for main functions
57+
api.hasGlobalName("main")
58+
or
59+
// Don't generate models for system-provided functions. If we want to
60+
// generate models for these we should use a database containing the
61+
// implementations of those system-provided functions in the source root.
62+
not exists(api.getLocation().getFile().getRelativePath())
4863
}
4964

5065
private predicate relevant(Callable api) {

0 commit comments

Comments
 (0)