Patch to fix an invalid AST of a locally redeclared built-in which causes an IRGen crash

Richard Smith richard at metafoo.co.uk
Wed May 21 17:19:13 PDT 2014


On Wed, May 21, 2014 at 4:43 PM, jahanian <fjahanian at apple.com> wrote:

>
> On May 21, 2014, at 4:29 PM, Richard Smith <richard at metafoo.co.uk> wrote:
>
> It's not OK to set a declaration invalid having only produced a warning.
>
>
> Yes.  But this is a unique situation:
>
> Both Old->getBuiltinID() and New-> getBuiltinID() refer to the same
> identifier
> New->getIdentifier()->setBuiltinID(Builtin::NotBuiltin)  (which we must
> do because it is user declared)
> makes “Old” as non-builtin as well. Not invalidating it we end up with a
> declaration of a built-in function
> which has no built-in ID!
>

With the patch, I'd expect that calls to the builtin function that don't
find the local extern decl will (sometimes) be silently discarded. It's far
too dangerous to allow a valid AST to contain invalid decls.

Is there an alternative? As things stand, we don’t keep source fidelity for
> local re-declaration
> of a built-in function  (and IRGen doesn’t like that :).
>

How about this: drop the setInvalidDecl() call. In its place, when we get a
type mismatch between two function declarations, if Old is implicit then
check whether it used to be a builtin. If so, check the type against the
most recent declaration instead.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140521/6436c02e/attachment.html>


More information about the cfe-commits mailing list