Skip to content

Commit 9cdc3aa

Browse files
authored
[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.
1 parent e96111d commit 9cdc3aa

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

clang-tools-extra/clang-doc/Mapper.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace clang {
1919
namespace doc {
2020

2121
static llvm::StringSet<> USRVisited;
22-
static llvm::sys::Mutex USRVisitedGuard;
22+
static llvm::sys::SmartMutex<true> USRVisitedGuard;
2323

2424
template <typename T> bool isTypedefAnonRecord(const T *D) {
2525
if (const auto *C = dyn_cast<CXXRecordDecl>(D)) {
@@ -48,7 +48,7 @@ bool MapASTVisitor::mapDecl(const T *D, bool IsDefinition) {
4848
return true;
4949
// Prevent Visiting USR twice
5050
{
51-
std::lock_guard<llvm::sys::Mutex> Guard(USRVisitedGuard);
51+
llvm::sys::SmartScopedLock<true> Guard(USRVisitedGuard);
5252
StringRef Visited = USR.str();
5353
if (USRVisited.count(Visited) && !isTypedefAnonRecord<T>(D))
5454
return true;

0 commit comments

Comments
 (0)