[clang] [LLVM][DWARF] Enable pubnames for -glldb when expliti flag is passed (PR #83206)

Alexander Yermolovich via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 27 15:25:26 PST 2024


https://github.com/ayermolo created https://github.com/llvm/llvm-project/pull/83206

This is a fix for https://github.com/llvm/llvm-project/pull/82840. On mac
tunning is by default LLDB. If the flag was passed in to clang after that PR it
would not have been passed in by the driver.


>From c7fb961e3a4dfa404187e62d32490c58977f212a Mon Sep 17 00:00:00 2001
From: Alexander Yermolovich <ayermolo at meta.com>
Date: Tue, 27 Feb 2024 14:54:22 -0800
Subject: [PATCH] [LLVM][DWARF] Enable pubnames for -glldb when expliti flag is
 passed

This is a fix for https://github.com/llvm/llvm-project/pull/82840. On mac
tunning is by default LLDB. If the flag was passed in to clang after that PR it
would not have been passed in by the driver.
---
 clang/lib/Driver/ToolChains/Clang.cpp | 9 +++++++--
 clang/test/Driver/split-debug.c       | 5 +++++
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index dbfc729bba24c7..7b38450d0720ef 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -4478,8 +4478,12 @@ renderDebugOptions(const ToolChain &TC, const Driver &D, const llvm::Triple &T,
       Args.getLastArg(options::OPT_ggnu_pubnames, options::OPT_gno_gnu_pubnames,
                       options::OPT_gpubnames, options::OPT_gno_pubnames);
   if (DwarfFission != DwarfFissionKind::None ||
-      (PubnamesArg && checkDebugInfoOption(PubnamesArg, Args, D, TC)))
-    if (DebuggerTuning != llvm::DebuggerKind::LLDB &&
+      (PubnamesArg && checkDebugInfoOption(PubnamesArg, Args, D, TC))) {
+    const bool OptionSet =
+        (PubnamesArg &&
+         (PubnamesArg->getOption().matches(options::OPT_gpubnames) ||
+          PubnamesArg->getOption().matches(options::OPT_ggnu_pubnames)));
+    if ((DebuggerTuning != llvm::DebuggerKind::LLDB || OptionSet) &&
         (!PubnamesArg ||
          (!PubnamesArg->getOption().matches(options::OPT_gno_gnu_pubnames) &&
           !PubnamesArg->getOption().matches(options::OPT_gno_pubnames))))
@@ -4487,6 +4491,7 @@ renderDebugOptions(const ToolChain &TC, const Driver &D, const llvm::Triple &T,
                                            options::OPT_gpubnames)
                             ? "-gpubnames"
                             : "-ggnu-pubnames");
+  }
   const auto *SimpleTemplateNamesArg =
       Args.getLastArg(options::OPT_gsimple_template_names,
                       options::OPT_gno_simple_template_names);
diff --git a/clang/test/Driver/split-debug.c b/clang/test/Driver/split-debug.c
index a2a3dc02354503..57f3989ed7b510 100644
--- a/clang/test/Driver/split-debug.c
+++ b/clang/test/Driver/split-debug.c
@@ -129,3 +129,8 @@
 // RUN: %clang -### -c -target x86_64 -gsplit-dwarf -g -glldb %s 2>&1 | FileCheck %s --check-prefixes=GLLDBSPLIT
 
 // GLLDBSPLIT-NOT: "-ggnu-pubnames"
+
+/// Generate -ggnu-pubnames for -glldb when it is explicitly enabled
+// RUN: %clang -### -c -target x86_64 -gsplit-dwarf -g -glldb -ggnu-pubnames %s 2>&1 | FileCheck %s --check-prefixes=GLLDBSPLIT2
+
+// GLLDBSPLIT2: "-ggnu-pubnames"



More information about the cfe-commits mailing list