diff options
-rw-r--r-- | include/clang/AST/TypeLoc.h | 2 | ||||
-rw-r--r-- | test/Index/annotate-nested-name-specifier.cpp | 10 | ||||
-rw-r--r-- | test/Index/recursive-cxx-member-calls.cpp | 12 | ||||
-rw-r--r-- | tools/libclang/CIndex.cpp | 5 |
4 files changed, 14 insertions, 15 deletions
diff --git a/include/clang/AST/TypeLoc.h b/include/clang/AST/TypeLoc.h index d1ce52b3dd..a1df744c2a 100644 --- a/include/clang/AST/TypeLoc.h +++ b/include/clang/AST/TypeLoc.h @@ -584,6 +584,8 @@ class TemplateTypeParmTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc, TemplateTypeParmTypeLoc, TemplateTypeParmType> { +public: + TemplateTypeParmDecl *getDecl() const { return getTypePtr()->getDecl(); } }; /// \brief Wrapper for substituted template type parameters. diff --git a/test/Index/annotate-nested-name-specifier.cpp b/test/Index/annotate-nested-name-specifier.cpp index a785f21b73..7c83740f08 100644 --- a/test/Index/annotate-nested-name-specifier.cpp +++ b/test/Index/annotate-nested-name-specifier.cpp @@ -177,7 +177,7 @@ struct X9 : X8 { // CHECK: Punctuation: "::" [31:18 - 31:20] CXXMethod=foo:31:33 (Definition) // CHECK: Identifier: "array" [31:20 - 31:25] TemplateRef=array:23:12 // CHECK: Punctuation: "<" [31:25 - 31:26] CXXMethod=foo:31:33 (Definition) -// CHECK: Identifier: "T" [31:26 - 31:27] CXXMethod=foo:31:33 (Definition) +// CHECK: Identifier: "T" [31:26 - 31:27] TypeRef=T:30:19 // CHECK: Punctuation: "," [31:27 - 31:28] CXXMethod=foo:31:33 (Definition) // CHECK: Identifier: "N" [31:29 - 31:30] DeclRefExpr=N:30:31 // CHECK: Punctuation: ">" [31:30 - 31:31] CXXMethod=foo:31:33 (Definition) @@ -193,7 +193,7 @@ struct X9 : X8 { // CHECK: Punctuation: "::" [35:17 - 35:19] VarDecl=max_size:35:32 (Definition) // CHECK: Identifier: "array" [35:19 - 35:24] TemplateRef=array:23:12 // CHECK: Punctuation: "<" [35:24 - 35:25] VarDecl=max_size:35:32 (Definition) -// CHECK: Identifier: "T" [35:25 - 35:26] VarDecl=max_size:35:32 (Definition) +// CHECK: Identifier: "T" [35:25 - 35:26] TypeRef=T:34:19 // CHECK: Punctuation: "," [35:26 - 35:27] VarDecl=max_size:35:32 (Definition) // CHECK: Identifier: "N" [35:28 - 35:29] DeclRefExpr=N:34:31 // CHECK: Punctuation: ">" [35:29 - 35:30] VarDecl=max_size:35:32 (Definition) @@ -259,13 +259,13 @@ struct X9 : X8 { // CHECK: Keyword: "template" [57:30 - 57:38] UnexposedExpr= // CHECK: Identifier: "vector" [57:39 - 57:45] TemplateRef=vector:4:12 // CHECK: Punctuation: "<" [57:45 - 57:46] UnexposedExpr= -// CHECK: Identifier: "T" [57:46 - 57:47] UnexposedExpr= +// CHECK: Identifier: "T" [57:46 - 57:47] TypeRef=T:54:19 // CHECK: Punctuation: ">" [57:47 - 57:48] UnexposedExpr= // CHECK: Punctuation: "::" [57:48 - 57:50] UnexposedExpr= // CHECK: Punctuation: "~" [57:50 - 57:51] UnexposedExpr= // CHECK: Identifier: "vector" [57:51 - 57:57] TemplateRef=vector:4:12 -// CHECK: Punctuation: "<" [57:57 - 57:58] CallExpr= -// CHECK: Identifier: "T" [57:58 - 57:59] CallExpr= +// CHECK: Punctuation: "<" [57:57 - 57:58] UnexposedExpr= +// CHECK: Identifier: "T" [57:58 - 57:59] TypeRef=T:54:19 // CHECK: Punctuation: ">" [57:59 - 57:60] CallExpr= // CHECK: Punctuation: "(" [57:60 - 57:61] CallExpr= // CHECK: Punctuation: ")" [57:61 - 57:62] CallExpr= diff --git a/test/Index/recursive-cxx-member-calls.cpp b/test/Index/recursive-cxx-member-calls.cpp index 3f5419d35d..6170fdcb81 100644 --- a/test/Index/recursive-cxx-member-calls.cpp +++ b/test/Index/recursive-cxx-member-calls.cpp @@ -210,7 +210,7 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo * Name) { // CHECK-tokens: Keyword: "struct" [4:37 - 4:43] ClassTemplate=pair:4:44 (Definition) // CHECK-tokens: Identifier: "pair" [4:44 - 4:48] ClassTemplate=pair:4:44 (Definition) // CHECK-tokens: Punctuation: "{" [4:49 - 4:50] ClassTemplate=pair:4:44 (Definition) -// CHECK-tokens: Identifier: "_T2" [4:51 - 4:54] FieldDecl=second:4:55 (Definition) +// CHECK-tokens: Identifier: "_T2" [4:51 - 4:54] TypeRef=_T2:4:31 // CHECK-tokens: Identifier: "second" [4:55 - 4:61] FieldDecl=second:4:55 (Definition) // CHECK-tokens: Punctuation: ";" [4:61 - 4:62] ClassTemplate=pair:4:44 (Definition) // CHECK-tokens: Punctuation: "}" [4:63 - 4:64] ClassTemplate=pair:4:44 (Definition) @@ -808,7 +808,7 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo * Name) { // CHECK-tokens: Keyword: "typename" [83:24 - 83:32] TemplateTypeParameter=R:83:33 (Definition) // CHECK-tokens: Identifier: "R" [83:33 - 83:34] TemplateTypeParameter=R:83:33 (Definition) // CHECK-tokens: Punctuation: "=" [83:35 - 83:36] TemplateTypeParameter=R:83:33 (Definition) -// CHECK-tokens: Identifier: "T" [83:37 - 83:38] TemplateTypeParameter=R:83:33 (Definition) +// CHECK-tokens: Identifier: "T" [83:37 - 83:38] TypeRef=T:83:21 // CHECK-tokens: Punctuation: ">" [83:39 - 83:40] ClassTemplate=StringSwitch:83:47 (Definition) // CHECK-tokens: Keyword: "class" [83:41 - 83:46] ClassTemplate=StringSwitch:83:47 (Definition) // CHECK-tokens: Identifier: "StringSwitch" [83:47 - 83:59] ClassTemplate=StringSwitch:83:47 (Definition) @@ -817,7 +817,7 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo * Name) { // CHECK-tokens: Identifier: "Str" [84:13 - 84:16] FieldDecl=Str:84:13 (Definition) // CHECK-tokens: Punctuation: ";" [84:16 - 84:17] ClassTemplate=StringSwitch:83:47 (Definition) // CHECK-tokens: Keyword: "const" [85:3 - 85:8] ClassTemplate=StringSwitch:83:47 (Definition) -// CHECK-tokens: Identifier: "T" [85:9 - 85:10] FieldDecl=Result:85:12 (Definition) +// CHECK-tokens: Identifier: "T" [85:9 - 85:10] TypeRef=T:83:21 // CHECK-tokens: Punctuation: "*" [85:11 - 85:12] FieldDecl=Result:85:12 (Definition) // CHECK-tokens: Identifier: "Result" [85:12 - 85:18] FieldDecl=Result:85:12 (Definition) // CHECK-tokens: Punctuation: ";" [85:18 - 85:19] ClassTemplate=StringSwitch:83:47 (Definition) @@ -861,7 +861,7 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo * Name) { // CHECK-tokens: Punctuation: "]" [88:64 - 88:65] ParmDecl=S:88:60 (Definition) // CHECK-tokens: Punctuation: "," [88:65 - 88:66] FunctionTemplate=Case:88:42 (Definition) // CHECK-tokens: Keyword: "const" [89:47 - 89:52] FunctionTemplate=Case:88:42 (Definition) -// CHECK-tokens: Identifier: "T" [89:53 - 89:54] ParmDecl=Value:89:57 (Definition) +// CHECK-tokens: Identifier: "T" [89:53 - 89:54] TypeRef=T:83:21 // CHECK-tokens: Punctuation: "&" [89:55 - 89:56] ParmDecl=Value:89:57 (Definition) // CHECK-tokens: Identifier: "Value" [89:57 - 89:62] ParmDecl=Value:89:57 (Definition) // CHECK-tokens: Punctuation: ")" [89:62 - 89:63] FunctionTemplate=Case:88:42 (Definition) @@ -871,11 +871,11 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo * Name) { // CHECK-tokens: Keyword: "this" [90:13 - 90:17] UnexposedExpr= // CHECK-tokens: Punctuation: ";" [90:17 - 90:18] UnexposedStmt= // CHECK-tokens: Punctuation: "}" [91:3 - 91:4] UnexposedStmt= -// CHECK-tokens: Identifier: "R" [92:3 - 92:4] CXXMethod=Default:92:5 (Definition) +// CHECK-tokens: Identifier: "R" [92:3 - 92:4] TypeRef=R:83:33 // CHECK-tokens: Identifier: "Default" [92:5 - 92:12] CXXMethod=Default:92:5 (Definition) // CHECK-tokens: Punctuation: "(" [92:12 - 92:13] CXXMethod=Default:92:5 (Definition) // CHECK-tokens: Keyword: "const" [92:13 - 92:18] CXXMethod=Default:92:5 (Definition) -// CHECK-tokens: Identifier: "T" [92:19 - 92:20] ParmDecl=Value:92:23 (Definition) +// CHECK-tokens: Identifier: "T" [92:19 - 92:20] TypeRef=T:83:21 // CHECK-tokens: Punctuation: "&" [92:21 - 92:22] ParmDecl=Value:92:23 (Definition) // CHECK-tokens: Identifier: "Value" [92:23 - 92:28] ParmDecl=Value:92:23 (Definition) // CHECK-tokens: Punctuation: ")" [92:28 - 92:29] CXXMethod=Default:92:5 (Definition) diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index 1379ee19fc..28f1506988 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -1452,10 +1452,7 @@ bool CursorVisitor::VisitTagTypeLoc(TagTypeLoc TL) { } bool CursorVisitor::VisitTemplateTypeParmTypeLoc(TemplateTypeParmTypeLoc TL) { - // FIXME: We can't visit the template type parameter, because there's - // no context information with which we can match up the depth/index in the - // type to the appropriate - return false; + return Visit(MakeCursorTypeRef(TL.getDecl(), TL.getNameLoc(), TU)); } bool CursorVisitor::VisitObjCInterfaceTypeLoc(ObjCInterfaceTypeLoc TL) { |