C++: Support __is_aggregate builtin

Fix some whitespace issues while here.
This commit is contained in:
Jeroen Ketema
2022-07-26 12:34:47 +02:00
parent c4283dd23f
commit 0c03935437
4 changed files with 34 additions and 11 deletions

View File

@@ -173,7 +173,7 @@ class BuiltInOperationHasAssign extends BuiltInOperation, @hasassignexpr {
* *
* Returns `true` if the type has a copy constructor. * Returns `true` if the type has a copy constructor.
* ``` * ```
* std::integral_constant< bool, __has_copy(_Tp)> hc; * std::integral_constant<bool, __has_copy(_Tp)> hc;
* ``` * ```
*/ */
class BuiltInOperationHasCopy extends BuiltInOperation, @hascopyexpr { class BuiltInOperationHasCopy extends BuiltInOperation, @hascopyexpr {
@@ -189,7 +189,7 @@ class BuiltInOperationHasCopy extends BuiltInOperation, @hascopyexpr {
* Returns `true` if a copy assignment operator has an empty exception * Returns `true` if a copy assignment operator has an empty exception
* specification. * specification.
* ``` * ```
* std::integral_constant< bool, __has_nothrow_assign(_Tp)> hnta; * std::integral_constant<bool, __has_nothrow_assign(_Tp)> hnta;
* ``` * ```
*/ */
class BuiltInOperationHasNoThrowAssign extends BuiltInOperation, @hasnothrowassign { class BuiltInOperationHasNoThrowAssign extends BuiltInOperation, @hasnothrowassign {
@@ -220,7 +220,7 @@ class BuiltInOperationHasNoThrowConstructor extends BuiltInOperation, @hasnothro
* *
* Returns `true` if the copy constructor has an empty exception specification. * Returns `true` if the copy constructor has an empty exception specification.
* ``` * ```
* std::integral_constant< bool, __has_nothrow_copy(MyType) >; * std::integral_constant<bool, __has_nothrow_copy(MyType) >;
* ``` * ```
*/ */
class BuiltInOperationHasNoThrowCopy extends BuiltInOperation, @hasnothrowcopy { class BuiltInOperationHasNoThrowCopy extends BuiltInOperation, @hasnothrowcopy {
@@ -266,7 +266,7 @@ class BuiltInOperationHasTrivialConstructor extends BuiltInOperation, @hastrivia
* *
* Returns true if the type has a trivial copy constructor. * Returns true if the type has a trivial copy constructor.
* ``` * ```
* std::integral_constant< bool, __has_trivial_copy(MyType) > htc; * std::integral_constant<bool, __has_trivial_copy(MyType)> htc;
* ``` * ```
*/ */
class BuiltInOperationHasTrivialCopy extends BuiltInOperation, @hastrivialcopy { class BuiltInOperationHasTrivialCopy extends BuiltInOperation, @hastrivialcopy {
@@ -468,7 +468,7 @@ class BuiltInOperationIsUnion extends BuiltInOperation, @isunionexpr {
* ``` * ```
* template<typename _Tp1, typename _Tp2> * template<typename _Tp1, typename _Tp2>
* struct types_compatible * struct types_compatible
* : public integral_constant<bool, __builtin_types_compatible_p(_Tp1, _Tp2) > * : public integral_constant<bool, __builtin_types_compatible_p(_Tp1, _Tp2)>
* { }; * { };
* ``` * ```
*/ */
@@ -547,7 +547,7 @@ class BuiltInOperationBuiltInAddressOf extends UnaryOperation, BuiltInOperation,
* ``` * ```
* template<typename T, typename... Args> * template<typename T, typename... Args>
* struct is_trivially_constructible * struct is_trivially_constructible
* : public integral_constant<bool, __is_trivially_constructible(T, Args...) > * : public integral_constant<bool, __is_trivially_constructible(T, Args...)>
* { }; * { };
* ``` * ```
*/ */
@@ -701,7 +701,7 @@ class BuiltInOperationIsTriviallyCopyable extends BuiltInOperation, @istrivially
* *
* ``` * ```
* template <typename _Tp> * template <typename _Tp>
* std::integral_constant< bool, __is_literal_type(_Tp)> ilt; * std::integral_constant<bool, __is_literal_type(_Tp)> ilt;
* ``` * ```
*/ */
class BuiltInOperationIsLiteralType extends BuiltInOperation, @isliteraltypeexpr { class BuiltInOperationIsLiteralType extends BuiltInOperation, @isliteraltypeexpr {
@@ -718,7 +718,7 @@ class BuiltInOperationIsLiteralType extends BuiltInOperation, @isliteraltypeexpr
* compiler, with semantics of the `memcpy` operation. * compiler, with semantics of the `memcpy` operation.
* ``` * ```
* template <typename _Tp> * template <typename _Tp>
* std::integral_constant< bool, __has_trivial_move_constructor(_Tp)> htmc; * std::integral_constant<bool, __has_trivial_move_constructor(_Tp)> htmc;
* ``` * ```
*/ */
class BuiltInOperationHasTrivialMoveConstructor extends BuiltInOperation, class BuiltInOperationHasTrivialMoveConstructor extends BuiltInOperation,
@@ -736,7 +736,7 @@ class BuiltInOperationHasTrivialMoveConstructor extends BuiltInOperation,
* ``` * ```
* template<typename T> * template<typename T>
* struct has_trivial_move_assign * struct has_trivial_move_assign
* : public integral_constant<bool, __has_trivial_move_assign(T) > * : public integral_constant<bool, __has_trivial_move_assign(T)>
* { }; * { };
* ``` * ```
*/ */
@@ -771,7 +771,7 @@ class BuiltInOperationHasNothrowMoveAssign extends BuiltInOperation, @hasnothrow
* ``` * ```
* template<typename T, typename... Args> * template<typename T, typename... Args>
* struct is_constructible * struct is_constructible
* : public integral_constant<bool, __is_constructible(T, Args...) > * : public integral_constant<bool, __is_constructible(T, Args...)>
* { }; * { };
* ``` * ```
*/ */
@@ -935,7 +935,7 @@ class BuiltInOperationIsValueClass extends BuiltInOperation, @isvalueclassexpr {
* ``` * ```
* template<typename T> * template<typename T>
* struct is_final * struct is_final
* : public integral_constant<bool, __is_final(T) > * : public integral_constant<bool, __is_final(T)>
* { }; * { };
* ``` * ```
*/ */
@@ -991,3 +991,17 @@ class BuiltInComplexOperation extends BuiltInOperation, @builtincomplex {
/** Gets the operand corresponding to the imaginary part of the complex number. */ /** Gets the operand corresponding to the imaginary part of the complex number. */
Expr getImaginaryOperand() { this.hasChild(result, 1) } Expr getImaginaryOperand() { this.hasChild(result, 1) }
} }
/**
* A C++ `__is_aggregate` built-in operation (used by some implementations of the
* `<type_traits>` header).
*
* Returns `true` if the type has is an aggregate type.
* ```
* std::integral_constant<bool, __is_aggregate(_Tp)> ia;
* ``` */
class BuiltInOperationIsAggregate extends BuiltInOperation, @isaggregate {
override string toString() { result = "__is_aggregate" }
override string getAPrimaryQlClass() { result = "BuiltInOperationIsAggregate" }
}

View File

@@ -1651,6 +1651,7 @@ case @expr.kind of
| 328 = @co_yield | 328 = @co_yield
| 329 = @temp_init | 329 = @temp_init
| 330 = @isassignable | 330 = @isassignable
| 331 = @isaggregate
; ;
@var_args_expr = @vastartexpr @var_args_expr = @vastartexpr
@@ -1713,6 +1714,7 @@ case @expr.kind of
| @builtinchooseexpr | @builtinchooseexpr
| @builtincomplex | @builtincomplex
| @isassignable | @isassignable
| @isaggregate
; ;
new_allocated_type( new_allocated_type(

View File

@@ -305,3 +305,7 @@
| ms.cpp:260:29:260:57 | __is_assignable | a_struct,int | 0 | | ms.cpp:260:29:260:57 | __is_assignable | a_struct,int | 0 |
| ms.cpp:260:29:260:57 | a_struct | | <none> | | ms.cpp:260:29:260:57 | a_struct | | <none> |
| ms.cpp:260:29:260:57 | int | | <none> | | ms.cpp:260:29:260:57 | int | | <none> |
| ms.cpp:262:28:262:51 | __is_aggregate | a_struct | 1 |
| ms.cpp:262:28:262:51 | a_struct | | <none> |
| ms.cpp:263:28:263:46 | __is_aggregate | int | 0 |
| ms.cpp:263:28:263:46 | int | | <none> |

View File

@@ -258,4 +258,7 @@ void f(void) {
bool b_is_assignable1 = __is_assignable(a_struct,a_struct); bool b_is_assignable1 = __is_assignable(a_struct,a_struct);
bool b_is_assignable2 = __is_assignable(a_struct,empty); bool b_is_assignable2 = __is_assignable(a_struct,empty);
bool b_is_assignable3 = __is_assignable(a_struct,int); bool b_is_assignable3 = __is_assignable(a_struct,int);
bool b_is_aggregate1 = __is_aggregate(a_struct);
bool b_is_aggregate2 = __is_aggregate(int);
} }