-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18783 from asgerf/js/downward-calls
JS: Resolve calls downward in class hierarchy
- Loading branch information
Showing
9 changed files
with
212 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
category: majorAnalysis | ||
--- | ||
* Improved call resolution logic to better handle calls resolving "downwards", targeting | ||
a method declared in a subclass of the enclosing class. Data flow analysis | ||
has also improved to avoid spurious flow between unrelated classes in the class hierarchy. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,5 +50,6 @@ obj.f(); | |
/** calls:NONE */ | ||
C.f(); | ||
|
||
const d = new D(); | ||
/** calls:NONE */ | ||
new D().f(); | ||
d.f(); |
60 changes: 60 additions & 0 deletions
60
javascript/ql/test/library-tests/CallGraphs/AnnotatedTest/subclasses.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import 'dummy'; | ||
|
||
class Base { | ||
workInBase() { | ||
/** calls:methodInBase */ | ||
this.methodInBase(); | ||
|
||
/** calls:methodInSub1 calls:methodInSub2 */ | ||
this.methodInSub(); | ||
|
||
/** calls:overriddenInSub0 calls:overriddenInSub1 calls:overriddenInSub2 */ | ||
this.overriddenInSub(); | ||
} | ||
|
||
/** name:methodInBase */ | ||
methodInBase() { | ||
/** calls:methodInSub1 calls:methodInSub2 */ | ||
this.methodInSub(); | ||
} | ||
|
||
/** name:overriddenInSub0 */ | ||
overriddenInSub() { | ||
} | ||
} | ||
|
||
class Subclass1 extends Base { | ||
workInSub() { | ||
/** calls:methodInBase */ | ||
this.methodInBase(); | ||
|
||
/** calls:overriddenInSub1 */ | ||
this.overriddenInSub(); | ||
} | ||
|
||
/** name:methodInSub1 */ | ||
methodInSub() { | ||
} | ||
|
||
/** name:overriddenInSub1 */ | ||
overriddenInSub() { | ||
} | ||
} | ||
|
||
class Subclass2 extends Base { | ||
workInSub() { | ||
/** calls:methodInBase */ | ||
this.methodInBase(); | ||
|
||
/** calls:overriddenInSub2 */ | ||
this.overriddenInSub(); | ||
} | ||
|
||
/** name:methodInSub2 */ | ||
methodInSub() { | ||
} | ||
|
||
/** name:overriddenInSub2 */ | ||
overriddenInSub() { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import 'dummy'; | ||
|
||
class Base { | ||
baseMethod(x) { | ||
this.subclassMethod(x); | ||
} | ||
} | ||
|
||
class Subclass1 extends Base { | ||
work() { | ||
this.baseMethod(source("sub1")); | ||
} | ||
subclassMethod(x) { | ||
sink(x); // $ hasValueFlow=sub1 | ||
} | ||
} | ||
|
||
class Subclass2 extends Base { | ||
work() { | ||
this.baseMethod(source("sub2")); | ||
} | ||
subclassMethod(x) { | ||
sink(x); // $ hasValueFlow=sub2 | ||
} | ||
} | ||
|
||
class Subclass3 extends Base { | ||
work() { | ||
this.baseMethod("safe"); | ||
} | ||
subclassMethod(x) { | ||
sink(x); | ||
} | ||
} |