enum CXCursorKind {
/* Declarations */
CXCursor_FirstDecl = 1,
+ /** \brief A typedef */
CXCursor_TypedefDecl = 1,
+ /** \brief A C or C++ struct. */
CXCursor_StructDecl = 2,
+ /** \brief A C or C++ union. */
CXCursor_UnionDecl = 3,
+ /** \brief A C++ class. */
CXCursor_ClassDecl = 4,
+ /** \brief An enumeration. */
CXCursor_EnumDecl = 5,
+ /**
+ * \brief A field (in C) or non-static data member (in C++) in a
+ * struct, union, or C++ class.
+ */
CXCursor_FieldDecl = 6,
+ /** \brief An enumerator constant. */
CXCursor_EnumConstantDecl = 7,
+ /** \brief A function. */
CXCursor_FunctionDecl = 8,
+ /** \brief A variable. */
CXCursor_VarDecl = 9,
+ /** \brief A function or method parameter. */
CXCursor_ParmDecl = 10,
+ /** \brief An Objective-C @interface. */
CXCursor_ObjCInterfaceDecl = 11,
+ /** \brief An Objective-C @interface for a category. */
CXCursor_ObjCCategoryDecl = 12,
+ /** \brief An Objective-C @protocol declaration. */
CXCursor_ObjCProtocolDecl = 13,
+ /** \brief An Objective-C @property declaration. */
CXCursor_ObjCPropertyDecl = 14,
+ /** \brief An Objective-C instance variable. */
CXCursor_ObjCIvarDecl = 15,
+ /** \brief An Objective-C instance method. */
CXCursor_ObjCInstanceMethodDecl = 16,
+ /** \brief An Objective-C class method. */
CXCursor_ObjCClassMethodDecl = 17,
+ /** \brief An Objective-C @implementation. */
CXCursor_ObjCImplementationDecl = 18,
+ /** \brief An Objective-C @implementation for a category. */
CXCursor_ObjCCategoryImplDecl = 19,
- CXCursor_LastDecl = 19,
+ /**
+ * \brief A declaration whose specific kind is not exposed via this
+ * interface.
+ *
+ * Unexposed declarations have the same operations as any other kind
+ * of declaration; one can extract their location information,
+ * spelling, find their definitions, etc. However, the specific kind
+ * of the declaration is not reported.
+ */
+ CXCursor_UnexposedDecl = 20,
+ CXCursor_LastDecl = 20,
/* References */
CXCursor_FirstRef = 40, /* Decl references */
}
// CHECK-scan: {start_line=1 start_col=1 end_line=7 end_col=1} Invalid Cursor => NoDeclFound
-// CHECK-scan: {start_line=8 start_col=1 end_line=8 end_col=7} Invalid Cursor => NotImplemented
+// CHECK-scan: {start_line=8 start_col=1 end_line=8 end_col=7} UnexposedDecl=:8:1
// CHECK-scan: {start_line=8 start_col=8 end_line=8 end_col=10} ObjCClassRef=Foo:10:1
// CHECK-scan: {start_line=8 start_col=11 end_line=9 end_col=1} Invalid Cursor => NoDeclFound
// CHECK-scan: {start_line=10 start_col=1 end_line=11 end_col=4} ObjCInterfaceDecl=Foo:10:1
}
// CHECK-scan: {start_line=1 start_col=1 end_line=7 end_col=1} Invalid Cursor => NoDeclFound
-// CHECK-scan: {start_line=8 start_col=1 end_line=8 end_col=7} Invalid Cursor => NotImplemented
+// CHECK-scan: {start_line=8 start_col=1 end_line=8 end_col=7} UnexposedDecl=:8:1
// CHECK-scan: {start_line=8 start_col=8 end_line=8 end_col=10} ObjCClassRef=Foo:8:8
// CHECK-scan: {start_line=8 start_col=11 end_line=9 end_col=1} Invalid Cursor => NoDeclFound
// CHECK-scan: {start_line=10 start_col=1 end_line=10 end_col=4} FunctionDecl=function:10:6 (Definition)
else if (isa<EnumConstantDecl>(D))
return CXCursor_EnumConstantRef;
else
- return CXCursor_NotImplemented;
+ return CXCursor_UnexposedDecl;
}
// Translation Unit Visitor.
extern "C" {
CXString clang_getDeclSpelling(CXDecl AnonDecl) {
assert(AnonDecl && "Passed null CXDecl");
- NamedDecl *ND = static_cast<NamedDecl *>(AnonDecl);
+ Decl *D = static_cast<Decl *>(AnonDecl);
+ NamedDecl *ND = dyn_cast<NamedDecl>(D);
+ if (!ND)
+ return CIndexer::createCXString("");
if (ObjCMethodDecl *OMD = dyn_cast<ObjCMethodDecl>(ND))
return CIndexer::createCXString(OMD->getSelector().getAsString().c_str(),
case CXCursor_ObjCClassMethodDecl: return "ObjCClassMethodDecl";
case CXCursor_ObjCImplementationDecl: return "ObjCImplementationDecl";
case CXCursor_ObjCCategoryImplDecl: return "ObjCCategoryImplDecl";
+ case CXCursor_UnexposedDecl: return "UnexposedDecl";
case CXCursor_ObjCSuperClassRef: return "ObjCSuperClassRef";
case CXCursor_ObjCProtocolRef: return "ObjCProtocolRef";
case CXCursor_ObjCClassRef: return "ObjCClassRef";
case Decl::ObjCCategoryImpl: return CXCursor_ObjCCategoryImplDecl;
case Decl::ObjCClass:
// FIXME
- return CXCursor_NotImplemented;
+ return CXCursor_UnexposedDecl;
case Decl::ObjCForwardProtocol:
// FIXME
- return CXCursor_NotImplemented;
+ return CXCursor_UnexposedDecl;
case Decl::ObjCImplementation: return CXCursor_ObjCImplementationDecl;
case Decl::ObjCInterface: return CXCursor_ObjCInterfaceDecl;
case Decl::ObjCIvar: return CXCursor_ObjCIvarDecl;
case TagDecl::TK_enum: return CXCursor_EnumDecl;
}
}
+
+ return CXCursor_UnexposedDecl;
}
llvm_unreachable("Invalid Decl");
case CXCursor_ObjCClassMethodDecl:
case CXCursor_ObjCImplementationDecl:
case CXCursor_ObjCCategoryImplDecl:
+ case CXCursor_UnexposedDecl:
return static_cast<Decl *>(Cursor.data[0])->getASTContext();
case CXCursor_ObjCSuperClassRef: