Skip to content

Commit bee0f97

Browse files
committed
C++: Add support for more builtin operations
1 parent 75d1cb9 commit bee0f97

2 files changed

Lines changed: 123 additions & 0 deletions

File tree

‎cpp/ql/lib/semmle/code/cpp/exprs/BuiltInOperations.qll‎

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,21 @@ class BuiltInOperationIsBaseOf extends BuiltInOperation, @isbaseofexpr {
353353
override string getAPrimaryQlClass() { result = "BuiltInOperationIsBaseOf" }
354354
}
355355

356+
/**
357+
* A C++ `__builtin_is_virtual_base_of` built-in operation (used by some implementations of the
358+
* `<type_traits>` header).
359+
*
360+
* Returns `true` if the first type is a virtual base class of the second type.
361+
* ```
362+
* bool v = __builtin_is_virtual_base_of(MyType, OtherType);
363+
* ```
364+
*/
365+
class BuiltInOperationIsVirtualBaseOf extends BuiltInOperation, @isvirtualbaseof {
366+
override string toString() { result = "__builtin_is_virtual_base_of" }
367+
368+
override string getAPrimaryQlClass() { result = "BuiltInOperationIsVirtualBaseOf" }
369+
}
370+
356371
/**
357372
* A C++ `__is_class` built-in operation (used by some implementations of the
358373
* `<type_traits>` header).
@@ -1999,3 +2014,97 @@ class BuiltInOperationIsNothrowInvocable extends BuiltInOperation, @isnothrowinv
19992014

20002015
override string getAPrimaryQlClass() { result = "BuiltInOperationIsNothrowInvocable" }
20012016
}
2017+
2018+
/**
2019+
* A C++ `__builtin_is_implicit_lifetime` built-in operation (used by some implementations
2020+
* of the `<type_traits>` header).
2021+
*
2022+
* Returns `true` if a type `_Tp` is an implicit lifetime type.
2023+
*
2024+
* ```
2025+
* template<typename _Tp>
2026+
* constexpr bool is_implicit_lifetime = __builtin_is_implicit_lifetime(_Tp);
2027+
* ```
2028+
*/
2029+
class BuiltInOperationIsImplicitLifetime extends BuiltInOperation, @isimplicitlifetime {
2030+
override string toString() { result = "__builtin_is_implicit_lifetime" }
2031+
2032+
override string getAPrimaryQlClass() { result = "BuiltInOperationIsImplicitLifetime" }
2033+
}
2034+
2035+
/**
2036+
* A C++ `__builtin_is_structural` built-in operation (used by some implementations
2037+
* of the `<type_traits>` header).
2038+
*
2039+
* Returns `true` if a type `_Tp` is structural type.
2040+
*
2041+
* ```
2042+
* template<typename _Tp>
2043+
* constexpr bool is_structural = __builtin_is_structural(_Tp);
2044+
* ```
2045+
*/
2046+
class BuiltInOperationIsStructural extends BuiltInOperation, @isstructural {
2047+
override string toString() { result = "__builtin_is_structural" }
2048+
2049+
override string getAPrimaryQlClass() { result = "BuiltInOperationIsStructural" }
2050+
}
2051+
2052+
/**
2053+
* A C++ `__builtin_lt_synthesizes_from_spaceship` built-in operation (used by some container
2054+
* implementations).
2055+
*
2056+
* Returns `true` if the `<` operator is synthesized from the spaceship operator `<=>`.
2057+
*
2058+
* ```
2059+
* bool v = __builtin_lt_synthesizes_from_spaceship(MyType, OtherType);
2060+
*/
2061+
class BuiltInOperationLtSynthesizesFromSpaceship extends BuiltInOperation, @ltsynthesizesfromspaceship {
2062+
override string toString() { result = "__builtin_lt_synthesizes_from_spaceship" }
2063+
2064+
override string getAPrimaryQlClass() { result = "BuiltInOperationLtSynthesizesFromSpaceship" }
2065+
}
2066+
2067+
/**
2068+
* A C++ `__builtin_gt_synthesizes_from_spaceship` built-in operation (used by some container
2069+
* implementations).
2070+
*
2071+
* Returns `true` if the `>` operator is synthesized from the spaceship operator `<=>`.
2072+
*
2073+
* ```
2074+
* bool v = __builtin_gt_synthesizes_from_spaceship(MyType, OtherType);
2075+
*/
2076+
class BuiltInOperationGtSynthesizesFromSpaceship extends BuiltInOperation, @gtsynthesizesfromspaceship {
2077+
override string toString() { result = "__builtin_gt_synthesizes_from_spaceship" }
2078+
2079+
override string getAPrimaryQlClass() { result = "BuiltInOperationGtSynthesizesFromSpaceship" }
2080+
}
2081+
2082+
/**
2083+
* A C++ `__builtin_le_synthesizes_from_spaceship` built-in operation (used by some container
2084+
* implementations).
2085+
*
2086+
* Returns `true` if the `<=` operator is synthesized from the spaceship operator `<=>`.
2087+
*
2088+
* ```
2089+
* bool v = __builtin_le_synthesizes_from_spaceship(MyType, OtherType);
2090+
*/
2091+
class BuiltInOperationLeSynthesizesFromSpaceship extends BuiltInOperation, @lesynthesizesfromspaceship {
2092+
override string toString() { result = "__builtin_le_synthesizes_from_spaceship" }
2093+
2094+
override string getAPrimaryQlClass() { result = "BuiltInOperationLeSynthesizesFromSpaceship" }
2095+
}
2096+
2097+
/**
2098+
* A C++ `__builtin_ge_synthesizes_from_spaceship` built-in operation (used by some container
2099+
* implementations).
2100+
*
2101+
* Returns `true` if the `>=` operator is synthesized from the spaceship operator `<=>`.
2102+
*
2103+
* ```
2104+
* bool v = __builtin_ge_synthesizes_from_spaceship(MyType, OtherType);
2105+
*/
2106+
class BuiltInOperationGeSynthesizesFromSpaceship extends BuiltInOperation, @gesynthesizesfromspaceship {
2107+
override string toString() { result = "__builtin_ge_synthesizes_from_spaceship" }
2108+
2109+
override string getAPrimaryQlClass() { result = "BuiltInOperationGeSynthesizesFromSpaceship" }
2110+
}

‎cpp/ql/lib/semmlecode.cpp.dbscheme‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2004,6 +2004,13 @@ case @expr.kind of
20042004
| 394 = @isinvocable
20052005
| 395 = @isnothrowinvocable
20062006
| 396 = @isbitwisecloneable
2007+
| 397 = @isvirtualbaseof
2008+
| 398 = @isimplicitlifetime
2009+
| 399 = @ltsynthesizesfromspaceship
2010+
| 400 = @gtsynthesizesfromspaceship
2011+
| 401 = @lesynthesizesfromspaceship
2012+
| 402 = @gesynthesizesfromspaceship
2013+
| 403 = @isstructural
20072014
;
20082015

20092016
@var_args_expr = @vastartexpr
@@ -2123,6 +2130,13 @@ case @expr.kind of
21232130
| @isinvocable
21242131
| @isnothrowinvocable
21252132
| @isbitwisecloneable
2133+
| @isvirtualbaseof
2134+
| @isimplicitlifetime
2135+
| @ltsynthesizesfromspaceship
2136+
| @gtsynthesizesfromspaceship
2137+
| @lesynthesizesfromspaceship
2138+
| @gesynthesizesfromspaceship
2139+
| @isstructural
21262140
;
21272141

21282142
compound_requirement_is_noexcept(

0 commit comments

Comments
 (0)