This is an archive of the discontinued LLVM Phabricator instance.

[libclang] Avoid crashing when getting layout info of an undeduced type.
ClosedPublic

Authored by emilio on Feb 22 2019, 7:17 PM.

Diff Detail

Repository
rC Clang

Event Timeline

emilio created this revision.Feb 22 2019, 7:17 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 22 2019, 7:17 PM
Anastasia added inline comments.Feb 25 2019, 3:33 AM
clang/tools/c-index-test/c-index-test.c
1695 ↗(On Diff #188024)

Should it not return undeduced error in the other case?

emilio marked 2 inline comments as done.Feb 25 2019, 7:56 AM
emilio added inline comments.
clang/tools/c-index-test/c-index-test.c
1695 ↗(On Diff #188024)

I'm not sure what you mean, can you clarify?

The undeduced error is only returned when you try to access the Auto type which is the return value, not the function type, which has a known layout.

So in the error case, T here is the auto Tie(void*) const; type, and RT is the undeduced auto type, which is what crashed.

We had no way to exercise this in c-index-test, so I changed it to exercise this codepath too. I can add a CHECK for the error code if you want.

Anastasia added inline comments.Feb 25 2019, 9:58 AM
clang/tools/c-index-test/c-index-test.c
1695 ↗(On Diff #188024)

Yep, error check would be good since it's covers better changes in your patch.

emilio updated this revision to Diff 188254.Feb 25 2019, 1:41 PM
emilio marked an inline comment as done.

Add CHECK tests.

emilio marked 2 inline comments as done.Feb 25 2019, 9:54 PM

Huh, somehow forgot to press "Submit" this morning :)

clang/tools/c-index-test/c-index-test.c
1695 ↗(On Diff #188024)

Alrighty, done!

Anastasia accepted this revision.Feb 26 2019, 3:57 AM

LGTM! Thanks!

This revision is now accepted and ready to land.Feb 26 2019, 3:57 AM
This revision was automatically updated to reflect the committed changes.
emilio marked an inline comment as done.

Thank you for all the reviews! :)