14 Commits

Author SHA1 Message Date
Timm Baeder
a9de444aa1
[clang][bytecode][NFC] Use an anonymous union in Pointer (#154405)
So we can save ourselves writing PointeeStorage all the time.
2025-08-20 09:23:19 +02:00
Timm Baeder
25c137e43b
[clang][bytecode] Save a per-block dynamic allocation ID (#154094)
This fixes an old todo item about wrong allocation counting and some
diagnostic differences.
2025-08-19 06:52:21 +02:00
Timm Baeder
7a6c9813d6
[clang][bytecode] Add AccessFlags to Block (#152590)
This way, we can check a single uint8_t for != 0 to know whether this
block is accessible or not. If not, we still need to figure out why not
and diagnose appropriately of course.
2025-08-09 15:46:28 +02:00
Timm Baeder
fde9ee1ac2
[clang][bytecode] Don't deallocate dynamic blocks with pointers (#152672)
This fixes the edge case we had with variables pointing to dynamic
blocks, which forced us to convert basically *all* dynamic blocks to
DeadBlock when deallocating them.

We now don't run dynamic blocks through InterpState::deallocate() but
instead add them to a DeadAllocations list when they are deallocated but
still have pointers.

As a consequence, not all blocks with Block::IsDead = true are
DeadBlocks.
2025-08-08 13:02:01 +02:00
Timm Baeder
3b5cc2dc63
[clang][bytecode][NFC] Refactor DynamicAllocator a bit (#152510)
Use empty()-style functions instead of exposing the size if we don't
need it.
2025-08-07 17:03:53 +02:00
Timm Baeder
1e8b65d8cd
[clang][bytecode][NFC] Add a FIXME comment for heap allocations (#151700) 2025-08-01 16:30:43 +02:00
Timm Baeder
fb49c6784a
[clang][bytecode] Move Pointer::{Prev,Next} into BlockPointer (#151097)
They are only relevant for block pointers.
2025-07-30 10:17:21 +02:00
Timm Baeder
857ffa1915
[clang][bytecode] Recursively start lifetimes as well (#141742)
The constructor starts the lifetime of all the subobjects.
2025-05-28 16:16:00 +02:00
Timm Baeder
294643e4bd
[clang][bytecode] Check lifetime of all ptr bases in placement-new (#141272)
placement-new'ing an object with a dead base object is not allowed, so
we need to check all the pointer bases.
2025-05-24 14:17:26 +02:00
Timm Baeder
211b51e471
[clang][bytecode] Propagate IsVolatile bit to subobjects (#137293)
For
```c++
  struct S {
    constexpr S(int=0) : i(1) {}
    int i;
  };
  constexpr volatile S vs;
```

reading from `vs.i` is not allowed, even though `i` is not volatile
qualified. Propagate the IsVolatile bit down the hierarchy, so we know
reading from `vs.i` is a volatile read.
2025-04-25 11:23:34 +02:00
Timm Baeder
2c1e9f14be
[clang][bytecode] Explicit composite array descriptor types (#129376)
When creating descriptor for array element types, we only save the
original source, e.g. int[2][2][2]. So later calls to getType() of the
element descriptors will also return int[2][2][2], instead of e.g.
int[2][2] for the second dimension.
Fix this by explicitly tracking the array types.
The last attached test case used to have an lvalue offset of 32 instead
of 24.

We should do this for more desriptor types though and not just composite
array, but I'm leaving that to a later patch.
2025-03-02 09:40:56 +01:00
Timm Baeder
e8d848824b
[clang][bytecode] Fix dynamic array allocation return values (#127387)
We need to return a pointer to the first element, not the array itself.
2025-02-16 12:24:35 +01:00
Timm Baeder
610b85395d
[clang][bytecode] Implement __builtin_operator{new,delete} (#107672) 2024-09-07 09:57:26 +02:00
Timm Baeder
a07aba5d44
[clang] Rename all AST/Interp stuff to AST/ByteCode (#104552)
"Interp" clashes with the clang interpreter and people often confuse
this.
2024-08-16 17:13:12 +02:00