Skip to content

Commit 1ba125a

Browse files
committed
C++: Add a few predicates to 'ReturnKind'.
1 parent 3d968c6 commit 1ba125a

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowPrivate.qll

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,15 @@ class ReturnKind extends TReturnKind {
509509

510510
/** Gets a textual representation of this return kind. */
511511
abstract string toString();
512+
513+
/** Holds if this `ReturnKind` is generated from a `return` statement. */
514+
abstract predicate isNormalReturn();
515+
516+
/**
517+
* Holds if this `ReturnKind` is generated from a write to the parameter with
518+
* index `argumentIndex`
519+
*/
520+
abstract predicate isIndirectReturn(int argumentIndex);
512521
}
513522

514523
/**
@@ -522,6 +531,10 @@ class NormalReturnKind extends ReturnKind, TNormalReturnKind {
522531
override int getIndirectionIndex() { result = indirectionIndex }
523532

524533
override string toString() { result = "indirect return" }
534+
535+
override predicate isNormalReturn() { any() }
536+
537+
override predicate isIndirectReturn(int argumentIndex) { none() }
525538
}
526539

527540
/**
@@ -536,6 +549,10 @@ private class IndirectReturnKind extends ReturnKind, TIndirectReturnKind {
536549
override int getIndirectionIndex() { result = indirectionIndex }
537550

538551
override string toString() { result = "indirect outparam[" + argumentIndex.toString() + "]" }
552+
553+
override predicate isNormalReturn() { none() }
554+
555+
override predicate isIndirectReturn(int argumentIndex_) { argumentIndex_ = argumentIndex }
539556
}
540557

541558
/** A data flow node that occurs as the result of a `ReturnStmt`. */

0 commit comments

Comments
 (0)