[cfe-commits] Patch to correct start location of FieldDecls in template instantiations

Daniel Jasper djasper at google.com
Tue May 22 14:36:58 PDT 2012


On Tue, May 22, 2012 at 10:03 PM, Richard Smith <richard at metafoo.co.uk>wrote:

> Hi Daniel,
>
> On Tue, May 22, 2012 at 12:18 PM, Daniel Jasper <djasper at google.com>wrote:
>
>> Hello,
>>
>> I have noticed that the start location of FieldDecls is different in
>> template instantiations and in the primary template (the instantiations
>> loose the location of leading qualifiers). The reason is that the location
>> of qualifiers is currently not tracked in the TypeLocs. However, it makes
>> sense to use the primary template's inner start location making the two
>> FieldDecls have the same code range independent of the TypeLoc
>> implementation.
>>
>> Please find the corresponding patch attached.
>>
>
> Can you add a test for this? Also, VarDecls (and the substitution of
> function types for function declarations) seem to have the same problem. We
> should fix all of them together.
>

Not much else there is actually tested. I could add
RecursiveASTVisitor-tests for a couple of things, but I think this should
be well-designed and will take more effort. I can try to find a diagnostic
that triggers on this (start location of FieldDecls in template
instantiations), but maybe we can get this in as a small bug-fix.

VarDecls seem to be fine, they actually use getInnerLocStart() at the
appropriate place. So, we are actually making the behavior more consistent
:-).


> I'm also concerned that DeclaratorDecl::getTypeSpecStartLoc does not
> return the location of the first type-specifier -- perhaps we should rename
> it to getTypeSpecLoc(), and document that it does not return the location
> of a cv-qualifier (though not as part of your patch). The other uses of it
> in Sema generally look acceptable (mostly for diagnostic locations), but
> I'm not sure whether the uses of it in the RewriteObjC code are correct.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120522/88852b40/attachment.html>


More information about the cfe-commits mailing list