[PATCH] D80242: [Clang] implement -fno-eliminate-unused-debug-types

David Blaikie via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 19 14:53:52 PDT 2020


dblaikie added a comment.

Looks like this only implements support for typedefs, but the flag in GCC does more than that (as the flag name indicates - it's about unused types in general) - could you test this across some non-trivial code and see if it matches GCC's behavior (or, where it doesn't, that there's a good reason for that divergence)

Here's a few cases I tested by hand:

  typedef int t1; // yes
  struct t2 { }; // yes
  template<typename T>
  struct t3 { T t; };
  void f1(
      decltype(t3<int>::t), // yes (t3<int>)
  t3<float>); // no (t3<float>)
  struct t4; // no
  struct t5; // yes because \/
  typedef t5* t6; // yes
  struct t7; // no
  void f2(t7*);

https://godbolt.org/z/SgHxJv



================
Comment at: clang/lib/CodeGen/CodeGenModule.cpp:5559
+  case Decl::Typedef:
+    if (getCodeGenOpts().DebugUnusedTypes)
+      if (CGDebugInfo *DI = getModuleDebugInfo())
----------------
Probably test this within the implementation of CGDebugInfo? & rename the EmitTypedef function to something that clarifies that it's for an otherwise unused type?

But that function might need to be generalized further, rather than only having it for typedefs. (see general comment above)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80242/new/

https://reviews.llvm.org/D80242





More information about the cfe-commits mailing list