Skip to content

Commit 93535d1

Browse files
committed
C++: Add tests for new builtin operations
1 parent 3d959ab commit 93535d1

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

cpp/ql/test/library-tests/builtins/type_traits/clang.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// semmle-extractor-options: --clang --clang_version 190000
1+
// semmle-extractor-options: --clang --clang_version 210000
22

33
struct S {
44
void f() {}
@@ -121,3 +121,11 @@ bool b_is_scoped_enum2 = __is_scoped_enum(int);
121121

122122
bool b_is_trivially_relocatable1 = __is_trivially_relocatable(int);
123123
bool b_is_trivially_relocatable2 = __is_trivially_relocatable(void);
124+
125+
struct S3{
126+
S3(S3 &);
127+
S3& operator=(S3&);
128+
};
129+
130+
bool bok_is_bitwise_cloneable1 = __is_bitwise_cloneable(int);
131+
bool bok_is_bitwise_cloneable2 = __is_bitwise_cloneable(S3);

cpp/ql/test/library-tests/builtins/type_traits/expr.expected

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,10 @@
165165
| clang.cpp:122:36:122:66 | int | | <none> |
166166
| clang.cpp:123:36:123:67 | __is_trivially_relocatable | void | 0 |
167167
| clang.cpp:123:36:123:67 | void | | <none> |
168+
| clang.cpp:130:34:130:60 | __is_bitwise_cloneable | int | 1 |
169+
| clang.cpp:130:34:130:60 | int | | <none> |
170+
| clang.cpp:131:34:131:59 | S3 | | <none> |
171+
| clang.cpp:131:34:131:59 | __is_bitwise_cloneable | S3 | 0 |
168172
| file://:0:0:0:0 | 0 | | 0 |
169173
| file://:0:0:0:0 | 0 | | 0 |
170174
| file://:0:0:0:0 | 1 | | 1 |
@@ -211,6 +215,16 @@
211215
| gcc.cpp:29:45:29:93 | __reference_converts_from_temporary | int &&,int && | 0 |
212216
| gcc.cpp:29:45:29:93 | int && | | <none> |
213217
| gcc.cpp:29:45:29:93 | int && | | <none> |
218+
| gcc.cpp:33:24:33:45 | __is_invocable | f_type | 1 |
219+
| gcc.cpp:33:24:33:45 | f_type | | <none> |
220+
| gcc.cpp:34:24:34:51 | __is_invocable | f_type,bool | 0 |
221+
| gcc.cpp:34:24:34:51 | bool | | <none> |
222+
| gcc.cpp:34:24:34:51 | f_type | | <none> |
223+
| gcc.cpp:36:32:36:61 | __is_nothrow_invocable | f_type | 1 |
224+
| gcc.cpp:36:32:36:61 | f_type | | <none> |
225+
| gcc.cpp:37:32:37:67 | __is_nothrow_invocable | f_type,bool | 0 |
226+
| gcc.cpp:37:32:37:67 | bool | | <none> |
227+
| gcc.cpp:37:32:37:67 | f_type | | <none> |
214228
| ms.cpp:38:41:38:45 | 0 | | 0 |
215229
| ms.cpp:88:27:88:45 | __has_assign | empty | 0 |
216230
| ms.cpp:88:27:88:45 | empty | | <none> |

cpp/ql/test/library-tests/builtins/type_traits/gcc.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// semmle-extractor-options: --gnu_version 130000
1+
// semmle-extractor-options: --gnu_version 150000
22

33
__attribute__ ((aligned(8))) int v;
44
bool b_has_attribute1 = __builtin_has_attribute(v, aligned);
@@ -27,3 +27,11 @@ bool b_reference_constructs_from_temporary2 = __reference_constructs_from_tempor
2727

2828
bool b_reference_converts_from_temporary1 = __reference_converts_from_temporary(int&&, int);
2929
bool b_reference_converts_from_temporary2 = __reference_converts_from_temporary(int&&, int&&);
30+
31+
using f_type = void(*)() noexcept;
32+
33+
bool b_is_invocable1 = __is_invocable(f_type);
34+
bool b_is_invocable2 = __is_invocable(f_type, bool);
35+
36+
bool b_is_nothrow_invocable1 = __is_nothrow_invocable(f_type);
37+
bool b_is_nothrow_invocable2 = __is_nothrow_invocable(f_type, bool);

0 commit comments

Comments
 (0)