[clang] [BoundsSafety][APINotes] Upstream API notes format for bounds-safety function parameters (PR #185257)

Connector Switch via cfe-commits cfe-commits at lists.llvm.org
Sun Mar 8 08:41:01 PDT 2026


================
@@ -1074,14 +1074,43 @@ void APINotesWriter::Implementation::writeGlobalVariableBlock(
 }
 
 namespace {
+void emitBoundsSafetyInfo(raw_ostream &OS, const BoundsSafetyInfo &BSI) {
+  llvm::support::endian::Writer writer(OS, llvm::endianness::little);
+  uint8_t flags = 0;
+  if (auto kind = BSI.getKind()) {
+    flags |= 0x01;                // 1 bit
+    flags |= (uint8_t)*kind << 1; // 3 bits
+  }
+  flags <<= 4;
+  if (auto level = BSI.getLevel()) {
+    flags |= 0x01;        // 1 bit
+    flags |= *level << 1; // 3 bits
+  }
----------------
c8ef wrote:

For the level I think 3 bits is enough for most use cases. Maybe @hnrklssn can shed more light on this?

https://github.com/llvm/llvm-project/pull/185257


More information about the cfe-commits mailing list