summaryrefslogtreecommitdiffstats
path: root/clang/tools/libclang/CIndex.cpp
diff options
context:
space:
mode:
authorJonathan Coe <jbcoe@me.com>2016-04-27 12:48:25 +0000
committerJonathan Coe <jbcoe@me.com>2016-04-27 12:48:25 +0000
commit2956535b7c44fb4cf742667ec4b61cf176f9d32d (patch)
tree2e5cb14efb2deae8228fa30d6b554473b8262969 /clang/tools/libclang/CIndex.cpp
parent7ac9628648c6ba72114d08c9669f00422f328533 (diff)
downloadbcm5719-llvm-2956535b7c44fb4cf742667ec4b61cf176f9d32d.tar.gz
bcm5719-llvm-2956535b7c44fb4cf742667ec4b61cf176f9d32d.zip
Expose cxx constructor and method properties through libclang and python bindings.
Summary: I have exposed the following function through libclang and the clang.cindex python bindings: clang_CXXConstructor_isConvertingConstructor, clang_CXXConstructor_isCopyConstructor, clang_CXXConstructor_isDefaultConstructor, clang_CXXConstructor_isMoveConstructor, clang_CXXMethod_isDefaulted I need (some of) these methods for a C++ code model I am building in Python to drive a code generator. Reviewers: compnerd, skalinichev Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D15469 llvm-svn: 267706
Diffstat (limited to 'clang/tools/libclang/CIndex.cpp')
-rw-r--r--clang/tools/libclang/CIndex.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
index 5add4a8ec95..6970578a4d8 100644
--- a/clang/tools/libclang/CIndex.cpp
+++ b/clang/tools/libclang/CIndex.cpp
@@ -7360,6 +7360,48 @@ CXFile clang_Module_getTopLevelHeader(CXTranslationUnit TU,
//===----------------------------------------------------------------------===//
extern "C" {
+
+unsigned clang_CXXConstructor_isDefaultConstructor(CXCursor C) {
+ if (!clang_isDeclaration(C.kind))
+ return 0;
+
+ const Decl *D = cxcursor::getCursorDecl(C);
+ const CXXConstructorDecl *Constructor =
+ D ? dyn_cast_or_null<CXXConstructorDecl>(D->getAsFunction()) : nullptr;
+ return (Constructor && Constructor->isDefaultConstructor()) ? 1 : 0;
+}
+
+unsigned clang_CXXConstructor_isCopyConstructor(CXCursor C) {
+ if (!clang_isDeclaration(C.kind))
+ return 0;
+
+ const Decl *D = cxcursor::getCursorDecl(C);
+ const CXXConstructorDecl *Constructor =
+ D ? dyn_cast_or_null<CXXConstructorDecl>(D->getAsFunction()) : nullptr;
+ return (Constructor && Constructor->isCopyConstructor()) ? 1 : 0;
+}
+
+unsigned clang_CXXConstructor_isMoveConstructor(CXCursor C) {
+ if (!clang_isDeclaration(C.kind))
+ return 0;
+
+ const Decl *D = cxcursor::getCursorDecl(C);
+ const CXXConstructorDecl *Constructor =
+ D ? dyn_cast_or_null<CXXConstructorDecl>(D->getAsFunction()) : nullptr;
+ return (Constructor && Constructor->isMoveConstructor()) ? 1 : 0;
+}
+
+unsigned clang_CXXConstructor_isConvertingConstructor(CXCursor C) {
+ if (!clang_isDeclaration(C.kind))
+ return 0;
+
+ const Decl *D = cxcursor::getCursorDecl(C);
+ const CXXConstructorDecl *Constructor =
+ D ? dyn_cast_or_null<CXXConstructorDecl>(D->getAsFunction()) : nullptr;
+ // Passing 'false' excludes constructors marked 'explicit'.
+ return (Constructor && Constructor->isConvertingConstructor(false)) ? 1 : 0;
+}
+
unsigned clang_CXXField_isMutable(CXCursor C) {
if (!clang_isDeclaration(C.kind))
return 0;
@@ -7390,6 +7432,16 @@ unsigned clang_CXXMethod_isConst(CXCursor C) {
return (Method && (Method->getTypeQualifiers() & Qualifiers::Const)) ? 1 : 0;
}
+unsigned clang_CXXMethod_isDefaulted(CXCursor C) {
+ if (!clang_isDeclaration(C.kind))
+ return 0;
+
+ const Decl *D = cxcursor::getCursorDecl(C);
+ const CXXMethodDecl *Method =
+ D ? dyn_cast_or_null<CXXMethodDecl>(D->getAsFunction()) : nullptr;
+ return (Method && Method->isDefaulted()) ? 1 : 0;
+}
+
unsigned clang_CXXMethod_isStatic(CXCursor C) {
if (!clang_isDeclaration(C.kind))
return 0;
OpenPOWER on IntegriCloud