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
Timm Baeder
898fd396b8
[clang][bytecode] Check allocation size limit for operator new ( #109590 )
2024-09-23 09:59:41 +02:00
Timm Baeder
f86050de73
[clang][bytecode] Don't call checkLiteralType() in visitInitializer() ( #109530 )
...
We were calling checkLiteralType() too many time and rejecting some
things we shouldn't. Add The calls manually when handling
MaterializeTemporaryExprs. Maybe we should call it in other places as
well, but adding more calls is easier than removing them from a generic
code path.
2024-09-21 20:01:21 +02:00
yronglin
f5a65d8752
[clang][bytecode] Implement arithmetic, bitwise and compound assignment operator ( #108949 )
...
Implement `+`, `-`, `*`, `/` , `%`, `&`, `|`, `^`, `<<`, `>>` and
compound assignment operator.
---------
Signed-off-by: yronglin <yronglin777@gmail.com >
2024-09-21 17:05:24 +08:00
Timm Baeder
5b4c80f123
[clang][bytecode] Create dummy pointers for ObjCStringLiterals ( #109520 )
...
We need to have the final APValue point to the ObjCStringLiteral
expression, not the StringLiteral itself.
2024-09-21 10:33:02 +02:00
Timm Baeder
9a32f28366
[clang][bytecode] Fix a problem with array size limits ( #109383 )
...
Descriptor::MaxArrayElemBytes is an unsigned value, which might overflow
the SizeT we have in CheckArraySize.
2024-09-20 11:26:58 +02:00
Timm Baeder
d267daa9eb
[clang][bytecode] Diagnose loads from weak variables ( #109256 )
2024-09-19 11:59:38 +02:00