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

Richard Smith richard at metafoo.co.uk
Wed Mar 4 15:41:17 PST 2015


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>())

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 inhttp://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/20150304/afd9ad63/attachment.html>


More information about the cfe-dev mailing list