[cfe-dev] Why is "..." printed 'After' the arg name in TypePrinter?

Vassil Vassilev vasil.georgiev.vasilev at cern.ch
Fri Aug 1 06:26:10 PDT 2014


Hi,
   Thanks for fixing this issue:
   There seem to be another issue with recent clang when printing:
   cat T.h
   typedef struct { } __pthread_unwind_buf_t __attribute__ ((__aligned__));

   clang -cc1  -x c++ -fsyntax-only T.h -ast-print
struct {
} typedef __pthread_unwind_buf_t __attribute__((aligned(clang: 
/home/vvassilev/workspace/llvm-github/obj/tools/clang/lib/AST/../../include/clang/AST/AttrImpl.inc:294: 
virtual void clang::AlignedAttr::printPretty(llvm::raw_ostream &, const 
clang::PrintingPolicy &) const: Assertion `isalignmentExpr && 
alignmentExpr != nullptr' failed.

Vassil

On 07/23/2014 05:25 AM, Richard Smith wrote:
> On Tue, Jul 22, 2014 at 1:40 AM, Manasij Mukherjee 
> <manasij7479 at gmail.com <mailto:manasij7479 at gmail.com>> wrote:
>
>     Hi
>     I was experimenting with printing out variadic templates with clang.
>     I had a slight issue with how TypePrinter works for function
>     arguments in variadic function templates.
>
>     If I have this in my original source file:
>     template <typename T, typename ...U>
>     void foo(T t,U... args)
>     {
>
>     }
>
>     TypePrinter currently generates this:
>     U args...
>     which should have been
>     U... args
>     as far as I know.
>
>     Is there some policy I can set to change this behaviour?
>
>     I had to slightly modify the the implementation to get what I
>     expected.
>
>     There are two functions in TypePrinter.cpp as follows:
>
>     void TypePrinter::printPackExpansionBefore(const PackExpansionType
>     *T,
>     raw_ostream &OS) {
>       printBefore(T->getPattern(), OS);
>       OS << "...";
>     }
>     void TypePrinter::printPackExpansionAfter(const PackExpansionType *T,
>     raw_ostream &OS) {
>
>         printAfter(T->getPattern(), OS);
>
>     }
>
>     The line:
>
>     OS << "...";
>
>     was previously in printPackExpansionAfter.
>
>     Why ?
>     Any side effects of moving it to the before function, as I did ?
>
>
> Yes. That'll break pretty-printing of template type argument packs:
>
> template<typename ...T> void f() {
>   std::tuple<T[3] ...> t;
> }
>
> ... would get pretty-printed as
>
>   std::tuple<T ...[3]> t;
>
> ... which is wrong.
>
> Fixed in r213718.
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140801/36da81ec/attachment.html>


More information about the cfe-dev mailing list