Skip to content

Commit b466f05

Browse files
committed
C++: Respond to more review comments. (1) Use getClassAndName to ensure a good join order, and (2) unify the two abstract predicates on PointerWrapper.
1 parent 0ce0861 commit b466f05

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

cpp/ql/src/semmle/code/cpp/models/implementations/SmartPointer.qll

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,10 @@ import semmle.code.cpp.models.interfaces.PointerWrapper
77
private class UniqueOrSharedPtr extends Class, PointerWrapper {
88
UniqueOrSharedPtr() { this.hasQualifiedName(["std", "bsl"], ["shared_ptr", "unique_ptr"]) }
99

10-
override MemberFunction getADereferenceFunction() {
11-
result.(OverloadedPointerDereferenceFunction).getDeclaringType() = this
12-
}
13-
1410
override MemberFunction getAnUnwrapperFunction() {
15-
result.getDeclaringType() = this and
16-
result.hasName(["operator->", "get"])
11+
result.(OverloadedPointerDereferenceFunction).getDeclaringType() = this
12+
or
13+
result.getClassAndName(["operator->", "get"]) = this
1714
}
1815
}
1916

cpp/ql/src/semmle/code/cpp/models/interfaces/PointerWrapper.qll

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ private import cpp
44

55
/** A class that wraps a pointer type. For example, `std::unique_ptr` and `std::shared_ptr`. */
66
abstract class PointerWrapper extends Class {
7-
/** Gets a member fucntion of this class that dereferences wrapped pointer, if any. */
8-
abstract MemberFunction getADereferenceFunction();
9-
10-
/** Gets a member fucntion of this class that returns the wrapped pointer, if any. */
7+
/**
8+
* Gets a member function of this class that returns the wrapped pointer, if any.
9+
*
10+
* This includes both functions that return the wrapped pointer by value, and functions
11+
* that return a reference to the pointed-to object.
12+
*/
1113
abstract MemberFunction getAnUnwrapperFunction();
1214
}

0 commit comments

Comments
 (0)