Page MenuHomePhabricator

[Frontend] Handle skipped bodies in template instantiations

Authored by ilya-biryukov on Dec 14 2017, 6:56 AM.


  • Fixed an assert in Sema::InstantiateFunctionDefinition and added support for instantiating a function template with skipped body.
  • Properly call setHasSkippedBody for FunctionTemplateDecl passed to Sema::ActOnSkippedFunctionBody.

Diff Detail


Event Timeline

ilya-biryukov created this revision.Dec 14 2017, 6:56 AM
sepavloff added inline comments.Dec 18 2017, 11:07 PM
12184 ↗(On Diff #126947)

In the case of Decl == nullptr this code would crash. Probably it makes sense to check for this condition at the beginning of the function and use dyn_cast instead of dyn_cast_or_null in the next check.

ilya-biryukov added inline comments.Dec 19 2017, 1:44 AM
12184 ↗(On Diff #126947)

Do we have callsites that pass null to this function? I don't see a meaningful semantics for this function if we pass null here.
I thought that Decls are always passed via pointers by convention, but I may be wrong.

ilya-biryukov marked an inline comment as done.
  • Added a check for null in ActOnSkippedBody
12184 ↗(On Diff #126947)

After looking at the callsites, they actually suggest that nulls can be passed. Tried adding an assert and it didn't fire when running check-all, though.

But it's better to be on the safe side. Added a check for null, updated the patch accordingly.

sepavloff accepted this revision.Dec 20 2017, 3:01 AM



This revision is now accepted and ready to land.Dec 20 2017, 3:01 AM
This revision was automatically updated to reflect the committed changes.