94 Commits

Author SHA1 Message Date
Timm Baeder
90696d17f2
[clang][bytecode][NFC] Simplify visitDeclRef (#123380)
Try to reduce indentation here.
2025-01-18 06:18:46 +01:00
Timm Baeder
c7ea4c18af
[clang][bytecode] Revisit global variables separately (#123358)
Call `EvaluateAsInitializer()` explicitly here, so we don't abort the
evaluation of the `DeflRefExpr` just because the initializer of that
global variable failed.
2025-01-17 18:55:24 +01:00
Timm Baeder
0171e56ed0
[clang][bytecode] Fix rejecting invalid sizeof expressions (#123332)
Emit the invalid note instead of nothing.
2025-01-17 15:14:47 +01:00
Timm Baeder
7075eee6bd
[clang][bytecode] Add InitLinkScope for toplevel Expr temporary (#123319) 2025-01-17 12:58:15 +01:00
Timm Baeder
4cec0ba929
[clang][bytecode][NFC] Simplify VisitCXXDefaultArgExpr (#123024)
We have `discard()` these days.
2025-01-15 10:09:10 +01:00
Timm Baeder
d1d25641f4
[clang][bytecode] Handle UETT_PtrAuthTypeDiscriminator (#122941) 2025-01-15 08:41:20 +01:00
Timm Baeder
58fa55c04b
[clang][bytecode] Add init link for the RVO ptr (#122904) 2025-01-14 17:18:04 +01:00
Timm Baeder
ac857f9bdd
[clang][bytecode] Change the way we do init chains (#122871)
See the comment in Compiler<>::VisitCXXThisExpr.
We need to mark the InitList explicitly, so we later know what to refer
to when the init chain is active.
2025-01-14 10:57:36 +01:00
Timm Baeder
e86b68ff56
[clang][bytecode] Add support for typeid pointers (#121251)
Add it as another kind of pointer, saving both a `Type*` for the result
of the typeid() expression as well as one for the type of the typeid
expression.
2024-12-28 14:07:01 +01:00
Timm Baeder
acb7dfaa01
[clang][bytecode] Create local scopes for if then/else statements (#120852)
In case those aren't compound statements.
2024-12-22 08:04:49 +01:00
Timm Baeder
56fd46edb3
[clang][bytecode] Remove a bitcast nullptr_t special case (#120188)
We still need to check the input pointer, so let this go through
BitCastPrim.
2024-12-17 13:23:14 +01:00
Timm Baeder
2f9cd43a73
[clang][bytecode] Check primitive bit casts for indeterminate bits (#118954)
Record bits ranges of initialized bits and check them in
allInitialized().
2024-12-06 15:50:59 +01:00
Timm Baeder
44be794658
[clang][bytecode] Not all null pointers are 0 (#118601)
Get the Value from the ASTContext instead.
2024-12-05 06:03:50 +01:00
Timm Baeder
7802fb5f51
[clang][bytecode] Fix __extension__ handling for vector operators (#118482)
Don't reject them, but delegate to the subexpression.
2024-12-03 14:48:55 +01:00
Timm Baeder
ff0babc917
[clang][bytecode] Fix discarded pointer subtractions (#118477)
We need to pop the value.
2024-12-03 14:34:32 +01:00
Timm Baeder
541d5d9111
[clang][bytecode][NFC] Reject invalid FromTypes in emitBuiltinBitcast (#118274)
instead of silently accepting them and failing later.
2024-12-02 11:12:20 +01:00
Timm Baeder
dd0d9561b8
[clang][bytecode] Support vector-to-vector bitcasts (#118230) 2024-12-02 08:20:41 +01:00
Timm Baeder
6f16a8bf17
[clang][bytecode] Use bitcasts to cast from integer to vector (#117547)
In C, a cast from an integer to a vector is a CK_BitCast. Implement this
using the same code we use for __builtin_bit_cast.
2024-11-25 14:51:26 +01:00
Timm Baeder
ceaf6e912a
[clang][bytecode] Support ImplicitValueInitExpr for multi-dim arrays (#117312)
The attached test case from
https://github.com/llvm/llvm-project/issues/117294 used to cause an
assertion because we called classifPrim() on an array type.

The new result doesn't crash but isn't exactly perfect either. Since the
problem arises when evaluating an ImplicitValueInitExpr, we have no
proper source location to point to. Point to the caller instead.
2024-11-25 12:15:31 +01:00
Kazu Hirata
63d9ef5e37
[AST] Migrate away from PointerUnion::{is,get} (NFC) (#117469)
Note that PointerUnion::{is,get} have been soft deprecated in
PointerUnion.h:

  // FIXME: Replace the uses of is(), get() and dyn_cast() with
  //        isa<T>, cast<T> and the llvm::dyn_cast<T>

I'm not touching PointerUnion::dyn_cast for now because it's a bit
complicated; we could blindly migrate it to dyn_cast_if_present, but
we should probably use dyn_cast when the operand is known to be
non-null.
2024-11-24 07:28:20 -08:00
Timm Baeder
5f84b332ec
[clang][bytecode] Fix discarding __builtin_bit_cast calls (#114926)
Optionally prepare storage for the result and do the bitcast anyway, to
get the right diagnostic output.
2024-11-05 11:05:23 +01:00
Timm Baeder
2f13fbfcd1
[clang][bytecode] Support bitcasting into float fields (#114825) 2024-11-05 05:52:03 +01:00
Timm Baeder
2588b8be56
[clang][bytecode] Implement bitcasts to composite types (#114776)
Only fixed-size, non-bitfield integral fields for now.
2024-11-04 15:10:10 +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
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
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
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
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
4c78c8cc21
[clang][bytecode] Fix discarding block expressions (#112185) 2024-10-14 15:11:39 +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
fed8695bb8
[clang][bytecode] Emit better diagnostic for invalid shufflevector index (#111643) 2024-10-09 09:56:37 +02:00
Timm Baeder
c57418037a
[clang][bytecode] Handle UETT_OpenMPRequiredSimdAlign (#111259) 2024-10-05 18:04:06 +02:00
Timm Baeder
3c85102756
[clang][bytecode] Handle DiscardResult for fixed-point literals (#110475) 2024-09-30 12:42:18 +02:00
Timm Baeder
dc6e4805a0
[clang][bytecode] Cast fixed-point cmp result to int if necessary (#110469)
This is the case in C.
2024-09-30 12:01:10 +02:00
Timm Baeder
6f04e65c3c
[clang][bytecode] Implement fixed-point shifts (#110429) 2024-09-29 20:56:17 +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