Skip to content

Commit 6472ed7

Browse files
committed
C++: Fix GVN for ImplicitThisFieldAccess
1 parent c51efb1 commit 6472ed7

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

cpp/ql/lib/semmle/code/cpp/valuenumbering/HashCons.qll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,8 @@ private predicate analyzablePointerFieldAccess(PointerFieldAccess access) {
372372
private predicate mk_PointerFieldAccess(HashCons qualifier, Field target, PointerFieldAccess access) {
373373
analyzablePointerFieldAccess(access) and
374374
target = access.getTarget() and
375-
qualifier = hashCons(access.getQualifier().getFullyConverted())
375+
qualifier = hashCons(access.getQualifier().getFullyConverted()) and
376+
not access instanceof ImplicitThisFieldAccess
376377
}
377378

378379
private predicate analyzableImplicitThisFieldAccess(ImplicitThisFieldAccess access) {

cpp/ql/test/examples/expressions/PrintAST.expected

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,7 +1298,7 @@ union_etc.cpp:
12981298
# 6| getExpr(): [AssignExpr] ... = ...
12991299
# 6| Type = [IntType] int
13001300
# 6| ValueCategory = lvalue
1301-
# 6| getLValue(): [PointerFieldAccess] x
1301+
# 6| getLValue(): [ImplicitThisFieldAccess,PointerFieldAccess] x
13021302
# 6| Type = [IntType] int
13031303
# 6| ValueCategory = lvalue
13041304
# 6| getQualifier(): [ThisExpr] this
@@ -1488,7 +1488,7 @@ union_etc.cpp:
14881488
# 33| getExpr(): [AssignExpr] ... = ...
14891489
# 33| Type = [IntType] int
14901490
# 33| ValueCategory = lvalue
1491-
# 33| getLValue(): [PointerFieldAccess] q
1491+
# 33| getLValue(): [ImplicitThisFieldAccess,PointerFieldAccess] q
14921492
# 33| Type = [IntType] int
14931493
# 33| ValueCategory = lvalue
14941494
# 33| getQualifier(): [ThisExpr] this

0 commit comments

Comments
 (0)