]> granicus.if.org Git - clang/commitdiff
Kill some CXDecl-related APIs that have been superceded by
authorDouglas Gregor <dgregor@apple.com>
Wed, 20 Jan 2010 21:45:58 +0000 (21:45 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 20 Jan 2010 21:45:58 +0000 (21:45 +0000)
CXCursor-based APIs.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94037 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang-c/Index.h
tools/CIndex/CIndex.cpp
tools/CIndex/CIndex.exports

index 00b4dfed6fc9bb888f0c8e54e5e248b1e6d5ef16..f1f36e57b7d8ed5bfdc3dba4d34958873093602d 100644 (file)
@@ -438,9 +438,7 @@ CINDEX_LINKAGE CXDecl clang_getDeclaration(CXEntity, CXTranslationUnit);
 /*
  * CXDecl Operations.
  */
-CINDEX_LINKAGE CXCursor clang_getCursorFromDecl(CXDecl);
 CINDEX_LINKAGE CXEntity clang_getEntityFromDecl(CXIndex, CXDecl);
-CINDEX_LINKAGE CXString clang_getDeclSpelling(CXDecl);
 
 /**
  * \brief Identifies a specific source location within a translation
@@ -610,13 +608,6 @@ CINDEX_LINKAGE void clang_getDefinitionSpellingAndExtent(CXCursor,
                                           unsigned *endLine,
                                           unsigned *endColumn);
 
-/*
- * If CXCursorKind == Cursor_Reference, then this will return the referenced
- * declaration.
- * If CXCursorKind == Cursor_Declaration, then this will return the declaration.
- */
-CINDEX_LINKAGE CXDecl clang_getCursorDecl(CXCursor);
-
 /**
  * \brief A semantic string that describes a code-completion result.
  *
index 485e6c9980f969e50fb4c2fb19891f5892fdf0e0..b9bd48f024b726f3aa2fec5bc337049c8a5f70de 100644 (file)
@@ -593,36 +593,6 @@ CXSourceLocation clang_getRangeEnd(CXSourceRange range) {
   return Result;
 }
 
-//===----------------------------------------------------------------------===//
-// CXDecl Operations.
-//===----------------------------------------------------------------------===//
-
-extern "C" {
-CXString clang_getDeclSpelling(CXDecl AnonDecl) {
-  assert(AnonDecl && "Passed null CXDecl");
-  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(),
-                                    true);
-
-  if (ObjCCategoryImplDecl *CIMP = dyn_cast<ObjCCategoryImplDecl>(ND))
-    // No, this isn't the same as the code below. getIdentifier() is non-virtual
-    // and returns different names. NamedDecl returns the class name and
-    // ObjCCategoryImplDecl returns the category name.
-    return CIndexer::createCXString(CIMP->getIdentifier()->getNameStart());
-
-  if (ND->getIdentifier())
-    return CIndexer::createCXString(ND->getIdentifier()->getNameStart());
-
-  return CIndexer::createCXString("");
-}
-
-} // end: extern "C"
-
 //===----------------------------------------------------------------------===//
 // CXFile Operations.
 //===----------------------------------------------------------------------===//
@@ -692,6 +662,27 @@ unsigned clang_visitChildren(CXTranslationUnit tu,
   return CursorVis.VisitChildren(parent);
 }
 
+static CXString getDeclSpelling(Decl *D) {
+  NamedDecl *ND = dyn_cast_or_null<NamedDecl>(D);
+  if (!ND)
+    return CIndexer::createCXString("");
+  
+  if (ObjCMethodDecl *OMD = dyn_cast<ObjCMethodDecl>(ND))
+    return CIndexer::createCXString(OMD->getSelector().getAsString().c_str(),
+                                    true);
+  
+  if (ObjCCategoryImplDecl *CIMP = dyn_cast<ObjCCategoryImplDecl>(ND))
+    // No, this isn't the same as the code below. getIdentifier() is non-virtual
+    // and returns different names. NamedDecl returns the class name and
+    // ObjCCategoryImplDecl returns the category name.
+    return CIndexer::createCXString(CIMP->getIdentifier()->getNameStart());
+  
+  if (ND->getIdentifier())
+    return CIndexer::createCXString(ND->getIdentifier()->getNameStart());
+  
+  return CIndexer::createCXString("");
+}
+    
 CXString clang_getCursorSpelling(CXCursor C) {
   assert(getCursorDecl(C) && "CXCursor has null decl");
   if (clang_isTranslationUnit(C.kind))
@@ -720,11 +711,11 @@ CXString clang_getCursorSpelling(CXCursor C) {
   if (clang_isExpression(C.kind)) {
     Decl *D = getDeclFromExpr(getCursorExpr(C));
     if (D)
-      return clang_getDeclSpelling(D);
+      return getDeclSpelling(D);
     return CIndexer::createCXString("");
   }
 
-  return clang_getDeclSpelling(getCursorDecl(C));
+  return getDeclSpelling(getCursorDecl(C));
 }
 
 const char *clang_getCursorKindSpelling(enum CXCursorKind Kind) {
@@ -817,11 +808,6 @@ unsigned clang_equalCursors(CXCursor X, CXCursor Y) {
   return X == Y;
 }
 
-CXCursor clang_getCursorFromDecl(CXDecl AnonDecl) {
-  assert(AnonDecl && "Passed null CXDecl");
-  return MakeCXCursor(static_cast<NamedDecl *>(AnonDecl));
-}
-
 unsigned clang_isInvalid(enum CXCursorKind K) {
   return K >= CXCursor_FirstInvalid && K <= CXCursor_LastInvalid;
 }
@@ -850,23 +836,6 @@ CXCursorKind clang_getCursorKind(CXCursor C) {
   return C.kind;
 }
 
-CXDecl clang_getCursorDecl(CXCursor C) {
-  if (clang_isDeclaration(C.kind))
-    return getCursorDecl(C);
-
-  if (clang_isReference(C.kind)) {
-    if (getCursorStmt(C))
-      return getDeclFromExpr(getCursorStmt(C));
-
-    return getCursorDecl(C);
-  }
-
-  if (clang_isExpression(C.kind))
-    return getDeclFromExpr(getCursorStmt(C));
-
-  return 0;
-}
-
 static SourceLocation getLocationFromExpr(Expr *E) {
   if (ObjCMessageExpr *Msg = dyn_cast<ObjCMessageExpr>(E))
     return /*FIXME:*/Msg->getLeftLoc();
index 2731549936874addc5738989b336074248db3a0f..05e3b61990eefd99e3c7fa105b8e99fdce5821f5 100644 (file)
@@ -12,17 +12,14 @@ _clang_getCompletionChunkCompletionString
 _clang_getCompletionChunkKind
 _clang_getCompletionChunkText
 _clang_getCursor
-_clang_getCursorDecl
 _clang_getCursorDefinition
 _clang_getCursorExtent
-_clang_getCursorFromDecl
 _clang_getCursorKind
 _clang_getCursorKindSpelling
 _clang_getCursorLocation
 _clang_getCursorReferenced
 _clang_getCursorSpelling
 _clang_getCursorUSR
-_clang_getDeclSpelling
 _clang_getDeclaration
 _clang_getDefinitionSpellingAndExtent
 _clang_getEntityFromDecl