mirror of https://github.com/microsoft/clang.git
[libclang] Visit TypeAliasTemplateDecl
This makes TypeAliasTemplateDecl accessible via LibClang and python bindings Differential Revision: http://reviews.llvm.org/D13844 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@253166 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
93622ca0d4
commit
2c0b7d1511
|
@ -1114,7 +1114,8 @@ CursorKind.INCLUSION_DIRECTIVE = CursorKind(503)
|
||||||
|
|
||||||
# A module import declaration.
|
# A module import declaration.
|
||||||
CursorKind.MODULE_IMPORT_DECL = CursorKind(600)
|
CursorKind.MODULE_IMPORT_DECL = CursorKind(600)
|
||||||
|
# A type alias template declaration
|
||||||
|
CursorKind.TYPE_ALIAS_TEMPLATE_DECL = CursorKind(601)
|
||||||
|
|
||||||
### Template Argument Kinds ###
|
### Template Argument Kinds ###
|
||||||
class TemplateArgumentKind(BaseEnumeration):
|
class TemplateArgumentKind(BaseEnumeration):
|
||||||
|
|
|
@ -13,6 +13,7 @@ def test_get_all_kinds():
|
||||||
assert CursorKind.OBJ_SELF_EXPR in kinds
|
assert CursorKind.OBJ_SELF_EXPR in kinds
|
||||||
assert CursorKind.MS_ASM_STMT in kinds
|
assert CursorKind.MS_ASM_STMT in kinds
|
||||||
assert CursorKind.MODULE_IMPORT_DECL in kinds
|
assert CursorKind.MODULE_IMPORT_DECL in kinds
|
||||||
|
assert CursorKind.TYPE_ALIAS_TEMPLATE_DECL in kinds
|
||||||
|
|
||||||
def test_kind_groups():
|
def test_kind_groups():
|
||||||
"""Check that every kind classifies to exactly one group."""
|
"""Check that every kind classifies to exactly one group."""
|
||||||
|
|
|
@ -2296,8 +2296,9 @@ enum CXCursorKind {
|
||||||
* \brief A module import declaration.
|
* \brief A module import declaration.
|
||||||
*/
|
*/
|
||||||
CXCursor_ModuleImportDecl = 600,
|
CXCursor_ModuleImportDecl = 600,
|
||||||
|
CXCursor_TypeAliasTemplateDecl = 601,
|
||||||
CXCursor_FirstExtraDecl = CXCursor_ModuleImportDecl,
|
CXCursor_FirstExtraDecl = CXCursor_ModuleImportDecl,
|
||||||
CXCursor_LastExtraDecl = CXCursor_ModuleImportDecl,
|
CXCursor_LastExtraDecl = CXCursor_TypeAliasTemplateDecl,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief A code completion overload candidate.
|
* \brief A code completion overload candidate.
|
||||||
|
|
|
@ -3036,6 +3036,7 @@ CXCursorKind clang::getCursorKindForDecl(const Decl *D) {
|
||||||
case Decl::ParmVar: return CXCursor_ParmDecl;
|
case Decl::ParmVar: return CXCursor_ParmDecl;
|
||||||
case Decl::Typedef: return CXCursor_TypedefDecl;
|
case Decl::Typedef: return CXCursor_TypedefDecl;
|
||||||
case Decl::TypeAlias: return CXCursor_TypeAliasDecl;
|
case Decl::TypeAlias: return CXCursor_TypeAliasDecl;
|
||||||
|
case Decl::TypeAliasTemplate: return CXCursor_TypeAliasTemplateDecl;
|
||||||
case Decl::Var: return CXCursor_VarDecl;
|
case Decl::Var: return CXCursor_VarDecl;
|
||||||
case Decl::Namespace: return CXCursor_Namespace;
|
case Decl::Namespace: return CXCursor_Namespace;
|
||||||
case Decl::NamespaceAlias: return CXCursor_NamespaceAlias;
|
case Decl::NamespaceAlias: return CXCursor_NamespaceAlias;
|
||||||
|
|
|
@ -800,7 +800,7 @@ class comment_to_xml_conversion_01 {
|
||||||
template<typename T>
|
template<typename T>
|
||||||
using comment_to_xml_conversion_09 = comment_to_xml_conversion_08<T, int>;
|
using comment_to_xml_conversion_09 = comment_to_xml_conversion_08<T, int>;
|
||||||
|
|
||||||
// CHECK: comment-to-html-xml-conversion.cpp:[[@LINE-2]]:3: UnexposedDecl=comment_to_xml_conversion_09:{{.*}} FullCommentAsXML=[<Typedef file="{{[^"]+}}comment-to-html-xml-conversion.cpp" line="[[@LINE-2]]" column="3"><Name>comment_to_xml_conversion_09</Name><USR>c:@S@comment_to_xml_conversion_01@comment_to_xml_conversion_09</USR><Declaration>template <typename T>\nusing comment_to_xml_conversion_09 = comment_to_xml_conversion_08<T, int></Declaration><Abstract><Para> Aaa.</Para></Abstract></Typedef>]
|
// CHECK: comment-to-html-xml-conversion.cpp:[[@LINE-2]]:3: TypeAliasTemplateDecl=comment_to_xml_conversion_09:{{.*}} FullCommentAsXML=[<Typedef file="{{[^"]+}}comment-to-html-xml-conversion.cpp" line="[[@LINE-2]]" column="3"><Name>comment_to_xml_conversion_09</Name><USR>c:@S@comment_to_xml_conversion_01@comment_to_xml_conversion_09</USR><Declaration>template <typename T>\nusing comment_to_xml_conversion_09 = comment_to_xml_conversion_08<T, int></Declaration><Abstract><Para> Aaa.</Para></Abstract></Typedef>]
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Aaa.
|
/// Aaa.
|
||||||
|
|
|
@ -110,6 +110,9 @@ static const int FxnTmpl_Var = 7;
|
||||||
template <>
|
template <>
|
||||||
void foo<float, 9, FxnTmplEnum_B, FxnTmpl_Var + 7>(float Value);
|
void foo<float, 9, FxnTmplEnum_B, FxnTmpl_Var + 7>(float Value);
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
using alias = T;
|
||||||
|
|
||||||
// RUN: c-index-test -test-load-source all -fno-delayed-template-parsing %s | FileCheck -check-prefix=CHECK-LOAD %s
|
// RUN: c-index-test -test-load-source all -fno-delayed-template-parsing %s | FileCheck -check-prefix=CHECK-LOAD %s
|
||||||
// CHECK-LOAD: index-templates.cpp:4:6: FunctionTemplate=f:4:6 Extent=[3:1 - 4:22]
|
// CHECK-LOAD: index-templates.cpp:4:6: FunctionTemplate=f:4:6 Extent=[3:1 - 4:22]
|
||||||
// CHECK-LOAD: index-templates.cpp:3:19: TemplateTypeParameter=T:3:19 (Definition) Extent=[3:10 - 3:20]
|
// CHECK-LOAD: index-templates.cpp:3:19: TemplateTypeParameter=T:3:19 (Definition) Extent=[3:10 - 3:20]
|
||||||
|
@ -189,6 +192,10 @@ void foo<float, 9, FxnTmplEnum_B, FxnTmpl_Var + 7>(float Value);
|
||||||
// CHECK-LOAD: index-templates.cpp:101:20: C++ base class specifier=Pair<int, int>:98:16 [access=public isVirtual=false] Extent=[101:20 - 101:34]
|
// CHECK-LOAD: index-templates.cpp:101:20: C++ base class specifier=Pair<int, int>:98:16 [access=public isVirtual=false] Extent=[101:20 - 101:34]
|
||||||
// CHECK-LOAD: index-templates.cpp:101:36: C++ base class specifier=Pair<T, U>:76:8 [access=public isVirtual=false] Extent=[101:36 - 101:46]
|
// CHECK-LOAD: index-templates.cpp:101:36: C++ base class specifier=Pair<T, U>:76:8 [access=public isVirtual=false] Extent=[101:36 - 101:46]
|
||||||
// CHECK-LOAD: index-templates.cpp:111:6: FunctionDecl=foo:111:6 [Specialization of foo:107:6] [Template arg 0: kind: 1, type: float] [Template arg 1: kind: 4, intval: 9] [Template arg 2: kind: 4, intval: 1] [Template arg 3: kind: 4, intval: 14] Extent=[110:1 - 111:64]
|
// CHECK-LOAD: index-templates.cpp:111:6: FunctionDecl=foo:111:6 [Specialization of foo:107:6] [Template arg 0: kind: 1, type: float] [Template arg 1: kind: 4, intval: 9] [Template arg 2: kind: 4, intval: 1] [Template arg 3: kind: 4, intval: 14] Extent=[110:1 - 111:64]
|
||||||
|
// CHECK-LOAD: index-templates.cpp:114:1: TypeAliasTemplateDecl=alias:114:1 (Definition) Extent=[113:1 - 114:16]
|
||||||
|
// CHECK-LOAD: index-templates.cpp:113:17: TemplateTypeParameter=T:113:17 (Definition) Extent=[113:11 - 113:18] [access=public]
|
||||||
|
// CHECK-LOAD: index-templates.cpp:114:7: TypeAliasDecl=alias:114:7 (Definition) Extent=[114:1 - 114:16]
|
||||||
|
// CHECK-LOAD: index-templates.cpp:114:15: TypeRef=T:113:17 Extent=[114:15 - 114:16]
|
||||||
|
|
||||||
// RUN: c-index-test -test-load-source-usrs all -fno-delayed-template-parsing %s | FileCheck -check-prefix=CHECK-USRS %s
|
// RUN: c-index-test -test-load-source-usrs all -fno-delayed-template-parsing %s | FileCheck -check-prefix=CHECK-USRS %s
|
||||||
// CHECK-USRS: index-templates.cpp c:@FT@>3#T#Nt0.0#t>2#T#Nt1.0f#>t0.22S0_#v# Extent=[3:1 - 4:22]
|
// CHECK-USRS: index-templates.cpp c:@FT@>3#T#Nt0.0#t>2#T#Nt1.0f#>t0.22S0_#v# Extent=[3:1 - 4:22]
|
||||||
|
|
|
@ -664,6 +664,13 @@ bool CursorVisitor::VisitTranslationUnitDecl(TranslationUnitDecl *D) {
|
||||||
llvm_unreachable("Translation units are visited directly by Visit()");
|
llvm_unreachable("Translation units are visited directly by Visit()");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CursorVisitor::VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D) {
|
||||||
|
if (VisitTemplateParameters(D->getTemplateParameters()))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return Visit(MakeCXCursor(D->getTemplatedDecl(), TU, RegionOfInterest));
|
||||||
|
}
|
||||||
|
|
||||||
bool CursorVisitor::VisitTypeAliasDecl(TypeAliasDecl *D) {
|
bool CursorVisitor::VisitTypeAliasDecl(TypeAliasDecl *D) {
|
||||||
if (TypeSourceInfo *TSInfo = D->getTypeSourceInfo())
|
if (TypeSourceInfo *TSInfo = D->getTypeSourceInfo())
|
||||||
return Visit(TSInfo->getTypeLoc());
|
return Visit(TSInfo->getTypeLoc());
|
||||||
|
@ -4436,6 +4443,8 @@ CXString clang_getCursorKindSpelling(enum CXCursorKind Kind) {
|
||||||
return cxstring::createRef("OMPCancelDirective");
|
return cxstring::createRef("OMPCancelDirective");
|
||||||
case CXCursor_OverloadCandidate:
|
case CXCursor_OverloadCandidate:
|
||||||
return cxstring::createRef("OverloadCandidate");
|
return cxstring::createRef("OverloadCandidate");
|
||||||
|
case CXCursor_TypeAliasTemplateDecl:
|
||||||
|
return cxstring::createRef("TypeAliasTemplateDecl");
|
||||||
}
|
}
|
||||||
|
|
||||||
llvm_unreachable("Unhandled CXCursorKind");
|
llvm_unreachable("Unhandled CXCursorKind");
|
||||||
|
|
|
@ -195,6 +195,7 @@ public:
|
||||||
bool VisitChildren(CXCursor Parent);
|
bool VisitChildren(CXCursor Parent);
|
||||||
|
|
||||||
// Declaration visitors
|
// Declaration visitors
|
||||||
|
bool VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D);
|
||||||
bool VisitTypeAliasDecl(TypeAliasDecl *D);
|
bool VisitTypeAliasDecl(TypeAliasDecl *D);
|
||||||
bool VisitAttributes(Decl *D);
|
bool VisitAttributes(Decl *D);
|
||||||
bool VisitBlockDecl(BlockDecl *B);
|
bool VisitBlockDecl(BlockDecl *B);
|
||||||
|
|
Loading…
Reference in New Issue