From ab5db2ea742284d8964885eba5d7239215df64dd Mon Sep 17 00:00:00 2001 From: Steve Merritt Date: Mon, 28 Jul 2025 09:05:57 -0700 Subject: [PATCH] [clang][DebugInfo] Don't emit VTable debug symbols for -gline-tables-only. The -gline-tables-only option emits minimal debug info for functions, files and line numbers while omitting variables, parameters and most type information. VTable debug symbols are emitted to facilitate a debugger's ability to perform automatic type promotion on variables and parameters. With variables and parameters being omitted, the VTable symbols are unnecessary. --- clang/lib/CodeGen/CGDebugInfo.cpp | 2 ++ clang/test/CodeGenCXX/debug-info-gline-tables-only.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index a371b6755f74d..6d428f0b7fef5 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -2641,6 +2641,8 @@ void CGDebugInfo::emitVTableSymbol(llvm::GlobalVariable *VTable, const CXXRecordDecl *RD) { if (!CGM.getTarget().getCXXABI().isItaniumFamily()) return; + if (DebugKind <= llvm::codegenoptions::DebugLineTablesOnly) + return; ASTContext &Context = CGM.getContext(); StringRef SymbolName = "_vtable$"; diff --git a/clang/test/CodeGenCXX/debug-info-gline-tables-only.cpp b/clang/test/CodeGenCXX/debug-info-gline-tables-only.cpp index 9b86a49d69f5b..192169b0ab798 100644 --- a/clang/test/CodeGenCXX/debug-info-gline-tables-only.cpp +++ b/clang/test/CodeGenCXX/debug-info-gline-tables-only.cpp @@ -14,9 +14,11 @@ class E : public C { // CHECK-NOT: DW_TAG_reference type void x(const D& d); }; +// CHECK-NOT: DW_TAG_structure_type struct F { enum X { }; void func(X); + // CHECK-NOT: DW_TAG_member virtual ~F(); }; F::~F() {