@@ -624,11 +624,21 @@ private module HashCons {
624
624
strictcount ( access .getTarget ( ) ) = 1
625
625
}
626
626
627
+ /**
628
+ * Gets the name of a variable.
629
+ *
630
+ * Extracted for performance reasons, to avoid magic, which was causing performance issues in getParameter(int i).
631
+ */
632
+ pragma [ nomagic]
633
+ private string getVariableName ( Variable v ) { result = v .getName ( ) }
634
+
627
635
/* Note: This changed from the original HashCons module to be able to find structural equivalent expression. */
628
636
private predicate mk_Variable ( Type t , string name , VariableAccess access ) {
629
637
analyzableVariable ( access ) and
630
638
exists ( Variable v |
631
- v = access .getTarget ( ) and t = v .getUnspecifiedType ( ) and name = v .getName ( )
639
+ v = access .getTarget ( ) and
640
+ t = v .getUnspecifiedType ( ) and
641
+ name = getVariableName ( v )
632
642
)
633
643
}
634
644
@@ -1104,7 +1114,14 @@ private module HashCons {
1104
1114
nee .getExpr ( ) .getFullyConverted ( ) = child .getAnExpr ( )
1105
1115
}
1106
1116
1107
- private predicate mk_StmtCons ( HashConsStmt hc , int i , HC_Stmts list , BlockStmt block ) {
1117
+ private class LambdaBlockStmt extends BlockStmt {
1118
+ LambdaBlockStmt ( ) {
1119
+ // Restricting to statements inside a lambda expressions.
1120
+ this .getParentScope * ( ) = any ( LambdaExpression le ) .getLambdaFunction ( )
1121
+ }
1122
+ }
1123
+
1124
+ private predicate mk_StmtCons ( HashConsStmt hc , int i , HC_Stmts list , LambdaBlockStmt block ) {
1108
1125
hc = hashConsStmt ( block .getStmt ( i ) ) and
1109
1126
(
1110
1127
exists ( HashConsStmt head , HC_Stmts tail |
@@ -1118,13 +1135,13 @@ private module HashCons {
1118
1135
}
1119
1136
1120
1137
private predicate mk_StmtConsInner (
1121
- HashConsStmt head , HC_Stmts tail , int i , HC_Stmts list , BlockStmt block
1138
+ HashConsStmt head , HC_Stmts tail , int i , HC_Stmts list , LambdaBlockStmt block
1122
1139
) {
1123
1140
list = HC_StmtCons ( head , i , tail ) and
1124
1141
mk_StmtCons ( head , i , tail , block )
1125
1142
}
1126
1143
1127
- private predicate mk_BlockStmtCons ( HC_Stmts hc , BlockStmt s ) {
1144
+ private predicate mk_BlockStmtCons ( HC_Stmts hc , LambdaBlockStmt s ) {
1128
1145
if s .getNumStmt ( ) > 0
1129
1146
then
1130
1147
exists ( HashConsStmt head , HC_Stmts tail |
@@ -1487,8 +1504,6 @@ private module HashCons {
1487
1504
1488
1505
cached
1489
1506
HashConsStmt hashConsStmt ( Stmt s ) {
1490
- // Restricting to statements inside a lambda expressions.
1491
- s .getParentScope * ( ) = any ( LambdaExpression le ) .getLambdaFunction ( ) and
1492
1507
exists ( HC_Stmts list |
1493
1508
mk_BlockStmtCons ( list , s ) and
1494
1509
result = HC_BlockStmt ( list )
0 commit comments