[clang] 7cb5faf - [Clang][Driver] Expose `-fno-eliminate-unused-debug-types` to clang-cl (#95259)

via cfe-commits cfe-commits at lists.llvm.org
Sat Jun 15 08:33:48 PDT 2024


Author: Alexandre Ganea
Date: 2024-06-15T11:33:44-04:00
New Revision: 7cb5faf6da5a6f6335aca8a2532e5320ec434458

URL: https://github.com/llvm/llvm-project/commit/7cb5faf6da5a6f6335aca8a2532e5320ec434458
DIFF: https://github.com/llvm/llvm-project/commit/7cb5faf6da5a6f6335aca8a2532e5320ec434458.diff

LOG: [Clang][Driver] Expose `-fno-eliminate-unused-debug-types` to clang-cl (#95259)

This is used to set DebugInfoKind to "UnusedTypeInfo". This helps in the
context of Unreal Engine and NATVIS files that reference unused
otherwise `static constexpr` class members. See
https://udn.unrealengine.com/s/question/0D5QP00000N012h0AB/fname-debug-visualizer-fails-to-work-with-the-clang-compiler

This partially fixes https://github.com/llvm/llvm-project/issues/46924

Added: 
    

Modified: 
    clang/docs/UsersManual.rst
    clang/include/clang/Driver/Options.td
    clang/test/Driver/cl-options.c

Removed: 
    


################################################################################
diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 8e01ea15064ba..d273102fe9000 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -3347,6 +3347,9 @@ below. If multiple flags are present, the last one is used.
   By default, Clang does not emit type information for types that are defined
   but not used in a program. To retain the debug info for these unused types,
   the negation **-fno-eliminate-unused-debug-types** can be used.
+  This can be particulary useful on Windows, when using NATVIS files that
+  can reference const symbols that would otherwise be stripped, even in full
+  debug or standalone debug modes.
 
 Controlling Macro Debug Info Generation
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

diff  --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 4ab8638175dd3..15f62c5c1a6ab 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2122,7 +2122,7 @@ def fno_elide_type : Flag<["-"], "fno-elide-type">, Group<f_Group>,
     MarshallingInfoNegativeFlag<DiagnosticOpts<"ElideType">>;
 def feliminate_unused_debug_symbols : Flag<["-"], "feliminate-unused-debug-symbols">, Group<f_Group>;
 defm eliminate_unused_debug_types : OptOutCC1FFlag<"eliminate-unused-debug-types",
-  "Do not emit ", "Emit ", " debug info for defined but unused types">;
+  "Do not emit ", "Emit ", " debug info for defined but unused types", [ClangOption, CLOption]>;
 def femit_all_decls : Flag<["-"], "femit-all-decls">, Group<f_Group>,
   Visibility<[ClangOption, CC1Option]>,
   HelpText<"Emit all declarations, even if unused">,

diff  --git a/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c
index 95d28e46bc582..a6f338533ad76 100644
--- a/clang/test/Driver/cl-options.c
+++ b/clang/test/Driver/cl-options.c
@@ -698,6 +698,8 @@
 // RUN:     -Wunused-variable \
 // RUN:     -fmacro-backtrace-limit=0 \
 // RUN:     -fstandalone-debug \
+// RUN:     -feliminate-unused-debug-types \
+// RUN:     -fno-eliminate-unused-debug-types \
 // RUN:     -flimit-debug-info \
 // RUN:     -flto \
 // RUN:     -fmerge-all-constants \


        


More information about the cfe-commits mailing list