[cfe-dev] Unexpected TypeLoc match for captured variable in lambda

Stephen Kelly via cfe-dev cfe-dev at lists.llvm.org
Mon Mar 25 03:11:55 PDT 2019


On 25/03/2019 08:59, Manuel Klimek via cfe-dev wrote:
> I think there was some work recently that changed how we represented 
> lambdas, but not sure whether that affected this behavior.
> Here, the FieldDecl of the CXXRecordDecl has a const Foo & type and it 
> has the 'fn' as the TypeLoc - I assume the location is a bug.

I don't know if it is a bug, but from the FieldDecl the matched typeloc 
seems to be:

 
getTypeSourceInfo()->getTypeLoc().getNextTypeLoc().getAs<clang::TemplateSpecializationTypeLoc>().getArgLoc(0).getTypeSourceInfo()->getTypeLoc().getAs<clang::TypeSpecTypeLoc>().getNameLoc()


  http://ce.steveire.com/z/Iw8YiQ


> 
> I got there through clang-query by adding hasParent() and guessing the 
> types, iterating between output dump, print and diag.

You might already know this, but you don't have to iterate between them 
anymore. You can just enable all three:

  enable output detailed-ast
  enable output print
  enable output diag # On by default, so this line is not needed


Thanks,

Stephen.




More information about the cfe-dev mailing list