24 Commits

Author SHA1 Message Date
Timm Bäder
d56110fa02 [clang][Interp] Fix _Complex comma operators
Handle them before shelling out to visitComplexBinOp().
2024-03-18 16:02:40 +01:00
Timm Bäder
2421e76159 [clang][Interp][NFC] Add more _Complex tests 2024-03-14 14:05:33 +01:00
Timm Bäder
8aed911fe9 [clang][Interp] Implement complex comparisons 2024-03-07 17:04:05 +01:00
Timm Bäder
89e41e2965 [clang][Interp] Implement __builtin_complex 2024-03-04 17:15:42 +01:00
Timm Bäder
a5ccf8522b [clang][Interp] Not all RVO call expressions are initializing
We do not necessarily prepare storage for the return value when
we are returning a complex value.
2024-02-26 11:40:58 +01:00
Timm Bäder
15426017bd [clang][Interp] Handle non-complex operands in complex bin ops
Either LHS or RHS might be non-complex, but not both.
2024-02-26 09:08:50 +01:00
Timm Baeder
9fa18f6598
[clang][Interp] Handle complex values in visitBool() (#79452)
In C++, we get a ComplexToBool cast, but we might not in C.
2024-02-20 10:27:41 +01:00
Timm Bäder
935f7d6333 [clang][Interp][NFC] We do support complex bitint now
Remove a stale FIXME comment and improve the test.
2024-02-09 17:05:41 +01:00
Timm Bäder
28b82075ff [clang][Interp] Support ImplicitValueInitExpr for complex types
Initialize both elements to 0, once again.
2024-02-07 08:26:47 +01:00
Timm Bäder
8c84096da1 [clang][Interp] Fix initializing _Complex values from DeclRefExpr
See the comment I added. When initializing a complex value from a
DeclRefExpr, we need to manually copy both array elements.
This adds some unfortunate code duplication that I'm still pondering
on how to get rid of best.
2024-02-07 08:07:05 +01:00
Timm Baeder
e524ada6cb
[clang][Interp] Support zero init for complex types (#79728)
Initialize both elements to 0.
2024-02-05 15:56:06 +01:00
Timm Baeder
6ff431b01e
[clang][Interp] Handle imaginary literals (#79130)
Initialize the first element to 0 and the second element to the value of
the subexpression.
2024-02-01 07:13:10 +01:00
Timm Bäder
a8f317aeac [clang][Interp] complex binary operators aren't always initializing
The added test case would trigger the removed assertion.
2024-02-01 07:09:43 +01:00
Timm Baeder
32c00485f1
[clang][Interp] Handle casts between complex types (#79269)
Just handle this like two primtive casts.
2024-01-31 16:53:33 +01:00
Timm Bäder
cd0b0055a7 [clang][Interp][NFC] Add some working _Complex tests 2024-01-25 14:21:59 +01:00
Timm Baeder
8b4bb15f6d
[clang][Interp] Implement integral->complex casts (#75590)
Allocate storage for them, initialize the first member with the given
value and the second member to 0.
2024-01-19 09:27:30 +01:00
Timm Baeder
18d0a7e4c0
[clang][Interp] Implement ComplexToReal casts (#77294)
Add a new emitComplexReal() helper function and use that for the new
casts as well as the old __real implementation.
2024-01-18 13:55:04 +01:00
Timm Baeder
12e425d0cf
[clang][Interp] Support __real/__imag on primitives (#75485) 2024-01-15 16:08:22 +01:00
Timm Bäder
d16cf470ac [clang][Interp] Start implementing binary operators for complex types
Differential Revision: https://reviews.llvm.org/D155572
2023-12-14 15:33:52 +01:00
Timm Bäder
88abd530ef [clang][Interp] Allow evaluating standalone complex expressions
We reach visitExpr() when evaluating standalone expressions. However,
the RetValue() code path was unused before, because we never reach it,
even with structs or arrays.

RetValue expects a pointer on the stack it can take apart to return an
APValue, so provide it with one.

Differential Revision: https://reviews.llvm.org/D150661
2023-12-14 15:07:42 +01:00
Timm Bäder
935f5ee9c9 [clang][Interp] ComplexFloatingToBoolean casts
Differential Revision: https://reviews.llvm.org/D150654
2023-12-14 13:17:40 +01:00
Timm Bäder
497480b38a [clang][Interp] IntegralComplexToBoolean casts
Differential Revision: https://reviews.llvm.org/D148426
2023-12-14 13:11:00 +01:00
Timm Bäder
07e3c245ba [clang][Interp] Support empty initlist initializers for complex types
Differential Revision: https://reviews.llvm.org/D147369
2023-12-14 12:53:40 +01:00
Timm Bäder
797fee68d1 [clang][Interp] Start supporting complex types
Differential Revision: https://reviews.llvm.org/D146408
2023-12-14 11:57:38 +01:00