summaryrefslogtreecommitdiffstats
path: root/clang/tools/CIndex
diff options
context:
space:
mode:
Diffstat (limited to 'clang/tools/CIndex')
-rw-r--r--clang/tools/CIndex/CIndex.cpp8
-rw-r--r--clang/tools/CIndex/CXCursor.cpp7
2 files changed, 11 insertions, 4 deletions
diff --git a/clang/tools/CIndex/CIndex.cpp b/clang/tools/CIndex/CIndex.cpp
index a7cbb8a4fc7..b4759a51275 100644
--- a/clang/tools/CIndex/CIndex.cpp
+++ b/clang/tools/CIndex/CIndex.cpp
@@ -208,7 +208,7 @@ static enum CXCursorKind TranslateDeclRefExpr(DeclRefExpr *DRE) {
else if (isa<EnumConstantDecl>(D))
return CXCursor_EnumConstantRef;
else
- return CXCursor_NotImplemented;
+ return CXCursor_UnexposedDecl;
}
// Translation Unit Visitor.
@@ -712,7 +712,10 @@ static const FileEntry *getFileEntryFromSourceLocation(SourceManager &SMgr,
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(),
@@ -871,6 +874,7 @@ const char *clang_getCursorKindSpelling(enum CXCursorKind Kind) {
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";
diff --git a/clang/tools/CIndex/CXCursor.cpp b/clang/tools/CIndex/CXCursor.cpp
index 00636f74d50..f284b248cdf 100644
--- a/clang/tools/CIndex/CXCursor.cpp
+++ b/clang/tools/CIndex/CXCursor.cpp
@@ -44,10 +44,10 @@ static CXCursorKind GetCursorKind(Decl *D) {
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;
@@ -68,6 +68,8 @@ static CXCursorKind GetCursorKind(Decl *D) {
case TagDecl::TK_enum: return CXCursor_EnumDecl;
}
}
+
+ return CXCursor_UnexposedDecl;
}
llvm_unreachable("Invalid Decl");
@@ -161,6 +163,7 @@ ASTContext &cxcursor::getCursorContext(CXCursor Cursor) {
case CXCursor_ObjCClassMethodDecl:
case CXCursor_ObjCImplementationDecl:
case CXCursor_ObjCCategoryImplDecl:
+ case CXCursor_UnexposedDecl:
return static_cast<Decl *>(Cursor.data[0])->getASTContext();
case CXCursor_ObjCSuperClassRef:
OpenPOWER on IntegriCloud