[LLVMbugs] [Bug 22472] New: Wrong source range for template and templated decl

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Feb 5 00:49:20 PST 2015


http://llvm.org/bugs/show_bug.cgi?id=22472

            Bug ID: 22472
           Summary: Wrong source range for template and templated decl
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: abramo.bagnara at bugseng.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

For the following source:

template <int> struct C { template <typename U> struct D; };
template <int> struct D { template <typename U> void f(); };

template <> template <typename V> struct C<0>::D { };
template <> template <typename V> void D<0>::f();

the AST generated for last two lines is:

|-ClassTemplateDecl 0x8036740 parent 0x8030360 prev 0x80306f0 <line:4:13,
col:52> col:48 D
| |-TemplateTypeParmDecl 0x8030290 <col:23, col:32> col:32 typename V
| `-CXXRecordDecl 0x8036670 parent 0x8030360 prev 0x8030660 <col:1, col:52>
col:48 struct D definition
|   `-CXXRecordDecl 0x8036810 <col:35, col:48> col:48 implicit struct D
`-FunctionTemplateDecl 0x8036ee0 parent 0x8036950 prev 0x8036cf0 <line:5:13,
col:48> col:46 f
  |-TemplateTypeParmDecl 0x80368b0 <col:23, col:32> col:32 typename V
  `-CXXMethodDecl 0x8036df0 parent 0x8036950 prev 0x8036c50 <col:1, col:48>
col:46 f 'void (void)'

As it can be observed the templated decls (CXXRecordDecl and CXXMethodDecl)
have a range that is larger than the related template decl (ClassTemplateDecl
and FunctionTemplateDecl).

This breaks the invariant that asks that inner nodes have a range that is a
subset or equal to range of outer nodes.

A sensible approach would be that templated CXXRecordDecl and DeclaratorDecl
have the begin of their source range at current InnerLocStart *and* that the
ClassTemplateDecl/FunctionTemplateDecl have the begin of their source range in
the location of the outer template keyword.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150205/62605a13/attachment.html>


More information about the llvm-bugs mailing list