diff options
author | Ted Kremenek <kremenek@apple.com> | 2010-04-11 21:47:37 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2010-04-11 21:47:37 +0000 |
commit | 1ee6cad59f017601ea54fbb4f62a6e8d69897e3e (patch) | |
tree | e566f9311ebcc0abf2199e98ff3add9bb92470c1 /tools/CIndex/CIndex.cpp | |
parent | f3d4a97a32da7f1a69280355aec2469c795ac13e (diff) |
Add CIndex support for blocks.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100989 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/CIndex/CIndex.cpp')
-rw-r--r-- | tools/CIndex/CIndex.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/tools/CIndex/CIndex.cpp b/tools/CIndex/CIndex.cpp index 7a8c78ecea..9171c9ee84 100644 --- a/tools/CIndex/CIndex.cpp +++ b/tools/CIndex/CIndex.cpp @@ -242,6 +242,7 @@ public: // Declaration visitors bool VisitAttributes(Decl *D); + bool VisitBlockDecl(BlockDecl *B); bool VisitDeclContext(DeclContext *DC); bool VisitTranslationUnitDecl(TranslationUnitDecl *D); bool VisitTypedefDecl(TypedefDecl *D); @@ -297,10 +298,11 @@ public: bool VisitForStmt(ForStmt *S); // Expression visitors - bool VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *E); - bool VisitExplicitCastExpr(ExplicitCastExpr *E); + bool VisitBlockExpr(BlockExpr *B); bool VisitCompoundLiteralExpr(CompoundLiteralExpr *E); + bool VisitExplicitCastExpr(ExplicitCastExpr *E); bool VisitObjCMessageExpr(ObjCMessageExpr *E); + bool VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *E); }; } // end anonymous namespace @@ -484,6 +486,15 @@ bool CursorVisitor::VisitChildren(CXCursor Cursor) { return false; } +bool CursorVisitor::VisitBlockDecl(BlockDecl *B) { + for (BlockDecl::param_iterator I=B->param_begin(), E=B->param_end(); I!=E;++I) + if (Decl *D = *I) + if (Visit(D)) + return true; + + return Visit(MakeCXCursor(B->getBody(), StmtParent, TU)); +} + bool CursorVisitor::VisitDeclContext(DeclContext *DC) { for (DeclContext::decl_iterator I = DC->decls_begin(), E = DC->decls_end(); I != E; ++I) { @@ -924,6 +935,10 @@ bool CursorVisitor::VisitForStmt(ForStmt *S) { return false; } +bool CursorVisitor::VisitBlockExpr(BlockExpr *B) { + return Visit(B->getBlockDecl()); +} + bool CursorVisitor::VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *E) { if (E->isArgumentType()) { if (TypeSourceInfo *TSInfo = E->getArgumentTypeInfo()) @@ -1552,6 +1567,8 @@ CXString clang_getCursorKindSpelling(enum CXCursorKind Kind) { return createCXString("TypeRef"); case CXCursor_UnexposedExpr: return createCXString("UnexposedExpr"); + case CXCursor_BlockExpr: + return createCXString("BlockExpr"); case CXCursor_DeclRefExpr: return createCXString("DeclRefExpr"); case CXCursor_MemberRefExpr: |