@@ -87,6 +87,9 @@ private cached newtype HCBase =
87
87
HC_NonmemberFunctionCall ( Function fcn , HC_Args args ) {
88
88
mk_NonmemberFunctionCall ( fcn , args , _)
89
89
}
90
+ or HC_ExprCall ( HashCons hc , HC_Args args ) {
91
+ mk_ExprCall ( hc , args , _)
92
+ }
90
93
or
91
94
HC_MemberFunctionCall ( Function trg , HashCons qual , HC_Args args ) {
92
95
mk_MemberFunctionCall ( trg , qual , args , _)
@@ -107,6 +110,12 @@ private cached newtype HCBase =
107
110
or
108
111
HC_AlignofExpr ( HashCons child ) { mk_AlignofExpr ( child , _) }
109
112
or
113
+ HC_UuidofOperator ( Type t ) { mk_UuidofOperator ( t , _) }
114
+ or
115
+ HC_TypeidType ( Type t ) { mk_TypeidType ( t , _) }
116
+ or
117
+ HC_TypeidExpr ( HashCons child ) { mk_TypeidExpr ( child , _) }
118
+ or
110
119
HC_ClassAggregateLiteral ( Class c , HC_Fields hcf ) {
111
120
mk_ClassAggregateLiteral ( c , hcf , _)
112
121
}
@@ -123,6 +132,14 @@ private cached newtype HCBase =
123
132
or
124
133
HC_ReThrowExpr ( )
125
134
or
135
+ HC_ConditionalExpr ( HashCons cond , HashCons trueHC , HashCons falseHC ) {
136
+ mk_ConditionalExpr ( cond , trueHC , falseHC , _)
137
+ }
138
+ or
139
+ HC_NoExceptExpr ( HashCons child ) {
140
+ mk_NoExceptExpr ( child , _)
141
+ }
142
+ or
126
143
// Any expression that is not handled by the cases above is
127
144
// given a unique number based on the expression itself.
128
145
HC_Unanalyzable ( Expr e ) { not analyzableExpr ( e , _) }
@@ -153,11 +170,11 @@ private newtype HC_Align =
153
170
154
171
/** Used to implement hash-consing of argument lists */
155
172
private newtype HC_Args =
156
- HC_EmptyArgs ( Function fcn ) {
173
+ HC_EmptyArgs ( ) {
157
174
any ( )
158
175
}
159
- or HC_ArgCons ( Function fcn , HashCons hc , int i , HC_Args list ) {
160
- mk_ArgCons ( fcn , hc , i , list , _)
176
+ or HC_ArgCons ( HashCons hc , int i , HC_Args list ) {
177
+ mk_ArgCons ( hc , i , list , _)
161
178
}
162
179
163
180
/**
@@ -228,12 +245,18 @@ class HashCons extends HCBase {
228
245
if this instanceof HC_SizeofExpr then result = "SizeofExprOperator" else
229
246
if this instanceof HC_AlignofType then result = "AlignofTypeOperator" else
230
247
if this instanceof HC_AlignofExpr then result = "AlignofExprOperator" else
248
+ if this instanceof HC_UuidofOperator then result = "UuidofOperator" else
249
+ if this instanceof HC_TypeidType then result = "TypeidType" else
250
+ if this instanceof HC_TypeidExpr then result = "TypeidExpr" else
231
251
if this instanceof HC_ArrayAggregateLiteral then result = "ArrayAggregateLiteral" else
232
252
if this instanceof HC_ClassAggregateLiteral then result = "ClassAggreagateLiteral" else
233
253
if this instanceof HC_DeleteExpr then result = "DeleteExpr" else
234
254
if this instanceof HC_DeleteArrayExpr then result = "DeleteArrayExpr" else
235
255
if this instanceof HC_ThrowExpr then result = "ThrowExpr" else
236
256
if this instanceof HC_ReThrowExpr then result = "ReThrowExpr" else
257
+ if this instanceof HC_ExprCall then result = "ExprCall" else
258
+ if this instanceof HC_ConditionalExpr then result = "ConditionalExpr" else
259
+ if this instanceof HC_NoExceptExpr then result = "NoExceptExpr" else
237
260
result = "error"
238
261
}
239
262
@@ -473,19 +496,40 @@ private predicate mk_NonmemberFunctionCall(Function fcn, HC_Args args, FunctionC
473
496
analyzableNonmemberFunctionCall ( fc ) and
474
497
(
475
498
exists ( HashCons head , HC_Args tail |
476
- args = HC_ArgCons ( fcn , head , fc .getNumberOfArguments ( ) - 1 , tail ) and
477
- mk_ArgCons ( fcn , head , fc .getNumberOfArguments ( ) - 1 , tail , fc )
499
+ args = HC_ArgCons ( head , fc .getNumberOfArguments ( ) - 1 , tail ) and
500
+ mk_ArgCons ( head , fc .getNumberOfArguments ( ) - 1 , tail , fc )
478
501
)
479
502
or
480
503
fc .getNumberOfArguments ( ) = 0 and
481
- args = HC_EmptyArgs ( fcn )
504
+ args = HC_EmptyArgs ( )
505
+ )
506
+ }
507
+
508
+ private predicate analyzableExprCall ( ExprCall ec ) {
509
+ forall ( int i |
510
+ exists ( ec .getArgument ( i ) ) |
511
+ strictcount ( ec .getArgument ( i ) .getFullyConverted ( ) ) = 1
512
+ ) and
513
+ strictcount ( ec .getExpr ( ) .getFullyConverted ( ) ) = 1
514
+ }
515
+
516
+ private predicate mk_ExprCall ( HashCons hc , HC_Args args , ExprCall ec ) {
517
+ hc .getAnExpr ( ) = ec .getExpr ( ) and
518
+ (
519
+ exists ( HashCons head , HC_Args tail |
520
+ args = HC_ArgCons ( head , ec .getNumberOfArguments ( ) - 1 , tail ) and
521
+ mk_ArgCons ( head , ec .getNumberOfArguments ( ) - 1 , tail , ec )
522
+ )
523
+ or
524
+ ec .getNumberOfArguments ( ) = 0 and
525
+ args = HC_EmptyArgs ( )
482
526
)
483
527
}
484
528
485
529
private predicate analyzableMemberFunctionCall (
486
530
FunctionCall fc ) {
487
531
forall ( int i |
488
- exists ( fc .getArgument ( i ) ) |
532
+ exists ( fc .getArgument ( i ) ) |
489
533
strictcount ( fc .getArgument ( i ) .getFullyConverted ( ) ) = 1
490
534
) and
491
535
strictcount ( fc .getTarget ( ) ) = 1 and
@@ -503,40 +547,39 @@ private predicate mk_MemberFunctionCall(
503
547
hashCons ( fc .getQualifier ( ) .getFullyConverted ( ) ) = qual and
504
548
(
505
549
exists ( HashCons head , HC_Args tail |
506
- args = HC_ArgCons ( fcn , head , fc .getNumberOfArguments ( ) - 1 , tail ) and
507
- mk_ArgCons ( fcn , head , fc .getNumberOfArguments ( ) - 1 , tail , fc )
550
+ args = HC_ArgCons ( head , fc .getNumberOfArguments ( ) - 1 , tail ) and
551
+ mk_ArgCons ( head , fc .getNumberOfArguments ( ) - 1 , tail , fc )
508
552
)
509
553
or
510
554
fc .getNumberOfArguments ( ) = 0 and
511
- args = HC_EmptyArgs ( fcn )
555
+ args = HC_EmptyArgs ( )
512
556
)
513
557
}
514
558
515
- private predicate analyzableFunctionCall (
516
- FunctionCall fc
517
- ) {
518
- analyzableNonmemberFunctionCall ( fc )
559
+ private predicate analyzableCall ( Call c ) {
560
+ analyzableNonmemberFunctionCall ( c )
561
+ or
562
+ analyzableMemberFunctionCall ( c )
519
563
or
520
- analyzableMemberFunctionCall ( fc )
564
+ analyzableExprCall ( c )
521
565
}
522
566
523
567
/**
524
568
* Holds if `fc` is a call to `fcn`, `fc`'s first `i` arguments have hash-cons
525
569
* `list`, and `fc`'s argument at index `i` has hash-cons `hc`.
526
570
*/
527
- private predicate mk_ArgCons ( Function fcn , HashCons hc , int i , HC_Args list , FunctionCall fc ) {
528
- analyzableFunctionCall ( fc ) and
529
- fc .getTarget ( ) = fcn and
530
- hc = hashCons ( fc .getArgument ( i ) .getFullyConverted ( ) ) and
571
+ private predicate mk_ArgCons ( HashCons hc , int i , HC_Args list , Call c ) {
572
+ analyzableCall ( c ) and
573
+ hc = hashCons ( c .getArgument ( i ) .getFullyConverted ( ) ) and
531
574
(
532
575
exists ( HashCons head , HC_Args tail |
533
- list = HC_ArgCons ( fcn , head , i - 1 , tail ) and
534
- mk_ArgCons ( fcn , head , i - 1 , tail , fc ) and
576
+ list = HC_ArgCons ( head , i - 1 , tail ) and
577
+ mk_ArgCons ( head , i - 1 , tail , c ) and
535
578
i > 0
536
579
)
537
580
or
538
581
i = 0 and
539
- list = HC_EmptyArgs ( fcn )
582
+ list = HC_EmptyArgs ( )
540
583
)
541
584
}
542
585
@@ -545,14 +588,15 @@ private predicate mk_ArgCons(Function fcn, HashCons hc, int i, HC_Args list, Fun
545
588
* Holds if `fc` is a call to `fcn`, `fc`'s first `i` arguments have hash-cons
546
589
* `list`, and `fc`'s argument at index `i` has hash-cons `hc`.
547
590
*/
548
- private predicate mk_AllocArgCons ( Function fcn , HashCons hc , int i , HC_Alloc list , boolean aligned , FunctionCall fc ) {
549
- analyzableFunctionCall ( fc ) and
550
- fc .getTarget ( ) = fcn and
551
- hc = hashCons ( fc .getArgument ( i ) .getFullyConverted ( ) ) and
591
+ private predicate mk_AllocArgCons ( Function fcn , HashCons hc , int i , HC_Alloc list , boolean aligned ,
592
+ Call c ) {
593
+ analyzableCall ( c ) and
594
+ c .getTarget ( ) = fcn and
595
+ hc = hashCons ( c .getArgument ( i ) .getFullyConverted ( ) ) and
552
596
(
553
597
exists ( HashCons head , HC_Alloc tail |
554
598
list = HC_AllocArgCons ( fcn , head , i - 1 , tail , aligned ) and
555
- mk_AllocArgCons ( fcn , head , i - 1 , tail , aligned , fc ) and
599
+ mk_AllocArgCons ( fcn , head , i - 1 , tail , aligned , c ) and
556
600
(
557
601
aligned = true and
558
602
i > 2
@@ -735,6 +779,34 @@ private predicate mk_SizeofExpr(HashCons child, SizeofExprOperator e) {
735
779
child = hashCons ( e .getAChild ( ) )
736
780
}
737
781
782
+ private predicate analyzableUuidofOperator ( UuidofOperator e ) {
783
+ strictcount ( e .getTypeOperand ( ) ) = 1
784
+ }
785
+
786
+ private predicate mk_UuidofOperator ( Type t , UuidofOperator e ) {
787
+ analyzableUuidofOperator ( e ) and
788
+ t = e .getTypeOperand ( )
789
+ }
790
+
791
+ private predicate analyzableTypeidType ( TypeidOperator e ) {
792
+ strictcount ( e .getAChild ( ) ) = 0
793
+ }
794
+
795
+ private predicate mk_TypeidType ( Type t , TypeidOperator e ) {
796
+ analyzableTypeidType ( e ) and
797
+ t = e .getResultType ( )
798
+ }
799
+
800
+ private predicate analyzableTypeidExpr ( Expr e ) {
801
+ e instanceof TypeidOperator and
802
+ strictcount ( e .getAChild ( ) .getFullyConverted ( ) ) = 1
803
+ }
804
+
805
+ private predicate mk_TypeidExpr ( HashCons child , TypeidOperator e ) {
806
+ analyzableTypeidExpr ( e ) and
807
+ child = hashCons ( e .getAChild ( ) )
808
+ }
809
+
738
810
private predicate analyzableAlignofType ( AlignofTypeOperator e ) {
739
811
strictcount ( e .getType ( ) .getUnspecifiedType ( ) ) = 1 and
740
812
strictcount ( e .getTypeOperand ( ) ) = 1
@@ -851,6 +923,30 @@ private predicate mk_ReThrowExpr(ReThrowExpr te) {
851
923
any ( )
852
924
}
853
925
926
+ private predicate analyzableConditionalExpr ( ConditionalExpr ce ) {
927
+ strictcount ( ce .getCondition ( ) .getFullyConverted ( ) ) = 1 and
928
+ strictcount ( ce .getThen ( ) .getFullyConverted ( ) ) = 1 and
929
+ strictcount ( ce .getElse ( ) .getFullyConverted ( ) ) = 1
930
+ }
931
+
932
+ private predicate mk_ConditionalExpr ( HashCons cond , HashCons trueHc , HashCons falseHc ,
933
+ ConditionalExpr ce ) {
934
+ analyzableConditionalExpr ( ce ) and
935
+ cond .getAnExpr ( ) = ce .getCondition ( ) and
936
+ trueHc .getAnExpr ( ) = ce .getThen ( ) and
937
+ falseHc .getAnExpr ( ) = ce .getElse ( )
938
+ }
939
+
940
+ private predicate analyzableNoExceptExpr ( NoExceptExpr nee ) {
941
+ strictcount ( nee .getAChild ( ) .getFullyConverted ( ) ) = 1
942
+ }
943
+
944
+ private predicate mk_NoExceptExpr ( HashCons child , NoExceptExpr nee ) {
945
+ analyzableNoExceptExpr ( nee ) and
946
+ nee .getExpr ( ) = child .getAnExpr ( ) .getFullyConverted ( )
947
+ }
948
+
949
+
854
950
/** Gets the hash-cons of expression `e`. */
855
951
cached HashCons hashCons ( Expr e ) {
856
952
exists ( int val , Type t
@@ -914,6 +1010,11 @@ cached HashCons hashCons(Expr e) {
914
1010
result = HC_NonmemberFunctionCall ( fcn , args )
915
1011
)
916
1012
or
1013
+ exists ( HashCons hc , HC_Args args
1014
+ | mk_ExprCall ( hc , args , e ) and
1015
+ result = HC_ExprCall ( hc , args )
1016
+ )
1017
+ or
917
1018
exists ( Function fcn , HashCons qual , HC_Args args
918
1019
| mk_MemberFunctionCall ( fcn , qual , args , e ) and
919
1020
result = HC_MemberFunctionCall ( fcn , qual , args )
@@ -940,6 +1041,16 @@ cached HashCons hashCons(Expr e) {
940
1041
)
941
1042
or
942
1043
exists ( Type t
1044
+ | mk_TypeidType ( t , e ) and
1045
+ result = HC_TypeidType ( t )
1046
+ )
1047
+ or
1048
+ exists ( HashCons child
1049
+ | mk_TypeidExpr ( child , e ) and
1050
+ result = HC_TypeidExpr ( child )
1051
+ )
1052
+ or
1053
+ exists ( Type t
943
1054
| mk_AlignofType ( t , e ) and
944
1055
result = HC_AlignofType ( t )
945
1056
)
@@ -979,6 +1090,11 @@ cached HashCons hashCons(Expr e) {
979
1090
result = HC_ReThrowExpr ( )
980
1091
)
981
1092
or
1093
+ exists ( HashCons cond , HashCons thenHC , HashCons elseHC
1094
+ | mk_ConditionalExpr ( cond , thenHC , elseHC , e ) and
1095
+ result = HC_ConditionalExpr ( cond , thenHC , elseHC )
1096
+ )
1097
+ or
982
1098
(
983
1099
mk_Nullptr ( e ) and
984
1100
result = HC_Nullptr ( )
@@ -1011,16 +1127,22 @@ predicate analyzableExpr(Expr e, string kind) {
1011
1127
( analyzablePointerDereferenceExpr ( e ) and kind = "PointerDereferenceExpr" ) or
1012
1128
( analyzableNonmemberFunctionCall ( e ) and kind = "NonmemberFunctionCall" ) or
1013
1129
( analyzableMemberFunctionCall ( e ) and kind = "MemberFunctionCall" ) or
1130
+ ( analyzableExprCall ( e ) and kind = "ExprCall" ) or
1014
1131
( analyzableNewExpr ( e ) and kind = "NewExpr" ) or
1015
1132
( analyzableNewArrayExpr ( e ) and kind = "NewArrayExpr" ) or
1016
1133
( analyzableSizeofType ( e ) and kind = "SizeofTypeOperator" ) or
1017
1134
( analyzableSizeofExpr ( e ) and kind = "SizeofExprOperator" ) or
1018
1135
( analyzableAlignofType ( e ) and kind = "AlignofTypeOperator" ) or
1019
1136
( analyzableAlignofExpr ( e ) and kind = "AlignofExprOperator" ) or
1137
+ ( analyzableUuidofOperator ( e ) and kind = "UuidofOperator" ) or
1138
+ ( analyzableTypeidType ( e ) and kind = "TypeidType" ) or
1139
+ ( analyzableTypeidExpr ( e ) and kind = "TypeidExpr" ) or
1020
1140
( analyzableClassAggregateLiteral ( e ) and kind = "ClassAggregateLiteral" ) or
1021
1141
( analyzableArrayAggregateLiteral ( e ) and kind = "ArrayAggregateLiteral" ) or
1022
1142
( analyzableDeleteExpr ( e ) and kind = "DeleteExpr" ) or
1023
1143
( analyzableDeleteArrayExpr ( e ) and kind = "DeleteArrayExpr" ) or
1024
1144
( analyzableThrowExpr ( e ) and kind = "ThrowExpr" ) or
1025
- ( analyzableReThrowExpr ( e ) and kind = "ReThrowExpr" )
1145
+ ( analyzableReThrowExpr ( e ) and kind = "ReThrowExpr" ) or
1146
+ ( analyzableConditionalExpr ( e ) and kind = "ConditionalExpr" ) or
1147
+ ( analyzableNoExceptExpr ( e ) and kind = "NoExceptExpr" )
1026
1148
}
0 commit comments