<html>
<head>
<base href="http://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - Wrong source range for template and templated decl"
href="http://llvm.org/bugs/show_bug.cgi?id=22472">22472</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Wrong source range for template and templated decl
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>C++
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>abramo.bagnara@bugseng.com
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>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.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>