From: Argyrios Kyrtzidis Date: Tue, 27 Sep 2011 00:30:30 +0000 (+0000) Subject: [libclang] Introduce clang_Cursor_isNull and clang_Cursor_getTranslationUnit functions. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b0d6eaa6b646c18c49923aefc76973801f561701;p=clang [libclang] Introduce clang_Cursor_isNull and clang_Cursor_getTranslationUnit functions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140587 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang-c/Index.h b/include/clang-c/Index.h index 07bcf9eec6..6bd0286d6e 100644 --- a/include/clang-c/Index.h +++ b/include/clang-c/Index.h @@ -1554,6 +1554,13 @@ CINDEX_LINKAGE CXCursor clang_getTranslationUnitCursor(CXTranslationUnit); */ CINDEX_LINKAGE unsigned clang_equalCursors(CXCursor, CXCursor); +/** + * \brief Returns non-zero if \arg cursor is null. + */ +static inline int clang_Cursor_isNull(CXCursor cursor) { + return clang_equalCursors(cursor, clang_getNullCursor()); +} + /** * \brief Compute a hash value for the given cursor. */ @@ -1669,6 +1676,11 @@ CINDEX_LINKAGE enum CXLanguageKind { */ CINDEX_LINKAGE enum CXLanguageKind clang_getCursorLanguage(CXCursor cursor); +/** + * \brief Returns the translation unit that a cursor originated from. + */ +CINDEX_LINKAGE CXTranslationUnit clang_Cursor_getTranslationUnit(CXCursor); + /** * \brief A fast container representing a set of CXCursors. diff --git a/tools/libclang/CXCursor.cpp b/tools/libclang/CXCursor.cpp index eb54ed2b68..c0e038467f 100644 --- a/tools/libclang/CXCursor.cpp +++ b/tools/libclang/CXCursor.cpp @@ -518,6 +518,14 @@ bool cxcursor::isFirstInDeclGroup(CXCursor C) { return ((uintptr_t) (C.data[1])) != 0; } +//===----------------------------------------------------------------------===// +// libclang CXCursor APIs +//===----------------------------------------------------------------------===// + +CXTranslationUnit clang_Cursor_getTranslationUnit(CXCursor cursor) { + return getCursorTU(cursor); +} + //===----------------------------------------------------------------------===// // CXCursorSet. //===----------------------------------------------------------------------===// diff --git a/tools/libclang/libclang.exports b/tools/libclang/libclang.exports index d01bb07f0c..71cd261438 100644 --- a/tools/libclang/libclang.exports +++ b/tools/libclang/libclang.exports @@ -20,6 +20,7 @@ clang_createCXCursorSet clang_createIndex clang_createTranslationUnit clang_createTranslationUnitFromSourceFile +clang_Cursor_getTranslationUnit clang_defaultCodeCompleteOptions clang_defaultDiagnosticDisplayOptions clang_defaultEditingTranslationUnitOptions