<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Oct 14, 2014 at 2:48 PM, Richard Smith <span dir="ltr"><<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><div class="h5">On Tue, Oct 14, 2014 at 1:50 PM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span>On Tue, Oct 14, 2014 at 1:42 PM, Richard Smith <span dir="ltr"><<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span>On Tue, Oct 14, 2014 at 1:31 PM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br></span><span><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">So I'm looking at addressing PR21216</div></blockquote><div><br></div></span><div>Are you sure that's the right bug number?</div></div></div></div></blockquote><div><br></div></span><div>Nope, sorry about that. Actually PR21246: <a href="http://llvm.org/bugs/show_bug.cgi?id=21246" target="_blank">http://llvm.org/bugs/show_bug.cgi?id=21246</a></div><div><div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">and I've come across a few hiccups:<br><br>* I can fix the bug as filed by using TemplateArgument's isDeclForReferenceParameter to either create a reference or a pointer type for the argument<br><br>* But this doesn't include const-ness. How would I differentiate the types of the arguments to these template parameters: "template<const int&, int&>" ?<br><br>* This also doesn't include rvalue ref-ness. How would I differentiate the types of the arguments to these template parameters: "template<int &, int&&>" ? <br><br>* Clang prints the desugared name (which we use in the debug info, but can also appear in diagnostics) somewhat strange/incorrectly:<br><br><div>int i;</div><div>template<int& I, int *J, int&& K, const int &L></div><div>struct foo {</div><div>};</div><div><br></div><div>foo<i, &i, i, i> f;</div><div><br></div><div>void f1(int);</div><div><br></div><div>template<typename T></div><div>void f2(T t) {</div><div>  f1(t);</div><div>}</div><div><br></div><div>int main() {</div><div>  f1(f);</div><div>  f2(f);</div><div>}<br><br>Clang produces (just cutting to the notes in question):<br><div><div>templ.cpp:16:3: error: no matching function for call to 'f1'</div><div>  f1(f);</div><div>  ^~</div><div>templ.cpp:8:6: note: candidate function not viable: no known conversion from 'foo<i, &i, i, i>' to 'int' for 1st argument</div><div>void f1(int);</div><div>     ^</div><div>templ.cpp:12:3: error: no matching function for call to 'f1'</div><div>  f1(t);</div><div>  ^~</div><div>templ.cpp:17:3: note: in instantiation of function template specialization 'f2<foo<&i, &i, &i, &i> >' requested here</div><div>  f2(f);</div><div>  ^</div><div>templ.cpp:8:6: note: candidate function not viable: no known conversion from 'foo<&i, &i, &i, &i>' to 'int' for 1st argument</div><div>void f1(int);</div><div>     ^<br><br>Note the desugaring of the template adds '&' to all the parameters, even the reference parameters.<br><br>GCC gets something that looks ugly but probably correct:<br><div>templ.cpp: In function ‘int main()’:</div><div>templ.cpp:16:7: error: cannot convert ‘foo<(* & i), (& i), (* & i), ((const int&)(& i))>’ to ‘int’ for argument ‘1’ to ‘void f1(int)’</div><div>   f1(f);</div><div>       ^<br><br>Though, weirdly, GCC doesn't reject the call to f2... which is weird.<br><br>Anyway: where should I get the right type for my non-type template arguments? Do I have to go spelunking through the template parameters (can I get to them from the template arguments) & try to stitch the type together? That's probably not ideal... <br></div></div></div></div></div></blockquote><div><br></div></div></div><div>Right now, I think you need the template parameters.</div></div></div></div></blockquote><div><br></div></div></div><div>Hrm. I'm a bit concerned about trying to make this work with complex dependent types... <br><br><div>template<typename T, typename T::foo F> struct foo { };</div><div>struct outer { typedef const int &foo; };</div><div>int i;<br></div><div>foo<outer, i> f;<br><br>is that going to be easier than I'm thinking? I'm a bit concerned about figuring out the instantiation of T::foo from the template parameter description... </div></div></div></div></div></blockquote><div><br></div></div></div><div>This is a problem; we don't preserve enough information here.</div></div></div></div></blockquote><div><br>Right you are, and as suggested offline it seems we had enough space to store the whole QualType (TemplateArgument::Integer is the long pole, with two 32 bit ints and two pointer sized elements - so TemplateArgument::Declaration is only that big (one 32 bit int and two pointer sized elements, plus alignment) on 64 bit, and smaller on 32 bit) so I've done that and implemented the full debug info support in <span style="color:rgb(0,0,0)">r219900.<br></span><br>I didn't look into/figure out where the weird type printing is coming from as yet, and there were some other oddities I've called out in the commit message.<br><br>- David </div></div><br></div></div>