From 9cdc3aab3eae55be30003cb486f290f3ee3df3a8 Mon Sep 17 00:00:00 2001 From: Paul Kirth Date: Mon, 14 Apr 2025 17:27:03 -0700 Subject: [PATCH] [clang-doc] Use SmartMutex when visiting the AST (#135514) 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. --- clang-tools-extra/clang-doc/Mapper.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang-tools-extra/clang-doc/Mapper.cpp b/clang-tools-extra/clang-doc/Mapper.cpp index 6c90db03424c..022e3b12d82b 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 USRVisitedGuard; template bool isTypedefAnonRecord(const T *D) { if (const auto *C = dyn_cast(D)) { @@ -48,7 +48,7 @@ bool MapASTVisitor::mapDecl(const T *D, bool IsDefinition) { return true; // Prevent Visiting USR twice { - std::lock_guard Guard(USRVisitedGuard); + llvm::sys::SmartScopedLock Guard(USRVisitedGuard); StringRef Visited = USR.str(); if (USRVisited.count(Visited) && !isTypedefAnonRecord(D)) return true;