This is an archive of the discontinued LLVM Phabricator instance.

Complex Variable defined in InitCapture Crash fix
Needs ReviewPublic

Authored by bviyer on Jul 31 2018, 6:04 PM.

Details

Summary

When a variable is defined in the init capture and it is of type struct that is dependent on additional structure, its definition is not found. An exception is created in the findInstantiatedDecl () function.

Diff Detail

Repository
rC Clang

Event Timeline

bviyer created this revision.Jul 31 2018, 6:04 PM

Hi Balaji,
Can you try to manually reduce the attached testcase? Its really difficult to understand exactly what is actually happening here, and why your fix is correct, without having a minimal reproducer. Ideally there would just be a few decls that succinctly demonstrate what the problem is.

Thanks!

aprantl added a subscriber: aprantl.Aug 1 2018, 7:29 AM
aprantl added inline comments.
test/SemaCXX/lambda-init-capture-vardefine.cpp
4

These kinds of tests that don't check for any output are a bit dangerous, because they will also succeed if clang is symlinked to /bin/true.

bviyer updated this revision to Diff 158870.Aug 2 2018, 5:25 PM

Simplified the case a bit more as requested by Erik. I also induced some errors in the test so that if someone symbolic-linked clang to /bin/true, the test will fail.

bviyer marked an inline comment as done.Aug 2 2018, 5:25 PM
lib/Sema/SemaTemplateInstantiate.cpp
2916–2918

Why are we failing to find the instantiation of the VarDecl in this case? It seems to me like we should of picked it up in the for loop above. Is it not getting added to the LocalInstantiationScope? Or are we looking in the wrong LocalInstantiationScope?

dexonsmith resigned from this revision.Oct 19 2020, 6:57 PM