Introduce new libclang API functions that determine the availability
of a cursor or code-completion result, e.g., whether that result
refers to an unavailable, deleted, or deprecated declaration.
llvm-svn: 111858
diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
index a98f064..e59bdde 100644
--- a/clang/tools/libclang/CIndex.cpp
+++ b/clang/tools/libclang/CIndex.cpp
@@ -3018,6 +3018,21 @@
}
extern "C" {
+
+enum CXAvailabilityKind clang_getCursorAvailability(CXCursor cursor) {
+ if (clang_isDeclaration(cursor.kind))
+ if (Decl *D = cxcursor::getCursorDecl(cursor)) {
+ if (D->hasAttr<UnavailableAttr>() ||
+ (isa<FunctionDecl>(D) && cast<FunctionDecl>(D)->isDeleted()))
+ return CXAvailability_Available;
+
+ if (D->hasAttr<DeprecatedAttr>())
+ return CXAvailability_Deprecated;
+ }
+
+ return CXAvailability_Available;
+}
+
CXLanguageKind clang_getCursorLanguage(CXCursor cursor) {
if (clang_isDeclaration(cursor.kind))
return getDeclLanguage(cxcursor::getCursorDecl(cursor));