Timm Bäder
498757e710
[clang][Interp][NFC] Fix initializing union APValues
...
The InitElem op assumes an array.
2024-06-19 18:31:25 +02:00
Timm Baeder
4d7d45e8ba
[clang][Interp] Implement complex division ( #94892 )
...
Share the implementation with the current interpreter.
2024-06-18 13:49:02 +02:00
Timm Bäder
4b4aaf1e79
[clang][Interp] Fix non-initializing CK_VectorSplat casts
...
Create the usual local variable to fill.
2024-06-18 09:05:28 +02:00
Timm Bäder
18000feec0
[clang][Interp][NFC] Reject non-floating CK_FloatingCast casts
...
We need the types to be floating types. Rejecting the HLSL vector
casts here is also what the current interpreter does.
2024-06-18 08:30:43 +02:00
Timm Bäder
2d38becda8
[clang][Interp][NFC] Don't create variables in non-constant contexts
...
When the evaluation in a contant context fails, we would otherwise try
to access and use that variable later in a (maybe) non-constant context.
If the evaluation succeeds in the non-constant context, we never
reported success because we reported failure from the first time
we visited the variable.
2024-06-18 08:30:43 +02:00
Timm Baeder
4bf160e396
[clang][Interp] Implement Complex-complex multiplication ( #94891 )
...
Share the implementation for floating-point complex-complex
multiplication with the current interpreter. This means we need a new
opcode for this, but there's no good way around that.
2024-06-17 16:07:58 +02:00
Timm Bäder
8e95454158
[clang][Interp] Support ExtVectorElementExprs
2024-06-15 15:12:36 +02:00
Timm Bäder
3e8f2170bb
[clang][Interp][NFC] Handle AddressSpaceConversion casts
...
Ignore them. No test yet, but this will be useful in a future commit.
2024-06-15 15:12:35 +02:00
Timm Bäder
904c53d53e
[clang][Interp] Use different inline descriptors for global variables
...
Most of the InlineDescriptor fields were unused for global variables.
But more importantly, we need to differentiate between global variables
that are uninitialized because they didn't have an initializer when we
originally created them, and ones that are uninitialized because they
DID have an initializer, but evaluating it failed.
2024-06-15 05:41:59 +02:00
Timm Bäder
ae73706075
[clang][Interp] Fix references to objects
...
The previous commit tried to handle this in a way that's too general.
Move the !Initializing case down to the array type.
2024-06-13 15:31:24 +02:00
Timm Bäder
ffab938f50
[clang][Interp] Handle BooleanToSignedIntegral casts
2024-06-13 13:49:20 +02:00
Timm Bäder
5563d914a7
[clang][Interp] Prepare return value for composite InitListExprs
2024-06-13 12:34:11 +02:00
Timm Bäder
64c9a1e126
[clang][Interp] Also revisit references to const types
...
Neither isConstant() not isConstQualified() return true for these.
2024-06-13 06:55:07 +02:00
Vitaly Buka
682d461d5a
Revert " ✨ [Sema, Lex, Parse] Preprocessor embed in C and C++ (and Obj-C and Obj-C++ by-proxy)" ( #95299 )
...
Reverts llvm/llvm-project#68620
Introduce or expose a memory leak and UB, see llvm/llvm-project#68620
2024-06-12 13:14:26 -07:00
Timm Bäder
8ad82b419b
[clang][Interp] Fix re-visiting OpenCL variables of in constant AS
...
We need to use isConstant() here, isConstQualified() is not enough.
2024-06-12 09:53:33 +02:00
The Phantom Derpstorm
5989450e00
[clang][Sema, Lex, Parse] Preprocessor embed in C and C++ (and Obj-C and Obj-C++ by-proxy) ( #68620 )
...
This commit implements the entirety of the now-accepted [N3017 -
Preprocessor
Embed](https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3017.htm ) and
its sister C++ paper [p1967](https://wg21.link/p1967 ). It implements
everything in the specification, and includes an implementation that
drastically improves the time it takes to embed data in specific
scenarios (the initialization of character type arrays). The mechanisms
used to do this are used under the "as-if" rule, and in general when the
system cannot detect it is initializing an array object in a variable
declaration, will generate EmbedExpr AST node which will be expanded
by AST consumers (CodeGen or constant expression evaluators) or
expand embed directive as a comma expression.
---------
Co-authored-by: Aaron Ballman <aaron@aaronballman.com>
Co-authored-by: cor3ntin <corentinjabot@gmail.com>
Co-authored-by: H. Vetinari <h.vetinari@gmx.com>
Co-authored-by: Podchishchaeva, Mariya <mariya.podchishchaeva@intel.com>
2024-06-12 09:16:02 +02:00
Timm Bäder
93d4fb032e
[clang][Interp] Support floats in APValues
2024-06-12 08:15:36 +02:00
Timm Bäder
4cf607fa15
[clang][Interp] Fix visiting non-FieldDecl MemberExprs
...
Ignore the base and visit the Member decl like a regular DeclRefExpr.
2024-06-11 18:13:28 +02:00
Timm Bäder
e805b77107
[clang][Interp] Support ObjCEncodeExprs
2024-06-11 15:07:28 +02:00
Timm Bäder
529b43c1fd
[clang][Interp] Refine diagnostics for casts from void*
...
This is still not perfect, but an improvement in general.
2024-06-11 11:19:06 +02:00
Timm Bäder
c0b65a2491
[clang][Interp] Diagnose casts from void pointers
2024-06-10 10:18:57 +02:00
Timm Bäder
5bb9c08d88
[clang][Interp] Reject compound assign operators pre-C++14
2024-06-09 14:58:21 +02:00
Timm Bäder
69cd2d288d
[clang][Interp] Handle __extension__ for complex values
2024-06-09 14:29:12 +02:00
Timm Bäder
cb8e9360d8
[clang][Interp] Implement ~ operator for complex values
2024-06-09 14:29:12 +02:00
Timm Bäder
b8cc85b318
[clang][Interp] Limit lambda capture lazy visting to actual captures
...
Check this by looking at the VarDecl.
2024-06-07 13:29:23 +02:00
Timm Bäder
3a31eaeac8
[clang][Interp] Fix refers_to_enclosing_variable_or_capture DREs
...
They do not count into lambda captures, so visit them lazily.
2024-06-07 11:48:44 +02:00
Timm Bäder
c15b86731b
[clang][Interp][NFC] Add GetPtrFieldPop opcode
...
And change the previous GetPtrField to only peek() the base pointer.
We can get rid of a whole bunch of DupPtr ops this way.
2024-06-07 09:40:26 +02:00
Timm Bäder
0b8acc06c4
[clang][Interp] Improve APValue machinery
...
Handle lvalues pointing to declarations, unions and member pointers.
2024-06-07 08:16:39 +02:00
Timm Baeder
a86c1e7175
[clang][Interp] Member Pointers ( #91303 )
...
This adds a `MemberPointer` class along with a `PT_MemberPtr` primitive
type.
A `MemberPointer` has a `Pointer` Base as well as a `Decl*` (could be
`ValueDecl*`?) decl it points to.
For the actual logic, this mainly changes the way we handle `PtrMemOp`s
in `VisitBinaryOperator`.
2024-06-06 11:17:48 +02:00
Timm Bäder
f1e78f7769
[clang][Interp] Handle lvalue APValues in visitAPValueInitializer()
2024-06-06 10:24:26 +02:00
Timm Bäder
1ea568895a
[clang][Interp][NFC] Mark failed globals as uninitialized
...
This happens automatically if anything _before_ the Ret op fails,
but in this case we have to un-initialize it again.
2024-06-05 13:10:18 +02:00
Timm Bäder
49b760ff2c
[clang][Interp] Fix calling virtual CXXOperatorCallExprs
2024-05-27 16:01:30 +02:00
Timm Bäder
6a197b35db
[clang][Interp] Fix returning references to functions
...
Previously, we pushed a pointer to the stack and later tried to use
it as if it was a function pointer, which doesn't work.
2024-05-27 15:43:12 +02:00
Timm Bäder
4447461bc4
[clang][Interp] Don't try to dereference a null type
2024-05-27 12:59:25 +02:00
Timm Bäder
d0bb917390
[clang][Interp] Handle ObjCBoxedExprs
2024-05-26 10:50:45 +02:00
Timm Bäder
5220b7bea8
[clang][Interp] Handle objc strings
2024-05-26 10:50:44 +02:00
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