<div dir="ltr">Hi Richard,<div><br></div><div>You are right. Actually I just need to consider the cases that there are full instantiations of the primary template. I have changed the strategy and not use that function. </div><div><br></div><div>Thanks a lot!</div><div>Cong</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Feb 10, 2016 at 2:17 AM, 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"><span class="">On Tue, Feb 9, 2016 at 4:15 PM, Cong Liu <<a href="mailto:congliu@google.com">congliu@google.com</a>> wrote:<br>
> Hi Richard,<br>
><br>
> Thank you for your reply. Yes, the case I need to deal with is like what you<br>
> said:<br>
>><br>
>> If you want to make the assumption that the primary template will be<br>
>> used for an unknown specialization, you'll need something like that<br>
>> function in ASTMatchFinder.<br>
><br>
><br>
> For example,<br>
><br>
>   template <typename T><br>
>   struct Base {};<br>
>   template <typename T><br>
>   struct Derived : Base<T>{};<br>
><br>
>   Derived<int> T1;<br>
><br>
> In this case, I need to firstly get the CXXBaseSpecifier from line 4, then<br>
> get the QualType of primary template (Base<T>), then get its declaration.<br>
> For this case, that function in ASTMatchFinder works but<br>
> Type::getAsCXXRecordDecl does not.<br>
><br>
> So, what do you suggest?<br>
<br>
</span>Using that may not be correct when analysing virtual function<br>
overrides. Consider this:<br>
<span class=""><br>
template<typename T> struct Base {<br>
</span>  virtual void f(T);<br>
};<br>
template<> struct Base<void> {<br>
  virtual void f();<br>
};<br>
template<typename T, bool = is_same<T, void>::value> struct Derived : Base<T> {<br>
  virtual void f();<br>
};<br>
template<typename T> struct Derived<T, false> : Base<T> {<br>
  virtual void f(T);<br>
};<br>
<br>
Here, it would be wrong to report that the Derived primary template<br>
fails to override a virtual function from the Base primary template,<br>
as the Derived primary template is actually only ever used when T ==<br>
void, and there's a specialization of the Base template for that case.<br>
I have no idea whether that's acceptable for your check.<br>
<br>
In principle, I'm fine with us moving the functionality in<br>
ASTMatchFinder (that I recently renamed to<br>
getAsCXXRecordDeclOrPrimaryTemplate to better express its purpose) to<br>
somewhere more central, but my concern is that most uses of it will in<br>
fact be subtle bugs.<br>
</blockquote></div><br></div>