Skip to content

Commit de7305b

Browse files
committed
[clang-doc] account anonymous typedef
1 parent d4fe3e8 commit de7305b

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@ namespace doc {
2121
static llvm::StringSet USRVisited;
2222
static llvm::sys::Mutex USRVisitedGuard;
2323

24+
25+
template <typename T> bool isTypedefAnonRecord(const T* D) {
26+
if (const auto *C = dyn_cast<CXXRecordDecl>(D)) {
27+
if (const TypedefNameDecl *TD = C->getTypedefNameForAnonDecl()) {
28+
return true;
29+
}
30+
}
31+
return false;
32+
}
33+
2434
void MapASTVisitor::HandleTranslationUnit(ASTContext &Context) {
2535
TraverseDecl(Context.getTranslationUnitDecl());
2636
}
@@ -44,7 +54,7 @@ template <typename T> bool MapASTVisitor::mapDecl(const T *D,
4454
{
4555
std::lock_guard<llvm::sys::Mutex> Guard(USRVisitedGuard);
4656
StringRef Visited = USR.str();
47-
if (USRVisited.count(Visited))
57+
if (USRVisited.count(Visited) && !isTypedefAnonRecord<T>(D))
4858
return true;
4959
// We considered a USR to be visited only when its defined
5060
if (IsDefinition)

0 commit comments

Comments
 (0)