| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| --- | ||
| Name: AppKit | ||
| Availability: available | ||
| AvailabilityMsg: '' | ||
| Classes: | ||
| - Name: NSCell | ||
| Availability: available | ||
| AvailabilityMsg: '' | ||
| Methods: | ||
| - Selector: init | ||
| MethodKind: Instance | ||
| NullabilityOfRet: U | ||
| Availability: available | ||
| AvailabilityMsg: '' | ||
| DesignatedInit: true | ||
| - Selector: 'initImageCell:' | ||
| MethodKind: Instance | ||
| Nullability: [ N ] | ||
| NullabilityOfRet: U | ||
| Availability: available | ||
| AvailabilityMsg: '' | ||
| DesignatedInit: true | ||
| - Selector: 'initTextCell:' | ||
| MethodKind: Instance | ||
| Nullability: [ N ] | ||
| NullabilityOfRet: U | ||
| Availability: available | ||
| AvailabilityMsg: '' | ||
| DesignatedInit: true | ||
| - Selector: 'initWithCoder:' | ||
| MethodKind: Instance | ||
| Nullability: [ N ] | ||
| NullabilityOfRet: U | ||
| Availability: available | ||
| AvailabilityMsg: '' | ||
| DesignatedInit: true | ||
| Required: true | ||
| - Name: NSView | ||
| AuditedForNullability: true | ||
| Availability: available | ||
| AvailabilityMsg: '' | ||
| Methods: | ||
| - Selector: 'addSubview:' | ||
| MethodKind: Instance | ||
| Nullability: [ N ] | ||
| NullabilityOfRet: N | ||
| Availability: available | ||
| AvailabilityMsg: '' | ||
| - Selector: 'addSubview:positioned:relativeTo:' | ||
| MethodKind: Instance | ||
| Nullability: [ N, N, O ] | ||
| NullabilityOfRet: N | ||
| Availability: available | ||
| AvailabilityMsg: '' | ||
| - Selector: 'beginDraggingSessionWithItems:event:source:' | ||
| MethodKind: Instance | ||
| Nullability: [ U, U, N ] | ||
| NullabilityOfRet: N | ||
| Availability: available | ||
| AvailabilityMsg: '' | ||
| Properties: | ||
| - Name: enclosingScrollView | ||
| Nullability: O | ||
| Availability: available | ||
| AvailabilityMsg: '' | ||
| - Name: makeBackingLayer | ||
| Nullability: N | ||
| Availability: available | ||
| AvailabilityMsg: '' | ||
| Functions: | ||
| - Name: NSAvailableWindowDepths | ||
| NullabilityOfRet: N | ||
| Availability: available | ||
| AvailabilityMsg: '' | ||
| Globals: | ||
| - Name: NSCalibratedWhiteColorSpace | ||
| Nullability: N | ||
| Availability: available | ||
| AvailabilityMsg: '' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| // RUN: %clang_cc1 -fapinotes -fapinotes-cache-path=%t/APINotesCache -fsyntax-only -I %S/Inputs/Headers -F %S/Inputs/Frameworks %s -verify | ||
|
|
||
| #include "HeaderLib.h" | ||
| #import <SomeKit/SomeKit.h> | ||
| #import <SomeKit/SomeKit_Private.h> | ||
|
|
||
| int main() { | ||
| int i; | ||
| i = unavailable_function(); // expected-error{{'unavailable_function' is unavailable: I beg you not to use this}} | ||
| // expected-note@HeaderLib.h:8{{'unavailable_function' has been explicitly marked unavailable here}} | ||
| i = unavailable_global_int; // expected-error{{'unavailable_global_int' is unavailable}} | ||
| // expected-note@HeaderLib.h:9{{'unavailable_global_int' has been explicitly marked unavailable here}} | ||
|
|
||
| B *b = 0; // expected-error{{'B' is unavailable: just don't}} | ||
| // expected-note@SomeKit/SomeKit.h:15{{'B' has been explicitly marked unavailable here}} | ||
|
|
||
| id<InternalProtocol> proto = 0; // expected-error{{'InternalProtocol' is unavailable: not for you}} | ||
| // expected-note@SomeKit/SomeKit_Private.h:12{{'InternalProtocol' has been explicitly marked unavailable here}} | ||
|
|
||
| A *a = 0; | ||
| i = a.intValue; // expected-error{{intValue' is unavailable: wouldn't work anyway}} | ||
| // expected-note@SomeKit/SomeKit.h:12{{'intValue' has been explicitly marked unavailable here}} | ||
|
|
||
| [a transform:a]; // expected-error{{'transform:' is unavailable: anything but this}} | ||
| // expected-note@SomeKit/SomeKit.h:6{{'transform:' has been explicitly marked unavailable here}} | ||
|
|
||
| return 0; | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| // RUN: rm -rf %t/APINotesCache | ||
| // RUN: %clang_cc1 -fapinotes -fapinotes-cache-path=%t/APINotesCache -I %S/Inputs/Headers -F %S/Inputs/Frameworks %s -verify | ||
|
|
||
| // Check for the presence of the cached compiled form. | ||
| // RUN: ls %t/APINotesCache | grep "APINotes-.*.apinotesc" | ||
| // RUN: ls %t/APINotesCache | grep "SomeKit-.*.apinotesc" | ||
|
|
||
| // Run test again to ensure that caching doesn't cause problems. | ||
| // RUN: %clang_cc1 -fapinotes -fapinotes-cache-path=%t/APINotesCache -I %S/Inputs/Headers -F %S/Inputs/Frameworks %s -verify | ||
|
|
||
| // Check that the driver provides a default -fapinotes-cache-path= | ||
| // RUN: %clang -fsyntax-only -fapinotes -I %S/Inputs/Headers -F %S/Inputs/Frameworks %s -### 2>&1 | FileCheck --check-prefix=CHECK-DEFAULT-PATH %s | ||
| // CHECK-DEFAULT-PATH: -fapinotes-cache-path={{.*}}org.llvm.clang/APINotesCache | ||
|
|
||
| // Check that the driver passes through a provided -fapinotes-cache-path= | ||
| // RUN: %clang -fsyntax-only -fapinotes -fapinotes-cache-path=/wobble -I %S/Inputs/Headers -F %S/Inputs/Frameworks %s -### 2>&1 | FileCheck --check-prefix=CHECK-PATH %s | ||
| // CHECK-PATH: -fapinotes-cache-path=/wobble | ||
|
|
||
| #include "HeaderLib.h" | ||
| #import <SomeKit/SomeKit.h> | ||
|
|
||
| int main() { | ||
| int i; | ||
| i = unavailable_function(); // expected-error{{'unavailable_function' is unavailable: I beg you not to use this}} | ||
| // expected-note@HeaderLib.h:8{{'unavailable_function' has been explicitly marked unavailable here}} | ||
|
|
||
| A *a = 0; | ||
| [a transform:a]; // expected-error{{'transform:' is unavailable: anything but this}} | ||
| // expected-note@SomeKit/SomeKit.h:6{{'transform:' has been explicitly marked unavailable here}} | ||
|
|
||
| return 0; | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| // We need 'touch' and 'find' for this test to work. | ||
| // REQUIRES: shell | ||
|
|
||
| // RUN: rm -rf %t/APINotesCache | ||
|
|
||
| // Run Clang. This should generated the cached versions of both and a timestamp. | ||
| // RUN: %clang_cc1 -fapinotes -fapinotes-cache-path=%t/APINotesCache -I %S/Inputs/Headers -F %S/Inputs/Frameworks %s -DINCLUDE_HEADERLIB | ||
| // RUN: ls %t/APINotesCache | grep "APINotes-.*.apinotesc" | ||
| // RUN: ls %t/APINotesCache | grep "SomeKit-.*.apinotesc" | ||
| // RUN: ls %t/APINotesCache | grep "APINotes.timestamp" | ||
|
|
||
| // Set the timestamp back a very long time. We should try to prune, | ||
| // but nothing gets pruned because the API Notes files are new enough. | ||
| // RUN: touch -m -a -t 201101010000 %t/APINotes.timestamp | ||
| // RUN: %clang_cc1 -fapinotes -fapinotes-cache-path=%t/APINotesCache -I %S/Inputs/Headers -F %S/Inputs/Frameworks %s | ||
| // RUN: ls %t/APINotesCache | grep "APINotes-.*.apinotesc" | ||
| // RUN: ls %t/APINotesCache | grep "SomeKit-.*.apinotesc" | ||
| // RUN: ls %t/APINotesCache | grep "APINotes.timestamp" | ||
|
|
||
| // Set the HeaderLib access time back a very long time. | ||
| // This shouldn't prune anything, because the timestamp has been updated, so | ||
| // the pruning mechanism won't fire. | ||
| // RUN: find %t/APINotesCache -name APINotes-*.apinotesc | xargs touch -a -t 201101010000 | ||
| // RUN: %clang_cc1 -fapinotes -fapinotes-cache-path=%t/APINotesCache -I %S/Inputs/Headers -F %S/Inputs/Frameworks %s | ||
| // RUN: ls %t/APINotesCache | grep "APINotes-.*.apinotesc" | ||
| // RUN: ls %t/APINotesCache | grep "SomeKit-.*.apinotesc" | ||
| // RUN: ls %t/APINotesCache | grep "APINotes.timestamp" | ||
|
|
||
| // Set the timestack back a very long time. This should prune the | ||
| // HeaderLib file, because the pruning mechanism should fire and | ||
| // HeaderLib is both old and not used. | ||
| // RUN: touch -m -a -t 201101010000 %t/APINotesCache/APINotes.timestamp | ||
| // RUN: %clang_cc1 -fapinotes -fapinotes-cache-path=%t/APINotesCache -I %S/Inputs/Headers -F %S/Inputs/Frameworks %s | ||
| // RUN: ls %t/APINotesCache | not grep "APINotes-.*.apinotesc" | ||
| // RUN: ls %t/APINotesCache | grep "SomeKit-.*.apinotesc" | ||
| // RUN: ls %t/APINotesCache | grep "APINotes.timestamp" | ||
|
|
||
| // Run Clang. This should generated the cached versions of both and a timestamp. | ||
| // RUN: %clang_cc1 -fapinotes -fapinotes-cache-path=%t/APINotesCache -I %S/Inputs/Headers -F %S/Inputs/Frameworks %s -DINCLUDE_HEADERLIB | ||
| // RUN: ls %t/APINotesCache | grep "APINotes-.*.apinotesc" | ||
| // RUN: ls %t/APINotesCache | grep "SomeKit-.*.apinotesc" | ||
| // RUN: ls %t/APINotesCache | grep "APINotes.timestamp" | ||
|
|
||
| #ifdef INCLUDE_HEADERLIB | ||
| #include "HeaderLib.h" | ||
| #endif | ||
| #include <SomeKit/SomeKit.h> | ||
|
|
||
| int main() { return 0; } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| // RUN: %clang_cc1 -fapinotes -fapinotes-cache-path=%t/APINotesCache -fsyntax-only -I %S/Inputs/Headers -F %S/Inputs/Frameworks %s -verify | ||
|
|
||
| #include "HeaderLib.h" | ||
|
|
||
| int main() { | ||
| custom_realloc(0, 0); // expected-warning{{null passed to a callee that requires a non-null argument}} | ||
| int i = 0; | ||
| do_something_with_pointers(&i, 0); | ||
| do_something_with_pointers(0, &i); // expected-warning{{null passed to a callee that requires a non-null argument}} | ||
|
|
||
| float *fp = global_int; // expected-warning{{incompatible pointer types initializing 'float *' with an expression of type 'int * _Nonnull'}} | ||
| return 0; | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| // RUN: %clang_cc1 -fapinotes -fapinotes-cache-path=%t/APINotesCache -fsyntax-only -I %S/Inputs/Headers -F %S/Inputs/Frameworks %s -verify | ||
|
|
||
| #import <SomeKit/SomeKit.h> | ||
|
|
||
|
|
||
| int main() { | ||
| A *a; | ||
|
|
||
| [a transform: 0 integer: 0]; // expected-warning{{null passed to a callee that requires a non-null argument}} | ||
|
|
||
| return 0; | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| // RUN: %clang_cc1 -fapinotes -fapinotes-cache-path=%t/APINotesCache -fsyntax-only -I %S/Inputs/Headers -F %S/Inputs/Frameworks %s -verify | ||
|
|
||
| #include "HeaderLib.h" | ||
| #import <SomeKit/SomeKit.h> | ||
|
|
||
| @interface CSub : C | ||
| -(instancetype)initWithA:(A*)a; | ||
| @end | ||
|
|
||
| @implementation CSub | ||
| -(instancetype)initWithA:(A*)a { // expected-warning{{designated initializer missing a 'super' call to a designated initializer of the super class}} | ||
| // expected-note@SomeKit/SomeKit.h:20 2{{method marked as designated initializer of the class here}} | ||
| self = [super init]; // expected-warning{{designated initializer invoked a non-designated initializer}} | ||
| return self; | ||
| } | ||
| @end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| // RUN: rm -rf %t | ||
| // RUN: not %clang_cc1 -fsyntax-only -fapinotes -fapinotes-cache-path=%t %s -I %S/Inputs/BrokenHeaders2 2>&1 | FileCheck %s | ||
|
|
||
| #include "SomeBrokenLib.h" | ||
|
|
||
| // CHECK: error: multiple definitions of global function 'do_something_with_pointers' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| # RUN: %clang -cc1apinotes -yaml-to-binary -target i386-apple-ios7 -o %t-ios.apinotesc %S/Inputs/os-availability.apinotes | ||
| # RUN: %clang -cc1apinotes -binary-to-yaml %t-ios.apinotesc -o %t.os-availability-ios.apinotes | ||
| # RUN: FileCheck %s -check-prefix=IOS < %t.os-availability-ios.apinotes | ||
|
|
||
| # RUN: %clang -cc1apinotes -yaml-to-binary -target x86_64-apple-macosx10.9 -o %t-osx.apinotesc %S/Inputs/os-availability.apinotes | ||
| # RUN: %clang -cc1apinotes -binary-to-yaml %t-osx.apinotesc -o %t.os-availability-osx.apinotes | ||
| # RUN: FileCheck %s -check-prefix=OSX < %t.os-availability-osx.apinotes | ||
|
|
||
| # IOS: Foundation | ||
| # IOS: NSArray | ||
| # IOS: initWithObjects | ||
| # IOS: familyNameios | ||
| # IOS: fontName | ||
| # IOS: NSCountedSet | ||
| # IOS: UIApplicationDelegate | ||
| # IOS: UIApplicationDelegateIOS | ||
| # IOS: NSAvailableWindowDepths | ||
| # IOS: NSAvailableWindowDepthsiOS | ||
| # IOS-NOT: NSCalibratedWhiteColorSpace | ||
|
|
||
| # OSX: Foundation | ||
| # qqOSX: NSArray | ||
| # OSX-NOT: initWithObjects | ||
| # OSX-NOT: familyNameios | ||
| # OSX: fontName | ||
| # OSX-NOT: NSCountedSet | ||
| # OSX: UIApplicationDelegate | ||
| # OSX-NOT: UIApplicationDelegateIOS | ||
| # OSX: NSAvailableWindowDepths | ||
| # OSX-NOT: NSAvailableWindowDepthsiOS | ||
| # OSX: NSCalibratedWhiteColorSpace |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| // RUN: rm -rf %t | ||
| // RUN: %clang_cc1 -fsyntax-only -fapinotes -fapinotes-cache-path=%t %s -I %S/Inputs/BrokenHeaders -verify | ||
|
|
||
| #include "SomeBrokenLib.h" | ||
|
|
||
| // expected-error@APINotes.apinotes:4{{unknown key 'Nu llabilityOfRet'}} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| # RUN: not %clang -cc1apinotes -yaml-to-binary -target i386-apple-ios7 -o %t.apinotesc %s > %t.err 2>&1 | ||
| # RUN: FileCheck %s < %t.err | ||
|
|
||
| --- | ||
| Name: UIKit | ||
| Availability: iOS | ||
| AvailabilityMsg: iOSOnly | ||
| Classes: | ||
| - Name: UIFont | ||
| Availability: iOS | ||
| AvailabilityMsg: iOSOnly | ||
| Methods: | ||
| - Selector: 'fontWithName:size:' | ||
| MethodKind: Instance | ||
| Nullability: [ N ] | ||
| NullabilityOfRet: O | ||
| Availability: iOS | ||
| AvailabilityMsg: iOSOnly | ||
| DesignatedInit: true | ||
| # CHECK: duplicate definition of method '-[UIFont fontWithName:size:]' | ||
| - Selector: 'fontWithName:size:' | ||
| MethodKind: Instance | ||
| Nullability: [ N ] | ||
| NullabilityOfRet: O | ||
| Availability: iOS | ||
| AvailabilityMsg: iOSOnly | ||
| DesignatedInit: true | ||
| Properties: | ||
| - Name: familyName | ||
| Nullability: N | ||
| Availability: iOS | ||
| AvailabilityMsg: iOSOnly | ||
| - Name: fontName | ||
| Nullability: N | ||
| Availability: iOS | ||
| AvailabilityMsg: iOSOnly | ||
| # CHECK: duplicate definition of property 'UIFont.familyName' | ||
| - Name: familyName | ||
| Nullability: N | ||
| Availability: iOS | ||
| AvailabilityMsg: iOSOnly | ||
| # CHECK: multiple definitions of class 'UIFont' | ||
| - Name: UIFont | ||
| Protocols: | ||
| - Name: MyProto | ||
| AuditedForNullability: true | ||
| # CHECK: multiple definitions of protocol 'MyProto' | ||
| - Name: MyProto | ||
| AuditedForNullability: true | ||
| Functions: | ||
| - Name: 'globalFoo' | ||
| Nullability: [ N, N, O, S ] | ||
| NullabilityOfRet: O | ||
| Availability: iOS | ||
| AvailabilityMsg: iOSOnly | ||
| - Name: 'globalFoo2' | ||
| Nullability: [ N, N, O, S ] | ||
| NullabilityOfRet: O | ||
| Globals: | ||
| - Name: globalVar | ||
| Nullability: O | ||
| Availability: iOS | ||
| AvailabilityMsg: iOSOnly | ||
| - Name: globalVar2 | ||
| Nullability: O |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| # RUN: %clang -cc1apinotes -dump %s | FileCheck %s | ||
| --- | ||
| Name: UIKit | ||
| Availability: iOS | ||
| AvailabilityMsg: iOSOnly | ||
| Classes: | ||
| - Name: UIFont | ||
| Availability: iOS | ||
| AvailabilityMsg: iOSOnly | ||
| Methods: | ||
| - Selector: 'fontWithName:size:' | ||
| MethodKind: Instance | ||
| Nullability: [ N ] | ||
| NullabilityOfRet: O | ||
| Availability: iOS | ||
| AvailabilityMsg: iOSOnly | ||
| DesignatedInit: true | ||
| Properties: | ||
| - Name: familyName | ||
| Nullability: N | ||
| Availability: iOS | ||
| AvailabilityMsg: iOSOnly | ||
| - Name: fontName | ||
| Nullability: N | ||
| Availability: iOS | ||
| AvailabilityMsg: iOSOnly | ||
| Protocols: | ||
| - Name: MyProto | ||
| AuditedForNullability: true | ||
| - Name: MyProto2 | ||
| AuditedForNullability: true | ||
| Functions: | ||
| - Name: 'globalFoo' | ||
| Nullability: [ N, N, O, S ] | ||
| NullabilityOfRet: O | ||
| Availability: iOS | ||
| AvailabilityMsg: iOSOnly | ||
| - Name: 'globalFoo2' | ||
| Nullability: [ N, N, O, S ] | ||
| NullabilityOfRet: O | ||
| Globals: | ||
| - Name: globalVar | ||
| Nullability: O | ||
| Availability: iOS | ||
| AvailabilityMsg: iOSOnly | ||
| - Name: globalVar2 | ||
| Nullability: O | ||
|
|
||
|
|
||
| # CHECK: Name: UIKit | ||
| # CHECK: Availability: iOS | ||
| # CHECK: AvailabilityMsg: iOSOnly | ||
| # CHECK: Classes: | ||
| # CHECK: - Name: UIFont | ||
| # CHECK: Availability: iOS | ||
| # CHECK: AvailabilityMsg: iOSOnly | ||
| # CHECK: Methods: | ||
| # CHECK: - Selector: 'fontWithName:size:' | ||
| # CHECK: MethodKind: Instance | ||
| # CHECK: Nullability: [ N ] | ||
| # CHECK: NullabilityOfRet: O | ||
| # CHECK: Availability: iOS | ||
| # CHECK: AvailabilityMsg: iOSOnly | ||
| # CHECK: DesignatedInit: true | ||
| # CHECK: Properties: | ||
| # CHECK: - Name: familyName | ||
| # CHECK: Nullability: N | ||
| # CHECK: Availability: iOS | ||
| # CHECK: AvailabilityMsg: iOSOnly | ||
| # CHECK: - Name: fontName | ||
| # CHECK: Nullability: N | ||
| # CHECK: Availability: iOS | ||
| # CHECK: AvailabilityMsg: iOSOnly | ||
| # CHECK:Protocols: | ||
| # CHECK: - Name: MyProto | ||
| # CHECK: AuditedForNullability: true | ||
| # CHECK: Availability: available | ||
| # CHECK: AvailabilityMsg: '' | ||
| # CHECK: - Name: MyProto2 | ||
| # CHECK: AuditedForNullability: true | ||
| # CHECK: Availability: available | ||
| # CHECK: AvailabilityMsg: '' | ||
| # CHECK:Functions: | ||
| # CHECK: - Name: globalFoo | ||
| # CHECK: Nullability: [ N, N, O, U ] | ||
| # CHECK: NullabilityOfRet: O | ||
| # CHECK: Availability: iOS | ||
| # CHECK: AvailabilityMsg: iOSOnly | ||
| # CHECK: - Name: globalFoo2 | ||
| # CHECK: Nullability: [ N, N, O, U ] | ||
| # CHECK: NullabilityOfRet: O | ||
| # CHECK: Availability: available | ||
| # CHECK: AvailabilityMsg: '' | ||
| # CHECK:Globals: | ||
| # CHECK: - Name: globalVar | ||
| # CHECK: Nullability: O | ||
| # CHECK: Availability: iOS | ||
| # CHECK: AvailabilityMsg: iOSOnly | ||
| # CHECK: - Name: globalVar2 | ||
| # CHECK: Nullability: O | ||
| # CHECK: Availability: available | ||
| # CHECK: AvailabilityMsg: |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # RUN: %clang -cc1apinotes -yaml-to-binary -o %t.apinotesc %S/Inputs/roundtrip.apinotes | ||
| # RUN: %clang -cc1apinotes -binary-to-yaml -o %t.apinotes %t.apinotesc | ||
|
|
||
| # Handle the infurating '...' the YAML writer adds but the parser | ||
| # can't read. | ||
|
|
||
| # RUN: cp %S/Inputs/roundtrip.apinotes %t-reference.apinotes | ||
| # RUN: echo "..." >> %t-reference.apinotes | ||
| # RUN: diff %t-reference.apinotes %t.apinotes | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| // RUN: %clang_cc1 %s -fblocks -verify -fsyntax-only | ||
|
|
||
| #if !__has_attribute(noescape) | ||
| # error "missing noescape attribute" | ||
| #endif | ||
|
|
||
| int *global_var __attribute((noescape)); // expected-warning{{'noescape' attribute only applies to parameters}} | ||
|
|
||
| void foo(__attribute__((noescape)) int *int_ptr, | ||
| __attribute__((noescape)) int (^block)(int), | ||
| __attribute((noescape)) int integer) { // expected-warning{{'noescape' attribute ignored on parameter of non-pointer type 'int'}} | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,158 @@ | ||
| // RUN: %clang_cc1 -verify -fsyntax-only -fobjc-arc -fblocks %s | ||
|
|
||
| // --- swift_private --- | ||
|
|
||
| __attribute__((swift_private)) | ||
| @protocol FooProto | ||
| @end | ||
|
|
||
| __attribute__((swift_private)) | ||
| @interface Foo | ||
| @end | ||
|
|
||
| @interface Bar | ||
| @property id prop __attribute__((swift_private)); | ||
| - (void)instMethod __attribute__((swift_private)); | ||
| + (instancetype)bar __attribute__((swift_private)); | ||
| @end | ||
|
|
||
| void function(id) __attribute__((swift_private)); | ||
|
|
||
| struct __attribute__((swift_private)) Point { | ||
| int x; | ||
| int y; | ||
| }; | ||
|
|
||
| enum __attribute__((swift_private)) Colors { | ||
| Red, Green, Blue | ||
| }; | ||
|
|
||
| typedef struct { | ||
| float x, y, z; | ||
| } Point3D __attribute__((swift_private)); | ||
|
|
||
|
|
||
| // --- swift_name --- | ||
|
|
||
| __attribute__((swift_name("SNFooType"))) | ||
| @protocol SNFoo | ||
| @end | ||
|
|
||
| __attribute__((swift_name("SNFooClass"))) | ||
| @interface SNFoo <SNFoo> | ||
| - (instancetype)init __attribute__((swift_name("init()"))); | ||
| - (instancetype)initWithValue:(int)value __attribute__((swift_name("fooWithValue(_:)"))); | ||
|
|
||
| + (void)refresh __attribute__((swift_name("refresh()"))); | ||
|
|
||
| + (instancetype)foo __attribute__((swift_name("foo()"))); | ||
| + (SNFoo *)fooWithValue:(int)value __attribute__((swift_name("foo(value:)"))); | ||
| + (SNFoo *)fooWithValue:(int)value value:(int)value2 __attribute__((swift_name("foo(value:extra:)"))); | ||
| + (SNFoo *)fooWithConvertingValue:(int)value value:(int)value2 __attribute__((swift_name("init(_:extra:)"))); | ||
|
|
||
| + (SNFoo *)fooWithOtherValue:(int)value __attribute__((swift_name("init"))); // expected-error {{parameter of 'swift_name' attribute must be a Swift function name string}} | ||
| + (SNFoo *)fooWithAnotherValue:(int)value __attribute__((swift_name("foo()"))); // expected-warning {{too few parameters in 'swift_name' attribute (expected 1; got 0)}} | ||
| + (SNFoo *)fooWithYetAnotherValue:(int)value __attribute__((swift_name("foo(value:extra:)"))); // expected-warning {{too many parameters in 'swift_name' attribute (expected 1; got 2)}} | ||
|
|
||
| + (SNFoo *)fooAndReturnErrorCode:(int *)errorCode __attribute__((swift_name("foo()"))); // no-warning | ||
| + (SNFoo *)fooWithValue:(int)value andReturnErrorCode:(int *)errorCode __attribute__((swift_name("foo(value:)"))); // no-warning | ||
| + (SNFoo *)fooFromErrorCode:(const int *)errorCode __attribute__((swift_name("foo()"))); // expected-warning {{too few parameters in 'swift_name' attribute (expected 1; got 0)}} | ||
| + (SNFoo *)fooWithValue:(int)value fromErrorCode:(const int *)errorCode __attribute__((swift_name("foo(value:)"))); // expected-warning {{too few parameters in 'swift_name' attribute (expected 2; got 1)}} | ||
| + (SNFoo *)fooWithPointerA:(int *)value andReturnErrorCode:(int *)errorCode __attribute__((swift_name("foo()"))); // no-warning | ||
| + (SNFoo *)fooWithPointerB:(int *)value andReturnErrorCode:(int *)errorCode __attribute__((swift_name("foo(pointer:)"))); // no-warning | ||
| + (SNFoo *)fooWithPointerC:(int *)value andReturnErrorCode:(int *)errorCode __attribute__((swift_name("foo(pointer:errorCode:)"))); // no-warning | ||
| + (SNFoo *)fooWithOtherFoo:(SNFoo *)other __attribute__((swift_name("foo()"))); // expected-warning {{too few parameters in 'swift_name' attribute (expected 1; got 0)}} | ||
|
|
||
| + (instancetype)specialFoo __attribute__((swift_name("init(options:)"))); | ||
| + (instancetype)specialBar __attribute__((swift_name("init(options:extra:)"))); // expected-warning {{too many parameters in 'swift_name' attribute (expected 0; got 2)}} | ||
| + (instancetype)specialBaz __attribute__((swift_name("init(_:)"))); // expected-warning {{too many parameters in 'swift_name' attribute (expected 0; got 1)}} | ||
| + (instancetype)specialGarply __attribute__((swift_name("foo(options:)"))); // expected-warning {{too many parameters in 'swift_name' attribute (expected 0; got 1)}} | ||
|
|
||
| + (instancetype)trailingParen __attribute__((swift_name("foo("))); // expected-error {{parameter of 'swift_name' attribute must be a Swift function name string}} | ||
| + (instancetype)trailingColon:(int)value __attribute__((swift_name("foo(value)"))); // expected-error {{parameter of 'swift_name' attribute must be a Swift function name string}} | ||
| + (instancetype)initialIgnore:(int)value __attribute__((swift_name("_(value:)"))); // expected-error {{parameter of 'swift_name' attribute must be a Swift function name string}} | ||
| + (instancetype)middleOmitted:(int)value __attribute__((swift_name("foo(:)"))); // expected-error {{parameter of 'swift_name' attribute must be a Swift function name string}} | ||
|
|
||
| @property(strong) id someProp __attribute__((swift_name("prop"))); | ||
| @end | ||
|
|
||
| enum __attribute__((swift_name("MoreColors"))) MoreColors { | ||
| Cyan, | ||
| Magenta, | ||
| Yellow __attribute__((swift_name("RoseGold"))), | ||
| Black __attribute__((swift_name("SpaceGrey()"))) // expected-error {{parameter of 'swift_name' attribute must be an ASCII identifier string}} | ||
| }; | ||
|
|
||
| struct __attribute__((swift_name("FooStruct"))) BarStruct { | ||
| int x, y, z __attribute__((swift_name("zed"))); | ||
| }; | ||
|
|
||
| int global_int __attribute__((swift_name("GlobalInt"))); | ||
|
|
||
| void foo1(int i) __attribute__((swift_name("foo"))); // expected-error{{parameter of 'swift_name' attribute must be a Swift function name string}} | ||
| void foo2(int i) __attribute__((swift_name("foo()"))); // expected-warning{{too few parameters in 'swift_name' attribute (expected 1; got 0)}} | ||
| void foo2(int i) __attribute__((swift_name("foo(a:b:)"))); // expected-warning{{too many parameters in 'swift_name' attribute (expected 1; got 2)}} | ||
| void foo3(int i, int j) __attribute__((swift_name("fooWithX(_:y:)"))); // okay | ||
| void foo4(int i, int *error) __attribute__((swift_name("fooWithA(_:)"))); // okay | ||
|
|
||
| typedef int some_int_type __attribute__((swift_name("SomeInt"))); | ||
|
|
||
| // --- swift_error --- | ||
|
|
||
| @class NSError; | ||
|
|
||
| typedef struct __attribute__((objc_bridge(NSError))) __CFError *CFErrorRef; | ||
|
|
||
| @interface Erroneous | ||
| - (_Bool) tom0: (NSError**) err __attribute__((swift_error(none))); | ||
| - (_Bool) tom1: (NSError**) err __attribute__((swift_error(nonnull_error))); | ||
| - (_Bool) tom2: (NSError**) err __attribute__((swift_error(null_result))); // expected-error {{'swift_error' attribute with 'null_result' convention can only be applied to a method returning a pointer}} | ||
| - (_Bool) tom3: (NSError**) err __attribute__((swift_error(nonzero_result))); | ||
| - (_Bool) tom4: (NSError**) err __attribute__((swift_error(zero_result))); | ||
|
|
||
| - (Undeclared) richard0: (NSError**) err __attribute__((swift_error(none))); // expected-error {{expected a type}} | ||
| - (Undeclared) richard1: (NSError**) err __attribute__((swift_error(nonnull_error))); // expected-error {{expected a type}} | ||
| - (Undeclared) richard2: (NSError**) err __attribute__((swift_error(null_result))); // expected-error {{expected a type}} | ||
| // FIXME: the follow-on warnings should really be suppressed, but apparently having an ill-formed return type doesn't mark anything as invalid | ||
| - (Undeclared) richard3: (NSError**) err __attribute__((swift_error(nonzero_result))); // expected-error {{expected a type}} expected-error {{can only be applied}} | ||
| - (Undeclared) richard4: (NSError**) err __attribute__((swift_error(zero_result))); // expected-error {{expected a type}} expected-error {{can only be applied}} | ||
|
|
||
| - (instancetype) harry0: (NSError**) err __attribute__((swift_error(none))); | ||
| - (instancetype) harry1: (NSError**) err __attribute__((swift_error(nonnull_error))); | ||
| - (instancetype) harry2: (NSError**) err __attribute__((swift_error(null_result))); | ||
| - (instancetype) harry3: (NSError**) err __attribute__((swift_error(nonzero_result))); // expected-error {{'swift_error' attribute with 'nonzero_result' convention can only be applied to a method returning an integral type}} | ||
| - (instancetype) harry4: (NSError**) err __attribute__((swift_error(zero_result))); // expected-error {{'swift_error' attribute with 'zero_result' convention can only be applied to a method returning an integral type}} | ||
|
|
||
| - (instancetype) harry0 __attribute__((swift_error(none))); | ||
| - (instancetype) harry1 __attribute__((swift_error(nonnull_error))); // expected-error {{'swift_error' attribute can only be applied to a method with an error parameter}} | ||
| - (instancetype) harry2 __attribute__((swift_error(null_result))); // expected-error {{'swift_error' attribute can only be applied to a method with an error parameter}} | ||
| - (instancetype) harry3 __attribute__((swift_error(nonzero_result))); // expected-error {{'swift_error' attribute can only be applied to a method with an error parameter}} | ||
| - (instancetype) harry4 __attribute__((swift_error(zero_result))); // expected-error {{'swift_error' attribute can only be applied to a method with an error parameter}} | ||
| @end | ||
|
|
||
| extern _Bool tom0(CFErrorRef *) __attribute__((swift_error(none))); | ||
| extern _Bool tom1(CFErrorRef *) __attribute__((swift_error(nonnull_error))); | ||
| extern _Bool tom2(CFErrorRef *) __attribute__((swift_error(null_result))); // expected-error {{'swift_error' attribute with 'null_result' convention can only be applied to a function returning a pointer}} | ||
| extern _Bool tom3(CFErrorRef *) __attribute__((swift_error(nonzero_result))); | ||
| extern _Bool tom4(CFErrorRef *) __attribute__((swift_error(zero_result))); | ||
|
|
||
| extern Undeclared richard0(CFErrorRef *) __attribute__((swift_error(none))); // expected-error {{unknown type name 'Undeclared'}} | ||
| extern Undeclared richard1(CFErrorRef *) __attribute__((swift_error(nonnull_error))); // expected-error {{unknown type name 'Undeclared'}} | ||
| extern Undeclared richard2(CFErrorRef *) __attribute__((swift_error(null_result))); // expected-error {{unknown type name 'Undeclared'}} | ||
| extern Undeclared richard3(CFErrorRef *) __attribute__((swift_error(nonzero_result))); // expected-error {{unknown type name 'Undeclared'}} | ||
| extern Undeclared richard4(CFErrorRef *) __attribute__((swift_error(zero_result))); // expected-error {{unknown type name 'Undeclared'}} | ||
|
|
||
| extern void *harry0(CFErrorRef *) __attribute__((swift_error(none))); | ||
| extern void *harry1(CFErrorRef *) __attribute__((swift_error(nonnull_error))); | ||
| extern void *harry2(CFErrorRef *) __attribute__((swift_error(null_result))); | ||
| extern void *harry3(CFErrorRef *) __attribute__((swift_error(nonzero_result))); // expected-error {{'swift_error' attribute with 'nonzero_result' convention can only be applied to a function returning an integral type}} | ||
| extern void *harry4(CFErrorRef *) __attribute__((swift_error(zero_result))); // expected-error {{'swift_error' attribute with 'zero_result' convention can only be applied to a function returning an integral type}} | ||
|
|
||
| extern void *wilma0(void) __attribute__((swift_error(none))); | ||
| extern void *wilma1(void) __attribute__((swift_error(nonnull_error))); // expected-error {{'swift_error' attribute can only be applied to a function with an error parameter}} | ||
| extern void *wilma2(void) __attribute__((swift_error(null_result))); // expected-error {{'swift_error' attribute can only be applied to a function with an error parameter}} | ||
| extern void *wilma3(void) __attribute__((swift_error(nonzero_result))); // expected-error {{'swift_error' attribute can only be applied to a function with an error parameter}} | ||
| extern void *wilma4(void) __attribute__((swift_error(zero_result))); // expected-error {{'swift_error' attribute can only be applied to a function with an error parameter}} | ||
|
|
||
|
|
||
| extern _Bool suzanne __attribute__((swift_error(none))); // expected-error {{'swift_error' attribute only applies to functions and methods}} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| // RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s | ||
| // RUN: %clang_cc1 -x objective-c++ -fsyntax-only -verify -Wno-objc-root-class %s | ||
| // rdar://16560476 | ||
|
|
||
| __attribute__((objc_subclassing_restricted)) | ||
| @interface Leaf // okay | ||
| @end | ||
|
|
||
| __attribute__((objc_subclassing_restricted)) | ||
| @interface SubClassOfLeaf : Leaf // expected-note {{class is declared here}} | ||
| @end | ||
|
|
||
|
|
||
| @interface SubClass : SubClassOfLeaf // expected-error {{cannot subclass a class with objc_subclassing_restricted attribute}} | ||
| @end | ||
|
|
||
| __attribute__((objc_root_class)) | ||
| @interface PlainRoot | ||
| @end | ||
|
|
||
| __attribute__((objc_subclassing_restricted)) | ||
| @interface Sub2Class : PlainRoot // okay | ||
| @end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,149 @@ | ||
| //===-- api_notes.cpp - API Notes Driver ----------------------------------===// | ||
| // | ||
| // The LLVM Compiler Infrastructure | ||
| // | ||
| // This file is distributed under the University of Illinois Open Source | ||
| // License. See LICENSE.TXT for details. | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
| /// | ||
| /// \file | ||
| /// This file provides conversion between the YAML (source) and binary forms | ||
| /// of API notes. | ||
| /// | ||
| //===----------------------------------------------------------------------===// | ||
| #include "clang/APINotes/APINotesYAMLCompiler.h" | ||
| #include "llvm/Support/CommandLine.h" | ||
| #include "llvm/Support/FileSystem.h" | ||
| #include "llvm/Support/MemoryBuffer.h" | ||
| #include "llvm/Support/raw_ostream.h" | ||
| #include "llvm/Support/PrettyStackTrace.h" | ||
| #include "llvm/Support/Signals.h" | ||
| #include "llvm/ADT/ArrayRef.h" | ||
| #include "llvm/ADT/StringMap.h" | ||
| #include "llvm/ADT/Triple.h" | ||
|
|
||
| using namespace llvm; | ||
| namespace api_notes = clang::api_notes; | ||
|
|
||
| int cc1apinotes_main(ArrayRef<const char *> Argv, const char *Argv0, | ||
| void *MainAddr) { | ||
|
|
||
| // Mark all our options with this category, everything else (except for | ||
| // -version and -help) will be hidden. | ||
| static cl::OptionCategory APINotesCategory("API Notes options"); | ||
|
|
||
| static cl::opt<api_notes::ActionType> | ||
| Action(cl::desc("Mode:"), cl::init(api_notes::ActionType::None), | ||
| cl::values( | ||
| clEnumValN(api_notes::ActionType::YAMLToBinary, | ||
| "yaml-to-binary", | ||
| "Convert YAML to binary format"), | ||
| clEnumValN(api_notes::ActionType::BinaryToYAML, | ||
| "binary-to-yaml", | ||
| "Convert binary format to YAML"), | ||
| clEnumValN(api_notes::ActionType::Dump, | ||
| "dump", | ||
| "Parse and dump the output"), | ||
| clEnumValEnd), | ||
| cl::cat(APINotesCategory)); | ||
|
|
||
| static cl::opt<std::string> | ||
| InputFilename(cl::Positional, cl::desc("<input file>"), | ||
| cl::Required, cl::cat(APINotesCategory)); | ||
|
|
||
| static cl::opt<std::string> | ||
| Target("target", cl::desc("Generate binary format for the given target"), | ||
| cl::cat(APINotesCategory)); | ||
|
|
||
| static cl::opt<std::string> | ||
| OutputFilename("o", cl::desc("Output file name"), cl::cat(APINotesCategory)); | ||
|
|
||
| cl::HideUnrelatedOptions(APINotesCategory); | ||
|
|
||
| SmallVector<const char *, 4> Args; | ||
| Args.push_back(Argv0); | ||
| Args.append(Argv.begin(), Argv.end()); | ||
| cl::ParseCommandLineOptions(Args.size(), | ||
| Args.data(), | ||
| "Clang API Notes Tool\n"); | ||
|
|
||
| if (Action == clang::api_notes::ActionType::None) { | ||
| errs() << "action required\n"; | ||
| cl::PrintHelpMessage(); | ||
| return 1; | ||
| } | ||
|
|
||
| auto fileBufOrErr = MemoryBuffer::getFile(InputFilename); | ||
| if (std::error_code EC = fileBufOrErr.getError()) { | ||
| llvm::errs() << "\n Could not open input file: " + EC.message() << '\n'; | ||
| return true; | ||
| } | ||
| StringRef input = fileBufOrErr.get()->getBuffer(); | ||
|
|
||
| switch (Action) { | ||
| case api_notes::ActionType::None: | ||
| llvm_unreachable("handled above"); | ||
|
|
||
| case api_notes::ActionType::YAMLToBinary: { | ||
| if (OutputFilename.empty()) { | ||
| errs() << "output file is required\n"; | ||
| cl::PrintHelpMessage(); | ||
| return 1; | ||
| } | ||
|
|
||
| api_notes::OSType targetOS = api_notes::OSType::Absent; | ||
| // TODO: Check that we've specified the target. | ||
| if (!Target.empty()) { | ||
| llvm::Triple target(llvm::Triple::normalize(Target)); | ||
| switch (target.getOS()) { | ||
| case llvm::Triple::Darwin: | ||
| case llvm::Triple::MacOSX: | ||
| targetOS = api_notes::OSType::OSX; | ||
| break; | ||
| case llvm::Triple::IOS: | ||
| targetOS = api_notes::OSType::IOS; | ||
| break; | ||
| default: | ||
| errs() << "target is not supported\n"; | ||
| return 1; | ||
| } | ||
| } | ||
| std::error_code EC; | ||
| llvm::raw_fd_ostream os(OutputFilename, EC, | ||
| llvm::sys::fs::OpenFlags::F_None); | ||
|
|
||
| if (api_notes::compileAPINotes(input, os, targetOS)) | ||
| return 1; | ||
|
|
||
| os.flush(); | ||
|
|
||
| return os.has_error(); | ||
| } | ||
|
|
||
| case api_notes::ActionType::BinaryToYAML: { | ||
| if (OutputFilename.empty()) { | ||
| errs() << "output file required\n"; | ||
| cl::PrintHelpMessage(); | ||
| return 1; | ||
| } | ||
|
|
||
| std::error_code EC; | ||
| llvm::raw_fd_ostream os(OutputFilename, EC, | ||
| llvm::sys::fs::OpenFlags::F_None); | ||
|
|
||
| if (api_notes::decompileAPINotes(std::move(fileBufOrErr.get()), os)) | ||
| return 1; | ||
|
|
||
| os.flush(); | ||
|
|
||
| return os.has_error(); | ||
| } | ||
|
|
||
| case api_notes::ActionType::Dump: | ||
| return api_notes::parseAndDumpAPINotes(input); | ||
| } | ||
|
|
||
| return 1; | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,6 +39,7 @@ set(SOURCES | |
|
|
||
| set(LIBS | ||
| clangAST | ||
| clangAPINotes | ||
| clangBasic | ||
| clangFrontend | ||
| clangIndex | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ target_link_libraries(LexTests | |
| clangAST | ||
| clangBasic | ||
| clangLex | ||
| clangAPINotes | ||
| clangParse | ||
| clangSema | ||
| ) | ||