[index/AST] Determine if a typedef shares a name and spelling location with its underlying tag type
In such a case, as when using the NS_ENUM macro, for indexing purposes treat the typedef as 'transparent',
meaning we treat its references as symbols of the underlying tag symbol.
Also provide a libclang API to check for such typedefs.
llvm-svn: 298392
diff --git a/clang/lib/Index/IndexDecl.cpp b/clang/lib/Index/IndexDecl.cpp
index f971023..dae0cdc 100644
--- a/clang/lib/Index/IndexDecl.cpp
+++ b/clang/lib/Index/IndexDecl.cpp
@@ -231,8 +231,9 @@
}
bool VisitTypedefNameDecl(const TypedefNameDecl *D) {
- if (!IndexCtx.handleDecl(D))
- return false;
+ if (!D->isTransparentTag())
+ if (!IndexCtx.handleDecl(D))
+ return false;
IndexCtx.indexTypeSourceInfo(D->getTypeSourceInfo(), D);
return true;
}