387 Commits

Author SHA1 Message Date
Timm Bäder
5c40db1da3 [clang][Interp] Don't retry weak declarations 2024-05-24 20:00:54 +02:00
Timm Bäder
f35aac6991 [clang][Interp] Fix zero-initializing unions
Only with primitive fields for now.
2024-05-24 15:15:40 +02:00
Timm Bäder
45a95c3c54 [clang][Interp] Fix DeclRefExprs of void-typed dummy pointers 2024-05-23 11:56:23 +02:00
Timm Bäder
10dc3a8e91 [clang][Interp] Fix empty InitListExprs for unions
We still need to handle Inits.size() == 0, but we can do that earlier.
2024-05-23 11:48:33 +02:00
Timm Bäder
af6812085c [clang][Interp] Fix initializing a union from an InitLIstExpr
We can't just count the field to initialize but need to consult the
InitListExpr to give us the right field.
2024-05-23 09:17:56 +02:00
Timm Bäder
4fbc95d136 [clang][Interp] Skip union members in default initializers 2024-05-22 17:57:00 +02:00
Timm Bäder
18e7bcbae1 [clang][Interp] Reject inc/dec ops before C++ 14 2024-05-21 13:20:42 +02:00
Timm Bäder
a7521fd162 [clang][Interp] Implement __builtin_sycl_unique_stable_name 2024-05-21 13:20:42 +02:00
Timm Bäder
d9c27cafdb [clang][Interp] Fix discarding construct exprs with zero initializers
We need to create the temporary earlier so the
visitZeroRecordInitializer() call has access to it.
2024-05-21 12:51:30 +02:00
Timm Bäder
808fc84069 [clang][Interp] Fix dummy DeclRefExprs for function pointers 2024-05-21 12:02:19 +02:00
Timm Bäder
9d70975c7a [clang][Interp][NFC] Remove an assertion that's too strong
Both types need to boil down to a vector type with the same length
and their element types need to match, but we still can't compare
them with == since they might be sugared, etc.
2024-05-21 11:38:45 +02:00
Timm Bäder
45cc6bdea9 [clang][Interp] Implement __builtin_shufflevector 2024-05-16 08:26:59 +02:00
Timm Bäder
74218a9c8f [clang][Interp] Implement __builtin_convertvector 2024-05-15 17:40:48 +02:00
Timm Bäder
413aaf11cd [clang][Interp][NFC] Support IntAP(S) in emitPrimCast 2024-05-15 17:12:41 +02:00
Timm Bäder
afba3daf82 [clang][Interp] Add basic support for AddrLabelExprs
Just create a local variable for them.
2024-05-15 10:17:10 +02:00
Timm Bäder
257013e4f5 [clang][Interp] Handle VariableArrayTypes 2024-05-13 17:21:39 +02:00
Timm Bäder
67c18721eb [clang][Interp] Return false from visitExpr() if allocateLocal failed 2024-05-13 16:59:30 +02:00
Timm Bäder
9a521e274d [clang][Interp] Fix primitive lambda capture defaults
We need to use InitField here, not SetField.
2024-05-06 10:37:30 +02:00
Timm Bäder
aac588abfa Reapply "[clang][Interp] Fix locals created in ExprWithCleanups"
This reverts commit 427c5bfd39ebb9d008b621370579444fbf2a60d7.
2024-05-02 16:56:38 +02:00
Timm Bäder
7dfb6f571c [clang][Interp] Fix ignored RequiresExprs
Also ConceptSpecializationExpr, although I don't have a test case
at hand for those.
2024-05-02 15:47:15 +02:00
Timm Bäder
427c5bfd39 Revert "[clang][Interp] Fix locals created in ExprWithCleanups"
This reverts commit 1c7673b91d4d3bab4e296f5c67751d3879fb21a2.

Unfortunately, this one is broken because de04e6cd90b891215f1dfc83ec886d037a7c2ed0
has been reverted.
2024-05-02 14:03:48 +02:00
Timm Bäder
1c7673b91d [clang][Interp] Fix locals created in ExprWithCleanups
Save the declaration we're creating a scope for (if applicable),
so we can attach a local temporary variable to the right scope.
2024-05-02 13:51:50 +02:00
Timm Bäder
e5fb656435 [clang][Interp] Handle RecoveryExprs
Instead of checking containsErrors() for every expression, just handle
RecoveryExprs directly.
2024-05-02 13:43:06 +02:00
Timm Bäder
5d9889a6c6 [clang][Interp] Fix zero-initializing records with non-trivial ctors
We need to do the zero-init and then subsequently call the constructor.
2024-05-02 13:20:04 +02:00
Timm Bäder
af5d41e0ca [clang][Interp] Support CXXScalarValueInitExprs of vector type 2024-04-30 12:41:14 +02:00
Timm Bäder
2f9462e9e4 [clang][Interp] Fix initializing vectors from a list of other vectors 2024-04-30 12:41:14 +02:00
Timm Bäder
3590ede848 [clang][Interp] Support vec_step 2024-04-29 18:21:24 +02:00
Timm Bäder
45bd85e481 [clang][Interp] Fix casting function pointers to integers 2024-04-29 16:33:21 +02:00
Timm Bäder
e34b41c707 [clang][Interp] Support CXXParenListInitExprs for non-record types
Merge the non-record code paths into visitInitList().
2024-04-29 16:30:13 +02:00
Timm Bäder
bb770deb9a [clang][Interp] Reject void-typed InitListExprs 2024-04-29 16:30:12 +02:00
Danial Klimkin
e57b872414
Avoid unusable variable in ByteCodeExprGen.cpp (#90469)
Inline assert to avoid unusable variable warning/error when asserts are
disabled.
2024-04-29 15:23:29 +02:00
Timm Bäder
f5ed917046 [clang][Interp] Fix creating variables for TemplateParamObjectDecls
Actually initialize them with their value. While at it, fix doing
it for non-primitive (only struct so far) types as well.
2024-04-29 14:34:33 +02:00
Timm Bäder
f2452d4b68 [clang][Interp] Implement zero-init for record types 2024-04-29 13:02:31 +02:00
Timm Bäder
15f02723d4 [clang][Interp] Improve support for virtual bases
Fix initializing virtual bases. We only consider their base size,
not their virtual size because they get flattened into the Record
hierarchy when we create them. Fix that and also virtual
derived-to-base casts.
2024-04-26 11:10:45 +02:00
Timm Bäder
bc8a4ea110 [clang][Interp][NFC] Move collectBaseOffset() to Context
We will need this outside of ByteCodeExprGen later.
2024-04-26 10:21:27 +02:00
Timm Bäder
15883684a7 [clang][Interp] Fix casting pointers to int128 2024-04-22 14:39:24 +02:00
Timm Bäder
103f1be76f [clang][Interp][NFC] getRecord() might return null 2024-04-22 14:39:24 +02:00
Timm Bäder
c2d665b7ae [clang][Interp] Support ImplicitArrayInitExpr for vectors 2024-04-22 10:58:55 +02:00
Timm Bäder
0ff992e5f2 [clang][Interp][NFC] Get ComplexType directly
Instead of doing a isa<> + getAs<>
2024-04-22 10:34:43 +02:00
Timm Bäder
fd98f80f60 [clang][Interp] Finish initializing structs from CompoundLiteralExprs 2024-04-18 10:31:31 +02:00
Timm Bäder
562f061e7e [clang][Interp] Load result of pre-inc/dec operation if necessary
This can happen in C.
2024-04-18 08:30:09 +02:00
Timm Bäder
9099f6f8dc [clang][Interp] Skip unnamed bit fields in initializers
Fixes the Codegen/CSKY/csky-hard-abi.c test
2024-04-18 08:19:36 +02:00
Timm Bäder
75054525ae [clang][Interp] Implement VectorSplat casts 2024-04-16 19:31:16 +02:00
Timm Bäder
32b74ca6e4 [clang][Interp] Load value from MemberExpr if required 2024-04-16 13:04:28 +02:00
Timm Bäder
c09384e2b4 [clang][Interp] Support MemberExprs pointing to VarDecls 2024-04-16 12:34:35 +02:00
Timm Bäder
31424be3ae [clang][Interp][NFC] Compare std::optionals directly 2024-04-16 12:09:49 +02:00
Timm Bäder
58b49cef1d [clang][Interp] Support __builtin_vectorelements 2024-04-16 11:21:41 +02:00
Timm Bäder
9141e1c24f [clang][Interp] Gracefully handle bitcasts to non-primitive types
We were calling classfiyPrim() instead of classify().
2024-04-16 11:08:30 +02:00
Timm Bäder
64c3997939 [clang][Interp] Allow initializing static class members
We need to handle this when registering global variables.
2024-04-11 19:05:29 +02:00
Timm Baeder
1709eac58f
[clang][Interp] Integral pointers (#84159)
This turns the current `Pointer` class into a discriminated union of
`BlockPointer` and `IntPointer`. The former is what `Pointer` currently
is while the latter is just an integer value and an optional
`Descriptor*`.

The `Pointer` then has type check functions like
`isBlockPointer()`/`isIntegralPointer()`/`asBlockPointer()`/`asIntPointer()`,
which can be used to access its data.

Right now, the `IntPointer` and `BlockPointer` structs do not have any
methods of their own and everything is instead implemented in Pointer
(like it was before) and the functions now just either assert for the
right type or decide what to do based on it.

This also implements bitcasts by decaying the pointer to an integral
pointer.

`test/AST/Interp/const-eval.c` is a new test testing all kinds of stuff
related to this. It still has a few tests `#ifdef`-ed out but that
mostly depends on other unimplemented things like
`__builtin_constant_p`.
2024-04-10 12:53:54 +02:00