Problem with source ranges for template classes

Richard Smith richard at metafoo.co.uk
Wed Feb 4 23:20:35 PST 2015


On Wed, Feb 4, 2015 at 1:02 AM, Abramo Bagnara <abramo.bagnara at bugseng.com>
wrote:

>
> Using this source:
>
> template <int> struct C { template <typename U> struct D; };
> template <> template <typename V> struct C<0>::D { };
>
> we get the following AST for the second line
>
> `-ClassTemplateDecl 0x8596370 parent 0x8595cf0 prev 0x8596080
> <line:2:13, col:52> col:48 D
>   |-TemplateTypeParmDecl 0x8595c20 <col:23, col:32> col:32 typename V
>   `-CXXRecordDecl 0x85962a0 parent 0x8595cf0 prev 0x8595ff0 <col:1,
> col:52> col:48 struct D definition
>     `-CXXRecordDecl 0x8596440 <col:35, col:48> col:48 implicit struct D
>
> Reading the dump we can note that the range of outer node
> ClassTemplateDecl (col 13-52) is smaller than the one of inner node
> CXXRecordDecl (col 1-52).
>
> This violates an (IMHO) important invariant where it is expected that
> inner nodes have a range that is a subset or equal to range of outer nodes.
>
> I'd think that the CXXRecordDecl range should begin from col 35 and the
> ClassTemplateDecl range should begin from col 1.
>
> Does this sound reasonable?


Yes.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150204/e1e099f1/attachment.html>


More information about the cfe-commits mailing list