Hi All,<div><br></div><div>I've run into what looks like a bug (or possibly ambiguous behaviour) when examining specialized static members of a templated class.</div><div><br></div><div><div>template <typename T></div>
<div>class TemplatedClass</div><div>{</div><div>public:</div><div><span class="" style="white-space:pre">   </span>static int Foo;</div><div>};</div><div><br></div><div>template <typename T></div><div>int TemplatedClass<T>::Foo = 1;</div>
<div><br></div><div>template <></div><div>int TemplatedClass<int>::Foo = 2;</div><div><br></div><div>The <int> specialization generates two VarDecls (as expected), one for the declaration and one for the definition. However if you query getSourceRange() for the declaration it will give you a range extending from the declaration to the definition - rather than one simply covering the declaration. This proves problematic when it comes to rewriting such declarations.</div>
<div><br></div><div>The declaration's location is set to the definition location by Sema::CheckMemberSpecialization(). In some ways this is correct as the specialization obviously "spawns" the specialized declaration but it does make the SourceRange somewhat useless in this case.</div>
<div><br></div><div>Any thoughts on this? It's easily resolved by removing the setLocation() call in CheckMemberSpecialization() but my feeling is this may be incorrect (or at least losing information). It's almost like there should be a "SourceLocation PointOfSpecialization" member in MemberSpecializationInfo - but perhaps I'm completely on the wrong track?</div>
<div><br></div><div>Obviously, I guess I can fall back on querying the non-specialized declaration for the SourceRange but this feels more than a little ugly.</div>















<div><br></div><div>- Will.</div><div><br></div>
</div>