This is an archive of the discontinued LLVM Phabricator instance.

Fix false positive with unreachable C++ catch handlers
ClosedPublic

Authored by aaron.ballman on Mar 6 2023, 11:20 AM.

Details

Summary

This addresses an issue found by WG21 and tracked by CWG2699 (which is not yet publicly published). The basic problem is that Clang issues a diagnostic about not being able to reach a handler, but that handler *is* reached at runtime. Clang's diagnostic behavior was matching the standard wording, and our runtime behavior was matching the standard's intent.

This fixes the diagnostic so that it matches the runtime behavior more closely, and reduces the number of false positives. This is the direction of choice taken by Core for CWG2699 and it seems unlikely that WG21 will change direction here.

Fixes #61177

Diff Detail

Event Timeline

aaron.ballman created this revision.Mar 6 2023, 11:20 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 6 2023, 11:20 AM
aaron.ballman requested review of this revision.Mar 6 2023, 11:20 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 6 2023, 11:20 AM
erichkeane added inline comments.Mar 6 2023, 11:25 AM
clang/docs/ReleaseNotes.rst
199

This link seems broken? I get 404 from it.

clang/lib/Sema/SemaStmt.cpp
4354

Do we do this because we don't want the pointee unqualified later? Else these seem identical to me.

aaron.ballman marked 2 inline comments as done.Mar 6 2023, 11:32 AM
aaron.ballman added inline comments.
clang/docs/ReleaseNotes.rst
199

Correct: (which is not yet publicly published) from the summary. That link will become valid whenever CWG issues the next update of the public issues list.

clang/lib/Sema/SemaStmt.cpp
4354

We want to strip the top-level qualifiers, and the previous code was stripping qualifiers off the pointee, not the pointer.

aaron.ballman marked 2 inline comments as done.Mar 14 2023, 7:30 AM

Ping

erichkeane accepted this revision.Mar 14 2023, 7:41 AM
This revision is now accepted and ready to land.Mar 14 2023, 7:41 AM
This revision was landed with ongoing or failed builds.Mar 14 2023, 8:08 AM
This revision was automatically updated to reflect the committed changes.

Apologies for late review.

clang/lib/Sema/SemaStmt.cpp
4405

Can we just make llvm::DenseMap<QualType, CXXCatchStmt *> a typedef so we don't have the verbose type in the function parameter right below and further down.