commit | 5ef1bdf226b46a84630a9f65690c9cf600f75522 | [log] [tgz] |
---|---|---|
author | Googler <no-reply@google.com> | Wed Jan 18 04:01:15 2023 -0800 |
committer | Copybara-Service <copybara-worker@google.com> | Wed Jan 18 04:02:00 2023 -0800 |
tree | 8dbb54ba883d33e0ba0432378eaa9fafa5529a9c | |
parent | 2bccf748afe1c595ea464f2bd0b9d906d8c857dd [diff] |
Detect/log/recover mismatch between expression and nullability vector The nullability vector for an expr is supposed to match that expr's type. If not, it's meaningless because we can't correspond entries to PointerTypes. This requires various places that manipulate nullability vectors to be in sync, but they very often go out of sync e.g. due to unhandled nodes. Currently this mostly results in the contents being misinterpreted in arbitrary ways. Often (not always!) we can detect this as a nullability vector with the wrong length. For now this is way too common for us to CHECK, but we can log the error and continue by discarding all nullability info. Logs look like: [ RUN ] PointerNullabilityTest.NonNullPtrImplicitCastToBool === Bad computed nullability: === Expression: ImplicitCastExpr 0x172fbf641688 '_Bool' <PointerToBoolean> `-ImplicitCastExpr 0x172fbf641670 'int * _Nonnull':'int *' <LValueToRValue> `-DeclRefExpr 0x172fbf641650 'int * _Nonnull':'int *' lvalue ParmVar 0x172fbf641410 'x' 'int * _Nonnull':'int *' Nullability (1 pointers): [_Nonnull] Type (0 pointers): BuiltinType 0x172fbfdea5d0 '_Bool' ================================= === Bad computed nullability: === Expression: ImplicitCastExpr 0x172fbf73c908 '_Bool' <PointerToBoolean> `-ImplicitCastExpr 0x172fbf73c8f0 'int * _Nonnull':'int *' <LValueToRValue> `-DeclRefExpr 0x172fbf73c8d0 'int * _Nonnull':'int *' lvalue ParmVar 0x172fbf73c690 'x' 'int * _Nonnull':'int *' Nullability (1 pointers): [_Nonnull] Type (0 pointers): BuiltinType 0x172fbf60aad0 '_Bool' ================================= [ OK ] PointerNullabilityTest.NonNullPtrImplicitCastToBool (13 ms) PiperOrigin-RevId: 502833813
Extremely experimental interop tooling for C++ and Rust.
Please don‘t use, this is an experiment and we don’t yet know where will it take us. There will be breaking changes without warning. Unfortunately, we can't take contributions at this point.
$ apt install clang lld bazel $ git clone git@github.com:google/crubit.git $ cd crubit $ bazel build --linkopt=-fuse-ld=/usr/bin/ld.lld //rs_bindings_from_cc:rs_bindings_from_cc_impl
$ git clone https://github.com/llvm/llvm-project $ cd llvm-project $ CC=clang CXX=clang++ cmake -S llvm -B build -DLLVM_ENABLE_PROJECTS='clang' -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=install $ cmake --build build -j $ # wait... $ cmake --install build $ cd ../crubit $ LLVM_INSTALL_PATH=../llvm-project/install bazel build //rs_bindings_from_cc:rs_bindings_from_cc_impl