Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4be969c

Browse files
committed
a bit of cleanup on SignatureExpr
1 parent 6e7db2d commit 4be969c

1 file changed

Lines changed: 16 additions & 9 deletions

File tree

ql/ql/src/codeql_ql/ast/Ast.qll

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -726,11 +726,9 @@ class Module extends TModule, ModuleDeclaration {
726726
/** Holds if the `i`th parameter of this module has `name` and type `sig`. */
727727
predicate hasParameter(int i, string name, SignatureExpr sig) {
728728
exists(QL::ModuleParam param |
729-
param = mod.getParameter(i) and name = param.getParameter().getValue()
730-
|
731-
toQL(sig) = param.getSignature().getPredicate()
732-
or
733-
toQL(sig) = param.getSignature().getTypeExpr()
729+
param = mod.getParameter(i) and
730+
name = param.getParameter().getValue() and
731+
sig.toQL() = param.getSignature()
734732
)
735733
}
736734
}
@@ -2240,15 +2238,24 @@ class ModuleExpr extends TModuleExpr, ModuleRef {
22402238
*/
22412239
SignatureExpr getArgument(int i) {
22422240
exists(QL::ModuleInstantiation instantiation | instantiation.getParent() = me |
2243-
toQL(result) = instantiation.getChild(i).getPredicate()
2244-
or
2245-
toQL(result) = instantiation.getChild(i).getTypeExpr()
2241+
result.toQL() = instantiation.getChild(i)
22462242
)
22472243
}
22482244
}
22492245

22502246
/** A signature expression, either a `PredicateExpr` or a `TypeExpr`. */
2251-
class SignatureExpr extends TSignatureExpr, AstNode { }
2247+
class SignatureExpr extends TSignatureExpr, AstNode {
2248+
QL::SignatureExpr sig;
2249+
2250+
SignatureExpr() {
2251+
toQL(this) = sig.getPredicate()
2252+
or
2253+
toQL(this) = sig.getTypeExpr()
2254+
}
2255+
2256+
/** Gets the generated AST node that contains this signature expression. */
2257+
QL::SignatureExpr toQL() { result = sig }
2258+
}
22522259

22532260
/** An argument to an annotation. */
22542261
private class AnnotationArg extends TAnnotationArg, AstNode {

0 commit comments

Comments
 (0)