[PATCH] D133924: add clang_CXXMethod_isDeleted function
Anders Langlands via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 15 02:31:33 PDT 2022
anderslanglands created this revision.
Herald added a subscriber: arphaman.
Herald added a project: All.
anderslanglands requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D133924
Files:
clang/bindings/python/clang/cindex.py
clang/include/clang-c/Index.h
clang/tools/c-index-test/c-index-test.c
clang/tools/libclang/CIndex.cpp
clang/tools/libclang/libclang.map
Index: clang/tools/libclang/libclang.map
===================================================================
--- clang/tools/libclang/libclang.map
+++ clang/tools/libclang/libclang.map
@@ -409,6 +409,7 @@
global:
clang_getUnqualifiedType;
clang_getNonReferenceType;
+ clang_CXXMethod_isDeleted;
};
# Example of how to add a new symbol version entry. If you do add a new symbol
Index: clang/tools/libclang/CIndex.cpp
===================================================================
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -8861,6 +8861,16 @@
return (Method && Method->isDefaulted()) ? 1 : 0;
}
+unsigned clang_CXXMethod_isDeleted(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->isDeleted()) ? 1 : 0;
+}
+
unsigned clang_CXXMethod_isStatic(CXCursor C) {
if (!clang_isDeclaration(C.kind))
return 0;
Index: clang/tools/c-index-test/c-index-test.c
===================================================================
--- clang/tools/c-index-test/c-index-test.c
+++ clang/tools/c-index-test/c-index-test.c
@@ -900,6 +900,8 @@
printf(" (mutable)");
if (clang_CXXMethod_isDefaulted(Cursor))
printf(" (defaulted)");
+ if (clang_CXXMethod_isDeleted(Cursor))
+ printf(" (deleted)");
if (clang_CXXMethod_isStatic(Cursor))
printf(" (static)");
if (clang_CXXMethod_isVirtual(Cursor))
Index: clang/include/clang-c/Index.h
===================================================================
--- clang/include/clang-c/Index.h
+++ clang/include/clang-c/Index.h
@@ -4924,6 +4924,11 @@
*/
CINDEX_LINKAGE unsigned clang_CXXMethod_isDefaulted(CXCursor C);
+/**
+ * Determine if a C++ method is declared '= default'.
+ */
+CINDEX_LINKAGE unsigned clang_CXXMethod_isDeleted(CXCursor C);
+
/**
* Determine if a C++ member function or member function template is
* pure virtual.
Index: clang/bindings/python/clang/cindex.py
===================================================================
--- clang/bindings/python/clang/cindex.py
+++ clang/bindings/python/clang/cindex.py
@@ -1473,6 +1473,12 @@
"""
return conf.lib.clang_CXXMethod_isDefaulted(self)
+ def is_deleted_method(self):
+ """Returns True if the cursor refers to a C++ member function or member
+ function template that is declared '= delete'.
+ """
+ return conf.lib.clang_CXXMethod_isDeleted(self)
+
def is_mutable_field(self):
"""Returns True if the cursor refers to a C++ field that is declared
'mutable'.
@@ -3426,6 +3432,10 @@
[Cursor],
bool),
+ ("clang_CXXMethod_isDeleted",
+ [Cursor],
+ bool),
+
("clang_CXXMethod_isPureVirtual",
[Cursor],
bool),
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133924.460335.patch
Type: text/x-patch
Size: 2923 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220915/1bcb6124/attachment-0001.bin>
More information about the cfe-commits
mailing list