mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
The Clang importer introduces a number of synthesized conformances for
imported enums (normal, NS_ENUMS, or NS_OPTIONS-based all have the
same issue) that aren't used in most translation units. Rather than go
through the effort of fully checking these conformances and generating
SIL for them always, rely on semantic analysis to force them to be
fully checked when the conformance is required. This cuts down on the
amount of work we need to do for imported enumeration types
considerably. For a simple program consisting of only:
import Foundation
var str = NSString()
My not-entirely-scientific measurements show that:
* Time to parse + type-check is reduced by 34%
* Time to generate SIL is reduced by 50%
* Time to generate IR is reduced by 47%
* SIL output size is reduced by 66%
Fixes rdar://problem/20047340.
Swift SVN r27946
15 lines
609 B
Swift
15 lines
609 B
Swift
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-silgen %s | FileCheck %s
|
|
|
|
// REQUIRES: objc_interop
|
|
|
|
import Foundation
|
|
|
|
func foo(a: NSKeyValueObservingOptions) -> Bool {
|
|
return (a ^ a) == nil
|
|
}
|
|
|
|
// Note: nothing needs the BitwiseOperationsType conformance, so don't emit it
|
|
// CHECK-NOT: sil_witness_table shared NSKeyValueObservingOptions: BitwiseOperationsType module Foundation
|
|
// CHECK: sil_witness_table shared NSKeyValueObservingOptions: _RawOptionSetType module Foundation
|
|
// CHECK-NOT: sil_witness_table shared NSKeyValueObservingOptions: BitwiseOperationsType module Foundation
|