Skip to content

Commit 23081f0

Browse files
authored
Merge pull request github#5922 from AlexDenisov/ref-qualifiers
C++: Add ref qualifiers
2 parents f5acc51 + 694eba6 commit 23081f0

File tree

6 files changed

+19
-0
lines changed

6 files changed

+19
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
lgtm,codescanning
2+
* lvalue/rvalue ref qualifiers are now accessible via the new predicates on `MemberFunction`(`.isLValueRefQualified`, `.isRValueRefQualified`, and `isRefQualified`).

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,15 @@ class MemberFunction extends Function {
4848
/** Holds if this member is public. */
4949
predicate isPublic() { this.hasSpecifier("public") }
5050

51+
/** Holds if this declaration has the lvalue ref-qualifier */
52+
predicate isLValueRefQualified() { hasSpecifier("&") }
53+
54+
/** Holds if this declaration has the rvalue ref-qualifier */
55+
predicate isRValueRefQualified() { hasSpecifier("&&") }
56+
57+
/** Holds if this declaration has a ref-qualifier */
58+
predicate isRefQualified() { isLValueRefQualified() or isRValueRefQualified() }
59+
5160
/** Holds if this function overrides that function. */
5261
predicate overrides(MemberFunction that) {
5362
overrides(underlyingElement(this), unresolveElement(that))

cpp/ql/test/library-tests/clang_ms/element.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
| clang_ms.cpp:17:1:17:32 | #pragma |
2727
| clang_ms.cpp:18:1:18:31 | #pragma |
2828
| file://:0:0:0:0 | |
29+
| file://:0:0:0:0 | & |
30+
| file://:0:0:0:0 | && |
2931
| file://:0:0:0:0 | (global namespace) |
3032
| file://:0:0:0:0 | (unnamed parameter 0) |
3133
| file://:0:0:0:0 | (unnamed parameter 0) |

cpp/ql/test/library-tests/conditions/elements.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
| file://:0:0:0:0 | |
2+
| file://:0:0:0:0 | & |
3+
| file://:0:0:0:0 | && |
24
| file://:0:0:0:0 | (global namespace) |
35
| file://:0:0:0:0 | (unnamed parameter 0) |
46
| file://:0:0:0:0 | (unnamed parameter 0) |

cpp/ql/test/library-tests/templates/instantiations_functions/elements.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
| file://:0:0:0:0 | |
2+
| file://:0:0:0:0 | & |
3+
| file://:0:0:0:0 | && |
24
| file://:0:0:0:0 | (composite<int> *)... |
35
| file://:0:0:0:0 | (composite<int> *)... |
46
| file://:0:0:0:0 | (global namespace) |

cpp/ql/test/library-tests/unnamed/elements.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
| file://:0:0:0:0 | | Other |
2+
| file://:0:0:0:0 | & | Other |
3+
| file://:0:0:0:0 | && | Other |
24
| file://:0:0:0:0 | (global namespace) | Other |
35
| file://:0:0:0:0 | (unnamed global/namespace variable) | Other |
46
| file://:0:0:0:0 | _Complex __float128 | Other |

0 commit comments

Comments
 (0)