r303648 - [index] The references to type aliases and typedefs from template
Alex Lorenz via cfe-commits
cfe-commits at lists.llvm.org
Tue May 23 09:27:42 PDT 2017
Author: arphaman
Date: Tue May 23 11:27:42 2017
New Revision: 303648
URL: http://llvm.org/viewvc/llvm-project?rev=303648&view=rev
Log:
[index] The references to type aliases and typedefs from template
instantiations should refer to the pattern type aliases / typedefs in the base
templates
rdar://32325459
Modified:
cfe/trunk/lib/Index/IndexingContext.cpp
cfe/trunk/test/Index/Core/index-instantiated-source.cpp
Modified: cfe/trunk/lib/Index/IndexingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexingContext.cpp?rev=303648&r1=303647&r2=303648&view=diff
==============================================================================
--- cfe/trunk/lib/Index/IndexingContext.cpp (original)
+++ cfe/trunk/lib/Index/IndexingContext.cpp Tue May 23 11:27:42 2017
@@ -127,7 +127,7 @@ bool IndexingContext::isTemplateImplicit
} else if (const auto *RD = dyn_cast<CXXRecordDecl>(D)) {
if (RD->getInstantiatedFromMemberClass())
TKind = RD->getTemplateSpecializationKind();
- } else if (isa<FieldDecl>(D)) {
+ } else if (isa<FieldDecl>(D) || isa<TypedefNameDecl>(D)) {
if (const auto *Parent = dyn_cast<Decl>(D->getDeclContext()))
return isTemplateImplicitInstantiation(Parent);
}
@@ -177,14 +177,15 @@ static const Decl *adjustTemplateImplici
return VD->getTemplateInstantiationPattern();
} else if (const auto *RD = dyn_cast<CXXRecordDecl>(D)) {
return RD->getInstantiatedFromMemberClass();
- } else if (const auto *FD = dyn_cast<FieldDecl>(D)) {
+ } else if (isa<FieldDecl>(D) || isa<TypedefNameDecl>(D)) {
+ const auto *ND = cast<NamedDecl>(D);
if (const CXXRecordDecl *Pattern =
- getDeclContextForTemplateInstationPattern(FD)) {
- for (const NamedDecl *ND : Pattern->lookup(FD->getDeclName())) {
- if (ND->isImplicit())
+ getDeclContextForTemplateInstationPattern(ND)) {
+ for (const NamedDecl *BaseND : Pattern->lookup(ND->getDeclName())) {
+ if (BaseND->isImplicit())
continue;
- if (isa<FieldDecl>(ND))
- return ND;
+ if (BaseND->getKind() == ND->getKind())
+ return BaseND;
}
}
}
Modified: cfe/trunk/test/Index/Core/index-instantiated-source.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/index-instantiated-source.cpp?rev=303648&r1=303647&r2=303648&view=diff
==============================================================================
--- cfe/trunk/test/Index/Core/index-instantiated-source.cpp (original)
+++ cfe/trunk/test/Index/Core/index-instantiated-source.cpp Tue May 23 11:27:42 2017
@@ -37,6 +37,11 @@ public:
public:
SubNestedType(int);
};
+ using TypeAlias = T;
+// CHECK: [[@LINE-1]]:11 | type-alias/C++ | TypeAlias | c:@ST>2#T#T at TemplateClass@S at NestedType@TypeAlias |
+
+ typedef int Typedef;
+// CHECK: [[@LINE-1]]:17 | type-alias/C | Typedef | c:{{.*}}index-instantiated-source.cpp at ST>2#T#T at TemplateClass@S at NestedType@T at Typedef |
};
};
@@ -64,4 +69,9 @@ void canonicalizeInstaniationReferences(
TT::NestedType::SubNestedType subNestedType(0);
// CHECK: [[@LINE-1]]:7 | struct/C++ | NestedType | c:@ST>2#T#T at TemplateClass@S at NestedType |
// CHECK: [[@LINE-2]]:19 | class/C++ | SubNestedType | c:@ST>2#T#T at TemplateClass@S at NestedType@S at SubNestedType |
+
+ TT::NestedType::TypeAlias nestedTypeAlias;
+// CHECK: [[@LINE-1]]:19 | type-alias/C++ | TypeAlias | c:@ST>2#T#T at TemplateClass@S at NestedType@TypeAlias |
+ TT::NestedType::Typedef nestedTypedef;
+// CHECK: [[@LINE-1]]:19 | type-alias/C | Typedef | c:{{.*}}index-instantiated-source.cpp at ST>2#T#T at TemplateClass@S at NestedType@T at Typedef |
}
More information about the cfe-commits
mailing list