Skip to content

Commit 07fa55f

Browse files
authored
Merge pull request #1647 from zlaski-semmle/zlaski/builtin-types-compatible-p
Approved by dave-bartolomeo
2 parents 9e8e630 + 075e4ab commit 07fa55f

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

cpp/ql/src/semmle/code/cpp/exprs/BuiltInOperations.qll

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,15 @@ class BuiltInOperationIsUnion extends BuiltInOperation, @isunionexpr {
210210
}
211211

212212
/**
213-
* A C++ `__builtin_types` expression (used by some implementations of the type_traits header).
213+
* DEPRECATED: Use `BuiltInOperationBuiltInTypesCompatibleP` instead.
214214
*/
215-
class BuiltInOperationBuiltInTypes extends BuiltInOperation, @typescompexpr {
216-
override string toString() { result = "__builtin_types" }
215+
deprecated class BuiltInOperationBuiltInTypes = BuiltInOperationBuiltInTypesCompatibleP;
216+
217+
/**
218+
* A C++ `__builtin_types_compatible_p` expression (used by some implementations of the type_traits header).
219+
*/
220+
class BuiltInOperationBuiltInTypesCompatibleP extends BuiltInOperation, @typescompexpr {
221+
override string toString() { result = "__builtin_types_compatible_p" }
217222
}
218223

219224
/**
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
| choose_expr.c:3:13:3:42 | __builtin_choose_expr |
2+
| types.c:4:9:4:57 | __builtin_types_compatible_p |
3+
| types.c:6:16:6:65 | __builtin_types_compatible_p |
24
| varargs.c:7:5:7:32 | __builtin_va_start |
35
| varargs.c:9:13:9:37 | __builtin_va_arg |
46
| varargs.c:11:5:11:24 | __builtin_va_end |
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
int main(int argc, char **argv) {
3+
char *s;
4+
if (__builtin_types_compatible_p(__typeof__(s), long)) {
5+
puts("long");
6+
} else if (__builtin_types_compatible_p(__typeof__(s), char*)) {
7+
puts("str");
8+
}
9+
return (0);
10+
};
11+

0 commit comments

Comments
 (0)