From bfebed2a839e12c3e99d635dbd1f4f875ce8b066 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Fri, 3 Sep 2010 17:24:10 +0000 Subject: [PATCH] libclang visitation for DependentScopeDeclRefExpr git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112975 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/Index/load-stmts.cpp | 5 +++++ tools/libclang/CIndex.cpp | 26 ++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/test/Index/load-stmts.cpp b/test/Index/load-stmts.cpp index 7a519c1be7..9d183de13e 100644 --- a/test/Index/load-stmts.cpp +++ b/test/Index/load-stmts.cpp @@ -51,6 +51,7 @@ void test_dependent_exprs(T t) { N::f(t); typedef T type; N::g(t); + type::template f(t); } // RUN: c-index-test -test-load-source all %s | FileCheck %s @@ -127,3 +128,7 @@ void test_dependent_exprs(T t) { // CHECK: load-stmts.cpp:53:3: NamespaceRef=N:41:11 Extent=[53:3 - 53:4] // CHECK: load-stmts.cpp:53:8: TypeRef=type:52:13 Extent=[53:8 - 53:12] // CHECK: load-stmts.cpp:53:14: DeclRefExpr=t:50:29 Extent=[53:14 - 53:15] +// CHECK: load-stmts.cpp:54:3: CallExpr= Extent=[54:3 - 54:29] +// CHECK: load-stmts.cpp:54:3: TypeRef=type:52:13 Extent=[54:3 - 54:7] +// CHECK: load-stmts.cpp:54:20: TypeRef=type:52:13 Extent=[54:20 - 54:24] +// CHECK: load-stmts.cpp:54:27: DeclRefExpr=t:50:29 Extent=[54:27 - 54:28] diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index 17afeca497..d75853b65d 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -392,6 +392,7 @@ public: bool VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E); // FIXME: UnaryTypeTraitExpr has poor source-location information. bool VisitOverloadExpr(OverloadExpr *E); + bool VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E); }; } // end anonymous namespace @@ -1636,6 +1637,31 @@ bool CursorVisitor::VisitOverloadExpr(OverloadExpr *E) { return false; } +bool CursorVisitor::VisitDependentScopeDeclRefExpr( + DependentScopeDeclRefExpr *E) { + // Visit the nested-name-specifier. + if (NestedNameSpecifier *Qualifier = E->getQualifier()) + if (VisitNestedNameSpecifier(Qualifier, E->getQualifierRange())) + return true; + + // Visit the declaration name. + if (VisitDeclarationNameInfo(E->getNameInfo())) + return true; + + // Visit the explicitly-specified template arguments. + if (const ExplicitTemplateArgumentList *ArgList + = E->getOptionalExplicitTemplateArgs()) { + for (const TemplateArgumentLoc *Arg = ArgList->getTemplateArgs(), + *ArgEnd = Arg + ArgList->NumTemplateArgs; + Arg != ArgEnd; ++Arg) { + if (VisitTemplateArgumentLoc(*Arg)) + return true; + } + } + + return false; +} + bool CursorVisitor::VisitObjCMessageExpr(ObjCMessageExpr *E) { if (TypeSourceInfo *TSInfo = E->getClassReceiverTypeInfo()) if (Visit(TSInfo->getTypeLoc())) -- 2.40.0