aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CGDebugInfo.cpp
diff options
context:
space:
mode:
authorMichael Buch <michaelbuch12@gmail.com>2025-01-14 21:12:13 +0000
committerGitHub <noreply@github.com>2025-01-14 21:12:13 +0000
commit3d24c77f14d42721226b31d7e5d08f853cfc92f1 (patch)
tree347870ea4b6f002fc26dbe95ace5198ae5ec36a8 /clang/lib/CodeGen/CGDebugInfo.cpp
parent93fd72cbb1a3c340add27fc380c4450406313d68 (diff)
downloadllvm-3d24c77f14d42721226b31d7e5d08f853cfc92f1.zip
llvm-3d24c77f14d42721226b31d7e5d08f853cfc92f1.tar.gz
llvm-3d24c77f14d42721226b31d7e5d08f853cfc92f1.tar.bz2
[clang][DebugInfo] Emit DW_AT_object_pointer on function definitions with explicit `this` (#122897)
We currently don't emit `DW_AT_object_pointer` on function declarations or definitions. GCC suffers from the same issue: https://godbolt.org/z/h4jeT54G5 Fixing this will help LLDB in identifying static vs. non-static member functions (see https://github.com/llvm/llvm-project/issues/120856). If I interpreted the DWARFv5 spec correctly, it doesn't mandate this attribute be present *only* for implicit object parameters: ``` If the member function entry describes a non-static member function, then that entry has a DW_AT_object_pointer attribute whose value is a reference to the formal parameter entry that corresponds to the object for which the function is called. That parameter also has a DW_AT_artificial attribute whose value is true. ``` This patch attaches the `DW_AT_object_pointer` for function *defintions*. The declarations will be handled in a separate patch. The part about `DW_AT_artificial` seems overly restrictive, and not true for explicit object parameters. We probably should relax this part of the DWARF spec. Partially fixes https://github.com/llvm/llvm-project/issues/120974
Diffstat (limited to 'clang/lib/CodeGen/CGDebugInfo.cpp')
-rw-r--r--clang/lib/CodeGen/CGDebugInfo.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index d7e5e95..f9cba41 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -4829,6 +4829,9 @@ llvm::DILocalVariable *CGDebugInfo::EmitDeclare(const VarDecl *VD,
if (IPD->getParameterKind() == ImplicitParamKind::CXXThis ||
IPD->getParameterKind() == ImplicitParamKind::ObjCSelf)
Flags |= llvm::DINode::FlagObjectPointer;
+ } else if (const auto *PVD = dyn_cast<ParmVarDecl>(VD)) {
+ if (PVD->isExplicitObjectParameter())
+ Flags |= llvm::DINode::FlagObjectPointer;
}
// Note: Older versions of clang used to emit byval references with an extra