22 Commits

Author SHA1 Message Date
Timm Baeder
ac6382425e
[clang][bytecode] Check for invalid call expressions (#181327) 2026-02-13 10:16:34 +01:00
Timm Baeder
af74bc96c2
[clang][bytecode] Improve rejecting UnaryExprOrTypeTraitExprs (#180710)
Some of them work just fine, even if the expression contains errors.
2026-02-10 11:44:26 +01:00
Timm Baeder
3230de5e65
[clang][bytecode] Fix assertion failure when returning function type (#180681)
... as an rvalue. Which can't work, so reject.
2026-02-10 10:54:45 +01:00
Timm Baeder
8ab034fa15
[clang][bytecode] Handle invalid UnaryExprOrTypeTraitExprs (#180692) 2026-02-10 09:24:11 +01:00
Timm Baeder
6dc9a484fd
[clang][bytecode] Handle missing target label in break statement (#180532)
Happens in error cases.
2026-02-10 06:55:10 +01:00
Timm Baeder
890cdbe653
[clang][bytecode] Handle a null record better (#179645)
This would otherwise later assert in vsitZeroRecordInitializer().
2026-02-04 14:17:11 +01:00
puneeth_aditya_5656
85c5029917
[clang][bytecode] Fix crash when dereferencing cast to larger type (#179030)
## Summary
When dereferencing a pointer that was `reinterpret_cast` to a larger
type (e.g. `*(int**)""`), the bytecode interpreter would crash with an
assertion failure because it tried to read more bytes than the
allocation contained.

## Changes
- Add a size check in `Pointer::toRValue()` before calling `deref<T>()`
to ensure the allocation is large enough
- If the allocation is too small, return `std::nullopt` to gracefully
fail the constant evaluation instead of crashing
- Add regression test

Fixes #179015
2026-02-04 07:48:18 +01:00
Timm Baeder
68850427ba
[clang][bytecode] Reject CK_BitCast nodes with errors early (#179087)
Fixes https://github.com/llvm/llvm-project/issues/179020
2026-02-01 10:08:06 +01:00
Timm Baeder
18d6d67067
[clang][bytecode] Check for invalid function decls (#175312)
If the function decl is invalid, the `interp::Function` shouldn't ever
be valid.

Fixes https://github.com/llvm/llvm-project/issues/175280
2026-01-10 16:52:54 +01:00
Timm Bäder
7b813c3d80 [clang][bytecode][test] Specify triple for Invalid.cpp
This should unbreak that test on 32bit builders, e.g.
https://lab.llvm.org/buildbot/#/builders/154/builds/24509
2025-11-27 13:42:46 +01:00
Timm Baeder
bd95a74a2c
[clang][bytecode] Check for invalid record decls in IntPointer::atOffset (#169786)
We can't access the RecordLayout of an invalid decl, so return failure
if that happens.

Fixes https://github.com/llvm/llvm-project/issues/167076
2025-11-27 13:06:15 +01:00
Timm Baeder
90e1391d18
[clang][bytecode] Check pointers in GetPtrField{,Pop} (#167335)
The pointer needs to point to a record.

Fixes https://github.com/llvm/llvm-project/issues/166371
2025-11-17 08:24:44 +01:00
Timm Baeder
a8a0ffba73
[clang][bytecode] Check source pointer for bitcast validity (#166907)
Unfortunately this is more dynamic than anticipated.

Fixes https://github.com/llvm/llvm-project/issues/165006
2025-11-10 08:17:08 +01:00
Timm Baeder
14c76437ee
[clang][bytecode] Check types when loading values (#165385)
We need to allow BitCasts between pointer types to different prim types,
but that means we need to catch the problem at a later stage, i.e. when
loading the values.

Fixes https://github.com/llvm/llvm-project/issues/158527
Fixes https://github.com/llvm/llvm-project/issues/163778
2025-11-05 16:02:19 +01:00
Timm Baeder
c750487292
[clang][bytecode] Diagnose volatile writes (#160350) 2025-09-28 07:21:40 +02:00
Timm Baeder
07b2ba2600
Reapply "[clang][bytecode] Fix incorrect offset in elem() (#155157)" (#155276)
This reverts commit 9642aadf7064192164d1687378d28d6bda1978c9.

Since elem() only works on primitive arrays anyway, we don't have to do
the isArrayRoot() check at all.
2025-08-26 05:24:18 +02:00
Timm Bäder
9642aadf70 Revert "[clang][bytecode] Fix incorrect offset in elem() (#155157)"
This reverts commit 0f4db1a7955e511844d7a685103aa32617fc279d.

This breaks the armv8-quick builder:
https://lab.llvm.org/buildbot/#/builders/154/builds/20676
2025-08-25 15:00:02 +02:00
Timm Baeder
0f4db1a795
[clang][bytecode] Fix incorrect offset in elem() (#155157)
We need to use the base offset in both cases.
Also, add additional assertions to make sure we don't miss this case
again.

Fixes #155132
2025-08-25 14:09:59 +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 Bäder
75ef95584d [clang][bytecode][NFC] Move test to verify=expected,both style 2024-08-24 07:18:36 +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
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