Proto commits in google/crubit

These commits are when the Protocol Buffers files have changed: (only the last 100 relevant commits are shown)

Commit:5f581c7
Author:Googler
Committer:Copybara-Service

Populate `impl_debug` in Crubit IR. Updates the importer to read the `crubit_override_debug` annotation on records, checks whether the `record_impl_debug` feature is enabled for the target, and populates the `impl_debug` boolean field in the IR. PiperOrigin-RevId: 944201431

Commit:27a5afd
Author:Luke Zarko
Committer:Copybara-Service

Add cfi_encoding attribute to generated enums, which are passed by value (and therefore need to have an encoding that matches the original C++). PiperOrigin-RevId: 944075367

Commit:96ab519
Author:Michael VanBemmel
Committer:Copybara-Service

Define `TemplateSpecializationKind`s for `absl::flat_hash_set` and `absl::flat_hash_map` and set them in the IR These will be used to customize the bindings for these types on the Rust side. PiperOrigin-RevId: 943990664

Commit:fad5fae
Author:Michael VanBemmel
Committer:Copybara-Service

Define `TemplateSpecializationKind`s for `absl::flat_hash_set` and `absl::flat_hash_map` and set them in the IR These will be used to customize the bindings for these types on the Rust side. PiperOrigin-RevId: 943381674

Commit:cec44a0
Author:Luke Zarko
Committer:Copybara-Service

Add cfi_encoding attribute to generated enums, which are passed by value (and therefore need to have an encoding that matches the original C++). PiperOrigin-RevId: 941406195

Commit:c6bbcef
Author:Googler
Committer:Copybara-Service

Deprecate children_item_ids in the rs_bindings_from_cc's backend and test matchers. children_item_ids are no longer used in the backend to resolve the db IR, hence we remove them and refactor tests to use the children items directly. PiperOrigin-RevId: 943267094

Commit:cc142f7
Author:Googler
Committer:Copybara-Service

Remove deprecated top-level IR fields (flat items array & top_level_item_ids) from the rs_bindings_from_cc's backend and test matchers. These fields are no longer used in the backend to resolve bindings, and tests are updated to assert on the root top_level_items directly. This CL should be a no-op. PiperOrigin-RevId: 941842425

Commit:64cf357
Author:Googler
Committer:Copybara-Service

Deprecate serialization of child_item_ids in rs_bindings_from_cc. child_item_ids fields are no longer used in the backend following the restructure. We move them from the C++ IR to the Clang `Invocation` as they are now only used as an internal implementation detail in the importer. This finalizes the cleanup needed for the IR restructure in[] PiperOrigin-RevId: 941201400

Commit:b497b77
Author:Luke Zarko
Committer:Copybara-Service

Add cfi_encoding attribute to generated enums, which are passed by value (and therefore need to have an encoding that matches the original C++). PiperOrigin-RevId: 941406195

Commit:90a36fc
Author:Googler
Committer:Copybara-Service

Deprecate serialization of child_item_ids in rs_bindings_from_cc. PiperOrigin-RevId: 941201400

Commit:576e2ac
Author:Googler
Committer:Copybara-Service

Populate `impl_debug` in Crubit IR. Updates the importer to read the `crubit_override_debug` annotation on records, checks whether the `record_impl_debug` feature is enabled for the target, and populates the `impl_debug` boolean field in the IR. PiperOrigin-RevId: 937701661

Commit:2a4be17
Author:Lukasz Anforowicz
Committer:Copybara-Service

`rs_bindings_from_cc` bindings: Support explicitly provided crate names. This CL supports Crubit clients where crate names are not directly based on a target name. For example, Chromium uses a mangling / hashing scheme to guarantee globally-unique crate names (see `chromium::import!` for more details). Together with https://crrev.com/c/8027730/1 this CL unblocks Chromium's ability to use transitive dependencies in `rs_bindings_from_cc`-generated bindings. PiperOrigin-RevId: 940662918

Commit:f8034e8
Author:Googler
Committer:Copybara-Service

Remove deprecated top-level IR fields (flat items array & top_level_item_ids) from the C++ IR struct. Following removal of top_level_item_ids from the Rust IR in the parent CL, this change removes the top_level_item_ids field from the C++ IR struct and IR::ToJson() serialization. Because of this, BuildTree() now accepts top_level_item_ids as a short-lived input parameter during AST import to populate top_level_items instead. PiperOrigin-RevId: 941103191

Commit:6ded4b0
Author:Googler
Committer:Copybara-Service

Populate `impl_debug` in Crubit IR. Updates the importer to read the `crubit_override_debug` annotation on records, checks whether the `record_impl_debug` feature is enabled for the target, and populates the `impl_debug` boolean field in the IR. PiperOrigin-RevId: 937701661

Commit:312c3b8
Author:Lukasz Anforowicz
Committer:Copybara-Service

`rs_bindings_from_cc` bindings: Support explicitly provided crate names. Together with https://crrev.com/c/8027730/1 this unblocks Chromium's ability to use transitive dependencies in `rs_bindings_from_cc`-generated bindings. PiperOrigin-RevId: 940662918

Commit:58781ec
Author:Googler
Committer:Copybara-Service

Deprecate use of top_level/children item_ids Removes the top_level_item_ids field from the IR and other call-sites (except for the importer, which we avoid modifying to de-risk for regressions). PiperOrigin-RevId: 939827060

Commit:e0922a2
Author:Googler
Committer:Copybara-Service

Add support for C++ user-defined conversion operators. We map depending on the target type and pin/move characteristics: - Movable, locally-defined type (Record is Unpin and local to the crate): `operator Dst() const` => `impl From<&Src> for Dst` - Immovable, locally-defined type: `operator Dst() const` => `impl CtorNew<&Src> for Dst` - Foreign types, primitives, or reference returns: If the target type is a value: `operator Dst() const` => `impl Into<Dst> for &Src` If the target type is a reference: - `operator const Dst&() const` => `impl Into<CRef<'_, Dst>> for &Src` - `operator Dst&()` => `impl Into<CMut<'_, Dst>> for &mut Src` `const T()` maps the receiver to `&Src`, `T()` maps the receiver to `&mut Src`. PiperOrigin-RevId: 938696877

Commit:a0fb790
Author:Googler
Committer:Copybara-Service

Add support for std::atomic in Crubit. Note that std::atomic and std::atomic intentionally fall back to opaque bindings. Rust's standard library does not provide an AtomicCLong. Because long is 32-bit on Windows LLP64 and 64-bit on Linux LP64, hardcoding it to AtomicI64 or AtomicI32 would cause stack corruption across the FFI boundary. Consequently, std::atomic<size_t> will also become opaque on 64-bit Linux because Clang canonicalizes it to unsigned long. Users should prefer std::atomic<uintptr_t> or std::atomic<uint64_t> for cross-language atomics. PiperOrigin-RevId: 920404627

Commit:3cc5d4e
Author:Googler
Committer:Copybara-Service

Undo Rust-side reconstruction of the FFI-passed nested IR to the database-managed IR. Unfortunately this caused some Crubit users to OOM during builds... PiperOrigin-RevId: 938020861

Commit:8c984df
Author:Googler
Committer:Copybara-Service

Undo Rust-side reconstruction of the FFI-passed nested IR to the database-managed IR. Unfortunately this caused some Crubit users to OOM during builds... PiperOrigin-RevId: 937997234

Commit:f6ee89e
Author:Googler
Committer:Copybara-Service

Undo Rust-side reconstruction of the FFI-passed nested IR to the database-managed IR. Unfortunately this caused some Crubit users to OOM during builds... PiperOrigin-RevId: 937627303

Commit:9683596
Author:Googler
Committer:Copybara-Service

Implement Rust-side reconstruction of the FFI-passed nested IR to the database-managed IR. Specifically, this change: - Implements `make_ir_from_tree` in `ir.rs` to reconstruct the declaration tree on the Rust side from `top_level_items`, and populate a lookup cache of itemId to items. - Ensures nested items are discoverable: `db::find_untyped_decl` looks up items in the reconstructed tree cache instead of `flat_ir.items`. - Propagates changes to IR structure and db to the relevant bindings generation logic ie. `generate_struct_and_union.rs` - Removes the `top_level_item_ids` field from the IR and other call-sites (except for the importer, which we avoid modifying to de-risk for regressions). Note that after further discussion, the (rest of this) restructure will be done atomically in this CL. The use_nested_ir flag has been deleted. PiperOrigin-RevId: 937556313

Commit:a1a44fe
Author:Googler
Committer:Copybara-Service

Implement Rust-side reconstruction of the FFI-passed nested IR to the database-managed IR. Specifically, this change: - Implements `make_ir_from_tree` in `ir.rs` to reconstruct the declaration tree on the Rust side from `top_level_items`, and populate a lookup cache of itemId to items. - Ensures nested items are discoverable: `db::find_untyped_decl` looks up items in the reconstructed tree cache instead of `flat_ir.items`. - Propagates changes to IR structure and db to the relevant bindings generation logic ie. `generate_struct_and_union.rs` - Removes the `top_level_item_ids` field from the IR and other call-sites (except for the importer, which we avoid modifying to de-risk for regressions). Note that after further discussion, the (rest of this) restructure will be done atomically in this CL. The use_nested_ir flag has been deleted. PiperOrigin-RevId: 933733681

Commit:1301872
Author:Googler
Committer:Copybara-Service

Add support for std::atomic in Crubit. Note that std::atomic and std::atomic intentionally fall back to opaque bindings. Rust's standard library does not provide an AtomicCLong. Because long is 32-bit on Windows LLP64 and 64-bit on Linux LP64, hardcoding it to AtomicI64 or AtomicI32 would cause stack corruption across the FFI boundary. Consequently, std::atomic<size_t> will also become opaque on 64-bit Linux because Clang canonicalizes it to unsigned long. Users should prefer std::atomic<uintptr_t> or std::atomic<uint64_t> for cross-language atomics. PiperOrigin-RevId: 920404627

Commit:0f4ba5a
Author:Googler
Committer:Copybara-Service

Add support for C++ user-defined conversion operators. We map depending on the target type and pin/move characteristics: - Movable, locally-defined type (Record is Unpin and local to the crate): `operator Dst() const` => `impl From<&Src> for Dst` - Immovable, locally-defined type: `operator Dst() const` => `impl CtorNew<&Src> for Dst` - Foreign types, primitives, or reference returns: If the target type is a value: `operator Dst() const` => `impl Into<Dst> for &Src` If the target type is a reference: - `operator const Dst&() const` => `impl Into<CRef<'_, Dst>> for &Src` - `operator Dst&()` => `impl Into<CMut<'_, Dst>> for &mut Src` `const T()` maps the receiver to `&Src`, `T()` maps the receiver to `&mut Src`. PiperOrigin-RevId: 932645952

Commit:940c3f9
Author:Googler
Committer:Copybara-Service

Build and serialize the nested IR on the frontend. We restructure the IR so namespaces and records can contain other items. This has several consequences: * To support forward-declaring and break circular dependencies (Item -> Namespace/Record -> Item), `Item` is now a struct inheriting from `std::variant`. * Nested items are held via `std::shared_ptr` over `std::unique_ptr` to preserve copy constructors during this transition, and to maintain support for certain things like redeclarations. PiperOrigin-RevId: 933993865

Commit:a051376
Author:Taylor Cramer
Committer:Copybara-Service

Support round-tripping to C++ and back for Rust types with lifetime parameters PiperOrigin-RevId: 930654647

Commit:7644af7
Author:Ethan Smith
Committer:Copybara-Service

Fix generated code that fails to compile. Previously we would generate `delete ptr;` in the C++ glue code. This fails to compile when the delete operator isn't public (or is explicitly deleted). Add a check for such types that also have a destructor, and use the destructor instead creating code that compiles. PiperOrigin-RevId: 929160936

Commit:aeeca8b
Author:Andrew Le
Committer:Copybara-Service

Added support for users to re-export their namespace to their crate root PiperOrigin-RevId: 928818908

Commit:f1dbd40
Author:Googler
Committer:Copybara-Service

Add unstable_rust_features option to Crubit additional_rust_srcs This allows enabling unstable rustc features via an additional `#![feature(...)]` declaration at the crate root when compiling extra Rust sources attached to Crubit bindings. PiperOrigin-RevId: 928646453

Commit:1b2b94d
Author:Ethan Smith
Committer:Copybara-Service

Wrap mutable fields in `Cell`. PiperOrigin-RevId: 927503898

Commit:e76cf91
Author:Googler
Committer:Copybara-Service

Add the `lifetime_inputs` field to proto messages and serialization logic. This field is currently ignored (b/454627672) but is expected by the backend. This CL also adds another field, `defining_target`, I had missed in the previous CL (translating IR to proto), which is used in the backend to search for unsupported items. PiperOrigin-RevId: 926305441

Commit:2e6d4f3
Author:Googler
Committer:Copybara-Service

Introduce a proto definition of the Clang-based IR and a feature flag gating its use. This change is made as part of an effort to move to a more compiler-agnostic IR format in place of our current JSON IR for the cpp-to-rust direction of Crubit. This will enable open-source users to use any version of Clang (or other compilers) and construct middleware to bridge this IR if they would like. The frontend and backend currently do not have the neccessary serialization/deserialization to construct and use the proto IR, hence we still default to the JSON IR (no-op change). PiperOrigin-RevId: 922909854

Commit:6f7838f
Author:Googler
Committer:Copybara-Service

Replace `Environment` enum with an equivalent boolean flag. This enum was used to control whether source location information should be included in doc comments. This CL replaces the enum with a more direct boolean flag following the refactor (of the FFI call) to use protobufs, which demands an otherwise unused unspecified variant. PiperOrigin-RevId: 922738061

Commit:d07631b
Author:Googler
Committer:Copybara-Service

Refactor `GenerateBindingsImpl()` to serialize the GenerateBindingsRequest/Response protos through the FFI boundary. PiperOrigin-RevId: 921680560

Commit:ef0dd21
Author:Googler
Committer:Copybara-Service

Refactor `GenerateBindingsImpl()` to use Request/Response protobufs. The protos are passed as raw pointers and wrapped into a safe Rust object through the Rust Protobuf API. PiperOrigin-RevId: 915497206

Commit:14e96ba
Author:Googler
Committer:Copybara-Service

Define a protobuf model for `GenerateBindingsImpl()` This incremental change aims to provide a safer, layout-consistent format when passing C++-derived IR across the FFI boundary. PiperOrigin-RevId: 916034617

Commit:b9ecd10
Author:Ethan Smith
Committer:Copybara-Service

Use renamed crates when checking for includes. Previously we would fail to find `--crate-header` for types in dependecies because we look them up without accounting for renames. For protos this means we look up `crate_proto` when our crate header is for `crate_rust_proto` and fail to find definitions. PiperOrigin-RevId: 910152011

Commit:ee9d342
Author:Andreas C. Osowski
Committer:Copybara-Service

Fix protobuf bridging for nested messages. Crubit previously incorrectly assumed that the C++ generated class name for a protobuf (e.g. `MyMessage_Request`) perfectly matched the expected Rust type path (`my_message::Request`). This caused the `rs_bindings_from_cc` generator to fail to find the correct type from the Rust protobuf crate. This fix traverses the `DeclContext` in C++ to correctly reconstruct the nested `snake_case` Rust module paths, and uses this reconstructed `rust_name` in the generator instead of ignoring it. PiperOrigin-RevId: 903251309

Commit:3aa2882
Author:Ethan Smith

Initial setup of test matrix

This commit does not contain any .proto files.

Commit:6a30b81
Author:Googler
Committer:Copybara-Service

Eliminate TUSummary and use CFGSummary as the top-level summary unit. Required reworking the VirtualMethodIndexSummary interactions, but minimally, since the information needed by the CFGSummary should already be TU-independent. This will enable deduplication of CFGSummary objects for CFGs present in headers that are included by multiple TUs, which should be a significant performance improvement for multi-TU inference. PiperOrigin-RevId: 846741546

Commit:69c0b17
Author:Googler
Committer:Copybara-Service

Instead of dropping inferable slots that cross a test boundary, tag and drop later Tag inferable slots as crossing a test boundary, as well as any evidence that is derived from such crossings. Only later do we drop the evidence. - This gives us an option to do some fall-back merging at the end. - It also avoids dropping inferable slots, which has a side-effect of not being able to pull in previous inference information when inferring with summaries. Also track the test boundary crossing in some summaries, when the later evidence collection doesn't involve the inferable slot summaries. PiperOrigin-RevId: 846722439

Commit:c8c6b24
Author:Googler
Committer:Copybara-Service

Rename proto field for clarity. This evidence kind is only used if it is determined that the value is nullable, not in all cases. PiperOrigin-RevId: 839252173

Commit:0f6b8dd
Author:Googler
Committer:Copybara-Service

Second step in downrank/excluding test -> nontest evidence Tracks whether virtual method overrides are test/nontest in the "index" and use that information later to avoid propagation crossing test -> nontest from derived to base classes. After this, we can consider tracking the crossing in evidence (instead of filtering), and downranking during merge instead. PiperOrigin-RevId: 838876544

Commit:0a9f85a
Author:Googler
Committer:Copybara-Service

Collect evidence for select templates of pointers from arg/param bindings. Matching the behavior of verification, these types are expected to have invariant nullability, though we only collect evidence for a single pointer type layer inside the template argument. PiperOrigin-RevId: 834909612

Commit:0b72b6d
Author:Googler
Committer:Copybara-Service

Second step in downrank/excluding test -> nontest evidence Tracks whether virtual method overrides are test/nontest in the "index" and use that information later to avoid propagation crossing test -> nontest from derived to base classes. After this, we can consider tracking the crossing in evidence (instead of filtering), and downranking during merge instead. PiperOrigin-RevId: 816976917

Commit:f125377
Author:Googler
Committer:Copybara-Service

Hook up more of the inference with summaries -- first in infer_tu and tests This adds a TUSummary proto, to collect each of the individual summaries and the virtual method summary. For now, we keep the old infer_tu behavior as well (and parameterize the tests), but we can delete that once we've switched the default. PiperOrigin-RevId: 821652874 Change-Id: I4604c1cf1bd1f2c814b42016d4ad8207b6b65890

The documentation is generated from this commit.

Commit:ed913f8
Author:Googler
Committer:Copybara-Service

Retain propagated_from Evidence field in samples for computed SlotInferences. This will retain any future fields added to Evidence unless they are specifically cleared. PiperOrigin-RevId: 820684621 Change-Id: I6f2d4699e7b9ed54f39fe00ccb014e07624708cb

Commit:4c77f8b
Author:Googler
Committer:Copybara-Service

Track the original symbol for which evidence was emitted when propagating to related virtual methods within a TU. PiperOrigin-RevId: 820225628 Change-Id: Ib1227eae3ccd37937945ced5cbc1434bb071d21e

Commit:db48d6f
Author:Googler
Committer:Copybara-Service

Add support for serializing VirtualMethodIndex to/from proto. This data needs to persist between inference stages. PiperOrigin-RevId: 817783981 Change-Id: Ic9dc537e6f5e7e6639338ecf1c6d98d5270b901a

Commit:cd51adc
Author:Googler
Committer:Copybara-Service

Nullability inference: support overrides from previous inference iterations when processing summarized evidence. In the phase2 of inference, SummaryEvidenceCollector can check for overrides of nullability annotations for the given symbol. The nullability of a param is thus adjusted during inference, and the new nullability is used for subsequent evidence collection steps. The overlay only applies to "anonymous" declarations -- those that are not referenced by name and so not picked up in InferableSlots, nor modeled symbolically. PiperOrigin-RevId: 817767923 Change-Id: I2ef9b536689ea5d31ca07977bf5bdb741bf9ba44

Commit:bfb3391
Author:Googler
Committer:Copybara-Service

Introduce function that summarizes the inference-relevant CFG portions and exports them in a protobuf. To avoid code duplication, we refactor SummarizerAndCollector into a templated class that abstracts over the backend "collector" class. The new function then reuses the summarization functionality, but exports the summaries in a protobuf, rather than processing them direclty. The existing functionality becomes a single standalone function which instantiates the template with the existing evidence collector class. This patch includes definition of new protobuf messages to represent the summaries. A basic selection of tests is added to verify the protobuf messages are created as expected. PiperOrigin-RevId: 817718410 Change-Id: I32b96843df6ab0d6118ace167cb310be985da968

Commit:6ab3976
Author:Googler
Committer:Copybara-Service

Treat overrides of ::testing::Test::SetUp as late initializers with similar semantics to constructors. Previously, the presence of any constructor leaving a smart pointer field default-initialized was enough for a nullable inference. Now, if any (there can currently be only one) late initializer initializes the field to something not-nullable, then we do not make that nullable inference. This allows inferences of nonnull for smart pointer fields that are only assigned a nonnull value in GoogleTest test fixtures' SetUp functions. These SetUp functions have long-standing, well-understood semantics that are not previously acknowledged by our analysis. The affected fields show up very frequently in codebases using GoogleTest, causing unnecessary Nullable annotations, but even more importantly, unnecessary conflicts. PiperOrigin-RevId: 775688004 Change-Id: I4ca17bd6659a57d0bec11def2cbe944f188fc747

Commit:89fa5a8
Author:Googler
Committer:Copybara-Service

Migrate references/test uses of template alias annotations to use clang specifiers. PiperOrigin-RevId: 769721367 Change-Id: I06a766fd2227c66c0fa55b1ce675f03084b75251

Commit:afa084b
Author:Googler
Committer:Copybara-Service

Internal change PiperOrigin-RevId: 768042619 Change-Id: I7f747a02f1130474a0011ea99ce0a450df63217e

Commit:3c0e985
Author:Googler
Committer:Copybara-Service

Add debugging information fields to SlotInference and SlotPartial to allow piping through and merging. PiperOrigin-RevId: 764265201 Change-Id: I2a36a51d28d84980706f713e03dc77f34957252e

Commit:4fdb70c
Author:Googler
Committer:Copybara-Service

Infer Nonnull for pointers accessed with operator[]. PiperOrigin-RevId: 734675720 Change-Id: I1efa1e9dd2e5dbc7c7d6adbf4451d79699c40147

Commit:b6854a4
Author:Googler
Committer:Copybara-Service

Replace existing annotation offsets before/after the range with whole independent ranges. This allows removing annotations that encapsulate or are further from the type than CVR qualifiers, without removing the qualifiers. PiperOrigin-RevId: 734572481 Change-Id: I1b96dd56b2992a6d8f75f0da5ac2bcbe06b311d9

Commit:e9f61d3
Author:Googler
Committer:Copybara-Service

Insert qualifier-positioned annotations on the left for named types not ending with `*`. This is consistent with Google's style for the placement of `const`. Our preference is to place the annotation closer to the type than `const`, but this is not required. PiperOrigin-RevId: 733036109 Change-Id: I45b9142ded5bfa63bb8680ccdeb5cebae3cb2563

Commit:abb28a3
Author:Marcel Hlopko
Committer:Copybara-Service

Do not generate crubit bindings for protobufs, only collect metadata PiperOrigin-RevId: 730805673 Change-Id: I788eaeb42b203d31e8951b7448b8daa3a64e6e42

Commit:f1a04f9
Author:Marcel Hlopko
Committer:Copybara-Service

Add (failing) protobuf rust integration test PiperOrigin-RevId: 727834378 Change-Id: I2747d6055fd0dbeace146c24d60fbe9865f4b1ab

Commit:abf9a30
Author:Googler
Committer:Copybara-Service

Remove unused slot_in_type from SlotRange. And re-number proto fields now that we've removed so many from this proto that doesn't get stored. PiperOrigin-RevId: 708317146 Change-Id: I0c10620264bd6bb15475279656854b900d3db4f5

Commit:9b7e103
Author:Googler
Committer:Copybara-Service

Remove support for detecting eligible ranges containing `auto*`. This detection is not needed for adding/removing macro annotations or removing any other annotation style and we no longer need to support (avoiding) adding template alias annotations to `auto*`. PiperOrigin-RevId: 707970366 Change-Id: I04babb5ca0b027160c048477b076ab6732411eff

Commit:d1e85f6
Author:Googler
Committer:Copybara-Service

Remove supporting metadata for adding template-based annotations to complex declarators. We no longer support addition of this annotation style. PiperOrigin-RevId: 707965602 Change-Id: Iaf29a2a95c2c2b533769763792743bbcc70d1e5c

Commit:5425195
Author:Googler
Committer:Copybara-Service

Add support for adding and removing absl nullability annotation macros. These annotations are expected to behave syntactically exactly as clang's _Nonnull, etc. do. The same level of partial, broken support for removing annotations of both clang/macro and template alias forms from complex declarators is retained. Tests are added to clarify this level of support. PiperOrigin-RevId: 707926518 Change-Id: I6cb3ced82608af11cdba61d72990415a0090fbe1

Commit:3074a9a
Author:Jakob Buchgraber
Committer:Copybara-Service

No public description PiperOrigin-RevId: 705850175 Change-Id: I2c6b2e7be116701436a8727804ce6eda8eaff019

Commit:b33d766
Author:Googler
Committer:Copybara-Service

Emit evidence for the second parameter of a main function, based on it's well-known definition as being a non-null pointer. PiperOrigin-RevId: 702718576 Change-Id: I8c9cfc9ebc84627d4ee9275caa1de0153980eadf

Commit:e3d7309
Author:Googler
Committer:Copybara-Service

Collect softer evidence from Nonnull pointers (or references to them) that are passed as arguments or return values to const reference types. Much like non-reference types, const reference type nullabilities in these positions are not completely invariant. It is safe for the recipient of a `int* _Nullable const&` to hold a reference to an immutable Nonnull value. PiperOrigin-RevId: 701973456 Change-Id: I378f9bae3561b83278c94e07fff513c90e911a1b

Commit:b4aec91
Author:Googler
Committer:Copybara-Service

More precisely collect evidence from the taking of references to pointers. When a reference to a mutable pointer is taken, their type nullabilities must match, not just the nullability of the decl's current value, to ensure that the underlying value is not made inappropriately null by assignment through the reference. When a reference declared as referring to a const Nonnull pointer is taken, the left and right side type nullabilities must also match, to ensure the underlying value is not made inappropriately null directly or through a different reference that is declared as pointing to a Nullable pointer. Also add some aspirational test cases for assignments to pointers to mutable pointers and some cases of copy assignment through references. PiperOrigin-RevId: 700398379 Change-Id: I5eba1c4fffcdc8de589b3d5d59d9430ddd42700b

Commit:86d7452
Author:Googler
Committer:Copybara-Service

Remove the slot field of a SlotRange. This allows the same SlotRange to represent a single source range that supplies the type for two different nullability slots (aka two different positions in potentially two different nullability vectors). This is a rare situation, but can occur with macros that accept type arguments and use the same type argument in multiple places. PiperOrigin-RevId: 695431990 Change-Id: I1a3b041c87f0eb603004db9d3c8ca81ea5b0dec3

Commit:f17d956
Author:Googler
Committer:Copybara-Service

Remove Inference proto in favor of only SlotInferences. This will allow future changes to potentially merge all evidence for a source range into an inference, instead of only being able to merge evidence for a symbol by slot. PiperOrigin-RevId: 694183620 Change-Id: I053114c83c050cf945e9937f808916e9f843cd26

Commit:d8bb7a6
Author:Googler
Committer:Copybara-Service

Remove TypeLocRanges and instead use collections of SlotRanges. This provides more flexibility in how these ranges are used to produce edits applying inferred nullabilities, particularly in cases where a single source range contains a type used in multiple places, e.g. through the use of macros. PiperOrigin-RevId: 693144103 Change-Id: I8eb24677bc619e3b987e1ef664674e4c424155ab

Commit:3d53595
Author:Googler
Committer:Copybara-Service

Expose the ordering of SlotRanges within the type they are extracted from, not just the inference slot number. This provides more flexibility when generating source range edits from SlotRanges which may not be contained within a TypeLocRanges or may not already be ordered by this newly-exposed ordering. PiperOrigin-RevId: 692980270 Change-Id: I0843bb913e212c89b1d74988494faa92c8761fd1

Commit:95b7d03
Author:Googler
Committer:Copybara-Service

Mark ranges for nested pointers using `auto`, not just top-level. PiperOrigin-RevId: 671745910 Change-Id: I40a787347f1006017ec0558d8b636233027fcedc

Commit:247f117
Author:Googler
Committer:Copybara-Service

Record when an eligible range is produced for an `auto*` type and add tests to reveal current behavior of inference for them. PiperOrigin-RevId: 670963249 Change-Id: I13af16e872b00da6a9e93951bfc63378e51d78ca

Commit:e5ab0c2
Author:Googler
Committer:Copybara-Service

Collect evidence from assignments from Nonnull and Unknown. Infer from Nonnull assignments with no evidence of any other assignments that the slot should be annotated Nonnull. PiperOrigin-RevId: 663339024 Change-Id: Ib3c4122242b553f670a21ce444a804cfa90e4b35

Commit:dddd56a
Author:Googler
Committer:Copybara-Service

Produce ranges for nested array/pointer/function pointer types with complex declarators. These types need special handling due to the placement of names and array brackets that is different when the pointer types are inside an alias template (such as a nullability annotation). This won't cover all cases, but those not covered are even more rare than these complex declarators already are in general. PiperOrigin-RevId: 651443512 Change-Id: I265849ba30466e8d90e1f8b7ecc274bb1a4d95cd

Commit:c4df741
Author:Googler
Committer:Copybara-Service

Use distinct evidence for reference type returns and arguments. Nullability of pointers held by reference needs to be invariant, unlike bare pointers. For reference/pointer-to-mutable-pointer parameters, this revealed a limitation of our post-transfer-function evidence collection, due to the treatment of these parameters as output parameters that leave the arguments as Unknown by the time we are collecting evidence. PiperOrigin-RevId: 647742932 Change-Id: I0f634892373d99b1b94ff982e8392cc3a2f729bf

Commit:113775f
Author:Googler
Committer:Copybara-Service

Avoid producing edits duplicative with an existing pragma-defined default nullability. PiperOrigin-RevId: 645395033 Change-Id: I1fce2801054b3edc2608e2812aa2178a6c2aa7ed

Commit:3bfffab
Author:Googler
Committer:Copybara-Service

Enable removal of Unknown annotations when Nonnull/Nullable inferences are produced. Only looks for absl::NullabilityUnknown<...> and _Null_unspecified as an Unknown annotation to be removed. If we have determined that there is an Unknown annotation and a Nonnull/Nullable inference, but we don't have lengths, we leave the Unknown annotation in place to avoid producing useless edits that may not build or be readable by verification tooling. PiperOrigin-RevId: 645390584 Change-Id: Idae050a168f0902df3871e612df561fbe6e84281

Commit:4ed35f6
Author:Googler
Committer:Copybara-Service

Infer stronger intent from non-literal nullable default member initializers. NULLABLE_DEFAULT_MEMBER_INITIALIZER evidence is considered in a soft no-conflict rule, subordinate to other evidence of Nonnull-ness, as literal nullptrs are often used simply to turn uninitialized-memory bugs into louder nullptr dereference crashes in cases where the pointer is still expected to be never null after construction of the containing object. ASSIGNED_TO_NULLABLE is more aggressive evidence, which will cause a conflict if we also see evidence requiring the pointer to be marked Nonnull, and we will now use this for cases where the default member initializer is a more complex nullable form than literal nullptr, which likely indicates more explicit Nullable intent. PiperOrigin-RevId: 642991495 Change-Id: I8f0d7cc232748cbb82c13ee5f500ba1e26fd0774

Commit:32c2964
Author:Googler
Committer:Copybara-Service

Collect evidence from the returns_nonnull attribute. Mirrors the evidence for parameters from the nonnull attribute. PiperOrigin-RevId: 641897483 Change-Id: Iba9d516ab01dd48ca6edaadfdcd62cc98fd46d14

Commit:978f57a
Author:Googler
Committer:Copybara-Service

Collect inference evidence for Nonnull-ness from nonnull attribute. Using a soft rule only because if e.g. someone were somehow getting past the compiler check and assigning a nullable, safety would be violated by applying a Nonnull inference instead of a Nullable one. Not treating it the same as one of our annotations because verification won't be reading the attribute as an annotation or checking for conflicts between ours and these attributes. PiperOrigin-RevId: 641892104 Change-Id: Ie51a6f624b6eef643d104e24d22828243fec539c

Commit:b96ab1e
Author:Googler
Committer:Copybara-Service

Rename remaining references to "bound" to "assigned". PiperOrigin-RevId: 636137233 Change-Id: I3ba14e0a6b205ca59e256adea60920614d8bb502

Commit:5b4f94d
Author:Googler
Committer:Copybara-Service

Collect evidence from field initializers in constructors. Collects evidence for both the member and any inference targets in the initializer, from the member initializer list and any default member initializers for members not present in the member initializer list. Additionally, make an inference from the evidence of nullable default member initializers. PiperOrigin-RevId: 629433226 Change-Id: If7ee7ddc492ce966cf588899049f02958651f826

Commit:ed92936
Author:Googler
Committer:Copybara-Service

Collect evidence for nullability of fields from function implementations. Does not yet collect ranges for them or collect evidence from their declarations or default initializers or from the state of fields at the end of constructors for the containing type. PiperOrigin-RevId: 626028690 Change-Id: Id8bc25dc53726564dab43a65675b6dcd3be88ab4

Commit:b0c928a
Author:Googler
Committer:Copybara-Service

Collect evidence from pointer arithmetic. This will over-collect for a small set of cases that are not UB for nullptrs: addition with 0 and subtraction with another nullptr. PiperOrigin-RevId: 623503790 Change-Id: If4670a6a3c19063c779ed0ce96c6ef1502571f2a

Commit:e4a1bc1
Author:Googler
Committer:Copybara-Service

Collect already-annotated ranges again, now marked as such. PiperOrigin-RevId: 620840035 Change-Id: I437b98c7288bafeff9f71a852b30887292a1ae33

Commit:72df018
Author:Googler
Committer:Copybara-Service

Collect Nullable evidence from assignments from null/nullable. E.g. `p = nullptr` indicates that p should be Nullable. This notably diverges from the way we treat Unknown-but-provably null values in other places in evidence collection, but in a more thorough way. Left TODOs to perhaps adjust those other places to be more like this, and added/adjusted tests to make current behaviors clear. PiperOrigin-RevId: 603704781 Change-Id: I193b23454af0e7bf2c015b29800cb51d126bb1ed

Commit:325a12f
Author:Googler
Committer:Copybara-Service

Collect evidence from calls to CHECK(expr), a macro assumed to abort if !expr. Adds necessary functionality to wrap the arguments to such macros in no-op functions that can be easily identified and noticed during evidence collection. Uses this functionality in tests, but not yet in the `infer_tu_main` tool, which will need to explicitly engage the macro replacement functionality in order to collect any such evidence. Also add already-passing test for verification handling of CHECK, i.e. treating the expression as Nonnull post-CHECK. PiperOrigin-RevId: 601192616 Change-Id: Ided9f922132a66fa7bffd01f996981ef56317edb

Commit:1447fe5
Author:Googler
Committer:Copybara-Service

Infer Nullable if bound to a mutable Nullable ref. The mutable reference can be used to set the pointer to null, so creating such a reference to a Nonnull-declared pointer would not be safe. Also adjust a few cases of type eligibility that don't currently handle references. Some are semantically a fit for isInferable, but not all. PiperOrigin-RevId: 588078953 Change-Id: Ie71a0f4082e9705c9ca263c3ff0d7dcaa5f4dee8

Commit:0727153
Author:Googler
Committer:Copybara-Service

Adds library to collect all eligible type locs from a given function declaration, which can then be combined (separately) with inference results to produce annotation edits. PiperOrigin-RevId: 586484034 Change-Id: I99626687edc0415ea07280ea73d999e1e24d2cf9

Commit:477b00d
Author:Googler
Committer:Copybara-Service

Collect evidence from assignments. Evidence collection involving binding values to types does not yet incorporate information from previous inferences input or from InferableSlotsConstraint. That's coming soon in a separate change. PiperOrigin-RevId: 578905076 Change-Id: If1b9878be063dd5a2d2127ea111b3d5543eee894

Commit:8c90fda
Author:Googler
Committer:Copybara-Service

Mark non-conflicting inferences made from existing annotations as trivial. PiperOrigin-RevId: 570048944 Change-Id: Id2b75fbdc339512d8f3015520a5d1c5662976889

Commit:43114e8
Author:Googler
Committer:Copybara-Service

Infer Nonnull parameters from the passing of an influenced value to a Nonnull parameter. An influenced value is a value that is made Nonnull by the inferred parameter being marked Nonnull. PiperOrigin-RevId: 568588041 Change-Id: I14939fc1f7a035721829cfcd4ed1e2b10fe1fa10

Commit:3e3ae48
Author:Googler
Committer:Copybara-Service

Collect evidence for return type from return statements. Records Nonnull, Nullable, and Unknown return values. PiperOrigin-RevId: 549329488 Change-Id: I3c95554d674e5555a25cc99d771509162b7cb78b

Commit:e1504a6
Author:Googler
Committer:Copybara-Service

Collect evidence for function parameters from observed call sites. Records Nonnull, Nullable, and Unknown arguments for use in flexible heuristics. PiperOrigin-RevId: 549105355 Change-Id: Iea59d3ff84987446357d84cdba11df6d6ba8478f

Commit:1af66fd
Author:Sam McCall
Committer:Copybara-Service

Define merge of Evidence -> Inference, with serializable partials for combine PiperOrigin-RevId: 548722528 Change-Id: I4c263d33a2ce0ff4336711e984d9650d688f1faa

Commit:83bc55c
Author:Sam McCall
Committer:Copybara-Service

Changes to Evidence proto for aggregation and debugging Instead of conclusions like must_be_nonnull, evidence simply describes the event it saw using an enum. This has a few benefits: - it's less lossy, so easier to reason about the meaning and final inference can make better decisions - emitting evidence and merging evidence are now purely mechanical - more information preserved for debugging Also add a facility for debugging: - from the above, evidence already includes "why" - we add a source location field, so we can see "where" - source locations can be preserved all the way to Inference, but only a few PiperOrigin-RevId: 548719575 Change-Id: I254bac8a2b1c7e1988023d33fa167d46216aa4ea

Commit:0046e0e
Author:Sam McCall
Committer:Copybara-Service

Add rest of protos to represent inference intermediates and results PiperOrigin-RevId: 547220791 Change-Id: I6753cb2414c13eb3ebef185b71926fe387a4e521