File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
go/ql/lib/semmle/go/controlflow Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change 55 */
66
77import go
8+ private import codeql.controlflow.SuccessorType
89
910/** A block statement that is not the body of a `switch` or `select` statement. */
1011class PlainBlock extends BlockStmt {
@@ -542,6 +543,30 @@ module CFG {
542543 }
543544 }
544545
546+ /**
547+ * Gets a successor type that matches completion `c`.
548+ *
549+ * Note that there isn't a 1-to-1 correspondence between completions and
550+ * successor types, so this is an approximation. For example sometimes the
551+ * completion `Done()` is used when the successor type would be
552+ * `ReturnSuccessor` or `ExitSuccessor`.
553+ */
554+ private SuccessorType getAMatchingSuccessorType ( Completion c ) {
555+ c = Done ( ) and result instanceof DirectSuccessor
556+ or
557+ exists ( boolean b | c = Bool ( b ) | result .( BooleanSuccessor ) .getValue ( ) = b )
558+ or
559+ c = Break ( _) and result instanceof BreakSuccessor
560+ or
561+ c = Continue ( _) and result instanceof ContinueSuccessor
562+ or
563+ c = Fallthrough ( ) and result instanceof DirectSuccessor
564+ or
565+ c = Return ( ) and result instanceof ReturnSuccessor
566+ or
567+ c = Panic ( ) and result instanceof ExceptionSuccessor
568+ }
569+
545570 /**
546571 * Holds if `e` should have an evaluation node in the control-flow graph.
547572 *
You can’t perform that action at this time.
0 commit comments