Skip to content

Commit c90fd32

Browse files
committed
C++: Pointer-to-member-function is constant
1 parent 55edfe4 commit c90fd32

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

cpp/ql/src/semmle/code/cpp/internal/AddressConstantExpression.qll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ private predicate constantAddressPointer(Expr pointer) {
6161
// tells us how it's going to be used.
6262
pointer.(FunctionAccess).getType() instanceof FunctionPointerType
6363
or
64+
// Pointer to member function. These accesses are always pointers even though
65+
// their type is `RoutineType`.
66+
pointer.(FunctionAccess).getTarget() instanceof MemberFunction
67+
or
6468
addressConstantVariable(pointer.(VariableAccess).getTarget()) and
6569
pointer.getType().getUnderlyingType() instanceof PointerType
6670
or
Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
| pointer_to_member__pmIsConst | pointer_to_member.cpp:33:3:36:31 | declaration | pointer_to_member.cpp:36:11:36:30 | initializer for pms | Standard edge, only from QL |
2-
| pointer_to_member__pmIsConst | pointer_to_member.cpp:33:3:36:31 | declaration | pointer_to_member.cpp:37:1:37:1 | return ... | Standard edge, only from extractor |
3-
| pointer_to_member__pmIsConst | pointer_to_member.cpp:36:11:36:30 | initializer for pms | pointer_to_member.cpp:36:13:36:19 | x1 | Standard edge, only from QL |
4-
| pointer_to_member__pmIsConst | pointer_to_member.cpp:36:11:36:30 | {...} | pointer_to_member.cpp:37:1:37:1 | return ... | Standard edge, only from QL |
5-
| pointer_to_member__pmIsConst | pointer_to_member.cpp:36:13:36:19 | x1 | pointer_to_member.cpp:36:22:36:28 | f1 | Standard edge, only from QL |
6-
| pointer_to_member__pmIsConst | pointer_to_member.cpp:36:22:36:28 | f1 | pointer_to_member.cpp:36:11:36:30 | {...} | Standard edge, only from QL |
71
| staticlocals__staticlocals_f2 | file://:0:0:0:0 | call to C | staticlocals.cpp:30:1:30:1 | return ... | Standard edge, only from QL |
82
| staticlocals__staticlocals_f2 | file://:0:0:0:0 | initializer for c | file://:0:0:0:0 | call to C | Standard edge, only from QL |
93
| staticlocals__staticlocals_f2 | staticlocals.cpp:29:5:29:17 | declaration | file://:0:0:0:0 | initializer for c | Standard edge, only from QL |

0 commit comments

Comments
 (0)