================
@@ -105,14 +105,73 @@ class CapExprSet : public SmallVector<CapabilityExpr, 4> {
 
 class FactManager;
 class FactSet;
+class LockableFactEntry;
 
 /// This is a helper class that stores a fact that is known at a
-/// particular point in program execution.  Currently, a fact is a capability,
+/// particular point in program execution. Concretely, a fact is a capability,
 /// along with additional information, such as where it was acquired, whether
 /// it is exclusive or shared, etc.
+///
+/// A capability's facts come in two forms, and a FactSet keeps them apart:
+///
+///  * At most one definite fact per capability: the capability is held (or,
+///    for a negative capability, provably not held). A LockableFactEntry for
+///    a mutex; a ScopedLockableFactEntry for a scope object's own capability,
+///    which also lists the mutexes the object manages. Its reentrancy depth
+///    counts the levels acquired on top of the first; the levels are
+///    interchangeable -- releasing "a" level is releasing "the" level -- so
+///    a counter is all they need.
+///
+///  * Any number of try facts per capability (TryFactEntry), one per
+///    originating try-acquire call and lock kind: what that call's stored
+///    result says about the capability. An unresolved try fact is conditional
+///    -- "held if that call succeeded" -- and a branch on the call's result
+///    resolves exactly the try facts that name it as their origin. A resolved
+///    try fact stays behind as the record of what the branch proved, for
+///    joins and rebranching.
+///
+/// Either form also records its source (SourceKind): whether the level was
+/// acquired directly, asserted, declared on entry, or is managed by a scope
+/// object, which is then the one to release it. The source is one value per
+/// fact, not per level, so a definite fact whose levels came from different
+/// sources carries only the first's.
+///
+/// A capability is:
+///  - held if a definite fact exists,
+///  - may be held if only conditional try facts exist,
+///  - and not held if neither does.
+///
+/// The forms compose: a try-acquire over a held capability -- whatever its
+/// reentrancy, since at runtime such a call fails rather than deadlocks --
----------------
aaronpuchert wrote:

We might still want to warn if it's not reentrant.

https://github.com/llvm/llvm-project/pull/241550
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to