This is an archive of the discontinued LLVM Phabricator instance.

[clang] Do not crash on "requires" after a fatal error occurred.
ClosedPublic

Authored by adamcz on Jul 11 2022, 9:22 AM.

Details

Summary

The code would assume that SubstExpr() cannot fail on concept
specialization. This is incorret - we give up on some things after fatal
error occurred, since there's no value in doing futher work that the
user will not see anyway. In this case, this lead to crash.

The fatal error is simulated in tests with -ferror-limit=1, but this
could happen in other cases too.

Fixes https://github.com/llvm/llvm-project/issues/55401

Diff Detail

Event Timeline

adamcz created this revision.Jul 11 2022, 9:22 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 11 2022, 9:22 AM
adamcz requested review of this revision.Jul 11 2022, 9:22 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 11 2022, 9:22 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Thanks! The fix LG, just a small nitpick for the test from my side

clang/test/SemaCXX/concept-fatal-error.cpp
8

We need want to pass -verify to clang for these directives to have an effect.
The fatal error can be matched by // expected-error@* {{too...}} (maybe that's obvious, but it took me some time to figure it out first time I needed it)
And there is no need to run FileCheck after that!

This patch makes sense to me, but please clean up the test as @ilya-biryukov suggested.

adamcz updated this revision to Diff 444315.Jul 13 2022, 9:44 AM

improved the test

clang/test/SemaCXX/concept-fatal-error.cpp
8

Ah, thanks! I knew there was a way to match fatal errors, I just didn't know what it was.

No clue what happened to -verify, I swear it was there at some point ;-)

This revision is now accepted and ready to land.Jul 13 2022, 10:02 AM