[clang] [llvm] [clang] Add support for emitting DW_AT_defaulted (PR #213188)

Michael Buch via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 31 02:01:47 PDT 2026


================
@@ -2504,6 +2504,19 @@ llvm::DISubprogram *CGDebugInfo::CreateCXXMemberFunction(
   if (Method->getCanonicalDecl()->isDeleted())
     SPFlags |= llvm::DISubprogram::SPFlagDeleted;
 
+  const bool isExplicitlyDefaultable =
+      isa<CXXDestructorDecl>(Method) ||
+      (isa<CXXConstructorDecl>(Method) &&
+       cast<CXXConstructorDecl>(Method)->isDefaultConstructor()) ||
+      Method->isCopyOrMoveConstructorOrAssignment();
----------------
Michael137 wrote:

In C++20 comparison operators can also be defaulted: https://en.cppreference.com/cpp/language/default_comparisons

And in c++29 https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3668r1.html

So maybe there ought to be a helper in Clang that gives us this info

Looks like `Sema::getDefaultedFunctionKind(const FunctionDecl *FD)` might be what you need. It also supports the comparison operators (and will support any new defaulted special member kinds in the future)

https://github.com/llvm/llvm-project/pull/213188


More information about the cfe-commits mailing list