From 692577cd3005922d9657a85c92e3fd68b50ddea1 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Fri, 17 Sep 2010 20:26:51 +0000 Subject: [PATCH] When traversing an InitListExpr, there may not be a syntactic form; check for NULL and visit the InitListExpr we have if there is no syntactic form. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114203 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/Index/index-templates.cpp | 18 ++++++++++++++++++ tools/libclang/CIndex.cpp | 5 ++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/test/Index/index-templates.cpp b/test/Index/index-templates.cpp index fd0f5ab25d..b79b4bee4b 100644 --- a/test/Index/index-templates.cpp +++ b/test/Index/index-templates.cpp @@ -72,6 +72,19 @@ void unresolved_exprs(T &x) { swap(x, x); } +template +struct Pair { + T first; + U second; +}; + +template +void init_list(T t, U u) { + typedef U second_type; + + Pair p = { t, second_type(u) }; +} + // RUN: c-index-test -test-load-source all %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:3:19: TemplateTypeParameter=T:3:19 (Definition) Extent=[3:19 - 3:20] @@ -140,6 +153,11 @@ void unresolved_exprs(T &x) { // CHECK-LOAD: index-templates.cpp:69:3: OverloadedDeclRef=swap[60:6, 59:39, 58:27] // CHECK-LOAD: index-templates.cpp:71:6: OverloadedDeclRef=f[63:7, 64:9] // CHECK-LOAD: index-templates.cpp:72:3: OverloadedDeclRef=swap[58:27, 59:39] +// CHECK-LOAD: index-templates.cpp:82:6: FunctionTemplate=init_list:82:6 (Definition) +// CHECK-LOAD: index-templates.cpp:85:14: VarDecl=p:85:14 (Definition) Extent=[85:14 - 85:39] +// CHECK-LOAD: index-templates.cpp:85:20: DeclRefExpr=t:82:18 Extent=[85:20 - 85:21] +// CHECK-LOAD: index-templates.cpp:85:23: TypeRef=second_type:83:13 Extent=[85:23 - 85:34] +// CHECK-LOAD: index-templates.cpp:85:35: DeclRefExpr=u:82:23 Extent=[85:35 - 85:36] // RUN: c-index-test -test-load-source-usrs all %s | FileCheck -check-prefix=CHECK-USRS %s // CHECK-USRS: index-templates.cpp c:@FT@>3#T#Nt0.0#t>2#T#Nt1.0f#>t0.22t0.0# Extent=[3:1 - 4:22] diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index 2de32b0715..19f99ae265 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -1663,7 +1663,10 @@ bool CursorVisitor::VisitVAArgExpr(VAArgExpr *E) { bool CursorVisitor::VisitInitListExpr(InitListExpr *E) { // We care about the syntactic form of the initializer list, only. - return VisitExpr(E->getSyntacticForm()); + if (InitListExpr *Syntactic = E->getSyntacticForm()) + return VisitExpr(Syntactic); + + return VisitExpr(E); } bool CursorVisitor::VisitDesignatedInitExpr(DesignatedInitExpr *E) { -- 2.40.0