diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp --- a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp @@ -628,9 +628,15 @@ // Offset example: // XNU 17 -- macOS 10.13 -- iOS 11 -- tvOS 11 -- watchOS 4 constexpr u16 GetOSMajorKernelOffset() { - if (TARGET_OS_OSX) return 4; - if (TARGET_OS_IOS || TARGET_OS_TV) return 6; - if (TARGET_OS_WATCH) return 13; +# if TARGET_OS_OSX + return 4; +# endif +# if TARGET_OS_IOS || TARGET_OS_TV + return 6; +# endif +# if TARGET_OS_WATCH + return 13; +# endif } using VersStr = char[64]; @@ -642,13 +648,13 @@ u16 os_major = kernel_major - offset; const char *format = "%d.0"; - if (TARGET_OS_OSX) { - if (os_major >= 16) { // macOS 11+ - os_major -= 5; - } else { // macOS 10.15 and below - format = "10.%d"; - } +# if TARGET_OS_OSX + if (os_major >= 16) { // macOS 11+ + os_major -= 5; + } else { // macOS 10.15 and below + format = "10.%d"; } +# endif return internal_snprintf(vers, sizeof(VersStr), format, os_major); } @@ -696,15 +702,14 @@ // Aligned versions example: // macOS 10.15 -- iOS 13 -- tvOS 13 -- watchOS 6 static void MapToMacos(u16 *major, u16 *minor) { - if (TARGET_OS_OSX) - return; - - if (TARGET_OS_IOS || TARGET_OS_TV) - *major += 2; - else if (TARGET_OS_WATCH) - *major += 9; - else - UNREACHABLE("unsupported platform"); +# if !TARGET_OS_OSX +# if TARGET_OS_IOS || TARGET_OS_TV + *major += 2; +# elif TARGET_OS_WATCH + *major += 9; +# else + UNREACHABLE("unsupported platform"); +# endif if (*major >= 16) { // macOS 11+ *major -= 5; @@ -712,6 +717,7 @@ *minor = *major; *major = 10; } +# endif } static MacosVersion GetMacosAlignedVersionInternal() {