https://github.com/Serafean updated https://github.com/llvm/llvm-project/pull/183286
>From cd43ef7c15ee8d4e5b3f0c2424b8b832f8873461 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Bedn=C3=A1r?= <[email protected]> Date: Wed, 25 Feb 2026 11:51:35 +0100 Subject: [PATCH] [libclang] Fix clang_CXXMethod_isDeleted for functions clang_CXXMethod_isDeleted() reported only for C++ methods. However, in C++ all functions can be deleted. --- clang/docs/ReleaseNotes.rst | 1 + clang/include/clang-c/Index.h | 2 +- clang/test/Index/deletion.cpp | 16 ++++++++++++++++ clang/tools/libclang/CIndex.cpp | 5 ++--- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index cb1010aee1edd..1f05fe4e07c43 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -430,6 +430,7 @@ libclang - Visit constraints of `auto` type to properly visit concept usages (#GH166580) - Visit switch initializer statements (https://bugs.kde.org/show_bug.cgi?id=415537#c2) - Fix crash in clang_getBinaryOperatorKindSpelling and clang_getUnaryOperatorKindSpelling +- Fix clang_CXXMethod_isDeleted() to also work on functions, not only methods. Code Completion --------------- diff --git a/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h index 203634c80d82a..72f88e2cd9e06 100644 --- a/clang/include/clang-c/Index.h +++ b/clang/include/clang-c/Index.h @@ -4748,7 +4748,7 @@ CINDEX_LINKAGE unsigned clang_CXXField_isMutable(CXCursor C); CINDEX_LINKAGE unsigned clang_CXXMethod_isDefaulted(CXCursor C); /** - * Determine if a C++ method is declared '= delete'. + * Determine if a function is declared '= delete'. */ CINDEX_LINKAGE unsigned clang_CXXMethod_isDeleted(CXCursor C); diff --git a/clang/test/Index/deletion.cpp b/clang/test/Index/deletion.cpp index aa5e869a86288..6cbbe77fb8e36 100644 --- a/clang/test/Index/deletion.cpp +++ b/clang/test/Index/deletion.cpp @@ -5,6 +5,14 @@ struct Foo { Foo(int); }; +int foo(int); +int foo(double) = delete; + +template <typename T> +void processPointer(T* ptr); + +template <> +void processPointer<void>(void* ptr) = delete; // RUN: c-index-test -test-print-type --std=c++11 %s | FileCheck %s // CHECK: StructDecl=Foo:1:8 (Definition) [type=Foo] [typekind=Record] [isPOD=1] @@ -12,3 +20,11 @@ struct Foo { // CHECK: CXXMethod=bar:3:7 [type=int (){{.*}}] [typekind=FunctionProto] [resulttype=int] [resulttypekind=Int] [isPOD=0] // CHECK: CXXConstructor=Foo:4:3 (unavailable) (default constructor) (deleted) [type=void (){{.*}}] [typekind=FunctionProto] [resulttype=void] [resulttypekind=Void] [isPOD=0] // CHECK: CXXConstructor=Foo:5:3 (converting constructor) [type=void (int){{.*}}] [typekind=FunctionProto] [resulttype=void] [resulttypekind=Void] [args= [int] [Int]] [isPOD=0] + +// CHECK: FunctionDecl=foo:8:5 [type=int (int)] [typekind=FunctionProto] [resulttype=int] [resulttypekind=Int] [args= [int] [Int]] [isPOD=0] [isAnonRecDecl=0] +// CHECK: ParmDecl=:8:12 (Definition) [type=int] [typekind=Int] [isPOD=1] [isAnonRecDecl=0] +// CHECK: FunctionDecl=foo:9:5 (unavailable) (deleted) [type=int (double)] [typekind=FunctionProto] [resulttype=int] [resulttypekind=Int] [args= [double] [Double]] [isPOD=0] [isAnonRecDecl=0] +// CHECK: ParmDecl=:9:15 (Definition) [type=double] [typekind=Double] [isPOD=1] [isAnonRecDecl=0] + +// CHECK: FunctionTemplate=processPointer:12:6 [type=void (T *)] [typekind=FunctionProto] [canonicaltype=void (type-parameter-0-0 *)] [canonicaltypekind=FunctionProto] [resulttype=void] [resulttypekind=Void] [isPOD=0] [isAnonRecDecl=0] +// CHECK: FunctionDecl=processPointer:15:6 (unavailable) (deleted) [Specialization of processPointer:12:6] [Template arg 0: kind: 1, type: void] [type=void (void *)] [typekind=FunctionProto] [resulttype=void] [resulttypekind=Void] [args= [void *] [Pointer]] [isPOD=0] [isAnonRecDecl=0] diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp index 31b6a3222d916..7984e1372e79e 100644 --- a/clang/tools/libclang/CIndex.cpp +++ b/clang/tools/libclang/CIndex.cpp @@ -9553,9 +9553,8 @@ unsigned clang_CXXMethod_isDeleted(CXCursor C) { return 0; const Decl *D = cxcursor::getCursorDecl(C); - const CXXMethodDecl *Method = - D ? dyn_cast_if_present<CXXMethodDecl>(D->getAsFunction()) : nullptr; - return (Method && Method->isDeleted()) ? 1 : 0; + const FunctionDecl *Function = D ? D->getAsFunction() : nullptr; + return (Function && Function->isDeleted()) ? 1 : 0; } unsigned clang_CXXMethod_isStatic(CXCursor C) { _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
