@@ -34,10 +34,19 @@ private module SourceVariables {
3434 bindingset [ ind]
3535 SourceVariable ( ) { any ( ) }
3636
37+ /** Gets a textual representation of this element. */
3738 abstract string toString ( ) ;
3839
40+ /**
41+ * Gets the number of loads performed on the base source variable
42+ * to reach the value of this source variable.
43+ */
3944 int getIndirection ( ) { result = ind }
4045
46+ /**
47+ * Gets the base source variable (i.e., the variable without any
48+ * indirections) of this source variable.
49+ */
4150 abstract BaseSourceVariable getBaseVariable ( ) ;
4251 }
4352
@@ -192,6 +201,10 @@ abstract private class DefOrUseImpl extends TDefOrUseImpl {
192201 /** Holds if this definition or use has index `index` in block `block`. */
193202 abstract predicate hasIndexInBlock ( IRBlock block , int index ) ;
194203
204+ /**
205+ * Holds if this definition (or use) has index `index` in block `block`,
206+ * and is a definition (or use) of the variable `sv`
207+ */
195208 final predicate hasIndexInBlock ( IRBlock block , int index , SourceVariable sv ) {
196209 this .hasIndexInBlock ( block , index ) and
197210 sv = this .getSourceVariable ( )
@@ -216,6 +229,10 @@ abstract private class DefOrUseImpl extends TDefOrUseImpl {
216229 */
217230 abstract BaseSourceVariableInstruction getBase ( ) ;
218231
232+ /**
233+ * Gets the base source variable (i.e., the variable without
234+ * any indirection) of this definition or use.
235+ */
219236 final BaseSourceVariable getBaseSourceVariable ( ) {
220237 this .getBase ( ) .getBaseSourceVariable ( ) = result
221238 }
@@ -437,10 +454,12 @@ class GlobalUse extends UseImpl, TGlobalUse {
437454
438455 override FinalGlobalValue getNode ( ) { result .getGlobalUse ( ) = this }
439456
440- override int getIndirection ( ) { result = ind + 1 } // TODO
457+ override int getIndirection ( ) { result = ind + 1 }
441458
459+ /** Gets the global variable associated with this use. */
442460 Cpp:: GlobalOrNamespaceVariable getVariable ( ) { result = global }
443461
462+ /** Gets the `IRFunction` whose body is exited from after this use. */
444463 IRFunction getIRFunction ( ) { result = f }
445464
446465 final override predicate hasIndexInBlock ( IRBlock block , int index ) {
@@ -454,6 +473,10 @@ class GlobalUse extends UseImpl, TGlobalUse {
454473
455474 final override Cpp:: Location getLocation ( ) { result = f .getLocation ( ) }
456475
476+ /**
477+ * Gets the type of this use after specifiers have been deeply stripped
478+ * and typedefs have been resolved.
479+ */
457480 Type getUnspecifiedType ( ) { result = global .getUnspecifiedType ( ) }
458481
459482 override predicate isCertain ( ) { any ( ) }
@@ -468,34 +491,49 @@ class GlobalDef extends TGlobalDef {
468491
469492 GlobalDef ( ) { this = TGlobalDef ( global , f , indirectionIndex ) }
470493
494+ /** Gets the global variable associated with this definition. */
471495 Cpp:: GlobalOrNamespaceVariable getVariable ( ) { result = global }
472496
497+ /** Gets the `IRFunction` whose body is evaluated after this definition. */
473498 IRFunction getIRFunction ( ) { result = f }
474499
500+ /** Gets the global variable associated with this definition. */
475501 int getIndirectionIndex ( ) { result = indirectionIndex }
476502
503+ /** Holds if this definition or use has index `index` in block `block`. */
477504 final predicate hasIndexInBlock ( IRBlock block , int index ) {
478505 exists ( EnterFunctionInstruction enter |
479506 enter = f .getEnterFunctionInstruction ( ) and
480507 block .getInstruction ( index ) = enter
481508 )
482509 }
483510
511+ /** Gets the global variable associated with this definition. */
484512 SourceVariable getSourceVariable ( ) { sourceVariableIsGlobal ( result , global , f , indirectionIndex ) }
485513
514+ /**
515+ * Holds if this definition has index `index` in block `block`, and
516+ * is a definition of the variable `sv`
517+ */
486518 final predicate hasIndexInBlock ( IRBlock block , int index , SourceVariable sv ) {
487519 this .hasIndexInBlock ( block , index ) and
488520 sv = this .getSourceVariable ( )
489521 }
490522
523+ /** Gets the location of this element. */
491524 final Cpp:: Location getLocation ( ) { result = f .getLocation ( ) }
492525
526+ /** Gets a textual representation of this element. */
493527 string toString ( ) {
494528 if indirectionIndex = 0
495529 then result = global .toString ( )
496530 else result = global .toString ( ) + " indirection"
497531 }
498532
533+ /**
534+ * Gets the type of this use after specifiers have been deeply stripped
535+ * and typedefs have been resolved.
536+ */
499537 Type getUnspecifiedType ( ) { result = global .getUnspecifiedType ( ) }
500538}
501539
0 commit comments