<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Aug 4, 2014 at 7:14 PM, Manuel Klimek <span dir="ltr"><<a href="mailto:klimek@google.com" target="_blank">klimek@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"><div><br></div><div>why are those not instantiated when a FrontendAction is run?</div>
</div></blockquote><div><br></div><div>My choice of words was bad -- the template is not instantiated here, merely parsed. We don't have any template arguments to give it.</div><div><br></div><div>We just (a few minutes ago, while experimenting with this) found a case where late-parsing a template whose body contains undefined symbols would generate an incomplete AST, e.g.</div>
<div><br></div><div><div>template<class T></div><div>void foo(const T& t) {</div><div>  UndefinedSymbol::bar(t);  // colon-colon</div><div>}</div></div><div><br></div><div><div>$ clang-check.exe -ast-dump incomplete.cpp -- -fno-delayed-template-parsing</div>
<div>TranslationUnitDecl 0xebe7e0 <<invalid sloc>> <invalid sloc></div><div>|-CXXRecordDecl 0xebeaa0 <<invalid sloc>> <invalid sloc> implicit class type_info</div><div>|-TypedefDecl 0xebeb20 <<invalid sloc>> <invalid sloc> implicit size_t 'unsigned int'</div>
<div>|-TypedefDecl 0xebeb80 <<invalid sloc>> <invalid sloc> implicit __builtin_va_list 'char *'</div><div>`-FunctionTemplateDecl 0xebed80 <incomplete.cpp:2:1, line:5:1> line:3:6 foo</div><div>
  |-TemplateTypeParmDecl 0xebebb0 <line:2:10, col:16> col:16 class T</div><div>  `-FunctionDecl 0xebed10 <line:3:1, line:5:1> line:3:6 foo 'void (const T &)'</div><div>    |-ParmVarDecl 0xebec80 <col:10, col:19> col:19 referenced t 'const T &'</div>
<div>    `-CompoundStmt 0xebee40 <col:22, line:5:1></div><div>      `-CallExpr 0xebee20 <line:4:3, col:25> '<dependent type>'</div><div>        |-DependentScopeDeclRefExpr 0xebede0 <col:3, col:20> '<dependent type>' lvalue</div>
<div>        `-DeclRefExpr 0xebee04 <col:24> 'const T' lvalue ParmVar 0xebec80 't' 'const T &'</div></div><div><br></div><div>This runs without error, while this:</div><div><br></div><div>
<div><div>template<class T></div><div>void foo(const T& t) {</div><div>  UndefinedSymbol.bar(t);  // dot</div><div>}</div></div></div><div><br></div><div>throws an error, as expected:</div><div><br></div><div><div>
  incomplete.cpp:4:4: error: use of undeclared identifier 'UndefinedSymbol'</div><div>     UndefinedSymbol.bar(t);</div><div>     ^</div></div><div><br></div><div>I don't know if this is a general bug in the parser, but it'd be nice to always get a diagnostic here.</div>
<div><br></div><div>- Kim</div></div></div></div>