From e77f443dbca8cdc23e5aa94a2653367e4a7cbe47 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Thu, 18 Feb 2010 03:09:07 +0000 Subject: [PATCH] Start adding cursor kinds for attributes, with first exposing IBActionAttr and IBOutletAttr respectively. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96563 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang-c/Index.h | 14 +++++++++++++- tools/CIndex/CIndex.cpp | 6 ++++++ tools/CIndex/CXCursor.cpp | 17 +++++++++++++++++ tools/CIndex/CXCursor.h | 6 ++++-- 4 files changed, 40 insertions(+), 3 deletions(-) diff --git a/include/clang-c/Index.h b/include/clang-c/Index.h index 2ff6a97d9f..0c671048dc 100644 --- a/include/clang-c/Index.h +++ b/include/clang-c/Index.h @@ -764,7 +764,19 @@ enum CXCursorKind { * The translation unit cursor exists primarily to act as the root * cursor for traversing the contents of a translation unit. */ - CXCursor_TranslationUnit = 300 + CXCursor_TranslationUnit = 300, + + /* Attributes */ + CXCursor_FirstAttr = 400, + /** + * \brief An attribute whose specific kind is not exposed via this + * interface. + */ + CXCursor_UnexposedAttr = 400, + + CXCursor_IBActionAttr = 401, + CXCursor_IBOutletAttr = 402, + CXCursor_LastAttr = CXCursor_IBOutletAttr }; /** diff --git a/tools/CIndex/CIndex.cpp b/tools/CIndex/CIndex.cpp index 5fc6168594..21f3860abd 100644 --- a/tools/CIndex/CIndex.cpp +++ b/tools/CIndex/CIndex.cpp @@ -1441,6 +1441,12 @@ CXString clang_getCursorKindSpelling(enum CXCursorKind Kind) { return createCXString("NotImplemented"); case CXCursor_TranslationUnit: return createCXString("TranslationUnit"); + case CXCursor_UnexposedAttr: + return createCXString("UnexposedAttr"); + case CXCursor_IBActionAttr: + return createCXString("attribute(ibaction)"); + case CXCursor_IBOutletAttr: + return createCXString("attribute(iboutlet)"); } llvm_unreachable("Unhandled CXCursorKind"); diff --git a/tools/CIndex/CXCursor.cpp b/tools/CIndex/CXCursor.cpp index ec1477eb8a..0fa73a513d 100644 --- a/tools/CIndex/CXCursor.cpp +++ b/tools/CIndex/CXCursor.cpp @@ -72,6 +72,23 @@ static CXCursorKind GetCursorKind(Decl *D) { return CXCursor_NotImplemented; } +static CXCursorKind GetCursorKind(const Attr *A) { + assert(A && "Invalid arguments!"); + switch (A->getKind()) { + default: break; + case Attr::IBActionKind: return CXCursor_IBActionAttr; + case Attr::IBOutletKind: return CXCursor_IBOutletAttr; + } + + return CXCursor_UnexposedAttr; +} + +CXCursor cxcursor::MakeCXCursor(const Attr *A, Decl *Parent, ASTUnit *TU) { + assert(A && Parent && TU && "Invalid arguments!"); + CXCursor C = { GetCursorKind(A), { Parent, (void*)A, TU } }; + return C; +} + CXCursor cxcursor::MakeCXCursor(Decl *D, ASTUnit *TU) { assert(D && TU && "Invalid arguments!"); CXCursor C = { GetCursorKind(D), { D, 0, TU } }; diff --git a/tools/CIndex/CXCursor.h b/tools/CIndex/CXCursor.h index 30fb26c936..934d5e2aeb 100644 --- a/tools/CIndex/CXCursor.h +++ b/tools/CIndex/CXCursor.h @@ -22,6 +22,7 @@ namespace clang { class ASTContext; class ASTUnit; +class Attr; class Decl; class Expr; class NamedDecl; @@ -32,9 +33,10 @@ class TypeDecl; namespace cxcursor { -CXCursor MakeCXCursorInvalid(CXCursorKind K); -CXCursor MakeCXCursor(clang::Stmt *S, clang::Decl *Parent, ASTUnit *TU); +CXCursor MakeCXCursor(const clang::Attr *A, clang::Decl *Parent, ASTUnit *TU); CXCursor MakeCXCursor(clang::Decl *D, ASTUnit *TU); +CXCursor MakeCXCursor(clang::Stmt *S, clang::Decl *Parent, ASTUnit *TU); +CXCursor MakeCXCursorInvalid(CXCursorKind K); /// \brief Create an Objective-C superclass reference at the given location. CXCursor MakeCursorObjCSuperClassRef(ObjCInterfaceDecl *Super, -- 2.40.0