Timm Bäder
c2a892f49a
Revert "[clang][bytecode] Implement bitcasts to floating-point values ( #114485 )"
...
This reverts commit c752efbdcc .
This broke bots:
- https://lab.llvm.org/buildbot/#/builders/13/builds/3268
- https://lab.llvm.org/buildbot/#/builders/42/builds/1718
2024-11-02 01:54:38 +01:00
Timm Baeder
c752efbdcc
[clang][bytecode] Implement bitcasts to floating-point values ( #114485 )
2024-11-01 14:58:19 +01:00
Timm Baeder
1e19f0f9d9
[clang][bytecode] Implement IntegralAP bitcasting ( #114471 )
...
Only for full-byte bitwidths for now.
2024-11-01 09:15:05 +01:00
Timm Baeder
ef2a104c94
[clang][bytecode] Start implementing __builtin_bit_cast ( #112126 )
...
This is a subset of #68288 , with hopefully narrower scope. It does not
support bitcasting to non-integral types yet.
Bitfields are supported, but only if they result in a full byte-sized
final buffer. It does not support casting from null-pointers yet or
casting from indeterminate bits.
The tests are from #68288 and partially from #74775 .
The `BitcastBuffer` struct is currently always working in single bits,
but I plan to (try to) optimize this for the common full-byte case.
2024-10-31 18:09:40 +01:00
Timm Baeder
ccb7cc319f
[clang][bytecode] Diagnose negative array sizes differently ( #114380 )
...
We have a special diagnostic ID for this.
2024-10-31 10:59:53 +01:00
Timm Baeder
f0b9a0ba06
[clang][bytecode] Diagnose delete with non-virtual dtor ( #114373 )
...
... in the base class.
2024-10-31 10:13:40 +01:00
Timm Baeder
87b6ec3be6
[clang][bytecode] Diagnose placement-new construction to inactive field ( #114047 )
...
We can reuse CheckActive() for this.
2024-10-29 15:08:41 +01:00
Timm Baeder
9ae41c24b3
[clang][bytecode] Create dummy pointers for non-reference DeclRefExprs ( #113202 )
...
... with non-constant initializers.
2024-10-22 10:38:13 +02:00
Timm Baeder
159f253017
[clang][bytecode] Diagnose invalid declrefs differently if we've... ( #113140 )
...
... tried their initializer already. In that case, diagnose the
non-const initializer instead of the reference to a non-constexpr
variable later. This is used in a lot of openmp tests.
2024-10-21 12:07:09 +02:00
Timm Baeder
923b8eea64
[clang][bytecode] Allow ArrayElemPtr ops on null pointers ( #113132 )
...
This regresses one of the _Complex test cases a bit, but since the
diagnostic output wasn't very good here in the first place, let's ignore
it.
2024-10-21 09:52:07 +02:00
Timm Baeder
df8b785838
[clang][bytecode] Narrow pointer in UO_Deref unary operators ( #113089 )
...
Otherwise we treat this like an array element even though we should
treat it as a single object.
2024-10-21 07:51:49 +02:00
c8ef
332ac18e31
[clang] constexpr built-in abs function. ( #112539 )
...
According to [P0533R9](https://wg21.link/P0533R9 ), the C++ standard
library functions corresponding to the C macros in `[c.math.abs]` are
now `constexpr`.
To implement this feature in libc++, we must make the built-in abs
function `constexpr`. This patch adds the implementation of a
`constexpr` abs function for the current constant evaluator and the new
bytecode interpreter.
It is important to note that in 2's complement systems, the absolute
value of the most negative value is out of range. In gcc, it will result
in an out-of-range error and will not be evaluated as constants. We
follow the same approach here.
2024-10-18 19:03:50 +08:00
Timm Baeder
3eaf4a9d1a
[clang][bytecode] Check for memory leaks after destroying global scope ( #112868 )
...
The global scope we create when evaluating expressions might free some
of the dynamic memory allocations, so we can't check for memory leaks
before destroying it.
2024-10-18 13:03:13 +02:00
Timm Baeder
9d0616ce52
[clang][bytecode] Ignore explicit calls to trivial dtors ( #112841 )
...
This is what the current interpreter does as well.
2024-10-18 09:45:02 +02:00
Timm Baeder
5d08625347
[clang][bytecode] Activate pointers in Init{,Pop} ( #112832 )
2024-10-18 07:38:22 +02:00
Timm Baeder
03888a9046
[clang][bytecode] Handle non-arrays in initElem{,Pop} ( #112719 )
...
... provided the given index is 0. Skip the atIndex() in that case.
2024-10-17 19:07:47 +02:00
yronglin
8079a2c578
[clang][bytecode] Diagnose reference to non-constexpr variable of const type in C23 constexpr ( #112211 )
...
```cpp
const int V33 = 4;
const int V34 = 0;
const int V35 = 2;
constexpr int V36 = V33 / V34;
// expected-error@-1 {{constexpr variable 'V36' must be initialized by a constant expression}}
constexpr int V37 = V33 / V35;
// expected-error@-1 {{constexpr variable 'V37' must be initialized by a constant expression}}
```
---------
Signed-off-by: yronglin <yronglin777@gmail.com >
2024-10-16 00:11:12 +08:00
Timm Baeder
51d0e40c2e
[clang][bytecode] Fix __builtin_convertvector with float-cast ( #112238 )
...
Comparing their PrimTypes isn't enough in this case. We can have a
floating cast here as well.
2024-10-15 07:49:55 +02:00
Timm Baeder
ff04bb8f40
[clang][bytecode] Use PredefinedExpr as base for its variable ( #111956 )
...
This fixes the error message generated.
2024-10-11 09:31:49 +02:00
Timm Baeder
36b0707767
[clang][bytecode] Return an lvalue path for dummy pointers ( #111862 )
...
Not doing this is wrong in general and we need to reject expressions
where it would matter differently.
2024-10-11 05:58:25 +02:00
Timm Baeder
55d51dd9dc
[clang][bytecode] Fix temporary lvalue base expression ( #111808 )
...
We need to use the MaterializeTemporaryExpr here so the checks in
ExprConstant.cpp do the right thing.
2024-10-10 14:10:38 +02:00
Timm Baeder
f93258e4ac
[clang][bytecode] Diagnose class-specific operator delete calls ( #111700 )
2024-10-10 08:40:14 +02:00
Timm Baeder
e637a5c9fe
[clang][bytecode] Only allow lossless ptr-to-int casts ( #111669 )
...
Only allow those casts if the bitwidth of the two types match.
2024-10-09 17:13:22 +02:00
Timm Baeder
fed8695bb8
[clang][bytecode] Emit better diagnostic for invalid shufflevector index ( #111643 )
2024-10-09 09:56:37 +02:00
Timm Bäder
020b8e8f8d
[clang][test] Remove a broken bytecode test
...
See e.g. https://lab.llvm.org/buildbot/#/builders/13/builds/2705
Looks like the expected value is legitimately sometimes 0.
I'll add another test back later.
2024-10-05 18:46:21 +02:00
Timm Baeder
c57418037a
[clang][bytecode] Handle UETT_OpenMPRequiredSimdAlign ( #111259 )
2024-10-05 18:04:06 +02:00
Timm Baeder
55c70f6d89
[clang][bytecode] Check GetPtrBase ops for null pointers ( #110673 )
2024-10-01 17:09:26 +02:00
Timm Baeder
3c85102756
[clang][bytecode] Handle DiscardResult for fixed-point literals ( #110475 )
2024-09-30 12:42:18 +02:00
Timm Baeder
5c811ccc4d
[clang][bytecode] Implement more binary operators for fixed point types ( #110423 )
2024-09-29 17:36:17 +02:00
Timm Baeder
95ce78b742
[clang][bytecode] Implement fixed-point-to-int casts ( #110417 )
...
And some cleanups around overflow handling.
2024-09-29 13:31:44 +02:00
Timm Baeder
1714b11384
[clang][bytcode] Convert Fixed Point values to target semantics... ( #110411 )
...
... after a binary operation. The Result of the operation is in the
common semantics of RHS and LHS, so we need to convert that to the
semantics of the BinaryOperator expression.
2024-09-29 10:01:21 +02:00
Timm Baeder
c2a37e41b9
[clang][bytecode] Implement fixed point casts ( #110409 )
2024-09-29 08:58:21 +02:00
Timm Baeder
defead4d2d
[clang][bytecode] Implement fixed-point add ( #110405 )
2024-09-29 07:13:17 +02:00
Timm Baeder
3a5b9da115
[clang][bytecode] Implement fixed-point-to-float casts ( #110369 )
2024-09-28 19:11:49 +02:00
Timm Baeder
6cbd8a3094
[clang][bytecode] Implement floating-to-fixed-point casts ( #110361 )
2024-09-28 17:24:28 +02:00
Timm Baeder
6b62e04e30
[clang][bytecode] Implement (N)EQ between fixed point and integral ( #110358 )
...
Convert the non-fixed-point side to a fixed-point type before doing the
comparison.
2024-09-28 15:38:33 +02:00
Timm Baeder
641b4d5370
[clang][bytecode] Implement integral-to-fixed-point casts ( #110350 )
2024-09-28 13:10:23 +02:00
Timm Baeder
6fd870bf35
[clang][bytecode] Implement zero-init for fixed point types ( #110257 )
2024-09-27 18:29:34 +02:00
Timm Baeder
d9b377d8b1
[clang][bytecode] Don't produce a null type when checking new exprs ( #110252 )
...
getType() might give us the right type already, so use that instead of
calling getPointeeType() for all CXXNewExprs.
2024-09-27 17:48:43 +02:00
Timm Baeder
581c015ed0
[clang][bytecode] Implement fixed point negation ( #110237 )
2024-09-27 13:29:14 +02:00
Timm Baeder
048bc67276
[clang][bytecode] Start implementing fixed point types ( #110216 )
...
Add the primitive type and implement to-bool casts.
2024-09-27 11:32:43 +02:00
Timm Baeder
09cd5a8673
[clang][bytecode] Refuse to contruct objects with virtual bases ( #110142 )
2024-09-27 05:56:12 +02:00
Richard Smith
d8a2815903
[clang] implement current direction of CWG2765 for string literal comparisons in constant evaluation ( #109208 )
...
Track the identity of each string literal object produced by evaluation
with a global version number. Accept comparisons between literals of the
same version, and between literals of different versions that cannot
possibly be placed in overlapping storage. Treat the remaining
comparisons as non-constant.
---------
Co-authored-by: Timm Baeder <tbaeder@redhat.com >
Co-authored-by: Aaron Ballman <aaron@aaronballman.com >
2024-09-26 15:56:33 -07:00
Timm Baeder
3ea55d3cb0
[clang][bytecode] Add a source location to destructor calls ( #110121 )
...
The added test case is still diagnosed differently, but I'm not sure
which version is better.
2024-09-26 16:50:56 +02:00
Timm Baeder
82ce8296b8
[clang][bytecode] Don't call dtors of anonymous unions ( #110087 )
2024-09-26 12:50:53 +02:00
Timm Baeder
4bd3a62cd6
[clang][bytecode] Fix diagnosing std::construct_at with wrong type ( #109828 )
...
We can't make the assumption that types are always fine in std
functions.
2024-09-25 08:00:32 +02:00
Timm Baeder
4b96400240
[clang][bytecode] Allow placement-new in std functions pre-C++26 ( #109753 )
2024-09-24 10:28:54 +02:00
Timm Baeder
e4d34261f8
[clang][bytecode] Ignore CPointerToObjCPointerCasts ( #109760 )
2024-09-24 10:18:33 +02:00
Timm Baeder
c712ab829b
[clang][bytecode] Implement placement-new ( #107033 )
...
If we have a placement-new destination already, use that instead of
allocating a new one.
Tests are partially based on
`test/SemaCXX/cxx2c-constexpr-placement-new.cpp`.
2024-09-23 13:26:49 +02:00
Timm Bäder
bad544461a
[clang][bytecode][NFC] Remove an outdated comment
2024-09-23 11:54:00 +02:00