[llvm-dev] Possible bug in TypePrinter::printElaboratedBefore?

Dejan Mircevski via llvm-dev llvm-dev at lists.llvm.org
Thu Oct 13 12:59:35 PDT 2016


My apologies if this topic is inappropriate; this is my first posting to
the list.  I've been playing around with the printers, and I noticed
that TypePrinter::printElaboratedBefore sets the printing policy to
suppress scope before proceeding to print the type name:
http://clang.llvm.org/doxygen/TypePrinter_8cpp_source.html#l01102

I presume this is so that the qualifier wouldn't get printed twice, but the
problem is when the ElaboratedType is a TemplateSpecialization: in that
case, the scope suppression policy applies not just to the type name but
also to all the template parameters.  I don't think this is correct, since
the template parameters aren't affected by the ElaboratedType qualifier, so
they do need to print their own scope if the original policy so requires.

I'm facing a problem trying to print this code outside of its original
namespace:

namespace NS {
struct A {};
class B {
public:
  virtual void foo(std::vector<A> &) = 0;
};
}

When I try to print foo in a different context, I get "std::vector<A>" for
the result, which is invalid outside NS.  But if I just use
"foo(vector<A>&)" as the input (of course, with the appropriate using
directive above it), then printing foo yields, correctly, "vector<NS::A>".

(The upstream problem manifestation can be seen, eg, here:
https://github.com/dekimir/RamFuzz/issues/1)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20161013/2b212cbe/attachment.html>


More information about the llvm-dev mailing list