[cfe-commits] Fix crash with lambda argument to a template function

Rafael EspĂ­ndola rafael.espindola at gmail.com
Fri Jan 11 12:13:16 PST 2013


Sending this again because I think it got lost in an unrelated thread.

The attached patch fixes a crash in the included testcase. It does so
by not trying to compute the LV at a time where me might still not
know it. The problematic sequence right now is:

* We try to find out if f's LV.
* For that we try to find the LV of the argument type.
* For that we try to find the LV of the lambda.
* For that we try to find the LV of the context (which is g).
* hasBody returns false for g, which causes us to get the wrong answer
because of -fvisibility-inlines-hidden.

A downside is that more decls get added to UndefinedInternals only to
be filtered out at the end of the translation unit.

A possible optimization on top of this patch is to add a
hasCachedLinkage method to NamedDecl. If we already know the linkage,
it is safe to use it.

A completely different option is to set a dummy (pointer cast of 1 for
example) body in g's decl while we construct the real one.

Cheers,
Rafael1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: t.patch
Type: application/octet-stream
Size: 1518 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130111/8fb458a3/attachment.obj>


More information about the cfe-commits mailing list