This patch changes InstantiateFunctionDefinition to also define used vtables as it goes recursively instantiating templates. This should allow us to track where delayed vtable instantiations were requested, fixing PR8640.<div>

<br></div><div>Also, this removes the while(1) loop in ActOnEndOfTranslationUnit(). It's replaced with "PerformPendingInstantiations(); if (DefineUsedVTables()) { PerformPendingInstantiations(); }" and it's a mystery to me why we need the first instantiation call. Removing it causes a single test failure in test/SemaCXX/destructor.cpp (namespace test6):</div>

<div><br></div><div>  // ... class A is defined with a virtual destructor ...</div><div><div>  class B : A<int> { B(); };</div><div>  B::B() {} // expected-note {{in instantiation of member function 'test6::A<int>::~A' requested here}}</div>

</div><div><br></div><div>the note moves onto the previous line. If the existing behaviour is correct (deriving A<int> instantiates the class but not any of the methods, then B::B() requires ~A to destruct the object in case of exceptions) then there's probably another bug in clang where we're adding that the vtable is needed on the line declaring class B. Alternately, the test is wrong. :)</div>

<div><br></div><div>Please review!</div><div><br></div><div>Nick</div><div><br></div>