[clang] [llvm] [clang][DebugInfo] Add virtuality call-site target information in DWARF. (PR #167666)

Felipe de Azevedo Piovezan via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 18 07:50:29 PST 2026


================
@@ -4978,6 +4978,24 @@ void CGDebugInfo::EmitFunctionDecl(GlobalDecl GD, SourceLocation Loc,
     Fn->setSubprogram(SP);
 }
 
+void CGDebugInfo::addCallTarget(const FunctionDecl *FD, llvm::CallBase *CI) {
+  if (!generateVirtualCallSite())
+    return;
+
+  if (!FD)
+    return;
+
+  // Record only indirect calls.
+  assert(CI && "Invalid Call Instruction.");
+  if (!CI->isIndirectCall())
+    return;
+
+  // Always get method definition.
+  if (llvm::DISubprogram *MD = getFunctionDeclaration(FD))
+    // Attach the target metadata
----------------
felipepiovezan wrote:

NIT: are these two comments adding anything to the code? The first one seems more confusing than clarifying (it says "definition" but then the line below is "get declaration"). The second comment is just restating what the `CI->setMetadata` words already state.

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


More information about the cfe-commits mailing list