[clang] Thread Safety Analysis: Use replaceLock instead of removeLock+addLock (PR #141500)
via cfe-commits
cfe-commits at lists.llvm.org
Mon May 26 08:09:52 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Marco Elver (melver)
<details>
<summary>Changes</summary>
In ScopedLockableFactEntry::unlock(), we can avoid a second search, pop_back(), and push_back() if we use the already obtained iterator into the FactSet to replace the old FactEntry and take its position in the vector.
---
Full diff: https://github.com/llvm/llvm-project/pull/141500.diff
1 Files Affected:
- (modified) clang/lib/Analysis/ThreadSafety.cpp (+3-3)
``````````diff
diff --git a/clang/lib/Analysis/ThreadSafety.cpp b/clang/lib/Analysis/ThreadSafety.cpp
index 198e324414be9..9dffb8fcd2204 100644
--- a/clang/lib/Analysis/ThreadSafety.cpp
+++ b/clang/lib/Analysis/ThreadSafety.cpp
@@ -1071,9 +1071,9 @@ class ScopedLockableFactEntry : public FactEntry {
return;
}
- FSet.removeLock(FactMan, Cp);
- FSet.addLock(FactMan,
- std::make_unique<LockableFactEntry>(!Cp, LK_Exclusive, loc));
+ FSet.replaceLock(
+ FactMan, It,
+ std::make_unique<LockableFactEntry>(!Cp, LK_Exclusive, loc));
} else if (Handler) {
SourceLocation PrevLoc;
if (const FactEntry *Neg = FSet.findLock(FactMan, !Cp))
``````````
</details>
https://github.com/llvm/llvm-project/pull/141500
More information about the cfe-commits
mailing list