[cfe-dev] __PRETTY_FUNCTION__ in clang

Mikhail Ramalho via cfe-dev cfe-dev at lists.llvm.org
Thu Feb 1 09:50:09 PST 2018

Hi all,

I recently noticed that clang and gcc print __PRETTY_FUNCTION__ in
different formats, e.g.:

template <typename T> struct X
  X() { std::cout << __PRETTY_FUNCTION__ << '\n';}
X<void> x;

In gcc:
X<T>::X() [with T = void]

In clang:
X<void>::X() [T = void]

I only found a discussion about it from 2011, that added the template args
to the output:


I also created a patch that implements the gcc format, but broke all the
diagnostic tests, because it needs the instantiated name to report
warning/errors (which is correct in my opinion).

One solution would be adding a new attribute in PrintingPolicy to handle
the case where we want to print these predefined expressions, then enabling
it in PredefinedExpr::ComputeName.

Is there any interest in the community to match gcc's output? There are
some valid points in the previous thread.

Thank you,


Mikhail Ramalho.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180201/757556f5/attachment.html>

More information about the cfe-dev mailing list