Skip to content

Commit 599b7a6

Browse files
committed
C++: Handle fields in 'getThisType'.
1 parent 9cb8edb commit 599b7a6

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/SsaImplCommon.qll

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,18 @@ private import TypeFlow
1111
private import semmle.code.cpp.ir.ValueNumbering
1212

1313
/**
14-
* Gets the C++ type of `this` in the member function `f`.
14+
* Gets the C++ type of `this` in an `IRFunction` generated from `f`.
1515
* The result is a glvalue if `isGLValue` is true, and
1616
* a prvalue if `isGLValue` is false.
1717
*/
1818
bindingset[isGLValue]
19-
private CppType getThisType(Cpp::MemberFunction f, boolean isGLValue) {
20-
result.hasType(f.getTypeOfThis(), isGLValue)
19+
private CppType getThisType(Cpp::Declaration f, boolean isGLValue) {
20+
result.hasType(f.(Cpp::MemberFunction).getTypeOfThis(), isGLValue)
21+
or
22+
exists(Cpp::PointerType pt |
23+
pt.getBaseType() = f.(Cpp::Field).getDeclaringType() and
24+
result.hasType(pt, isGLValue)
25+
)
2126
}
2227

2328
/**

0 commit comments

Comments
 (0)