<div dir="ltr">Thanks for the clarification, Richard. I've opened <a href="http://llvm.org/bugs/show_bug.cgi?id=20666">http://llvm.org/bugs/show_bug.cgi?id=20666</a> to track this.</div><div class="gmail_extra"><br><br>
<div class="gmail_quote">On Tue, Aug 12, 2014 at 12:05 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:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><div class="h5">On Tue, Aug 12, 2014 at 8:54 AM, Eli Bendersky <span dir="ltr"><<a href="mailto:eliben@google.com" target="_blank">eliben@google.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">Hello,<div><br></div><div>We may be observing an invalid SourceRange being attached to an extern template declaration. Consider this code:</div>
<div><br></div><div><div> template <typename T></div><div>
int __ostream_insert() {</div><div> return 0;</div><div> }</div><div><br></div><div> extern template int __ostream_insert<char>();</div><div><br></div><div> template<> int __ostream_insert<long>() {</div>
<div> return 1;</div><div> }</div></div><div><br></div><div>The AST dump for it is:</div><div><br></div><div><div> TranslationUnitDecl 0x3763300 <<invalid sloc>> <invalid sloc></div><div> |-TypedefDecl 0x3763840 <<invalid sloc>> <invalid sloc> implicit __int128_t '__int128'</div>
<div> |-TypedefDecl 0x37638a0 <<invalid sloc>> <invalid sloc> implicit __uint128_t 'unsigned __int128'</div><div> |-TypedefDecl 0x3763c60 <<invalid sloc>> <invalid sloc> implicit __builtin_va_list '__va_list_tag [1]'</div>
<div> |-FunctionTemplateDecl 0x3763e50 </tmp/jp.cpp:1:3, line:4:3> line:2:7 __ostream_insert</div><div> | |-TemplateTypeParmDecl 0x3763cb0 <line:1:13, col:22> col:22 typename T</div><div> | |-FunctionDecl 0x3763db0 <line:2:3, line:4:3> line:2:7 __ostream_insert 'int (void)'</div>
<div> | | `-CompoundStmt 0x3763ed8 <col:26, line:4:3></div><div> | | `-ReturnStmt 0x3763eb8 <line:3:5, col:12></div><div> | | `-IntegerLiteral 0x3763e98 <col:12> 'int' 0</div><div>
| |-FunctionDecl 0x37a4f60 <line:2:3, line:4:3> line:2:7 __ostream_insert 'int (void)'</div><div> | | `-TemplateArgument type 'char'</div><div> | `-Function 0x37a50a0 '__ostream_insert' 'int (void)'</div>
<div> `-FunctionDecl 0x37a50a0 prev 0x37a51c0 <line:8:3, line:10:3> line:8:18 __ostream_insert 'int (void)'</div><div> |-TemplateArgument type 'long'</div><div> `-CompoundStmt 0x37a5380 <col:43, line:10:3></div>
<div> `-ReturnStmt 0x37a5360 <line:9:5, col:12></div><div> `-IntegerLiteral 0x37a5340 <col:12> 'int' 1</div></div><div><br></div><div><br></div><div>Note that the node representing the extern declaration has the source range of the original template. Is this a (known) bug, or am I misunderstanding something?</div>
</div></blockquote><div><br></div></div></div><div>This is certainly a bug. Note that we don't have a declaration of __ostream_insert<char> lexically within the TU either; we don't create any explicit representation of it. See this FIXME:</div>
<div><br></div><div><a href="http://clang.llvm.org/doxygen/SemaTemplate_8cpp_source.html#l07688" target="_blank">http://clang.llvm.org/doxygen/SemaTemplate_8cpp_source.html#l07688</a></div></div></div></div>
</blockquote></div><br></div>