Add skeleton proto for distributed nullability inference
PiperOrigin-RevId: 542954465
diff --git a/WORKSPACE b/WORKSPACE
index 569b33d..4f3e782 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -186,3 +186,16 @@
load("@llvm-loader//:llvm.bzl", "llvm_repository")
llvm_repository(name = "llvm-project")
+
+# protobuf (used in nullability/; crubit proper should not depend on it)
+http_archive(
+ name = "rules_proto",
+ sha256 = "dc3fb206a2cb3441b485eb1e423165b231235a1ea9b031b4433cf7bc1fa460dd",
+ strip_prefix = "rules_proto-5.3.0-21.7",
+ urls = [
+ "https://github.com/bazelbuild/rules_proto/archive/refs/tags/5.3.0-21.7.tar.gz",
+ ],
+)
+load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
+rules_proto_dependencies()
+rules_proto_toolchains()
diff --git a/nullability/inference/BUILD b/nullability/inference/BUILD
index d45b968..69e1465 100644
--- a/nullability/inference/BUILD
+++ b/nullability/inference/BUILD
@@ -1,5 +1,7 @@
# Inference of nullability annotations
+load("@rules_proto//proto:defs.bzl", "proto_library")
+
package(default_applicable_licenses = ["//:license"])
cc_library(
@@ -11,3 +13,13 @@
"@llvm-project//clang:basic",
],
)
+
+proto_library(
+ name = "inference_proto",
+ srcs = ["inference.proto"],
+)
+
+cc_proto_library(
+ name = "inference_cc_proto",
+ deps = [":inference_proto"],
+)
diff --git a/nullability/inference/inference.proto b/nullability/inference/inference.proto
new file mode 100644
index 0000000..c409f3b
--- /dev/null
+++ b/nullability/inference/inference.proto
@@ -0,0 +1,28 @@
+// Part of the Crubit project, under the Apache License v2.0 with LLVM
+// Exceptions. See /LICENSE for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+// Data structures for whole-codebase nullability inference.
+//
+// To accurately determine nullability of public APIs, we join information from
+// many translation units (e.g. a function's implementation, and all callsites).
+//
+// In large codebases, we may distribute this process as a mapreduce:
+// - process the many translation units in parallel, obtaining evidence
+// about all functions defined/called
+// - group the evidence by the function it describes, and combine it to form
+// conclusions for each one
+//
+// Key data structures are the evidence from one TU (map output/reduce input),
+// and the conclusions (reduce output).
+syntax = "proto2";
+
+package clang.tidy.nullability;
+
+// Describes a restriction on the nullability of a pointer type.
+// This constrains a single nullability slot, e.g. the top-level of an int**.
+message NullabilityConstraint {
+ // We have evidence that requires this type to be non-null.
+ // For example, a pointer parameter that is dereferenced in the function body.
+ optional bool must_be_nonnull = 1;
+}