7 Commits

Author SHA1 Message Date
Aaron Ballman
4d80dff819 int -> uintptr_t to silence diagnostics
'int' may not be sufficiently large to store a pointer representation
anyway, so this is also a correctness fix.
2024-04-10 13:57:18 -04:00
Timm Baeder
1709eac58f
[clang][Interp] Integral pointers (#84159)
This turns the current `Pointer` class into a discriminated union of
`BlockPointer` and `IntPointer`. The former is what `Pointer` currently
is while the latter is just an integer value and an optional
`Descriptor*`.

The `Pointer` then has type check functions like
`isBlockPointer()`/`isIntegralPointer()`/`asBlockPointer()`/`asIntPointer()`,
which can be used to access its data.

Right now, the `IntPointer` and `BlockPointer` structs do not have any
methods of their own and everything is instead implemented in Pointer
(like it was before) and the functions now just either assert for the
right type or decide what to do based on it.

This also implements bitcasts by decaying the pointer to an integral
pointer.

`test/AST/Interp/const-eval.c` is a new test testing all kinds of stuff
related to this. It still has a few tests `#ifdef`-ed out but that
mostly depends on other unimplemented things like
`__builtin_constant_p`.
2024-04-10 12:53:54 +02:00
Balazs Benics
a87dc23a62
[clang][NFC] Trim license header comments to 81 characters (#82919)
clang-format would format these headers poorly by splitting it into
multiple lines.
2024-03-06 16:32:14 +01:00
Timm Bäder
411c5dde59 [clang][Interp] Handle null function pointers
We were instead asserting that they are non-null before.
2024-02-25 17:26:36 +01:00
Timm Bäder
f1a318b3dd [clang][Interp][NFC] Add FunctionPointer.h header comment 2023-06-02 08:38:13 +02:00
Timm Bäder
f8a9c55bef [clang][Interp] Emit diagnostic when comparing function pointers
Function pointers can be compared for (in)equality but, but LE, GE, LT,
and GT opcodes should emit an error and abort.

Differential Revision: https://reviews.llvm.org/D149154
2023-04-27 12:33:28 +02:00
Timm Bäder
3ad167329a [clang][Interp] Implement function pointers
Differential Revision: https://reviews.llvm.org/D141472
2023-03-30 15:37:49 +02:00