mirror of
https://github.com/github/codeql.git
synced 2026-01-29 14:23:03 +01:00
Fix global value numbering.
This commit is contained in:
@@ -338,7 +338,10 @@ private predicate mkBoolConst(DataFlow::Node nd, boolean val) {
|
||||
nd.isPlatformIndependentConstant()
|
||||
}
|
||||
|
||||
private predicate mkFunc(DataFlow::Node nd, Function f) { nd = f.getARead() }
|
||||
private predicate mkFunc(DataFlow::Node nd, Function f) {
|
||||
nd = f.getARead() and
|
||||
not f instanceof Method
|
||||
}
|
||||
|
||||
private predicate analyzableConst(DataFlow::Node e) {
|
||||
mkNumericConst(e, _) or mkStringConst(e, _) or mkBoolConst(e, _) or mkFunc(e, _)
|
||||
@@ -349,7 +352,7 @@ private predicate analyzableMethodAccess(Read access, DataFlow::Node receiver, M
|
||||
not access.isConst()
|
||||
}
|
||||
|
||||
private predicate mkMethodAccess(DataFlow::Node access, GVN qualifier, Function m) {
|
||||
private predicate mkMethodAccess(DataFlow::Node access, GVN qualifier, Method m) {
|
||||
exists(DataFlow::Node base |
|
||||
analyzableMethodAccess(access, base, m) and
|
||||
qualifier = globalValueNumber(base)
|
||||
|
||||
@@ -40,3 +40,5 @@
|
||||
| regressions.go:7:11:7:15 | false | regressions.go:7:11:7:15 | false |
|
||||
| regressions.go:9:11:9:12 | !... | regressions.go:11:11:11:14 | true |
|
||||
| regressions.go:11:11:11:14 | true | regressions.go:11:11:11:14 | true |
|
||||
| regressions.go:30:9:30:22 | call to getPayload | regressions.go:30:9:30:22 | call to getPayload |
|
||||
| regressions.go:30:26:30:39 | call to getPayload | regressions.go:30:26:30:39 | call to getPayload |
|
||||
|
||||
@@ -12,7 +12,7 @@ const f = true
|
||||
|
||||
type cell struct {
|
||||
payload int
|
||||
next *cell
|
||||
next *cell
|
||||
}
|
||||
|
||||
func test4(x, y cell) int {
|
||||
@@ -20,4 +20,12 @@ func test4(x, y cell) int {
|
||||
y.payload +
|
||||
x.next.payload +
|
||||
y.next.payload
|
||||
}
|
||||
}
|
||||
|
||||
func (c *cell) getPayload() int {
|
||||
return c.payload
|
||||
}
|
||||
|
||||
func test5(x, y cell) int {
|
||||
return x.getPayload() + y.getPayload()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user