the attached patch fixes the source range on CXXNewExprs. For code like
foo:A* a = new foo::A;
the CXXNewExpr's source range's end would point to `foo` instead of
`A`. This was because Sema::BuildCXXNew() uses the allocated type's
TypeLoc's source range's end as end location for CXXNewExpr if no
parens are present (new foo::A() is handled correctly already), and
TypeSpecTypeLoc has only a start location.
My patch adds an end location to TypeSpecTypeLoc and fills it in in
TypeSpecLocFiller::VisitTagTypeLoc(). The rest of the patch consists
of copying this new TypeSpecTypeLoc field every time a TypeSpecTypeLoc
is copied, which happens in surprisingly many places.
Acurate sourceranges on all ast nodes are important for writing rewriters.
Ah. So the problem is that the TypeSpecTypeLoc's location should be
the location of the qualified identifier, not the location of the start of the
qualification.
Ah yes, I see the problem. You're right, we need to use getAnnotationEndLoc(),
both here and elsewhere. I think we probably also need the change to
SemaType.cpp, though.