Skip to content

Commit 1c9f5b8

Browse files
authored
Merge pull request github#15300 from github/sashabu/uuidof
C++: Add a test with `__uuidof` in a template.
2 parents 42f6dbe + 3493252 commit 1c9f5b8

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

cpp/ql/test/library-tests/literals/uuidof/uuidof.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,9 @@ void GetUUID() {
1717
uuid = __uuidof(s);
1818
uuid = __uuidof(0);
1919
}
20+
21+
template <typename Placeholder, typename ...>
22+
auto Wrapper = __uuidof(Placeholder);
23+
auto inst = Wrapper<S>;
24+
2025
// semmle-extractor-options: --microsoft

cpp/ql/test/library-tests/literals/uuidof/uuidof.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ uuidofOperators
1212
| uuidof.cpp:15:12:15:29 | __uuidof(S) | const _GUID | 01234567-89ab-cdef-0123-456789abcdef |
1313
| uuidof.cpp:17:12:17:22 | __uuidof(S) | const _GUID | 01234567-89ab-cdef-0123-456789abcdef |
1414
| uuidof.cpp:18:12:18:22 | __uuidof(0) | const _GUID | 00000000-0000-0000-0000-000000000000 |
15+
| uuidof.cpp:22:16:22:36 | __uuidof(Placeholder) | const _GUID | |
16+
| uuidof.cpp:22:16:22:36 | __uuidof(S) | const _GUID | 01234567-89ab-cdef-0123-456789abcdef |

cpp/ql/test/library-tests/literals/uuidof/uuidof.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ query predicate classUuids(Class cls, string uuid) {
55
}
66

77
query predicate uuidofOperators(UuidofOperator op, string type, string uuid) {
8-
uuid = op.getValue() and
8+
(if exists(op.getValue()) then uuid = op.getValue() else uuid = "") and
99
type = op.getType().toString()
1010
}

0 commit comments

Comments
 (0)