[cfe-commits] r112884 - in /cfe/trunk: test/Index/load-stmts.cpp tools/libclang/CIndex.cpp
Douglas Gregor
dgregor at apple.com
Thu Sep 2 15:29:21 PDT 2010
Author: dgregor
Date: Thu Sep 2 17:29:21 2010
New Revision: 112884
URL: http://llvm.org/viewvc/llvm-project?rev=112884&view=rev
Log:
Teach libclang to visit OverloadExprs, so that we can reuse this
code. Also, teach it about explicitly-specified template arguments.
Modified:
cfe/trunk/test/Index/load-stmts.cpp
cfe/trunk/tools/libclang/CIndex.cpp
Modified: cfe/trunk/test/Index/load-stmts.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/load-stmts.cpp?rev=112884&r1=112883&r2=112884&view=diff
==============================================================================
--- cfe/trunk/test/Index/load-stmts.cpp (original)
+++ cfe/trunk/test/Index/load-stmts.cpp Thu Sep 2 17:29:21 2010
@@ -41,11 +41,16 @@
namespace N {
int f(int);
float f(float);
+
+ template<typename T> T g(T);
+ template<typename T> T g(T*);
}
template<typename T>
void test_dependent_exprs(T t) {
N::f(t);
+ typedef T type;
+ N::g<type>(t);
}
// RUN: c-index-test -test-load-source all %s | FileCheck %s
@@ -113,7 +118,12 @@
// CHECK: load-stmts.cpp:38:3: DeclRefExpr=int_ptr:37:12 Extent=[38:3 - 38:10]
// CHECK: load-stmts.cpp:38:12: TypeRef=Integer:36:15 Extent=[38:12 - 38:19]
// CHECK: load-stmts.cpp:38:22: TypeRef=Integer:36:15 Extent=[38:22 - 38:29]
-// CHECK: load-stmts.cpp:47:6: FunctionTemplate=test_dependent_exprs:47:6 (Definition)
-// CHECK: load-stmts.cpp:48:3: CallExpr= Extent=[48:3 - 48:10]
-// CHECK: load-stmts.cpp:48:3: NamespaceRef=N:41:11 Extent=[48:3 - 48:4]
-// CHECK: load-stmts.cpp:48:8: DeclRefExpr=t:47:29 Extent=[48:8 - 48:9]
+// CHECK: load-stmts.cpp:50:6: FunctionTemplate=test_dependent_exprs:50:6 (Definition)
+// CHECK: load-stmts.cpp:51:3: CallExpr= Extent=[51:3 - 51:10]
+// CHECK: load-stmts.cpp:51:3: NamespaceRef=N:41:11 Extent=[51:3 - 51:4]
+// CHECK: load-stmts.cpp:51:8: DeclRefExpr=t:50:29 Extent=[51:8 - 51:9]
+// CHECK: load-stmts.cpp:52:13: TypedefDecl=type:52:13 (Definition) Extent=[52:13 - 52:17]
+// CHECK: load-stmts.cpp:53:3: CallExpr= Extent=[53:3 - 53:16]
+// 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]
Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=112884&r1=112883&r2=112884&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Thu Sep 2 17:29:21 2010
@@ -391,7 +391,7 @@
// FIXME: CXXNewExpr has poor source-location information
bool VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E);
// FIXME: UnaryTypeTraitExpr has poor source-location information.
- bool VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E);
+ bool VisitOverloadExpr(OverloadExpr *E);
};
} // end anonymous namespace
@@ -1610,7 +1610,7 @@
return false;
}
-bool CursorVisitor::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
+bool CursorVisitor::VisitOverloadExpr(OverloadExpr *E) {
// Visit the nested-name-specifier.
if (NestedNameSpecifier *Qualifier = E->getQualifier())
if (VisitNestedNameSpecifier(Qualifier, E->getQualifierRange()))
@@ -1620,6 +1620,17 @@
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;
+ }
+ }
+
// FIXME: We don't have a way to visit all of the declarations referenced
// here.
return false;
More information about the cfe-commits
mailing list