[cfe-commits] r104075 - in /cfe/trunk: include/clang-c/Index.h tools/libclang/CIndex.cpp tools/libclang/libclang.darwin.exports tools/libclang/libclang.exports
Douglas Gregor
dgregor at apple.com
Tue May 18 15:41:38 PDT 2010
On May 18, 2010, at 3:32 PM, Ted Kremenek wrote:
> Author: kremenek
> Date: Tue May 18 17:32:15 2010
> New Revision: 104075
>
> URL: http://llvm.org/viewvc/llvm-project?rev=104075&view=rev
> Log:
> Add function 'clang_isTagDeclDefinition()' to allow clients of libclang to distinguish between
> forward declarations and definitions of structs/classes/enums.
Could/should we generalize this to clang_isDeclarationADefinition(), making it work for any entity that has definitions? (Variables, Functions, Tags, etc.)
- Doug
> Modified:
> cfe/trunk/include/clang-c/Index.h
> cfe/trunk/tools/libclang/CIndex.cpp
> cfe/trunk/tools/libclang/libclang.darwin.exports
> cfe/trunk/tools/libclang/libclang.exports
>
> Modified: cfe/trunk/include/clang-c/Index.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=104075&r1=104074&r2=104075&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang-c/Index.h (original)
> +++ cfe/trunk/include/clang-c/Index.h Tue May 18 17:32:15 2010
> @@ -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);
> +
> +/**
> * @}
> */
>
>
> Modified: cfe/trunk/tools/libclang/CIndex.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=104075&r1=104074&r2=104075&view=diff
> ==============================================================================
> --- cfe/trunk/tools/libclang/CIndex.cpp (original)
> +++ cfe/trunk/tools/libclang/CIndex.cpp Tue May 18 17:32:15 2010
> @@ -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"
>
> //===----------------------------------------------------------------------===//
>
> Modified: cfe/trunk/tools/libclang/libclang.darwin.exports
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/libclang.darwin.exports?rev=104075&r1=104074&r2=104075&view=diff
> ==============================================================================
> --- cfe/trunk/tools/libclang/libclang.darwin.exports (original)
> +++ cfe/trunk/tools/libclang/libclang.darwin.exports Tue May 18 17:32:15 2010
> @@ -81,6 +81,7 @@
> _clang_isPreprocessing
> _clang_isReference
> _clang_isStatement
> +_clang_isTagDeclDefinition
> _clang_isTranslationUnit
> _clang_isUnexposed
> _clang_setUseExternalASTGeneration
>
> Modified: cfe/trunk/tools/libclang/libclang.exports
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/libclang.exports?rev=104075&r1=104074&r2=104075&view=diff
> ==============================================================================
> --- cfe/trunk/tools/libclang/libclang.exports (original)
> +++ cfe/trunk/tools/libclang/libclang.exports Tue May 18 17:32:15 2010
> @@ -81,8 +81,10 @@
> clang_isPreprocessing
> clang_isReference
> clang_isStatement
> +clang_isTagDeclDefinition
> clang_isTranslationUnit
> clang_isUnexposed
> clang_setUseExternalASTGeneration
> clang_tokenize
> clang_visitChildren
> +
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list