aboutsummaryrefslogtreecommitdiff
path: root/clang/test/AST/ByteCode
AgeCommit message (Collapse)AuthorFilesLines
8 days[clang][bytecode] Activate primitive fields before initializing them (#149963)Timm Baeder1-3/+14
The initializer itself might need the field to be active.
8 days[clang][bytecode] Only implicitly start lifetime of ↵Timm Baeder1-0/+55
trivially-default-constructible union members (#149835) See https://github.com/llvm/llvm-project/commit/faee39baa87e43f4b746dd77e479268391163658
9 days[clang][bytecode] Error on bitcasts to bool that aren't 0 or 1 (#149996)Timm Baeder1-0/+4
This is also what the current interpreter does.
11 days[clang][bytecode] Diagnose dereferencing a null pointer (#149330)Timm Baeder4-10/+9
12 days[Clang] Be less strict about diagnosing null pointer dereference. (#149648)Corentin Jabot1-2/+0
In #143667, we made constant evaluation fail on `*null_ptr`, as this is UB. However, `&(*(foo*)0)` seems to be a common pattern, which made #143667 too disruptive. So instead of failing the evaluation, we note the UB, which let clang recovers when checking for constant initialization. Fixes #149500
12 days[clang][bytecode] Use bytecode interpreter in isPotentialConstantExprU… ↵Timm Baeder1-0/+8
(#149462) …nevaluated Fake a function call to the given function and evaluate the given expression as if it was part of that function call. Fixes #149383
13 days[clang][bytecode] Fix const-in-mutable fields (#149286)Timm Baeder1-8/+48
For mutable and const fields, we have two bits in InlineDescriptor, which both get inherited down the hierarchy. When a field is both const and mutable, we CAN read from it if it is a mutable-in-const field, but we _can't_ read from it if it is a const-in-mutable field. We need another bit to distinguish the two cases.
13 days[clang][bytecode] Report mutable reads when copying unions (#149320)Timm Baeder1-0/+14
2025-07-16[Clang] Diagnose forming references to nullptr (#143667)Corentin Jabot4-8/+14
Per [decl.ref], > Because a null pointer value or a pointer past the end of an object does not point to an object, a reference in a well-defined program cannot refer to such things. Note this does not fixes the new bytecode interpreter. Fixes #48665
2025-07-16[clang][bytecode] Fix contains check using llvm::find (#149050)Timm Baeder1-0/+8
We need to compare to the end() interator.
2025-07-16[clang][bytecode] Make union activation more granular (#148835)Timm Baeder2-3/+157
Only activate things if the syntactical structure suggests so. This adds a bunch of new opcodes to control whether to activate in stores, etc. Fixes #134789
2025-07-10[clang][bytecode] Check new/delete mismatch earlier (#147732)Timm Baeder1-0/+14
This fixes a mismatch in diagnostic output with the current intepreter.
2025-07-09[clang][bytecode] Devirtualize calls during con- and destruction (#147685)Timm Baeder2-6/+73
When compiliung compiling a ctor or dtor, we need to devirtualize the virtual function calls so we always call the implementation of the current class.
2025-07-08[clang][bytecode] Fix __builtin_is_within_lifetime in initializers (#147480)Timm Baeder1-0/+20
2025-07-08[Clang] include attribute scope in diagnostics (#144619)Oleksandr T.1-1/+1
This patch updates diagnostics to print fully qualified attribute names, including scope when present.
2025-07-08[clang][bytecode] Fix activating nested unions (#147338)Timm Baeder1-0/+45
When activating the new pointer, we need to de-activate pointers of all parent unions, not just the topmost one.
2025-07-06[clang][bytecode] Fix APValue generation for RValueReferenceType (#147207)Timm Baeder1-0/+122
We need to ignore the lvalue path, just like we do for lvalue reference types.
2025-07-06[clang][bytecode] Fix visiting for-range loop variable (#147188)Timm Baeder1-0/+264
Make sure we're properly registering DecompositionDecls.
2025-07-06[clang][bytecode] Fix a crash in overflow builtins (#147189)Timm Baeder1-0/+8
Only initialize pointers that can be initialized.
2025-07-06[clang][bytecode] Misc union fixes (#146824)Timm Baeder1-4/+104
First, don't forget to also activate fields which are bitfields on assignment. Second, when deactivating fields, recurse into records.
2025-07-05[clang][bytecode] Fix comparing pointers pointing to base classes (#146285)Timm Baeder2-0/+48
In the attached test case, one pointer points to the `Derived` class and one to `Base`, but they should compare equal. They didn't because those two bases are saved at different offsets in the block. Use `computeOffsetForComparison` not just for unions and fix it to work in the more general cases.
2025-07-04[clang][bytecode] Fix copy constructors for empty unions (#147050)Timm Baeder1-0/+12
Nothing to do in that case.
2025-07-01[clang][bytecode] Check pointer data type for bitcast eligibility (#146552)Timm Baeder1-0/+21
So we get the proper type for a heap-allocated value.
2025-06-24[clang][bytecode] Only use int128 if it is availableTimm Bäder1-1/+2
This broke a number of buildbots, e.g. https://lab.llvm.org/buildbot/#/builders/64/builds/4410
2025-06-23[clang][bytecode] Fix IntegralAP::{isMin,isMax} (#145339)Timm Baeder1-0/+7
We need to take signeness into account here.
2025-06-23[clang][bytecode] Fix assignInteger() with allocated primtypes (#145302)Timm Baeder1-0/+14
2025-06-23[clang][bytecode] Fix shifts with an allocated RHS (#145280)Timm Baeder1-0/+14
This was broken before because we ended up using a constructor that was disabled via assert(false). Use ShiftAP() if either LHS or RHS is allocated.
2025-06-20Reapply "Reapply "[clang][bytecode] Allocate IntegralAP and Floating … ↵Timm Baeder2-12/+10
(#145014) …types usi… (#144676)" This reverts commit 68471d29eed2c49f9b439e505b3f24d387d54f97. IntegralAP contains a union: union { uint64_t *Memory = nullptr; uint64_t Val; }; On 64bit systems, both Memory and Val have the same size. However, on 32 bit system, Val is 64bit and Memory only 32bit. Which means the default initializer for Memory will only zero half of Val. We fixed this by zero-initializing Val explicitly in the IntegralAP(unsigned BitWidth) constructor. See also the discussion in https://github.com/llvm/llvm-project/pull/144246
2025-06-18Revert "Reapply "[clang][bytecode] Allocate IntegralAP and Floating types ↵Timm Bäder2-10/+12
usi… (#144676)" This reverts commit 7c15edb306932e41c159f3d69c161ed0d89d47b7. This still breaks clang-armv8-quick: https://lab.llvm.org/buildbot/#/builders/154/builds/17587
2025-06-18Reapply "[clang][bytecode] Allocate IntegralAP and Floating types usi… ↵Timm Baeder2-12/+10
(#144676) …ng an allocator (#144246)" This reverts commit 57828fec760f086b334ce0cb1c465fc559dcaea4.
2025-06-17Revert "[clang][bytecode] Allocate IntegralAP and Floating types using an ↵Timm Bäder2-10/+12
allocator (#144246)" This reverts commit c66be289901b3f035187d391e80e3610d7d6232e. This breaks the armv8-quick builder: https://lab.llvm.org/buildbot/#/builders/154/builds/17549
2025-06-17[clang][bytecode] Allocate IntegralAP and Floating types using an allocator ↵Timm Baeder2-12/+10
(#144246) Both `APInt` and `APFloat` will heap-allocate memory themselves using the system allocator when the size of their data exceeds 64 bits. This is why clang has `APNumericStorage`, which allocates its memory using an allocator (via `ASTContext`) instead. Calling `getValue()` on an ast node like that will then create a new `APInt`/`APFloat` , which will copy the data (in the `APFloat` case, we even copy it twice). That's sad but whatever. In the bytecode interpreter, we have a similar problem. Large integers and floating-point values are placement-new allocated into the `InterpStack` (or into the bytecode, which is a `vector<std::byte>`). When we then later interrupt interpretation, we don't run the destructor for all items on the stack, which means we leak the memory the `APInt`/`APFloat` (which backs the `IntegralAP`/`Floating` the interpreter uses). Fix this by using an approach similar to the one used in the AST. Add an allocator to `InterpState`, which is used for temporaries and local values. Those values will be freed at the end of interpretation. For global variables, we need to promote the values to global lifetime, which we do via `InitGlobal` and `FinishInitGlobal` ops. Interestingly, this results in a slight _improvement_ in compile times: https://llvm-compile-time-tracker.com/compare.php?from=6bfcdda9b1ddf0900f82f7e30cb5e3253a791d50&to=88d1d899127b408f0fb0f385c2c58e6283195049&stat=instructions:u (but don't ask me why). Fixes https://github.com/llvm/llvm-project/issues/139012
2025-06-16[clang][bytecode] Fix calling operator new with nothrow/align parameter ↵Timm Baeder1-6/+16
(#144271) Discard all the parameters we don't care about.
2025-06-15[clang][bytecode] Avoid revisiting decomposition decl in visitDeclRef (#144226)Sirui Mu1-0/+8
This simple patch removes the code to revisit `DecompositionDecl` in `visitDeclRef`. The revisit will try to emit the initializer of the `DecompositionDecl`, which could result in evaluation errors if the `DecompositionDecl` is not within a constexpr context.
2025-06-13Remove delayed typo expressions (#143423)Aaron Ballman1-2/+6
This removes the delayed typo correction functionality from Clang (regular typo correction still remains) due to fragility of the solution. An RFC was posted here: https://discourse.llvm.org/t/rfc-removing-support-for-delayed-typo-correction/86631 and while that RFC was asking for folks to consider stepping up to be maintainers, and we did have a few new contributors show some interest, experiments show that it's likely worth it to remove this functionality entirely and focus efforts on improving regular typo correction. This removal fixes ~20 open issues (quite possibly more), improves compile time performance by roughly .3-.4% (https://llvm-compile-time-tracker.com/?config=Overview&stat=instructions%3Au&remote=AaronBallman&sortBy=date), and does not appear to regress diagnostic behavior in a way we wouldn't find acceptable. Fixes #142457 Fixes #139913 Fixes #138850 Fixes #137867 Fixes #137860 Fixes #107840 Fixes #93308 Fixes #69470 Fixes #59391 Fixes #58172 Fixes #46215 Fixes #45915 Fixes #45891 Fixes #44490 Fixes #36703 Fixes #32903 Fixes #23312 Fixes #69874
2025-06-03[clang][bytecode] Partially address string literal uniqueness (#142555)Timm Baeder2-2/+30
This still leaves the case of the constexpr auto b3 = name1() == name1(); test from cxx20.cpp broken.
2025-06-03[clang][bytecode] Remove some unused code (#142580)Timm Baeder1-0/+8
Remove unused functions and add tests for fixed-point to bool casts, which work.
2025-05-28[clang][bytecode] Recursively start lifetimes as well (#141742)Timm Baeder1-0/+42
The constructor starts the lifetime of all the subobjects.
2025-05-24[clang][bytecode] Check lifetime of all ptr bases in placement-new (#141272)Timm Baeder2-5/+18
placement-new'ing an object with a dead base object is not allowed, so we need to check all the pointer bases.
2025-05-23[clang][bytecode] Fix AccessKinds in placement new CheckStore() call (#141123)Timm Baeder1-2/+13
CheckStore is for assignments, but we're constructing something here, so pass AK_Construct instead. We already diagnosed the test case, but as an assignment.
2025-05-23[clang][bytecode] Diagnose placement-new'ing to a temporary (#141099)Timm Baeder1-1/+8
... that's been created in a different evaluation.
2025-05-22[clang][bytecode] Fix self-init diagnostics in C++23 (#141044)Timm Baeder1-0/+6
2025-05-22[clang][bytecode] Change diagnostics for self-initialization (#141006)Timm Baeder2-2/+17
Change the diagnostics when reading from the variable we're currently initializing do be the same as the one the current interpreter emits.
2025-05-20[clang][bytecode] Diagnose comparisons of unrelated zero-sized pointers ↵Timm Baeder1-0/+7
(#140695)
2025-05-20[clang][bytecode] Check downcasts for the correct type (#140689)Timm Baeder1-0/+12
In multiple inheritance/diamond scenarios, we might arrive at the wrong type.
2025-05-19[clang][bytecode] Do not diagnose volatile reads in CPCE mode (#140546)Timm Baeder1-0/+10
This matches the diagnostic output of the current interpreter.
2025-05-19[clang][bytecode] Add a scope to function calls (#140441)Timm Baeder1-0/+18
We need a place to destroy the temporaries created for call arguments.
2025-05-16[clang][bytecode] Explicitly start variable lifetimes via placement new ↵Timm Baeder1-0/+49
(#140221) placement new /std::construct{,_at} can resurrect a variable after it's destructor has been called.
2025-05-15[clang][bytecode] Check dtor calls for one-past-end pointers (#140047)Timm Baeder1-0/+8
2025-05-15[clang][bytecode] Check destructors for temporaries (#140039)Timm Baeder1-0/+10
Also, increase the EvalID in isPotentialConstantExpr(), since this is its own evaluation.