[cfe-dev] Assertion error when attempting to iterate over RecordDecl

Jeff Waller truthset at gmail.com
Thu Mar 5 02:09:24 PST 2015


On Mar 4, 2015, at 6:41 PM, Richard Smith <richard at metafoo.co.uk> wrote:

> This is wrong:
> 
>                if(type->isRecordType())
>                {
>                   const RecordType *asRecordType = static_cast<const RecordType*>(type);
> 
> Your Type is not necessarily a RecordType here; it might be a typedef for a record type or some other type sugar node. The right way to write this is:
> 
>                if (const RecordType *asRecordType = type->getAs<RecordType>())

Hey great, and thanks, is getAs always the thing to do versus simple casting?

> 
> On Wed, Mar 4, 2015 at 3:15 PM, Jeff Waller <truthset at gmail.com> wrote:
> 
> A cross-post from cfe-users. I think there will be no luck
> on that list.
> =======================
> I’m getting the failure:
> 
> void clang::RecordDecl::LoadFieldsFromExternalStorage() const: Assertion `hasExternalLexicalStorage() && Source && "No external storage?"' failed.
> when trying to iterate over a RecordDecl and not sure even what’s going on let along how to deal with it:
> 
> I’m proceeding from the example in
> http://clang.llvm.org/docs/LibASTMatchersTutorial.html
> 
> Here is some context:
> https://gist.github.com/waTeim/8757662c445ce3b4084f
> 
> Thanks in advance for any help
> 
> 
> _______________________________________________
> 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/20150305/a96b0480/attachment.html>


More information about the cfe-dev mailing list