[cfe-dev] Should dump methods be LLVM_ATTRIBUTE_USED only in debug builds?

Chandler Carruth chandlerc at google.com
Thu Jan 2 17:59:09 PST 2014

On Thu, Jan 2, 2014 at 8:46 PM, Philip Reames <listmail at philipreames.com>wrote:

> I very strongly second this.  I would be in complete opposition to any
> proposal which has the effect of worsening the out-of-box debugging
> experience.
> I understand and support your desire to reduce size in Release builds.
> Can you spell out a case for such reduction in Debug builds?  Maybe there's
> something I'm missing here.

I'd like to re-iterate my concrete suggestion. I think that *all* of the
dump methods in LLVM and Clang should be consistently defined as such:

  void some_helper_function_only_used_by_dump() const;
  LLVM_DUMP_METHOD void dump() const;

And then I would provide the following defines in Compiler.h or whatever
header seems appropriate:

#define LLVM_ENABLE_DUMP !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)

This ensures that dump methods are always available in assert builds, and
can be enabled explicitly in no-assert builds as needed (LLVM_ENABLE_DUMP
comes from configure or cmake), and when dump methods are disabled both
those methods and everything they use gets pruned out, with no warnings
about unused private methods etc.

What doesn't work with this approach?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140102/eb3f54d5/attachment.html>

More information about the cfe-dev mailing list