[cfe-commits] r112860 - in /cfe/trunk: test/Index/index-templates.cpp tools/libclang/CIndex.cpp
Douglas Gregor
dgregor at apple.com
Thu Sep 2 14:07:44 PDT 2010
Author: dgregor
Date: Thu Sep 2 16:07:44 2010
New Revision: 112860
URL: http://llvm.org/viewvc/llvm-project?rev=112860&view=rev
Log:
In libclang, visit the nested-name-specifier and explicitly-specified template arguments of a MemberExpr.
Modified:
cfe/trunk/test/Index/index-templates.cpp
cfe/trunk/tools/libclang/CIndex.cpp
Modified: cfe/trunk/test/Index/index-templates.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/index-templates.cpp?rev=112860&r1=112859&r2=112860&view=diff
==============================================================================
--- cfe/trunk/test/Index/index-templates.cpp (original)
+++ cfe/trunk/test/Index/index-templates.cpp Thu Sep 2 16:07:44 2010
@@ -46,8 +46,13 @@
template class vector<int*>;
+struct Z4 {
+ template<typename T> T getAs();
+};
+
void template_exprs() {
f<Unsigned, OneDimension, array>(array<Unsigned, OneDimension>());
+ Z4().getAs<Unsigned>();
}
// RUN: c-index-test -test-load-source all %s | FileCheck -check-prefix=CHECK-LOAD %s
@@ -101,11 +106,20 @@
// CHECK-LOAD: index-templates.cpp:44:31: NonTypeTemplateParameter=Value:44:31 (Definition) Extent=[44:22 - 44:36]
// CHECK-LOAD: index-templates.cpp:44:22: TypeRef=Unsigned:42:18 Extent=[44:22 - 44:30]
// CHECK-LOAD: index-templates.cpp:47:16: ClassDecl=vector:47:16 (Definition) [Specialization of vector:14:7] Extent=[47:1 - 47:22]
-// CHECK-LOAD: index-templates.cpp:49:6: FunctionDecl=template_exprs:49:6 (Definition) Extent=[49:6 - 51:2]
-// CHECK-LOAD: index-templates.cpp:50:3: DeclRefExpr=f:4:6 Extent=[50:3 - 50:35]
-// CHECK-LOAD: index-templates.cpp:50:5: TypeRef=Unsigned:42:18 Extent=[50:5 - 50:13]
-// CHECK-LOAD: index-templates.cpp:50:15: DeclRefExpr=OneDimension:35:16 Extent=[50:15 - 50:27]
-// CHECK-LOAD: index-templates.cpp:50:29: TemplateRef=array:37:8 Extent=[50:29 - 50:34]
+// CHECK-LOAD: index-templates.cpp:49:8: StructDecl=Z4:49:8 (Definition) Extent=[49:1 - 51:2]
+// CHECK-LOAD: index-templates.cpp:50:26: FunctionTemplate=getAs:50:26 Extent=[50:3 - 50:33]
+// CHECK-LOAD: index-templates.cpp:50:21: TemplateTypeParameter=T:50:21 (Definition) Extent=[50:21 - 50:22]
+// CHECK-LOAD: index-templates.cpp:53:6: FunctionDecl=template_exprs:53:6 (Definition)
+// CHECK-LOAD: <invalid loc>:0:0: UnexposedStmt=
+// CHECK-LOAD: index-templates.cpp:54:3: CallExpr=f:4:6 Extent=[54:3 - 54:68]
+// CHECK-LOAD: index-templates.cpp:54:3: UnexposedExpr=f:4:6 Extent=[54:3 - 54:35]
+// CHECK-LOAD: index-templates.cpp:54:3: DeclRefExpr=f:4:6 Extent=[54:3 - 54:35]
+// CHECK-LOAD: index-templates.cpp:54:5: TypeRef=Unsigned:42:18 Extent=[54:5 - 54:13]
+// CHECK-LOAD: index-templates.cpp:54:15: DeclRefExpr=OneDimension:35:16 Extent=[54:15 - 54:27]
+// CHECK-LOAD: index-templates.cpp:54:29: TemplateRef=array:37:8 Extent=[54:29 - 54:34]
+// CHECK-LOAD: index-templates.cpp:55:8: MemberRefExpr=getAs:50:26 Extent=[55:3 - 55:23]
+// CHECK-LOAD: index-templates.cpp:55:3: CallExpr= Extent=[55:3 - 55:7]
+// CHECK-LOAD: index-templates.cpp:55:14: TypeRef=Unsigned:42:18 Extent=[55:14 - 55:22]
// 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]
Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=112860&r1=112859&r2=112860&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Thu Sep 2 16:07:44 2010
@@ -370,7 +370,6 @@
// Expression visitors
bool VisitDeclRefExpr(DeclRefExpr *E);
- // FIXME: MemberExpr with template arguments, nested-name-specifier
bool VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E);
bool VisitBlockExpr(BlockExpr *B);
bool VisitCompoundLiteralExpr(CompoundLiteralExpr *E);
@@ -379,6 +378,7 @@
bool VisitObjCEncodeExpr(ObjCEncodeExpr *E);
bool VisitOffsetOfExpr(OffsetOfExpr *E);
bool VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *E);
+ bool VisitMemberExpr(MemberExpr *E);
// FIXME: AddrLabelExpr (once we have cursors for labels)
bool VisitTypesCompatibleExpr(TypesCompatibleExpr *E);
bool VisitVAArgExpr(VAArgExpr *E);
@@ -1511,6 +1511,34 @@
return VisitExpr(E);
}
+bool CursorVisitor::VisitMemberExpr(MemberExpr *E) {
+ // Visit the base expression.
+ if (Visit(MakeCXCursor(E->getBase(), StmtParent, TU)))
+ return true;
+
+ // Visit the nested-name-specifier
+ if (NestedNameSpecifier *Qualifier = E->getQualifier())
+ if (VisitNestedNameSpecifier(Qualifier, E->getQualifierRange()))
+ return true;
+
+ // Visit the declaration name.
+ if (VisitDeclarationNameInfo(E->getMemberNameInfo()))
+ return true;
+
+ // Visit the explicitly-specified template arguments, if any.
+ if (E->hasExplicitTemplateArgs()) {
+ for (const TemplateArgumentLoc *Arg = E->getTemplateArgs(),
+ *ArgEnd = Arg + E->getNumTemplateArgs();
+ Arg != ArgEnd;
+ ++Arg) {
+ if (VisitTemplateArgumentLoc(*Arg))
+ return true;
+ }
+ }
+
+ return false;
+}
+
bool CursorVisitor::VisitExplicitCastExpr(ExplicitCastExpr *E) {
if (TypeSourceInfo *TSInfo = E->getTypeInfoAsWritten())
if (Visit(TSInfo->getTypeLoc()))
More information about the cfe-commits
mailing list