[cfe-commits] r112862 - in /cfe/trunk: test/Index/load-stmts.cpp tools/libclang/CIndex.cpp
Douglas Gregor
dgregor at apple.com
Thu Sep 2 14:20:16 PDT 2010
Author: dgregor
Date: Thu Sep 2 16:20:16 2010
New Revision: 112862
URL: http://llvm.org/viewvc/llvm-project?rev=112862&view=rev
Log:
Add libclang visitation for C++ typeid expressions.
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=112862&r1=112861&r2=112862&view=diff
==============================================================================
--- cfe/trunk/test/Index/load-stmts.cpp (original)
+++ cfe/trunk/test/Index/load-stmts.cpp Thu Sep 2 16:20:16 2010
@@ -25,6 +25,16 @@
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
// 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]
@@ -82,4 +92,6 @@
// 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 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]
Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=112862&r1=112861&r2=112862&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Thu Sep 2 16:20:16 2010
@@ -384,6 +384,7 @@
bool VisitVAArgExpr(VAArgExpr *E);
// FIXME: InitListExpr (for the designators)
// FIXME: DesignatedInitExpr
+ bool VisitCXXTypeidExpr(CXXTypeidExpr *E);
};
} // end anonymous namespace
@@ -1567,6 +1568,17 @@
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) {
if (TypeSourceInfo *TSInfo = E->getClassReceiverTypeInfo())
if (Visit(TSInfo->getTypeLoc()))
More information about the cfe-commits
mailing list