This is an archive of the discontinued LLVM Phabricator instance.

Fix crash-on-invalid bug in template instantiation.
ClosedPublic

Authored by klimek on Jun 22 2015, 5:17 PM.

Details

Reviewers
klimek
rsmith
Summary

When a template is instantiated after a fatal error has occurred,
template instantiation is aborted. In that case, we need to mark the
instantiated decl as invalid, otherwise we try to access it later.

Diff Detail

Event Timeline

klimek updated this revision to Diff 28179.Jun 22 2015, 5:17 PM
klimek retitled this revision from to Fix crash-on-invalid bug in template instantiation..
klimek updated this object.
klimek edited the test plan for this revision. (Show Details)
klimek added a reviewer: rsmith.
klimek added a subscriber: Unknown Object (MLST).
rsmith added inline comments.Jun 25 2015, 1:13 PM
lib/Sema/SemaTemplateInstantiate.cpp
1930–1939

Is it sufficient to move this block of code to after the bail-out below? It seems like the problem may be that we've done some amount of the instantiation work (storing the TSK on the specialization) before we bail out, and so the AST is left in an inconsistent state.

This fix LGTM, but I do wonder about one thing. The following pattern seems to occur all over Sema:

InstantiatingTemplate Inst(*this, PointOfInstantiation, Decl);
  if (Inst.isInvalid())
    ...

For example, in Sema::InstantiateEnum. Why aren't we marking decls invalid in those other places?

rsmith added inline comments.Jun 25 2015, 2:02 PM
lib/Sema/SemaTemplateInstantiate.cpp
2273–2297

Better solution: just delete all of this code.

That works! \o/

klimek accepted this revision.Jun 25 2015, 7:15 PM
klimek added a reviewer: klimek.
This revision is now accepted and ready to land.Jun 25 2015, 7:15 PM
klimek closed this revision.Jun 25 2015, 7:16 PM

Submitted the deletion as r240752.