[cfe-commits] [Request for approval] Added basic source locations to Elaborated and DependentName types.

John McCall rjmccall at apple.com
Thu May 13 13:43:07 PDT 2010


On May 13, 2010, at 2:09 AM, Abramo Bagnara wrote:
> The attached patch improves support for locations inside Elaborated and
> DependentName types.

DependentNameType needs to be able to situationally store a TemplateSpecializationTypeLoc as its NextTypeLoc.  This is not going to be very clean.  The best solution would be to split DependentNameType in two, so that we have both DependentNameType (typename A<T>::foo) and DependentTemplateSpecializationType (A<T>::template B<int>).  If you're willing to do that refactor, that would be awesome;  otherwise, let me know and we'll get to it eventually.

   /* FIXME: preserve source information better than this */
-  SourceRange SR(TL.getNameLoc());
+  SourceRange SR(TL.getSourceRange());
 
This is supposed to be the source range for the nested name specifier.  Please save this SourceRange in the TypeLocs for now;  when we have proper source information for nested-name-specifiers, we can use that.

+    else if (isa<TemplateSpecializationType>(NamedT)) {
+      TemplateSpecializationTypeLoc NamedTLoc
+        = TLB.push<TemplateSpecializationTypeLoc>(NamedT);
+      // FIXME: fill locations
+    }

It's fine to punt on this for now, but please at least call NamedTLoc.initializeLocal(SourceLocation());  otherwise the memory will be uninitialized.

> A part of the patch adds the missing classof to make typeloc cast
> assertions work as expected.

Great, thanks.

> The next step should be adding source location to NestedNameSpecifier.

I'm not sure this is the right approach;  I think it might be better to use a TypeLoc-like solution.  But we should talk about this separately.

John.



More information about the cfe-commits mailing list