[cfe-commits] r110681 - in /cfe/trunk: test/Index/annotate-tokens.c tools/libclang/CIndex.cpp
Douglas Gregor
dgregor at apple.com
Tue Aug 10 08:02:35 PDT 2010
Author: dgregor
Date: Tue Aug 10 10:02:34 2010
New Revision: 110681
URL: http://llvm.org/viewvc/llvm-project?rev=110681&view=rev
Log:
Teach the libclang cursor visitor to walk into the type information
provided by __builtin_types_compatible_p and __builtin_va_arg
expressions, now that Abramo has added proper type-source information
to those expressions.
Modified:
cfe/trunk/test/Index/annotate-tokens.c
cfe/trunk/tools/libclang/CIndex.cpp
Modified: cfe/trunk/test/Index/annotate-tokens.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/annotate-tokens.c?rev=110681&r1=110680&r2=110681&view=diff
==============================================================================
--- cfe/trunk/test/Index/annotate-tokens.c (original)
+++ cfe/trunk/test/Index/annotate-tokens.c Tue Aug 10 10:02:34 2010
@@ -9,7 +9,14 @@
const char * hello = "Hello";
}
-// RUN: c-index-test -test-annotate-tokens=%s:4:1:9:32 %s | FileCheck %s
+typedef int Int;
+void g(int i, ...) {
+ __builtin_va_list va;
+ (void)__builtin_va_arg(va, Int);
+ (void)__builtin_types_compatible_p(Int, Int);
+}
+
+// RUN: c-index-test -test-annotate-tokens=%s:4:1:17:1 %s | FileCheck %s
// CHECK: Identifier: "T" [4:3 - 4:4] TypeRef=T:1:13
// CHECK: Punctuation: "*" [4:4 - 4:5] VarDecl=t_ptr:4:6 (Definition)
// CHECK: Identifier: "t_ptr" [4:6 - 4:11] VarDecl=t_ptr:4:6 (Definition)
@@ -61,5 +68,11 @@
// CHECK: Literal: ""Hello"" [9:24 - 9:31] UnexposedExpr=
// CHECK: Punctuation: ";" [9:31 - 9:32] UnexposedStmt=
// CHECK: Punctuation: "}" [10:1 - 10:2] UnexposedStmt=
+// CHECK: Keyword: "__builtin_va_arg" [15:9 - 15:25] UnexposedExpr=
+// CHECK: Identifier: "Int" [15:30 - 15:33] TypeRef=Int:12:13
+// CHECK: Keyword: "__builtin_types_compatible_p" [16:9 - 16:37] UnexposedExpr=
+// CHECK: Identifier: "Int" [16:38 - 16:41] TypeRef=Int:12:13
+// CHECK: Punctuation: "," [16:41 - 16:42] UnexposedExpr=
+// CHECK: Identifier: "Int" [16:43 - 16:46] TypeRef=Int:12:13
// RUN: c-index-test -test-annotate-tokens=%s:4:1:165:32 %s | FileCheck %s
// RUN: c-index-test -test-annotate-tokens=%s:4:1:165:38 %s | FileCheck %s
Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=110681&r1=110680&r2=110681&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Tue Aug 10 10:02:34 2010
@@ -344,6 +344,8 @@
// bool VisitSwitchCase(SwitchCase *S);
// Expression visitors
+ // FIXME: DeclRefExpr with template arguments, nested-name-specifier
+ // FIXME: MemberExpr with template arguments, nested-name-specifier
bool VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E);
bool VisitBlockExpr(BlockExpr *B);
bool VisitCompoundLiteralExpr(CompoundLiteralExpr *E);
@@ -352,6 +354,11 @@
bool VisitObjCEncodeExpr(ObjCEncodeExpr *E);
bool VisitOffsetOfExpr(OffsetOfExpr *E);
bool VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *E);
+ // FIXME: AddrLabelExpr (once we have cursors for labels)
+ bool VisitTypesCompatibleExpr(TypesCompatibleExpr *E);
+ bool VisitVAArgExpr(VAArgExpr *E);
+ // FIXME: InitListExpr (for the designators)
+ // FIXME: DesignatedInitExpr
};
} // end anonymous namespace
@@ -1110,6 +1117,18 @@
return VisitExpr(E);
}
+bool CursorVisitor::VisitTypesCompatibleExpr(TypesCompatibleExpr *E) {
+ return Visit(E->getArgTInfo1()->getTypeLoc()) ||
+ Visit(E->getArgTInfo2()->getTypeLoc());
+}
+
+bool CursorVisitor::VisitVAArgExpr(VAArgExpr *E) {
+ if (Visit(E->getWrittenTypeInfo()->getTypeLoc()))
+ return true;
+
+ return Visit(MakeCXCursor(E->getSubExpr(), StmtParent, TU));
+}
+
bool CursorVisitor::VisitObjCMessageExpr(ObjCMessageExpr *E) {
if (TypeSourceInfo *TSInfo = E->getClassReceiverTypeInfo())
if (Visit(TSInfo->getTypeLoc()))
More information about the cfe-commits
mailing list