Timm Baeder
0050503b7a
[clang][bytecode] Allow right-shift of negative values ( #108987 )
...
We used to incorrectly diagnose this as a "left shift of negative
value".
2024-09-17 18:25:16 +02:00
Timm Baeder
8e2dbab242
[clang][bytecode] Fix defining extern variables ( #108940 )
...
At the point of defintion of the variable, a function might already
refert to the variable by its index. Replace the index with the new one.
2024-09-17 15:21:28 +02:00
Timm Baeder
0bc8168070
[clang][bytecode] Fix reinterpret_casts from pointer to non-pointers ( #108811 )
...
We need to be a little more careful here with whether or nor we are able
to do the cast at all or not.
2024-09-16 17:35:38 +02:00
Timm Baeder
fbf0a80153
[clang][bytecode] Implement HLSLVectorTruncation casts ( #108499 )
2024-09-13 11:32:12 +02:00
Timm Baeder
bd8d432d7b
[clang][bytecode] Add support for creating dummies for expressions ( #108394 )
...
And use that to fix VisitObjCBoxedExprs.
2024-09-12 17:25:40 +02:00
Timm Baeder
43fd2c401e
[clang][bytecode] Implement base casts on integral pointers ( #108340 )
...
Get the right offset to apply from the RecordLayout.
2024-09-12 17:19:37 +02:00
Timm Baeder
f22a8d1822
[clang][bytecode] Fix modify_global diagnostics in C++11 ( #108358 )
...
We shouldn't emit this until C++14.
2024-09-12 13:25:25 +02:00
Timm Baeder
35f7cfb224
[clang][bytecode] Check for Pointer dereference in EvaluationResult ( #108207 )
...
We will deref<>() it later, so this is the right check.
2024-09-11 16:14:41 +02:00
Timm Baeder
d03822d888
[clang][bytecode] Fix lookup of source locations in implicit ctors ( #107992 )
...
Implicit functions may still have a body. The !hasBody() check is
enough.
2024-09-11 07:21:49 +02:00
Timm Bäder
46870175c5
[clang][bytecode][NFC] Fix CallBI function signature
...
This doesn't modify the PC, so pass OpPC as a copy.
2024-09-10 13:32:25 +02:00
Timm Baeder
3928edecfb
[clang][bytecode] Fix local destructor order ( #107951 )
...
Add appropriate scopes and use reverse-order iteration in
LocalScope::emitDestructors().
2024-09-10 06:26:46 +02:00
Timm Baeder
6f67c38684
[clang][bytecode] Fix a variable scope problem with continue/break jumps ( #107738 )
...
Cleaning up _all_ the scopes is a little too much. Only clean up until
the point here we started the scope relevant for the break/continue
statement.
2024-09-08 19:22:18 +02:00
yronglin
cf11eb62e1
[clang][bytecode] Implement logical operators for vector type ( #107678 )
...
Implement `&&`, `||` logical operators for vector type.
---------
Signed-off-by: yronglin <yronglin777@gmail.com>
2024-09-08 14:04:00 +08:00
Timm Baeder
d6d60707ec
[clang][bytecode] Fix two-pointer-style std::initializer_lists ( #107682 )
...
The first pointer needs to point to the first element of the underlying
array. This requires some changes to how we handle array expansion
2024-09-07 14:27:09 +02:00
Timm Baeder
78cf9b830c
[clang][bytecode] Implement using operator new/operator delete ( #107679 )
...
Reuse the __builtin_operator_{new,delete} implementations.
2024-09-07 12:17:54 +02:00
Timm Bäder
7d4afba831
[clang][bytecode][NFC] Fix Function::getName() for non-decl functions
2024-09-07 10:56:18 +02:00
Timm Baeder
610b85395d
[clang][bytecode] Implement __builtin_operator{new,delete} ( #107672 )
2024-09-07 09:57:26 +02:00
Timm Baeder
83fea8b809
[clang][bytecode] Allow continuing when discarded MemberExpr Base fails ( #107231 )
...
We don't need the value in this case, since we're discarding it anyway.
Allow continuing the interpretation but note the side effect.
2024-09-07 09:33:27 +02:00
Timm Baeder
eef8116be1
[clang][bytecode] Only visit local variables if they have constant init ( #107576 )
...
See the comment I added for why this is weird. We might want to have a
different mechanism for this in the future.
Fixes https://github.com/llvm/llvm-project/issues/101801
2024-09-07 06:36:21 +02:00
Timm Baeder
60eb9b214c
[clang][bytecode] Fix reinterpret casts of two non-primitive types ( #107564 )
...
We don't want to allow e.g. cast from a record to an array or the other
way arround.
2024-09-07 06:16:02 +02:00
yronglin
67f9183c11
[clang][bytecode] Implement comparsion operators for vector type ( #107258 )
...
Implement ==, !=, <, <=, >, >= comparsion operators for vector type.
---------
Signed-off-by: yronglin <yronglin777@gmail.com>
2024-09-06 20:27:11 +08:00
Mital Ashok
2a07509c8d
[Clang] Add __builtin_is_within_lifetime to implement P2641R4's std::is_within_lifetime ( #91895 )
...
[P2641R4](https://wg21.link/P2641R4 )
This new builtin function is declared `consteval`. Support for
`-fexperimental-new-constant-interpreter` will be added in a later
patch.
---------
Co-authored-by: cor3ntin <corentinjabot@gmail.com>
2024-09-05 14:42:59 +02:00
Timm Baeder
f70ccdaeb4
[clang][bytecode][NFC] Move Call ops into Interp.cpp ( #107104 )
...
They are quite long and not templated.
2024-09-03 16:15:58 +02:00
Timm Baeder
0f5f440f24
[clang][bytecode] Pass FPOptions to floating point ops ( #107063 )
...
So we don't have to retrieve them from the InterpFrame, which is slow.
2024-09-03 14:24:11 +02:00
Timm Baeder
733a92d7bc
[clang][bytecode] Print Pointers via APValue ( #107056 )
...
Instead of doing this ourselves, just rely on printing the APValue.
2024-09-03 11:07:19 +02:00
Timm Baeder
a9006bffa9
[clang][bytecode] Fix zero-init of first union member ( #106962 )
...
... if done via a ImplicitValueInitExpr.
We were already doing this later in visitZeroRecordInitializer().
2024-09-02 13:51:01 +02:00
Timm Baeder
f838d6b1b2
[clang][bytecode] Implement __noop ( #106714 )
...
This does nothing and returns 0.
2024-09-02 13:50:22 +02:00
Timm Baeder
e4f3b56dae
[clang][bytecode] Fix diagnosing reads from temporaries ( #106868 )
...
Fix the DeclID not being set in global temporaries and use the same
strategy for deciding if a temporary is readable as the current
interpreter.
2024-09-01 07:40:43 +02:00
Timm Baeder
e4cf0a047d
[clang][bytecode][NFC] Check for custom typechecking in call cleanup ( #106826 )
...
The comment already explains that this is only true for _some_ builtin
functions. This also brings the time it takes me to run the
builtin-functions.cpp test locally from 50s down to 47s.
2024-08-31 08:06:06 +02:00
Timm Baeder
6f81c878ec
[clang][bytecode][NFC] Implement MemberPointer::toDiagnosticString() ( #106825 )
2024-08-31 07:26:02 +02:00
Timm Baeder
360e4abfc8
[clang][bytecode] Diagnose comparisons with literals ( #106734 )
...
This requires adding a new opcode for PointerToBoolean casts, since we
otherwise emit too many diagnostics. But that fixes an older problem
when casting weak pointers to bool.
2024-08-31 06:24:36 +02:00
Timm Baeder
3745a2e8ab
[clang][bytecode][NFC] Cache the BuiltinID in Function ( #106745 )
...
FunctionDecl::getBuiltinID() is surprisingly slow and we tend to call it
quite a bit, especially when interpreting builtin functions. Caching the
BuiltinID here reduces the time I need to compile the
floating_comparison namespace from builtin-functions.cpp from 7.2s to
6.3s locally.
2024-08-31 01:50:59 +02:00
yronglin
b294951e39
[clang][bytecode] Fix the handling of address of a vector ( #106558 )
...
The PR https://github.com/llvm/llvm-project/pull/105996 broke taking the
address of a vector:
**compound-literal.c**
```C
typedef int v4i32 __attribute((vector_size(16)));
v4i32 *y = &(v4i32){1,2,3,4};
```
That because the current interpreter handle vector unary operator as a
fallback when the generic code path fail. but the new interpreter was
not. we need to handle `UO_AddrOf` in
`Compiler<Emitter>::VisitVectorUnaryOperator`.
Signed-off-by: yronglin <yronglin777@gmail.com>
2024-08-30 17:34:00 +08:00
Timm Baeder
df11ee213e
[clang][bytecode] Diagnose member calls on deleted blocks ( #106529 )
...
This requires a bit of restructuring of ctor calls when checking for a
potential constant expression.
2024-08-29 15:22:59 +02:00
Timm Baeder
cb608cc5f6
[clang][bytecode] Properly diagnose non-const reads ( #106514 )
...
If the global variable is constant (but not constexpr), we need to
diagnose, but keep evaluating.
2024-08-29 13:44:59 +02:00
yronglin
ee0d706338
[clang][bytecode] Implement constexpr vector unary operators +, -, ~, ! ( #105996 )
...
Implement constexpr vector unary operators +, -, ~ and ! .
- Follow the current constant interpreter. All of our boolean operations
on vector types should be '-1' for the 'truth' type.
- Move the following functions from `Sema` to `ASTContext`, because we
used it in new interpreter.
```C++
QualType GetSignedVectorType(QualType V);
QualType GetSignedSizelessVectorType(QualType V);
```
---------
Signed-off-by: yronglin <yronglin777@gmail.com>
2024-08-29 06:10:30 +08:00
Timm Baeder
40db261551
[clang][bytecode] Fix #55390 here as well ( #106395 )
...
Ignore the multiplication overflow but report the 0 denominator.
2024-08-28 19:09:12 +02:00
Timm Baeder
f7a74ece5a
[clang][bytecode] Diagnose array-to-pointer decays of dummy pointers ( #106366 )
...
We have type information for them now, so we can do this.
2024-08-28 13:41:01 +02:00
yronglin
d9e7286019
[NFC][clang][bytecode] Rename clang::interp::State::getCtx to clang::interp::State::getASTContext ( #106071 )
...
The new constant interpreter's `clang::interp::InterpState` contains
both `clang::interp::Context` and `clang::ASTContext`. So using `S.Ctx`
and `S.getCtx()` was a bit confusing. This PR rename `getCtx()` to
`getASTContext` to make things more clearer.
Signed-off-by: yronglin <yronglin777@gmail.com>
2024-08-26 22:23:07 +08:00
Timm Baeder
99b85cae62
[clang][bytecode][NFC] Add an additional assertion ( #105927 )
...
Since this must be true, add an assertion instead of just documenting it
via the comment.
2024-08-24 09:23:25 +02:00
Timm Bäder
68030f86ae
[clang][bytecode][NFC] Fix printing signed IntegralAP values
2024-08-24 08:21:25 +02:00
Timm Baeder
c81d666560
[clang][bytecode] Fix IntegralAP::is{Positive,Negative} ( #105924 )
...
This depends on signed-ness.
2024-08-24 07:50:23 +02:00
Timm Baeder
2f144ac5a1
[clang][bytecode][NFC] Remove containsErrors check from visitInitializer ( #105811 )
2024-08-23 14:28:52 +02:00
Timm Baeder
7b4b85b75d
[clang][bytecode] Reject void InitListExpr differently ( #105802 )
...
This reverts c79d1fa540390f6e37e1ea326153559eeadd0de6 and
125aa10b3d645bd26523a1bc321bb2e6b1cf04e1
Instead, use the previous approach but allow void-typed InitListExprs
with 0 initializers.
2024-08-23 11:56:42 +02:00
Timm Baeder
38b8e54682
[clang][bytecode][NFC] Remove containsErrors() check from delegate ( #105804 )
...
This check was removed a while ago from visit(), remove it from
delegate() as well.
2024-08-23 11:55:30 +02:00
Timm Baeder
a69ba0a5f9
[clang][bytecode][NFC] Get rid of const_casts in Move fns ( #105698 )
2024-08-23 09:16:22 +02:00
Timm Baeder
b9c4c4ccf9
[clang][bytecode] Fix 'if consteval' in non-constant contexts ( #104707 )
...
The previous code made this a compile-time decision but it's not.
2024-08-22 19:06:09 +02:00
Timm Baeder
db94852b9b
[clang][bytecode] Allow adding offsets to function pointers ( #105641 )
...
Convert them to Pointers, do the offset calculation and then convert
them back to function pointers.
2024-08-22 15:23:50 +02:00
Timm Baeder
125aa10b3d
[clang][bytecode] Fix void unary * operators ( #105640 )
...
Discard the subexpr.
2024-08-22 14:05:17 +02:00
Timm Baeder
c79d1fa540
[clang][bytecode] Don't discard all void-typed expressions ( #105625 )
...
For void-types InitListExprs, we need to diagnose them as invalid. But
only if we are _not_ discarding.
2024-08-22 09:51:16 +02:00