This is an archive of the discontinued LLVM Phabricator instance.

[clang] Fix ICE on invalid type parameters for concepts
ClosedPublic

Authored by mizvekov on Mar 5 2021, 6:12 PM.

Details

Summary

See PR48593.

Constraints with invalid type parameters were causing a null pointer
dereference.

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>

Diff Detail

Event Timeline

mizvekov requested review of this revision.Mar 5 2021, 6:12 PM
mizvekov created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptMar 5 2021, 6:12 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
mizvekov updated this revision to Diff 328919.Mar 7 2021, 6:54 PM

Repush, no changes.

rsmith added inline comments.Mar 8 2021, 1:03 PM
clang/lib/Sema/SemaType.cpp
1644–1661

Minor style nits: reduce scope of TemplateId variable and consistently brace the else if and only if the if is braced.

5947–5949

Given that we recover from an invalid TemplateId by creating an unconstrained AutoType, it would be more consistent to skip filling in the NestedNameSpecifierLoc here in that case too. (That way, we would populate the NestedNameSpecifierLoc if and only if we created a constrained AutoType.) I think it doesn't matter right now because no-one should look at this information for an unconstrained AutoType, but I could imagine we would switch to storing smaller TypeLoc data in the future if the type is unconstrained, and if we did, the writes to the NestedNameSpecifierLoc below would break.

mizvekov added inline comments.Mar 8 2021, 1:56 PM
clang/lib/Sema/SemaType.cpp
5947–5949

Good catch, thanks!

mizvekov updated this revision to Diff 329149.Mar 8 2021, 2:55 PM

Addressed rsmith's concerns.
Fixed test type name to avoid picking up suggestions from other tests.

rsmith accepted this revision.Mar 12 2021, 1:50 PM
This revision is now accepted and ready to land.Mar 12 2021, 1:50 PM
This revision was automatically updated to reflect the committed changes.