mirror of
https://github.com/Gericom/teak-llvm.git
synced 2025-06-26 06:48:51 -04:00

in non-void functions that fall off at the end without returning a value when compiling C++. Clang uses the new compiler flag to determine when it should treat control flow paths that fall off the end of a non-void function as unreachable. If -fno-strict-return is on, the code generator emits the ureachable and trap IR only when the function returns either a record type with a non-trivial destructor or another non-trivially copyable type. The primary goal of this flag is to avoid treating falling off the end of a non-void function as undefined behaviour. The burden of undefined behaviour is placed on the caller instead: if the caller ignores the returned value then the undefined behaviour is avoided. This kind of behaviour is useful in several cases, e.g. when compiling C code in C++ mode. rdar://13102603 Differential Revision: https://reviews.llvm.org/D27163 llvm-svn: 290960
30 lines
550 B
Plaintext
30 lines
550 B
Plaintext
// RUN: %clang_cc1 -emit-llvm -fblocks -triple x86_64-apple-darwin -fstrict-return -o - %s | FileCheck %s
|
|
// RUN: %clang_cc1 -emit-llvm -fblocks -triple x86_64-apple-darwin -fstrict-return -O -o - %s | FileCheck %s
|
|
|
|
@interface I
|
|
@end
|
|
|
|
@implementation I
|
|
|
|
- (int)method {
|
|
}
|
|
|
|
@end
|
|
|
|
enum Enum {
|
|
a
|
|
};
|
|
|
|
int (^block)(Enum) = ^int(Enum e) {
|
|
switch (e) {
|
|
case a:
|
|
return 1;
|
|
}
|
|
};
|
|
|
|
// Ensure that both methods and blocks don't use the -fstrict-return undefined
|
|
// behaviour optimization.
|
|
|
|
// CHECK-NOT: call void @llvm.trap
|
|
// CHECK-NOT: unreachable
|