9
9
import cpp
10
10
private import semmle.code.cpp.Print
11
11
12
- private newtype TPrintASTConfiguration = MkPrintASTConfiguration ( )
12
+ private newtype TPrintASTConfiguration = MkPrintAstConfiguration ( )
13
13
14
14
/**
15
15
* The query can extend this class to control which functions are printed.
16
16
*/
17
- class PrintASTConfiguration extends TPrintASTConfiguration {
17
+ class PrintAstConfiguration extends TPrintASTConfiguration {
18
18
/**
19
19
* Gets a textual representation of this `PrintASTConfiguration`.
20
20
*/
@@ -27,8 +27,11 @@ class PrintASTConfiguration extends TPrintASTConfiguration {
27
27
predicate shouldPrintFunction ( Function func ) { any ( ) }
28
28
}
29
29
30
+ /** DEPRECATED: Alias for PrintAstConfiguration */
31
+ deprecated class PrintASTConfiguration = PrintAstConfiguration ;
32
+
30
33
private predicate shouldPrintFunction ( Function func ) {
31
- exists ( PrintASTConfiguration config | config .shouldPrintFunction ( func ) )
34
+ exists ( PrintAstConfiguration config | config .shouldPrintFunction ( func ) )
32
35
}
33
36
34
37
bindingset [ s]
@@ -86,7 +89,7 @@ private Function getEnclosingFunction(Locatable ast) {
86
89
* nodes for things like parameter lists and constructor init lists.
87
90
*/
88
91
private newtype TPrintASTNode =
89
- TASTNode ( Locatable ast ) { shouldPrintFunction ( getEnclosingFunction ( ast ) ) } or
92
+ TAstNode ( Locatable ast ) { shouldPrintFunction ( getEnclosingFunction ( ast ) ) } or
90
93
TDeclarationEntryNode ( DeclStmt stmt , DeclarationEntry entry ) {
91
94
// We create a unique node for each pair of (stmt, entry), to avoid having one node with
92
95
// multiple parents due to extractor bug CPP-413.
@@ -106,7 +109,7 @@ private newtype TPrintASTNode =
106
109
/**
107
110
* A node in the output tree.
108
111
*/
109
- class PrintASTNode extends TPrintASTNode {
112
+ class PrintAstNode extends TPrintASTNode {
110
113
/**
111
114
* Gets a textual representation of this node in the PrintAST output tree.
112
115
*/
@@ -116,17 +119,17 @@ class PrintASTNode extends TPrintASTNode {
116
119
* Gets the child node at index `childIndex`. Child indices must be unique,
117
120
* but need not be contiguous.
118
121
*/
119
- abstract PrintASTNode getChildInternal ( int childIndex ) ;
122
+ abstract PrintAstNode getChildInternal ( int childIndex ) ;
120
123
121
124
/**
122
125
* Gets the child node at index `childIndex`.
123
126
* Adds edges to fully converted expressions, that are not part of the
124
127
* regular parent/child relation traversal.
125
128
*/
126
- final PrintASTNode getChild ( int childIndex ) {
129
+ final PrintAstNode getChild ( int childIndex ) {
127
130
// The exact value of `childIndex` doesn't matter, as long as we preserve the correct order.
128
131
result =
129
- rank [ childIndex ] ( PrintASTNode child , int nonConvertedIndex , boolean isConverted |
132
+ rank [ childIndex ] ( PrintAstNode child , int nonConvertedIndex , boolean isConverted |
130
133
childAndAccessorPredicate ( child , _, nonConvertedIndex , isConverted )
131
134
|
132
135
// Unconverted children come first, then sort by original child index within each group.
@@ -138,11 +141,11 @@ class PrintASTNode extends TPrintASTNode {
138
141
* Gets the node for the `.getFullyConverted()` version of the child originally at index
139
142
* `childIndex`, if that node has any conversions.
140
143
*/
141
- private PrintASTNode getConvertedChild ( int childIndex ) {
144
+ private PrintAstNode getConvertedChild ( int childIndex ) {
142
145
exists ( Expr expr |
143
- expr = getChildInternal ( childIndex ) .( ASTNode ) .getAST ( ) and
146
+ expr = getChildInternal ( childIndex ) .( AstNode ) .getAST ( ) and
144
147
expr .getFullyConverted ( ) instanceof Conversion and
145
- result .( ASTNode ) .getAST ( ) = expr .getFullyConverted ( ) and
148
+ result .( AstNode ) .getAST ( ) = expr .getFullyConverted ( ) and
146
149
not expr instanceof Conversion
147
150
)
148
151
}
@@ -166,12 +169,12 @@ class PrintASTNode extends TPrintASTNode {
166
169
/**
167
170
* Gets the children of this node.
168
171
*/
169
- final PrintASTNode getAChild ( ) { result = getChild ( _) }
172
+ final PrintAstNode getAChild ( ) { result = getChild ( _) }
170
173
171
174
/**
172
175
* Gets the parent of this node, if any.
173
176
*/
174
- final PrintASTNode getParent ( ) { result .getAChild ( ) = this }
177
+ final PrintAstNode getParent ( ) { result .getAChild ( ) = this }
175
178
176
179
/**
177
180
* Gets the location of this node in the source code.
@@ -196,7 +199,7 @@ class PrintASTNode extends TPrintASTNode {
196
199
* one result tuple, with `isConverted = false`.
197
200
*/
198
201
private predicate childAndAccessorPredicate (
199
- PrintASTNode child , string childPredicate , int nonConvertedIndex , boolean isConverted
202
+ PrintAstNode child , string childPredicate , int nonConvertedIndex , boolean isConverted
200
203
) {
201
204
child = getChildInternal ( nonConvertedIndex ) and
202
205
childPredicate = getChildAccessorPredicateInternal ( nonConvertedIndex ) and
@@ -234,12 +237,15 @@ class PrintASTNode extends TPrintASTNode {
234
237
private Function getEnclosingFunction ( ) { result = getParent * ( ) .( FunctionNode ) .getFunction ( ) }
235
238
}
236
239
240
+ /** DEPRECATED: Alias for PrintAstNode */
241
+ deprecated class PrintASTNode = PrintAstNode ;
242
+
237
243
/**
238
244
* Class that restricts the elements that we compute `qlClass` for.
239
245
*/
240
246
private class PrintableElement extends Element {
241
247
PrintableElement ( ) {
242
- exists ( TASTNode ( this ) )
248
+ exists ( TAstNode ( this ) )
243
249
or
244
250
exists ( TDeclarationEntryNode ( _, this ) )
245
251
or
@@ -262,7 +268,7 @@ private string qlClass(PrintableElement el) {
262
268
/**
263
269
* A node representing an AST node.
264
270
*/
265
- abstract class BaseASTNode extends PrintASTNode {
271
+ abstract class BaseAstNode extends PrintAstNode {
266
272
Locatable ast ;
267
273
268
274
override string toString ( ) { result = qlClass ( ast ) + ast .toString ( ) }
@@ -275,22 +281,28 @@ abstract class BaseASTNode extends PrintASTNode {
275
281
final Locatable getAST ( ) { result = ast }
276
282
}
277
283
284
+ /** DEPRECATED: Alias for BaseAstNode */
285
+ deprecated class BaseASTNode = BaseAstNode ;
286
+
278
287
/**
279
288
* A node representing an AST node other than a `DeclarationEntry`.
280
289
*/
281
- abstract class ASTNode extends BaseASTNode , TASTNode {
282
- ASTNode ( ) { this = TASTNode ( ast ) }
290
+ abstract class AstNode extends BaseAstNode , TAstNode {
291
+ AstNode ( ) { this = TAstNode ( ast ) }
283
292
}
284
293
294
+ /** DEPRECATED: Alias for AstNode */
295
+ deprecated class ASTNode = AstNode ;
296
+
285
297
/**
286
298
* A node representing an `Expr`.
287
299
*/
288
- class ExprNode extends ASTNode {
300
+ class ExprNode extends AstNode {
289
301
Expr expr ;
290
302
291
303
ExprNode ( ) { expr = ast }
292
304
293
- override ASTNode getChildInternal ( int childIndex ) { result .getAST ( ) = expr .getChild ( childIndex ) }
305
+ override AstNode getChildInternal ( int childIndex ) { result .getAST ( ) = expr .getChild ( childIndex ) }
294
306
295
307
override string getProperty ( string key ) {
296
308
result = super .getProperty ( key )
@@ -334,7 +346,7 @@ class ConversionNode extends ExprNode {
334
346
335
347
ConversionNode ( ) { conv = expr }
336
348
337
- override ASTNode getChildInternal ( int childIndex ) {
349
+ override AstNode getChildInternal ( int childIndex ) {
338
350
childIndex = 0 and
339
351
result .getAST ( ) = conv .getExpr ( ) and
340
352
conv .getExpr ( ) instanceof Conversion
@@ -363,7 +375,7 @@ class CastNode extends ConversionNode {
363
375
class StmtExprNode extends ExprNode {
364
376
override StmtExpr expr ;
365
377
366
- override ASTNode getChildInternal ( int childIndex ) {
378
+ override AstNode getChildInternal ( int childIndex ) {
367
379
childIndex = 0 and
368
380
result .getAST ( ) = expr .getStmt ( )
369
381
}
@@ -372,18 +384,18 @@ class StmtExprNode extends ExprNode {
372
384
/**
373
385
* A node representing a `DeclarationEntry`.
374
386
*/
375
- class DeclarationEntryNode extends BaseASTNode , TDeclarationEntryNode {
387
+ class DeclarationEntryNode extends BaseAstNode , TDeclarationEntryNode {
376
388
override DeclarationEntry ast ;
377
389
DeclStmt declStmt ;
378
390
379
391
DeclarationEntryNode ( ) { this = TDeclarationEntryNode ( declStmt , ast ) }
380
392
381
- override PrintASTNode getChildInternal ( int childIndex ) { none ( ) }
393
+ override PrintAstNode getChildInternal ( int childIndex ) { none ( ) }
382
394
383
395
override string getChildAccessorPredicateInternal ( int childIndex ) { none ( ) }
384
396
385
397
override string getProperty ( string key ) {
386
- result = BaseASTNode .super .getProperty ( key )
398
+ result = BaseAstNode .super .getProperty ( key )
387
399
or
388
400
key = "Type" and
389
401
result = qlClass ( ast .getType ( ) ) + ast .getType ( ) .toString ( )
@@ -396,7 +408,7 @@ class DeclarationEntryNode extends BaseASTNode, TDeclarationEntryNode {
396
408
class VariableDeclarationEntryNode extends DeclarationEntryNode {
397
409
override VariableDeclarationEntry ast ;
398
410
399
- override ASTNode getChildInternal ( int childIndex ) {
411
+ override AstNode getChildInternal ( int childIndex ) {
400
412
childIndex = 0 and
401
413
result .getAST ( ) = ast .getVariable ( ) .getInitializer ( )
402
414
}
@@ -410,12 +422,12 @@ class VariableDeclarationEntryNode extends DeclarationEntryNode {
410
422
/**
411
423
* A node representing a `Stmt`.
412
424
*/
413
- class StmtNode extends ASTNode {
425
+ class StmtNode extends AstNode {
414
426
Stmt stmt ;
415
427
416
428
StmtNode ( ) { stmt = ast }
417
429
418
- override BaseASTNode getChildInternal ( int childIndex ) {
430
+ override BaseAstNode getChildInternal ( int childIndex ) {
419
431
exists ( Locatable child |
420
432
child = stmt .getChild ( childIndex ) and
421
433
(
@@ -449,12 +461,12 @@ class DeclStmtNode extends StmtNode {
449
461
/**
450
462
* A node representing a `Parameter`.
451
463
*/
452
- class ParameterNode extends ASTNode {
464
+ class ParameterNode extends AstNode {
453
465
Parameter param ;
454
466
455
467
ParameterNode ( ) { param = ast }
456
468
457
- final override PrintASTNode getChildInternal ( int childIndex ) { none ( ) }
469
+ final override PrintAstNode getChildInternal ( int childIndex ) { none ( ) }
458
470
459
471
final override string getChildAccessorPredicateInternal ( int childIndex ) { none ( ) }
460
472
@@ -469,12 +481,12 @@ class ParameterNode extends ASTNode {
469
481
/**
470
482
* A node representing an `Initializer`.
471
483
*/
472
- class InitializerNode extends ASTNode {
484
+ class InitializerNode extends AstNode {
473
485
Initializer init ;
474
486
475
487
InitializerNode ( ) { init = ast }
476
488
477
- override ASTNode getChildInternal ( int childIndex ) {
489
+ override AstNode getChildInternal ( int childIndex ) {
478
490
childIndex = 0 and
479
491
result .getAST ( ) = init .getExpr ( )
480
492
}
@@ -488,7 +500,7 @@ class InitializerNode extends ASTNode {
488
500
/**
489
501
* A node representing the parameters of a `Function`.
490
502
*/
491
- class ParametersNode extends PrintASTNode , TParametersNode {
503
+ class ParametersNode extends PrintAstNode , TParametersNode {
492
504
Function func ;
493
505
494
506
ParametersNode ( ) { this = TParametersNode ( func ) }
@@ -497,7 +509,7 @@ class ParametersNode extends PrintASTNode, TParametersNode {
497
509
498
510
final override Location getLocation ( ) { result = getRepresentativeLocation ( func ) }
499
511
500
- override ASTNode getChildInternal ( int childIndex ) {
512
+ override AstNode getChildInternal ( int childIndex ) {
501
513
result .getAST ( ) = func .getParameter ( childIndex )
502
514
}
503
515
@@ -515,7 +527,7 @@ class ParametersNode extends PrintASTNode, TParametersNode {
515
527
/**
516
528
* A node representing the initializer list of a `Constructor`.
517
529
*/
518
- class ConstructorInitializersNode extends PrintASTNode , TConstructorInitializersNode {
530
+ class ConstructorInitializersNode extends PrintAstNode , TConstructorInitializersNode {
519
531
Constructor ctor ;
520
532
521
533
ConstructorInitializersNode ( ) { this = TConstructorInitializersNode ( ctor ) }
@@ -524,7 +536,7 @@ class ConstructorInitializersNode extends PrintASTNode, TConstructorInitializers
524
536
525
537
final override Location getLocation ( ) { result = getRepresentativeLocation ( ctor ) }
526
538
527
- final override ASTNode getChildInternal ( int childIndex ) {
539
+ final override AstNode getChildInternal ( int childIndex ) {
528
540
result .getAST ( ) = ctor .getInitializer ( childIndex )
529
541
}
530
542
@@ -542,7 +554,7 @@ class ConstructorInitializersNode extends PrintASTNode, TConstructorInitializers
542
554
/**
543
555
* A node representing the destruction list of a `Destructor`.
544
556
*/
545
- class DestructorDestructionsNode extends PrintASTNode , TDestructorDestructionsNode {
557
+ class DestructorDestructionsNode extends PrintAstNode , TDestructorDestructionsNode {
546
558
Destructor dtor ;
547
559
548
560
DestructorDestructionsNode ( ) { this = TDestructorDestructionsNode ( dtor ) }
@@ -551,7 +563,7 @@ class DestructorDestructionsNode extends PrintASTNode, TDestructorDestructionsNo
551
563
552
564
final override Location getLocation ( ) { result = getRepresentativeLocation ( dtor ) }
553
565
554
- final override ASTNode getChildInternal ( int childIndex ) {
566
+ final override AstNode getChildInternal ( int childIndex ) {
555
567
result .getAST ( ) = dtor .getDestruction ( childIndex )
556
568
}
557
569
@@ -569,22 +581,22 @@ class DestructorDestructionsNode extends PrintASTNode, TDestructorDestructionsNo
569
581
/**
570
582
* A node representing a `Function`.
571
583
*/
572
- class FunctionNode extends ASTNode {
584
+ class FunctionNode extends AstNode {
573
585
Function func ;
574
586
575
587
FunctionNode ( ) { func = ast }
576
588
577
589
override string toString ( ) { result = qlClass ( func ) + getIdentityString ( func ) }
578
590
579
- override PrintASTNode getChildInternal ( int childIndex ) {
591
+ override PrintAstNode getChildInternal ( int childIndex ) {
580
592
childIndex = 0 and
581
593
result .( ParametersNode ) .getFunction ( ) = func
582
594
or
583
595
childIndex = 1 and
584
596
result .( ConstructorInitializersNode ) .getConstructor ( ) = func
585
597
or
586
598
childIndex = 2 and
587
- result .( ASTNode ) .getAST ( ) = func .getEntryPoint ( )
599
+ result .( AstNode ) .getAST ( ) = func .getEntryPoint ( )
588
600
or
589
601
childIndex = 3 and
590
602
result .( DestructorDestructionsNode ) .getDestructor ( ) = func
@@ -856,7 +868,7 @@ private predicate namedExprChildPredicates(Expr expr, Element ele, string pred)
856
868
}
857
869
858
870
/** Holds if `node` belongs to the output tree, and its property `key` has the given `value`. */
859
- query predicate nodes ( PrintASTNode node , string key , string value ) {
871
+ query predicate nodes ( PrintAstNode node , string key , string value ) {
860
872
node .shouldPrint ( ) and
861
873
value = node .getProperty ( key )
862
874
}
@@ -865,7 +877,7 @@ query predicate nodes(PrintASTNode node, string key, string value) {
865
877
* Holds if `target` is a child of `source` in the AST, and property `key` of the edge has the
866
878
* given `value`.
867
879
*/
868
- query predicate edges ( PrintASTNode source , PrintASTNode target , string key , string value ) {
880
+ query predicate edges ( PrintAstNode source , PrintAstNode target , string key , string value ) {
869
881
exists ( int childIndex |
870
882
source .shouldPrint ( ) and
871
883
target .shouldPrint ( ) and
0 commit comments