diff options
author | Ted Kremenek <kremenek@apple.com> | 2010-02-18 03:09:07 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2010-02-18 03:09:07 +0000 |
commit | e77f443dbca8cdc23e5aa94a2653367e4a7cbe47 (patch) | |
tree | 6a465ce7a03f7e38ef28831d8e29f55c93e4861d | |
parent | 63e5d7c85299134f088033614afd9eb213c50b48 (diff) |
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
-rw-r--r-- | include/clang-c/Index.h | 14 | ||||
-rw-r--r-- | tools/CIndex/CIndex.cpp | 6 | ||||
-rw-r--r-- | tools/CIndex/CXCursor.cpp | 17 | ||||
-rw-r--r-- | 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, |