@@ -2,8 +2,11 @@ private import codeql.ssa.Ssa as SsaImplCommon
2
2
private import semmle.code.cpp.ir.IR
3
3
private import DataFlowUtil
4
4
private import DataFlowImplCommon as DataFlowImplCommon
5
+ private import semmle.code.cpp.ir.dataflow.internal.ModelUtil
5
6
private import semmle.code.cpp.models.interfaces.Allocation as Alloc
6
7
private import semmle.code.cpp.models.interfaces.DataFlow as DataFlow
8
+ private import semmle.code.cpp.models.interfaces.FlowOutBarrier as FOB
9
+ private import semmle.code.cpp.models.interfaces.FunctionInputsAndOutputs as FIO
7
10
private import semmle.code.cpp.ir.internal.IRCppLanguage
8
11
private import DataFlowPrivate
9
12
private import ssa0.SsaInternals as SsaInternals0
@@ -784,10 +787,30 @@ private Node getAPriorDefinition(SsaDefOrUse defOrUse) {
784
787
)
785
788
}
786
789
790
+ /**
791
+ * Holds if there should not be use-use flow out of `n` (or a conversion that
792
+ * flows to `n`).
793
+ */
794
+ private predicate modeledFlowBarrier ( Node n ) {
795
+ exists ( FIO:: FunctionInput input , CallInstruction call |
796
+ call .getStaticCallTarget ( ) .( FOB:: FlowOutBarrierFunction ) .isFlowOutBarrier ( input ) and
797
+ n = callInput ( call , input )
798
+ )
799
+ or
800
+ exists ( Operand operand , Instruction instr , Node n0 , int indirectionIndex |
801
+ modeledFlowBarrier ( n0 ) and
802
+ nodeHasInstruction ( n0 , instr , indirectionIndex ) and
803
+ conversionFlow ( operand , instr , false , _) and
804
+ nodeHasOperand ( n , operand , indirectionIndex )
805
+ )
806
+ }
807
+
787
808
/** Holds if there is def-use or use-use flow from `nodeFrom` to `nodeTo`. */
788
809
predicate ssaFlow ( Node nodeFrom , Node nodeTo ) {
789
810
exists ( Node nFrom , boolean uncertain , SsaDefOrUse defOrUse |
790
- ssaFlowImpl ( defOrUse , nFrom , nodeTo , uncertain ) and nodeFrom != nodeTo
811
+ ssaFlowImpl ( defOrUse , nFrom , nodeTo , uncertain ) and
812
+ not modeledFlowBarrier ( nFrom ) and
813
+ nodeFrom != nodeTo
791
814
|
792
815
if uncertain = true then nodeFrom = [ nFrom , getAPriorDefinition ( defOrUse ) ] else nodeFrom = nFrom
793
816
)
0 commit comments