This is an archive of the discontinued LLVM Phabricator instance.

[Clang] Fix crash in coverage of if consteval.
ClosedPublic

Authored by cor3ntin on Aug 26 2022, 1:24 AM.

Details

Summary

Clang crashes when encountering an if consteval statement.
This is the minimum fix not to crash.
The fix is consistent with the current behavior of if constexpr,
which does generate coverage data for the discarded branches.
This is of course not correct and a better solution is
needed for both if constexpr and if consteval.
See https://github.com/llvm/llvm-project/issues/54419.

Fixes #57377

Diff Detail

Event Timeline

cor3ntin created this revision.Aug 26 2022, 1:24 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 26 2022, 1:24 AM
cor3ntin requested review of this revision.Aug 26 2022, 1:24 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 26 2022, 1:24 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

@aaron.ballman I did a minimal fix, both because It's unclear to me how coverage work and because I think we should try to land this is 15.
I hope that's okay.

Can you also add a release note?

clang/lib/CodeGen/CoverageMappingGen.cpp
1375

Spurious whitespace change.

1380–1382

Fighting our usual crusade against braces.

1406–1407
  1. Pick a name which doesn't shadow
  2. Spell out the type instead of using auto
cor3ntin updated this revision to Diff 455883.Aug 26 2022, 5:56 AM

Release notes + style issues (There was no shadowing though)

cor3ntin marked an inline comment as done.Aug 26 2022, 5:58 AM
cor3ntin added inline comments.
clang/lib/CodeGen/CoverageMappingGen.cpp
1406–1407

auto Gap... was preexisting, I changed both instances. Both variables are in their own non nested scopes though.

cor3ntin updated this revision to Diff 455917.Aug 26 2022, 8:30 AM

Formatting

aaron.ballman accepted this revision.Aug 26 2022, 8:38 AM

LGTM, thanks for the fix!

clang/lib/CodeGen/CoverageMappingGen.cpp
1406–1407

Yeah, I somehow missed these were in different scopes!

This revision is now accepted and ready to land.Aug 26 2022, 8:38 AM
This revision was landed with ongoing or failed builds.Aug 26 2022, 8:47 AM
This revision was automatically updated to reflect the committed changes.