@@ -8,7 +8,7 @@ private import dotnet
8
8
private import ControlFlow:: SuccessorTypes
9
9
private import semmle.code.csharp.commons.Assertions
10
10
private import semmle.code.csharp.commons.ComparisonTest
11
- private import semmle.code.csharp.commons.StructuralComparison:: Internal
11
+ private import semmle.code.csharp.commons.StructuralComparison as SC
12
12
private import semmle.code.csharp.controlflow.BasicBlocks
13
13
private import semmle.code.csharp.controlflow.internal.Completion
14
14
private import semmle.code.csharp.frameworks.System
@@ -1798,32 +1798,30 @@ module Internal {
1798
1798
}
1799
1799
1800
1800
/**
1801
- * A helper class for calculating structurally equal access/call expressions.
1801
+ * Holds if access/call expression `e` (targeting declaration `target`)
1802
+ * is a sub expression of a guard that controls whether basic block
1803
+ * `bb` is reached.
1802
1804
*/
1803
- private class ConditionOnExprComparisonConfig extends InternalStructuralComparisonConfiguration {
1804
- ConditionOnExprComparisonConfig ( ) { this = "ConditionOnExprComparisonConfig" }
1805
-
1806
- override predicate candidate ( ControlFlowElement x , ControlFlowElement y ) {
1807
- exists ( BasicBlock bb , Declaration d |
1808
- this .candidateAux ( x , d , bb ) and
1809
- y =
1810
- any ( AccessOrCallExpr e |
1811
- e .getAControlFlowNode ( ) .getBasicBlock ( ) = bb and
1812
- e .getTarget ( ) = d
1813
- )
1814
- )
1815
- }
1805
+ pragma [ noinline]
1806
+ private predicate candidateAux ( AccessOrCallExpr e , Declaration target , BasicBlock bb ) {
1807
+ target = e .getTarget ( ) and
1808
+ guardControlsSub ( _, bb , e )
1809
+ }
1816
1810
1817
- /**
1818
- * Holds if access/call expression `e` (targeting declaration `target`)
1819
- * is a sub expression of a guard that controls whether basic block
1820
- * `bb` is reached.
1821
- */
1822
- pragma [ noinline]
1823
- private predicate candidateAux ( AccessOrCallExpr e , Declaration target , BasicBlock bb ) {
1824
- target = e .getTarget ( ) and
1825
- guardControlsSub ( _, bb , e )
1826
- }
1811
+ private predicate candidate ( AccessOrCallExpr x , AccessOrCallExpr y ) {
1812
+ exists ( BasicBlock bb , Declaration d |
1813
+ candidateAux ( x , d , bb ) and
1814
+ y =
1815
+ any ( AccessOrCallExpr e |
1816
+ e .getAControlFlowNode ( ) .getBasicBlock ( ) = bb and
1817
+ e .getTarget ( ) = d
1818
+ )
1819
+ )
1820
+ }
1821
+
1822
+ private predicate same ( AccessOrCallExpr x , AccessOrCallExpr y ) {
1823
+ candidate ( x , y ) and
1824
+ SC:: sameGvn ( x , y )
1827
1825
}
1828
1826
1829
1827
cached
@@ -1849,7 +1847,7 @@ module Internal {
1849
1847
pragma [ nomagic]
1850
1848
private predicate guardControlsSubSame ( Guard g , BasicBlock bb , ControlGuardDescendant sub ) {
1851
1849
guardControlsSub ( g , bb , sub ) and
1852
- any ( ConditionOnExprComparisonConfig c ) . same ( sub , _)
1850
+ same ( sub , _)
1853
1851
}
1854
1852
1855
1853
pragma [ nomagic]
@@ -1862,7 +1860,7 @@ module Internal {
1862
1860
guardedBB = guardedCfn .getBasicBlock ( ) and
1863
1861
guardControls ( g , guardedBB , v ) and
1864
1862
guardControlsSubSame ( g , guardedBB , sub ) and
1865
- any ( ConditionOnExprComparisonConfig c ) . same ( sub , guarded )
1863
+ same ( sub , guarded )
1866
1864
}
1867
1865
1868
1866
pragma [ nomagic]
0 commit comments