commit | 7ca32fca90c0579233d61827990b495504866870 | [log] [tgz] |
---|---|---|
author | Dani Ferreira Franco Moura <danimoura@google.com> | Thu Nov 24 04:19:16 2022 -0800 |
committer | Copybara-Service <copybara-worker@google.com> | Thu Nov 24 04:19:58 2022 -0800 |
tree | 93a0a4cde14b1182fe7258849d0d2e8a92b5e953 | |
parent | 8c1a6c45fe4ae1aad9fdc40d4f73d7e978742991 [diff] |
Handle more shapes of template instantiations by recursively computing nullability annotations. This change has to do with propagating nullability information through template instantiations. Previously, we used if-statements to "pattern match" over method calls of template instantiated classes and propagate their nullability information. However, this pattern matching only handled very specific expression shapes. We are replacing the type pattern-matching with a recursive algorithm that can handle many type shapes, including templates with arguments that have more than one pointer type (e.g. a nested pointer or pair of pointers), or have no pointer at all (e.g., an integer argument). We are also adding support for propagating the nullability of templated member calls (e.g, x.f, where x is a template-instantiated class). We have added test cases to cover the new functionality. We test member call expressions from structs with varying number of typename and int arguments. We have also added a test case with a struct that uses another struct template in a member variable. Nested member calls (for example, x.f.g) are commented out as the current implementation does not handle them. PiperOrigin-RevId: 490708002
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