[cfe-dev] When are SourceLocation's actually required in the AST

Douglas Gregor dgregor at apple.com
Sun Aug 24 21:16:29 PDT 2014


> On Aug 15, 2014, at 9:53 AM, Reid Kleckner <rnk at google.com> wrote:
> 
> My understanding is that the asserts were added to template instantiation because previously it transformed types without transforming location information. You ended up with QualTypes instead of TypeSourceInfo*'s or TypeLocs, which lost a lot of information. I think those asserts were added to make sure that the rest of the compiler continue to forward proper slocs. I don't think they are truly needed for correctness.
> 
> I think Doug was responsible for those assertions. Maybe he has time now to answer questions, but maybe not. :)

That’s essentially the reason. Earlier on, we had some trouble with a loss of source-location information through template instantiation (and tree transformation in general), which manifest in poor diagnostics later on. That’s generally the reason to conjure up source locations that point at something related, because a diagnostic given an invalid source location is useless.

	- Doug

> 
> On Fri, Aug 15, 2014 at 9:38 AM, Keno Fischer <kfischer at college.harvard.edu> wrote:
> I've recently been generating a lot of clang ASTs programmatically and
> I am wondering when SourceLocation's are supposed to be required in
> the AST for clang to compile it correctly and when they are not. From
> my experience, most of the time it works fine to just make it an
> invalid clang::SourceLocation, but some of the time (three or four
> instances I know of), it does not (e.g. template instantiations throw
> assertion failures when the source location is invalid). So I'm
> wondering if there is any rational on when a valid (even if
> nonsensical - that always works fine) source location is required and
> when not, so I know which are bugs and need fixing (which I'm happy to
> do) and which are expected and I should simply work around.
> 
> Thanks,
> Keno
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140824/18de8310/attachment.html>


More information about the cfe-dev mailing list