[clang-tools-extra] [clang-doc] Use SmartMutex when visiting the AST (PR #135514)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Apr 12 19:41:21 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-tools-extra
Author: Paul Kirth (ilovepi)
<details>
<summary>Changes</summary>
The SmartMutex will allow us to have a cheap mutex implementation when
using the Standalone executor, since it's single threaded. Performance
should be about the same for AllTUs executor.
---
Full diff: https://github.com/llvm/llvm-project/pull/135514.diff
1 Files Affected:
- (modified) clang-tools-extra/clang-doc/Mapper.cpp (+2-2)
``````````diff
diff --git a/clang-tools-extra/clang-doc/Mapper.cpp b/clang-tools-extra/clang-doc/Mapper.cpp
index 6c90db03424c6..022e3b12d82bc 100644
--- a/clang-tools-extra/clang-doc/Mapper.cpp
+++ b/clang-tools-extra/clang-doc/Mapper.cpp
@@ -19,7 +19,7 @@ namespace clang {
namespace doc {
static llvm::StringSet<> USRVisited;
-static llvm::sys::Mutex USRVisitedGuard;
+static llvm::sys::SmartMutex<true> USRVisitedGuard;
template <typename T> bool isTypedefAnonRecord(const T *D) {
if (const auto *C = dyn_cast<CXXRecordDecl>(D)) {
@@ -48,7 +48,7 @@ bool MapASTVisitor::mapDecl(const T *D, bool IsDefinition) {
return true;
// Prevent Visiting USR twice
{
- std::lock_guard<llvm::sys::Mutex> Guard(USRVisitedGuard);
+ llvm::sys::SmartScopedLock<true> Guard(USRVisitedGuard);
StringRef Visited = USR.str();
if (USRVisited.count(Visited) && !isTypedefAnonRecord<T>(D))
return true;
``````````
</details>
https://github.com/llvm/llvm-project/pull/135514
More information about the cfe-commits
mailing list