Files
clang-p2996/clang/test/CodeGenObjC/ubsan-nullability-return-unreachable.m
Vedant Kumar 65f0785fff [ubsan] Omit return value check when return block is unreachable
If the return block is unreachable, clang removes it in
CodeGenFunction::FinishFunction(). This removal can leave dangling
references to values defined in the return block if the return block has
successors, which it /would/ if UBSan's return value check is emitted.

In this case, as the UBSan check wouldn't be reachable, it's better to
simply not emit it.

rdar://59196131
2020-02-06 10:24:03 -08:00

15 lines
471 B
Objective-C

// RUN: %clang_cc1 -fsanitize=nullability-return -emit-llvm %s -o - -triple x86_64-apple-macosx10.10.0 -Wno-objc-root-class | FileCheck %s
// CHECK-LABEL: define internal i8* @"\01-[I init]"
// CHECK: unreachable
// CHECK-NEXT: }
#pragma clang assume_nonnull begin
@interface I
- (instancetype)init __attribute__((unavailable));
@end
@implementation I
- (instancetype)init __attribute__((unavailable)) { __builtin_unreachable(); }
@end
#pragma clang assume_nonnull end