File tree Expand file tree Collapse file tree 2 files changed +12
-6
lines changed
lib/semmle/code/cpp/ir/dataflow/internal
test/library-tests/dataflow/asDefinition Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -312,6 +312,13 @@ class Node extends TIRDataFlowNode {
312312 */
313313 Expr asDefinition ( ) { result = this .asDefinition ( _) }
314314
315+ private predicate isCertainStore ( ) {
316+ exists ( SsaImpl:: Definition def |
317+ SsaImpl:: defToNode ( this , def , _) and
318+ def .isCertain ( )
319+ )
320+ }
321+
315322 /**
316323 * Gets the definition associated with this node, if any.
317324 *
@@ -361,11 +368,10 @@ class Node extends TIRDataFlowNode {
361368 * pointed to by `p`.
362369 */
363370 Expr asDefinition ( boolean uncertain ) {
364- exists ( StoreInstruction store , SsaImpl :: Definition def |
371+ exists ( StoreInstruction store |
365372 store = this .asInstruction ( ) and
366373 result = asDefinitionImpl ( store ) and
367- SsaImpl:: defToNode ( this , def , _) and
368- if def .isCertain ( ) then uncertain = false else uncertain = true
374+ if this .isCertainStore ( ) then uncertain = false else uncertain = true
369375 )
370376 }
371377
Original file line number Diff line number Diff line change @@ -10,9 +10,9 @@ void test() {
1010 y = 44 ; // $ asDefinition="... = ..."
1111 use (y);
1212
13- int x = 43 ; // $ MISSING: asDefinition=43
14- x = 44 ; // $ MISSING: asDefinition="... = ..."
13+ int x = 43 ; // $ asDefinition=43
14+ x = 44 ; // $ asDefinition="... = ..."
1515
1616 S s;
17- s.x = 42 ; // $ MISSING: asDefinition="... = ..."
17+ s.x = 42 ; // $ asDefinition="... = ..."
1818}
You can’t perform that action at this time.
0 commit comments