File tree Expand file tree Collapse file tree
src/codeql_ql/ast/internal Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -31,7 +31,8 @@ private predicate definesPredicate(
3131 name = alias .getName ( ) and
3232 resolvePredicateExpr ( alias .getAlias ( ) , p ) and
3333 public = getPublicBool ( alias ) and
34- arity = alias .getArity ( )
34+ arity = alias .getArity ( ) and
35+ arity = p .getArity ( )
3536 )
3637 )
3738}
@@ -53,10 +54,12 @@ private module Cached {
5354 }
5455
5556 private predicate resolvePredicateCall ( PredicateCall pc , PredicateOrBuiltin p ) {
57+ // calls to class methods
5658 exists ( Class c , ClassType t |
5759 c = pc .getParent * ( ) and
5860 t = c .getType ( ) and
59- p = t .getClassPredicate ( pc .getPredicateName ( ) , pc .getNumberOfArguments ( ) )
61+ p = t .getClassPredicate ( pc .getPredicateName ( ) , pc .getNumberOfArguments ( ) ) and
62+ not exists ( pc .getQualifier ( ) ) // no module qualifier, because then it's not a call to a class method.
6063 )
6164 or
6265 exists ( FileOrModule m , boolean public |
Original file line number Diff line number Diff line change 1+ predicate foo ( int a , int b ) {
2+ a = 2 and
3+ b = 2
4+ }
5+
6+ predicate foo ( int a , int b , int c ) {
7+ a = 2 and
8+ b = 2 and
9+ c = 2
10+ }
11+
12+ predicate myFoo = foo / 2 ;
13+
14+ predicate test ( int i ) { myFoo ( i , i ) } // <- should only resolve to the `foo` with 2 arguments (and the `myFoo` alias).
15+
16+ module MyMod {
17+ predicate bar ( ) { any ( ) }
18+
19+ class Bar extends int {
20+ Bar ( ) { this = 42 }
21+
22+ predicate bar ( ) {
23+ MyMod:: bar ( ) // <- should resolve to the module's predicate.
24+ }
25+ }
26+ }
Original file line number Diff line number Diff line change @@ -14,6 +14,9 @@ getTarget
1414| Foo.qll:31:5:31:12 | PredicateCall | Foo.qll:24:3:24:32 | ClasslessPredicate alias0 |
1515| Foo.qll:36:36:36:65 | MemberCall | file://:0:0:0:0 | replaceAll |
1616| Foo.qll:38:39:38:67 | MemberCall | file://:0:0:0:0 | regexpCapture |
17+ | MultiResolve.qll:14:25:14:35 | PredicateCall | MultiResolve.qll:1:1:4:1 | ClasslessPredicate foo |
18+ | MultiResolve.qll:14:25:14:35 | PredicateCall | MultiResolve.qll:12:1:12:24 | ClasslessPredicate myFoo |
19+ | MultiResolve.qll:25:7:25:18 | PredicateCall | MultiResolve.qll:17:3:19:3 | ClasslessPredicate bar |
1720| Overrides.qll:8:30:8:39 | MemberCall | Overrides.qll:6:3:6:29 | ClassPredicate bar |
1821| Overrides.qll:16:39:16:48 | MemberCall | Overrides.qll:6:3:6:29 | ClassPredicate bar |
1922| Overrides.qll:16:39:16:48 | MemberCall | Overrides.qll:14:12:14:43 | ClassPredicate bar |
@@ -43,5 +46,7 @@ exprPredicate
4346| Foo.qll:26:22:26:31 | predicate | Foo.qll:20:3:20:54 | ClasslessPredicate myThing2 |
4447| Foo.qll:47:55:47:62 | predicate | Foo.qll:42:20:42:27 | NewTypeBranch MkRoot |
4548| Foo.qll:47:65:47:70 | predicate | Foo.qll:44:9:44:56 | ClasslessPredicate edge |
49+ | MultiResolve.qll:12:19:12:23 | predicate | MultiResolve.qll:1:1:4:1 | ClasslessPredicate foo |
50+ | MultiResolve.qll:12:19:12:23 | predicate | MultiResolve.qll:6:1:10:1 | ClasslessPredicate foo |
4651| ParamModules.qll:4:18:4:25 | predicate | ParamModules.qll:2:13:2:36 | ClasslessPredicate fooSig |
4752| ParamModules.qll:10:34:10:40 | predicate | ParamModules.qll:8:3:8:35 | ClasslessPredicate myFoo |
You can’t perform that action at this time.
0 commit comments