================
@@ -338,6 +338,78 @@ inline bool operator!=(const ContextInfo &LHS, const
ContextInfo &RHS) {
return !(LHS == RHS);
}
+class BoundsSafetyInfo {
+public:
+ enum class BoundsSafetyKind {
+ CountedBy = 0,
+ CountedByOrNull,
+ SizedBy,
+ SizedByOrNull,
+ EndedBy,
+ };
+
+private:
+ /// Whether the bounds safety kind has been audited.
+ LLVM_PREFERRED_TYPE(bool)
+ unsigned KindAudited : 1;
+
+ /// The kind of bounds safety for this property. Only valid if the bounds
+ /// safety has been audited.
+ LLVM_PREFERRED_TYPE(BoundsSafetyKind)
+ unsigned Kind : 3;
+
+ /// Whether the pointer indirection level has been specified.
+ LLVM_PREFERRED_TYPE(bool)
+ unsigned LevelAudited : 1;
+
+ /// The pointer indirection level at which the bounds annotation applies.
+ /// Only valid if LevelAudited is set.
+ unsigned Level : 3;
+
+public:
+ std::string ExternalBounds;
+
+ BoundsSafetyInfo()
+ : KindAudited(false), Kind(0), LevelAudited(false), Level(0),
+ ExternalBounds("") {}
+
+ std::optional<BoundsSafetyKind> getKind() const {
+ return KindAudited ? std::optional<BoundsSafetyKind>(
----------------
compnerd wrote:
Is the `std::optional<BoundsSafetyKind(...)` actually required? I would think
that it would implicitly call the ctor (unless it is marked `explicit`).
https://github.com/llvm/llvm-project/pull/186960
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits