This is an archive of the discontinued LLVM Phabricator instance.

[clang] Fix a nullptr dereference bug on invalid code
ClosedPublic

Authored by adamcz on Jan 21 2021, 9:05 AM.

Details

Summary

When working with invalid code, we would try to dereference a nullptr
while deducing template arguments in some dependend code operating on a
lambda with invalid return type.

Diff Detail

Event Timeline

adamcz requested review of this revision.Jan 21 2021, 9:05 AM
adamcz created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptJan 21 2021, 9:05 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
hokein added inline comments.Jan 21 2021, 12:06 PM
clang/test/SemaCXX/subst-func-type-invalid-ret-type.cpp
3

A common practice is to avoid depending on STL in tests. I think we need to pull out (even simplify?) std::result_of implementation if it is needed for reproducing the crash.

adamcz added inline comments.Jan 22 2021, 6:13 AM
clang/test/SemaCXX/subst-func-type-invalid-ret-type.cpp
3

I've noticed that pattern, but can't tell why this is. Is it documented somewhere?

adamcz updated this revision to Diff 318534.Jan 22 2021, 8:35 AM

addressed review comments

PTAL

clang/test/SemaCXX/subst-func-type-invalid-ret-type.cpp
3

Anyway, I updated the change to not require type_traits. Turned out to be simpler than expected ;-)

hokein accepted this revision.Jan 25 2021, 5:55 AM

Thanks.

clang/test/SemaCXX/subst-func-type-invalid-ret-type.cpp
3

I've noticed that pattern, but can't tell why this is. Is it documented somewhere?

I did try to find some documentation about this before making the previous comment, but didn't find any.

Depending on the clang builtin includes is legitimate, but depending on the stand library is more complicated, it would hurt hermeticity of the test -- you may not always get the exact behavior you intend to test (as it may depend on the stand library versions, host environment etc).

This revision is now accepted and ready to land.Jan 25 2021, 5:55 AM
This revision was automatically updated to reflect the committed changes.