File tree Expand file tree Collapse file tree 3 files changed +27
-5
lines changed Expand file tree Collapse file tree 3 files changed +27
-5
lines changed Original file line number Diff line number Diff line change @@ -141,7 +141,10 @@ bool isStandardPointerConvertible(QualType From, QualType To) {
141
141
if (RD->isCompleteDefinition () &&
142
142
isBaseOf (From->getPointeeType ().getTypePtr (),
143
143
To->getPointeeType ().getTypePtr ())) {
144
- return true ;
144
+ // If B is an inaccessible or ambiguous base class of D, a program
145
+ // that necessitates this conversion is ill-formed
146
+ return isUnambiguousPublicBaseClass (From->getPointeeType ().getTypePtr (),
147
+ To->getPointeeType ().getTypePtr ());
145
148
}
146
149
}
147
150
@@ -375,10 +378,7 @@ bool ExceptionAnalyzer::ExceptionInfo::filterByCatch(
375
378
isPointerOrPointerToMember (ExceptionCanTy->getTypePtr ())) {
376
379
// A standard pointer conversion not involving conversions to pointers to
377
380
// private or protected or ambiguous classes ...
378
- if (isStandardPointerConvertible (ExceptionCanTy, HandlerCanTy) &&
379
- isUnambiguousPublicBaseClass (
380
- ExceptionCanTy->getTypePtr ()->getPointeeType ().getTypePtr (),
381
- HandlerCanTy->getTypePtr ()->getPointeeType ().getTypePtr ())) {
381
+ if (isStandardPointerConvertible (ExceptionCanTy, HandlerCanTy)) {
382
382
TypesToDelete.push_back (ExceptionTy);
383
383
}
384
384
// A function pointer conversion ...
Original file line number Diff line number Diff line change @@ -245,6 +245,10 @@ Changes in existing checks
245
245
where source is already a ``void` `` pointer, making middle ``void `` pointer
246
246
casts bug-free.
247
247
248
+ - Improved :doc: `exception-escape <clang-tidy/checks/bugprone/exception-escape >`
249
+ check to correctly detect exception handler of type ``CV void * `` as catching all
250
+ ``CV `` compatible pointer types.
251
+
248
252
- Improved :doc: `bugprone-forwarding-reference-overload
249
253
<clang-tidy/checks/bugprone/forwarding-reference-overload>`
250
254
check to ignore deleted constructors which won't hide other overloads.
Original file line number Diff line number Diff line change @@ -756,3 +756,21 @@ struct test_implicit_throw {
756
756
};
757
757
758
758
}}
759
+
760
+ void pointer_exception_can_not_escape_with_const_void_handler () noexcept {
761
+ // CHECK-MESSAGES-NOT: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'pointer_exception_can_not_escape_with_const_void_handler' which should not throw exceptions
762
+ const int value = 42 ;
763
+ try {
764
+ throw &value;
765
+ } catch (const void *) {
766
+ }
767
+ }
768
+
769
+ void pointer_exception_can_not_escape_with_void_handler () noexcept {
770
+ // CHECK-MESSAGES-NOT: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'pointer_exception_can_not_escape_with_void_handler' which should not throw exceptions
771
+ int value = 42 ;
772
+ try {
773
+ throw &value;
774
+ } catch (void *) {
775
+ }
776
+ }
You can’t perform that action at this time.
0 commit comments