| commit | 7b0536794349734c8862fc140808e4e5a2ab8f8d | [log] [tgz] |
|---|---|---|
| author | Sergei Barannikov <barannikov88@gmail.com> | Fri Jan 10 16:43:19 2025 +0300 |
| committer | GitHub <noreply@github.com> | Fri Jan 10 16:43:19 2025 +0300 |
| tree | f51a38f9eb7d48e2b6049bf57123f4f46dbf6b39 | |
| parent | 799e9883eaf7c7bdebfb8ddb3366d9137527b29d [diff] |
[ADT] Fix specialization of ValueIsPresent for PointerUnion (#121847) Two instances of `PointerUnion` with different active members and null value compare unequal. Currently, this results in counterintuitive behavior when using functions from `Casting.h`, e.g.: ```C++ PointerUnion<int *, float *> U; // U = (int *)nullptr; dyn_cast<int *>(U); // Aborts dyn_cast<float *>(U); // Aborts U = (float *)nullptr; dyn_cast<int *>(U); // OK dyn_cast<float *>(U); // OK ``` `dyn_cast` should abort in all cases because the argument is null. Currently, it aborts only if the first member is active. This happens because the partial template specialization of `ValueIsPresent` for nullable types compares the union with a union constructed from nullptr, and the two unions compare equal only if their active members are the same. This patch changed the specialization of `ValueIsPresent` for nullable types to make `isPresent()` return false for all possible null values of a PointerUnion, and fixes two places where the old behavior was exploited. Pull Request: https://github.com/llvm/llvm-project/pull/121847
Welcome to the LLVM project!
This repository contains the source code for LLVM, a toolkit for the construction of highly optimized compilers, optimizers, and run-time environments.
The LLVM project has multiple components. The core of the project is itself called “LLVM”. This contains all of the tools, libraries, and header files needed to process intermediate representations and convert them into object files. Tools include an assembler, disassembler, bitcode analyzer, and bitcode optimizer.
C-like languages use the Clang frontend. This component compiles C, C++, Objective-C, and Objective-C++ code into LLVM bitcode -- and from there into object files, using LLVM.
Other components include: the libc++ C++ standard library, the LLD linker, and more.
Consult the Getting Started with LLVM page for information on building and running LLVM.
For information on how to contribute to the LLVM project, please take a look at the Contributing to LLVM guide.
Join the LLVM Discourse forums, Discord chat, LLVM Office Hours or Regular sync-ups.
The LLVM project has adopted a code of conduct for participants to all modes of communication within the project.