11/**
2- * @name Sanity check
3- * @description General sanity check to be run on any and all code. Should never produce any results.
4- * @id py/sanity -check
2+ * @name Consistency check
3+ * @description General consistency check to be run on any and all code. Should never produce any results.
4+ * @id py/consistency -check
55 */
66
77import python
@@ -24,7 +24,7 @@ predicate uniqueness_error(int number, string what, string problem) {
2424 )
2525}
2626
27- predicate ast_sanity ( string clsname , string problem , string what ) {
27+ predicate ast_consistency ( string clsname , string problem , string what ) {
2828 exists ( AstNode a | clsname = a .getAQlClass ( ) |
2929 uniqueness_error ( count ( a .toString ( ) ) , "toString" , problem ) and
3030 what = "at " + a .getLocation ( ) .toString ( )
@@ -39,7 +39,7 @@ predicate ast_sanity(string clsname, string problem, string what) {
3939 )
4040}
4141
42- predicate location_sanity ( string clsname , string problem , string what ) {
42+ predicate location_consistency ( string clsname , string problem , string what ) {
4343 exists ( Location l | clsname = l .getAQlClass ( ) |
4444 uniqueness_error ( count ( l .toString ( ) ) , "toString" , problem ) and what = "at " + l .toString ( )
4545 or
@@ -65,7 +65,7 @@ predicate location_sanity(string clsname, string problem, string what) {
6565 )
6666}
6767
68- predicate cfg_sanity ( string clsname , string problem , string what ) {
68+ predicate cfg_consistency ( string clsname , string problem , string what ) {
6969 exists ( ControlFlowNode f | clsname = f .getAQlClass ( ) |
7070 uniqueness_error ( count ( f .getNode ( ) ) , "getNode" , problem ) and
7171 what = "at " + f .getLocation ( ) .toString ( )
@@ -80,7 +80,7 @@ predicate cfg_sanity(string clsname, string problem, string what) {
8080 )
8181}
8282
83- predicate scope_sanity ( string clsname , string problem , string what ) {
83+ predicate scope_consistency ( string clsname , string problem , string what ) {
8484 exists ( Scope s | clsname = s .getAQlClass ( ) |
8585 uniqueness_error ( count ( s .getEntryNode ( ) ) , "getEntryNode" , problem ) and
8686 what = "at " + s .getLocation ( ) .toString ( )
@@ -125,7 +125,7 @@ private predicate introspected_builtin_object(Object o) {
125125 py_cobject_sources ( o , 0 )
126126}
127127
128- predicate builtin_object_sanity ( string clsname , string problem , string what ) {
128+ predicate builtin_object_consistency ( string clsname , string problem , string what ) {
129129 exists ( Object o |
130130 clsname = o .getAQlClass ( ) and
131131 what = best_description_builtin_object ( o ) and
@@ -146,7 +146,7 @@ predicate builtin_object_sanity(string clsname, string problem, string what) {
146146 )
147147}
148148
149- predicate source_object_sanity ( string clsname , string problem , string what ) {
149+ predicate source_object_consistency ( string clsname , string problem , string what ) {
150150 exists ( Object o | clsname = o .getAQlClass ( ) and not o .isBuiltin ( ) |
151151 uniqueness_error ( count ( o .getOrigin ( ) ) , "getOrigin" , problem ) and
152152 what = "at " + o .getOrigin ( ) .getLocation ( ) .toString ( )
@@ -161,7 +161,7 @@ predicate source_object_sanity(string clsname, string problem, string what) {
161161 )
162162}
163163
164- predicate ssa_sanity ( string clsname , string problem , string what ) {
164+ predicate ssa_consistency ( string clsname , string problem , string what ) {
165165 /* Zero or one definitions of each SSA variable */
166166 exists ( SsaVariable var | clsname = var .getAQlClass ( ) |
167167 uniqueness_error ( strictcount ( var .getDefinition ( ) ) , "getDefinition" , problem ) and
@@ -196,7 +196,7 @@ predicate ssa_sanity(string clsname, string problem, string what) {
196196 )
197197}
198198
199- predicate function_object_sanity ( string clsname , string problem , string what ) {
199+ predicate function_object_consistency ( string clsname , string problem , string what ) {
200200 exists ( FunctionObject func | clsname = func .getAQlClass ( ) |
201201 what = func .getName ( ) and
202202 (
@@ -229,7 +229,7 @@ predicate intermediate_origins(ControlFlowNode use, ControlFlowNode inter, Objec
229229 )
230230}
231231
232- predicate points_to_sanity ( string clsname , string problem , string what ) {
232+ predicate points_to_consistency ( string clsname , string problem , string what ) {
233233 exists ( Object obj |
234234 multiple_origins_per_object ( obj ) and
235235 clsname = obj .getAQlClass ( ) and
@@ -245,7 +245,7 @@ predicate points_to_sanity(string clsname, string problem, string what) {
245245 )
246246}
247247
248- predicate jump_to_definition_sanity ( string clsname , string problem , string what ) {
248+ predicate jump_to_definition_consistency ( string clsname , string problem , string what ) {
249249 problem = "multiple (jump-to) definitions" and
250250 exists ( Expr use |
251251 strictcount ( getUniqueDefinition ( use ) ) > 1 and
@@ -254,7 +254,7 @@ predicate jump_to_definition_sanity(string clsname, string problem, string what)
254254 )
255255}
256256
257- predicate file_sanity ( string clsname , string problem , string what ) {
257+ predicate file_consistency ( string clsname , string problem , string what ) {
258258 exists ( File file , Folder folder |
259259 clsname = file .getAQlClass ( ) and
260260 problem = "has same name as a folder" and
@@ -269,7 +269,7 @@ predicate file_sanity(string clsname, string problem, string what) {
269269 )
270270}
271271
272- predicate class_value_sanity ( string clsname , string problem , string what ) {
272+ predicate class_value_consistency ( string clsname , string problem , string what ) {
273273 exists ( ClassValue value , ClassValue sup , string attr |
274274 what = value .getName ( ) and
275275 sup = value .getASuperType ( ) and
@@ -283,16 +283,16 @@ predicate class_value_sanity(string clsname, string problem, string what) {
283283
284284from string clsname , string problem , string what
285285where
286- ast_sanity ( clsname , problem , what ) or
287- location_sanity ( clsname , problem , what ) or
288- scope_sanity ( clsname , problem , what ) or
289- cfg_sanity ( clsname , problem , what ) or
290- ssa_sanity ( clsname , problem , what ) or
291- builtin_object_sanity ( clsname , problem , what ) or
292- source_object_sanity ( clsname , problem , what ) or
293- function_object_sanity ( clsname , problem , what ) or
294- points_to_sanity ( clsname , problem , what ) or
295- jump_to_definition_sanity ( clsname , problem , what ) or
296- file_sanity ( clsname , problem , what ) or
297- class_value_sanity ( clsname , problem , what )
286+ ast_consistency ( clsname , problem , what ) or
287+ location_consistency ( clsname , problem , what ) or
288+ scope_consistency ( clsname , problem , what ) or
289+ cfg_consistency ( clsname , problem , what ) or
290+ ssa_consistency ( clsname , problem , what ) or
291+ builtin_object_consistency ( clsname , problem , what ) or
292+ source_object_consistency ( clsname , problem , what ) or
293+ function_object_consistency ( clsname , problem , what ) or
294+ points_to_consistency ( clsname , problem , what ) or
295+ jump_to_definition_consistency ( clsname , problem , what ) or
296+ file_consistency ( clsname , problem , what ) or
297+ class_value_consistency ( clsname , problem , what )
298298select clsname + " " + what + " has " + problem
0 commit comments