arphaman added a comment.

I don't think that generating calls to `dispatch_once` and `Gestalt` is the 
right approach. Swift generates a call to `_stdlib_isOSVersionAtLeast`, so 
maybe we could add some function like that into compiler-rt?

`Gestalt` is also deprecated, we should use something better. Swift's 
`_stdlib_isOSVersionAtLeast` calls `_swift_stdlib_operatingSystemVersion` 
(https://github.com/apple/swift/blob/2fe4254cb712fa101a220f95b6ade8f99f43dc74/stdlib/public/core/Availability.swift)
 which in turn either calls `NSProcessInfo.operatingSystemVersion` or loads the 
version from a PLIST file 
(https://github.com/apple/swift/blob/3328592c20ac51a7c525a439af778a75521ab781/stdlib/public/stubs/Availability.mm).
 I don't think we can use Objective-C in compiler-rt though, so we probably 
have to use another solution. Maybe use `sysctlbyname("kern.osrelease", ...)` 
that returns the version of the kernel, which can be remapped into the OS 
version (although that seems hacky)?



================
Comment at: lib/CodeGen/CGExprScalar.cpp:305
+    VersionTuple Version = E->getVersion();
+    Optional<unsigned> Min = Version.getMinor(), SMin = Version.getSubminor();
+
----------------
You can move this line after the `if` below since these `Min` and `SMin` are 
used only after the if.


https://reviews.llvm.org/D27827



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to