]> granicus.if.org Git - clang/commitdiff
Add function 'clang_isTagDeclDefinition()' to allow clients of libclang to distinguis...
authorTed Kremenek <kremenek@apple.com>
Tue, 18 May 2010 22:32:15 +0000 (22:32 +0000)
committerTed Kremenek <kremenek@apple.com>
Tue, 18 May 2010 22:32:15 +0000 (22:32 +0000)
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

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

index 3c69d0f292a2ef821e8a0c2488219eae9848bafa..fa35d058e5db938153f5f6ecfa26e023637a78b0 100644 (file)
@@ -1354,6 +1354,12 @@ CINDEX_LINKAGE unsigned clang_isCursorDefinition(CXCursor);
  */
 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);
+
 /**
  * @}
  */
index 6ea1619c3dcb82d64d5cb53533df0d7f584baabb..85383d0be08f1e3935075a0e12fe2defd50849f7 100644 (file)
@@ -2809,6 +2809,15 @@ unsigned clang_CXXMethod_isStatic(CXCursor C) {
   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"
 
 //===----------------------------------------------------------------------===//
index 4b61bd34cbd392c8dbb7936cacc8276be0245ec4..1071a23d03213bfd6b6d606cb5aa5cf20d36dfde 100644 (file)
@@ -81,6 +81,7 @@ _clang_isInvalid
 _clang_isPreprocessing
 _clang_isReference
 _clang_isStatement
+_clang_isTagDeclDefinition
 _clang_isTranslationUnit
 _clang_isUnexposed
 _clang_setUseExternalASTGeneration
index ad984f0e9d68ac8e2b6ad5427881f7ab2f377e61..b986aeb54c7ee6b96be33aaa5d3270f3fc588b70 100644 (file)
@@ -81,8 +81,10 @@ clang_isInvalid
 clang_isPreprocessing
 clang_isReference
 clang_isStatement
+clang_isTagDeclDefinition
 clang_isTranslationUnit
 clang_isUnexposed
 clang_setUseExternalASTGeneration
 clang_tokenize
 clang_visitChildren
+