[PATCH] D20428: Tracking exception specification source locations

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 24 12:39:41 PDT 2016


On Fri, Jun 24, 2016 at 10:30 AM, Aaron Ballman <aaron.ballman at gmail.com> wrote:
> On Fri, Jun 24, 2016 at 8:39 AM, Richard Smith <richard at metafoo.co.uk> wrote:
>> rsmith added a comment.
>>
>> Ah right, we were (intentionally, but unfortunately) making an assumption that the `TypeLoc` data layout doesn't change when the exception spec of a function is updated. You'd need to make yourself a `TypeLocBuilder`, copy the relevant data, and update the exception spec loc.
>
> Would that look something like what we do in SemaType.cpp
> GetFullTypeForDeclarator()? i.e.,
>
> if (TInfo) {
>   TypeLocBuilder TLB;
>   TLB.pushFullCopy(TInfo->getTypeLoc());
>   ObjCObjectPointerTypeLoc TLoc = TLB.push<ObjCObjectPointerTypeLoc>(T);
>   TLoc.setStarLoc(FixitLoc);
>   TInfo = TLB.getTypeSourceInfo(Context, T);
> }

I just realized that TypeLocBuilder is part of Sema and this
functionality is needed from ASTContext, which is a laying violation.
I think ASTContext::adjustExceptionSpec() needs to go away, and we
need to expose this functionality from Sema::UpdateExceptionSpec() (or
expose a new Sema method), and make places that call
adjustExceptionSpec() instead call UpdateExceptionSpec() (or the new
function). Thankfully, there are only four places
adjustExceptionSpec() is called from: UpdateExceptionSpec(),
ActOnFunctionDeclarator(), actOnDelayedExceptionSpecific(), and the
AST reader -- all of which are either in Sema or have access to a Sema
object.

Thoughts?

~Aaron

>
> ~Aaron
>
>>
>> Where are we adjusting the exception specification on the type source info? That (changing the type-info-as-written) seems like a somewhat unusual thing to do implicitly.
>>
>>
>> http://reviews.llvm.org/D20428
>>
>>
>>


More information about the cfe-commits mailing list