[cfe-commits] r96563 - in /cfe/trunk: include/clang-c/Index.h tools/CIndex/CIndex.cpp tools/CIndex/CXCursor.cpp tools/CIndex/CXCursor.h
Ted Kremenek
kremenek at apple.com
Wed Feb 17 19:09:08 PST 2010
Author: kremenek
Date: Wed Feb 17 21:09:07 2010
New Revision: 96563
URL: http://llvm.org/viewvc/llvm-project?rev=96563&view=rev
Log:
Start adding cursor kinds for attributes, with first exposing
IBActionAttr and IBOutletAttr respectively.
Modified:
cfe/trunk/include/clang-c/Index.h
cfe/trunk/tools/CIndex/CIndex.cpp
cfe/trunk/tools/CIndex/CXCursor.cpp
cfe/trunk/tools/CIndex/CXCursor.h
Modified: cfe/trunk/include/clang-c/Index.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=96563&r1=96562&r2=96563&view=diff
==============================================================================
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Wed Feb 17 21:09:07 2010
@@ -764,7 +764,19 @@
* 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
};
/**
Modified: cfe/trunk/tools/CIndex/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/CIndex/CIndex.cpp?rev=96563&r1=96562&r2=96563&view=diff
==============================================================================
--- cfe/trunk/tools/CIndex/CIndex.cpp (original)
+++ cfe/trunk/tools/CIndex/CIndex.cpp Wed Feb 17 21:09:07 2010
@@ -1441,6 +1441,12 @@
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");
Modified: cfe/trunk/tools/CIndex/CXCursor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/CIndex/CXCursor.cpp?rev=96563&r1=96562&r2=96563&view=diff
==============================================================================
--- cfe/trunk/tools/CIndex/CXCursor.cpp (original)
+++ cfe/trunk/tools/CIndex/CXCursor.cpp Wed Feb 17 21:09:07 2010
@@ -72,6 +72,23 @@
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 } };
Modified: cfe/trunk/tools/CIndex/CXCursor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/CIndex/CXCursor.h?rev=96563&r1=96562&r2=96563&view=diff
==============================================================================
--- cfe/trunk/tools/CIndex/CXCursor.h (original)
+++ cfe/trunk/tools/CIndex/CXCursor.h Wed Feb 17 21:09:07 2010
@@ -22,6 +22,7 @@
class ASTContext;
class ASTUnit;
+class Attr;
class Decl;
class Expr;
class NamedDecl;
@@ -32,9 +33,10 @@
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,
More information about the cfe-commits
mailing list