Add libclang visitation for C++ typeid expressions.

llvm-svn: 112862
This commit is contained in:
Douglas Gregor 2010-09-02 21:20:16 +00:00
parent 3c9b5f394b
commit 46af501065
2 changed files with 25 additions and 1 deletions

View File

@ -25,6 +25,16 @@ class C : public A, private B {
class D : virtual public C, virtual private A {}; class D : virtual public C, virtual private A {};
namespace std {
class type_info { };
}
void test_exprs(C *c) {
int typeid_marker;
typeid(C);
typeid(c);
}
// RUN: c-index-test -test-load-source all %s | FileCheck %s // RUN: c-index-test -test-load-source all %s | FileCheck %s
// CHECK: load-stmts.cpp:1:13: TypedefDecl=T:1:13 (Definition) Extent=[1:13 - 1:14] // CHECK: load-stmts.cpp:1:13: TypedefDecl=T:1:13 (Definition) Extent=[1:13 - 1:14]
// CHECK: load-stmts.cpp:2:8: StructDecl=X:2:8 (Definition) Extent=[2:1 - 2:23] // CHECK: load-stmts.cpp:2:8: StructDecl=X:2:8 (Definition) Extent=[2:1 - 2:23]
@ -82,4 +92,6 @@ class D : virtual public C, virtual private A {};
// CHECK: load-stmts.cpp:26:7: ClassDecl=D:26:7 (Definition) Extent=[26:1 - 26:49] // CHECK: load-stmts.cpp:26:7: ClassDecl=D:26:7 (Definition) Extent=[26:1 - 26:49]
// CHECK: <invalid loc>:0:0: C++ base class specifier=class C:22:7 [access=public isVirtual=true] // CHECK: <invalid loc>:0:0: C++ base class specifier=class C:22:7 [access=public isVirtual=true]
// CHECK: <invalid loc>:0:0: C++ base class specifier=class A:14:7 [access=private isVirtual=true] // CHECK: <invalid loc>:0:0: C++ base class specifier=class A:14:7 [access=private isVirtual=true]
// CHECK: load-stmts.cpp:33:7: VarDecl=typeid_marker:33:7 (Definition)
// CHECK: load-stmts.cpp:34:10: TypeRef=class C:22:7 Extent=[34:10 - 34:11]
// CHECK: load-stmts.cpp:35:10: DeclRefExpr=c:32:20 Extent=[35:10 - 35:11]

View File

@ -384,6 +384,7 @@ public:
bool VisitVAArgExpr(VAArgExpr *E); bool VisitVAArgExpr(VAArgExpr *E);
// FIXME: InitListExpr (for the designators) // FIXME: InitListExpr (for the designators)
// FIXME: DesignatedInitExpr // FIXME: DesignatedInitExpr
bool VisitCXXTypeidExpr(CXXTypeidExpr *E);
}; };
} // end anonymous namespace } // end anonymous namespace
@ -1567,6 +1568,17 @@ bool CursorVisitor::VisitVAArgExpr(VAArgExpr *E) {
return Visit(MakeCXCursor(E->getSubExpr(), StmtParent, TU)); return Visit(MakeCXCursor(E->getSubExpr(), StmtParent, TU));
} }
bool CursorVisitor::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
if (E->isTypeOperand()) {
if (TypeSourceInfo *TSInfo = E->getTypeOperandSourceInfo())
return Visit(TSInfo->getTypeLoc());
return false;
}
return VisitExpr(E);
}
bool CursorVisitor::VisitObjCMessageExpr(ObjCMessageExpr *E) { bool CursorVisitor::VisitObjCMessageExpr(ObjCMessageExpr *E) {
if (TypeSourceInfo *TSInfo = E->getClassReceiverTypeInfo()) if (TypeSourceInfo *TSInfo = E->getClassReceiverTypeInfo())
if (Visit(TSInfo->getTypeLoc())) if (Visit(TSInfo->getTypeLoc()))