This is an archive of the discontinued LLVM Phabricator instance.

[Sema] Fix crash in unused-lambda-capture warning for VLAs
ClosedPublic

Authored by malcolm.parsons on Dec 8 2017, 8:55 AM.

Details

Summary

Clang was crashing when diagnosing an unused-lambda-capture for a VLA because
From.getVariable() is null for the capture of a VLA bound.
Warning about the VLA bound capture is not helpful, so only warn for the VLA
itself.

Fixes: PR35555

Diff Detail

Event Timeline

malcolm.parsons created this revision.Dec 8 2017, 8:55 AM
dim accepted this revision.Dec 8 2017, 11:25 AM

For the rest, LGTM. It fixes the segfault, for both the full original test case, and my reduced version.

lib/Sema/SemaLambda.cpp
1491

Just for sanity's sake, I would still put an assert here, that getVariable() does not return nullptr. That might catch similar issues in the future. (And it is better than a segfault... :) )

This revision is now accepted and ready to land.Dec 8 2017, 11:25 AM
malcolm.parsons marked an inline comment as done.

Add assert.

lib/Sema/SemaLambda.cpp
1491

I'm adding an assert to getVariable() instead.

This revision was automatically updated to reflect the committed changes.