Add function 'clang_isTagDeclDefinition()' to allow clients of libclang to distinguish between
forward declarations and definitions of structs/classes/enums.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104075 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang-c/Index.h b/include/clang-c/Index.h
index 3c69d0f..fa35d05 100644
--- a/include/clang-c/Index.h
+++ b/include/clang-c/Index.h
@@ -1355,6 +1355,12 @@
CINDEX_LINKAGE unsigned clang_CXXMethod_isStatic(CXCursor C);
/**
+ * \brief Determine if a given struct/class/enum declaration is a definition
+ * or just a forward declaration.
+ */
+CINDEX_LINKAGE unsigned clang_isTagDeclDefinition(CXCursor C);
+
+/**
* @}
*/
diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp
index 6ea1619..85383d0 100644
--- a/tools/libclang/CIndex.cpp
+++ b/tools/libclang/CIndex.cpp
@@ -2809,6 +2809,15 @@
CXXMethodDecl *D = dyn_cast<CXXMethodDecl>(cxcursor::getCursorDecl(C));
return (D && D->isStatic()) ? 1 : 0;
}
+
+unsigned clang_isTagDeclDefinition(CXCursor C) {
+ if (!clang_isDeclaration(C.kind))
+ return 0;
+
+ const TagDecl *D = dyn_cast<TagDecl>(cxcursor::getCursorDecl(C));
+ return D && D->isDefinition() ? 1 : 0;
+}
+
} // end: extern "C"
//===----------------------------------------------------------------------===//
diff --git a/tools/libclang/libclang.darwin.exports b/tools/libclang/libclang.darwin.exports
index 4b61bd3..1071a23 100644
--- a/tools/libclang/libclang.darwin.exports
+++ b/tools/libclang/libclang.darwin.exports
@@ -81,6 +81,7 @@
_clang_isPreprocessing
_clang_isReference
_clang_isStatement
+_clang_isTagDeclDefinition
_clang_isTranslationUnit
_clang_isUnexposed
_clang_setUseExternalASTGeneration
diff --git a/tools/libclang/libclang.exports b/tools/libclang/libclang.exports
index ad984f0..b986aeb 100644
--- a/tools/libclang/libclang.exports
+++ b/tools/libclang/libclang.exports
@@ -81,8 +81,10 @@
clang_isPreprocessing
clang_isReference
clang_isStatement
+clang_isTagDeclDefinition
clang_isTranslationUnit
clang_isUnexposed
clang_setUseExternalASTGeneration
clang_tokenize
clang_visitChildren
+