Skip to content

Commit 99dbbdf

Browse files
committed
C++: Add some comments
1 parent 9c4d4f8 commit 99dbbdf

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

cpp/ql/src/semmle/code/cpp/Element.qll

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,45 @@ import semmle.code.cpp.Location
22
private import semmle.code.cpp.Enclosing
33
private import semmle.code.cpp.internal.Type
44

5-
cached @element resolveElement(@element e) {
5+
/**
6+
* Get the `@element` that represents this `@element`.
7+
* Normally this will simply be `e`, but sometimes it is not.
8+
* For example, for an incomplete struct `e` the result may be a
9+
* complete struct with the same name.
10+
*/
11+
private cached @element resolveElement(@element e) {
612
if isClass(e)
713
then result = resolve(e)
814
else result = e
915
}
1016

17+
/**
18+
* Get the `Element` that represents this `@element`.
19+
* Normally this will simply be a cast of `e`, but sometimes it is not.
20+
* For example, for an incomplete struct `e` the result may be a
21+
* complete struct with the same name.
22+
*/
1123
Element mkElement(@element e) {
1224
result = resolveElement(e)
1325
}
1426

27+
/**
28+
* Get an `@element` that resolves to the `Element`. This should
29+
* normally only be called from member predicates, where `e` is not
30+
* `this` and you need the result for an argument to a database
31+
* extensional.
32+
* See `underlyingElement` for when `e` is `this`.
33+
*/
1534
@element unresolveElement(Element e) {
1635
resolveElement(result) = e
1736
}
1837

38+
/**
39+
* Get the `@element` that this `Element` extends. This should normally
40+
* only be called from member predicates, where `e` is `this` and you
41+
* need the result for an argument to a database extensional.
42+
* See `unresolveElement` for when `e` is `this`.
43+
*/
1944
@element underlyingElement(Element e) {
2045
result = e
2146
}

0 commit comments

Comments
 (0)