]> granicus.if.org Git - clang/commitdiff
[libclang] Introduce clang_Cursor_isNull and clang_Cursor_getTranslationUnit functions.
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Tue, 27 Sep 2011 00:30:30 +0000 (00:30 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Tue, 27 Sep 2011 00:30:30 +0000 (00:30 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140587 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang-c/Index.h
tools/libclang/CXCursor.cpp
tools/libclang/libclang.exports

index 07bcf9eec6ed92c77c96add8e90e21bad0b627ae..6bd0286d6ecf8a6b2ca616a24d5f4327624ff446 100644 (file)
@@ -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.
index eb54ed2b6889d45ab04c0c546a2fdb0d03c83396..c0e038467fbb73d8338c06a6c3f1de8dc2ffa16f 100644 (file)
@@ -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.
 //===----------------------------------------------------------------------===//
index d01bb07f0c891e2e6088f444ab924a8e312770bd..71cd2614385de2a65afb50368d0b6909c6bc58b1 100644 (file)
@@ -20,6 +20,7 @@ clang_createCXCursorSet
 clang_createIndex
 clang_createTranslationUnit
 clang_createTranslationUnitFromSourceFile
+clang_Cursor_getTranslationUnit
 clang_defaultCodeCompleteOptions
 clang_defaultDiagnosticDisplayOptions
 clang_defaultEditingTranslationUnitOptions