Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[OBJC] Add attribute to mark Objective C class as non-lazy
A non-lazy class will be initialized eagerly when the Objective-C runtime is loaded. This is required for certain system classes which have instances allocated in non-standard ways, such as the classes for blocks and constant strings. Adding this attribute is essentially equivalent to providing a trivial +load method but avoids the (fairly small) load-time overheads associated with defining and calling such a method. Differential Revision: https://reviews.llvm.org/D56555 llvm-svn: 353116
- Loading branch information
Joe Daniels
committed
Feb 4, 2019
1 parent
3062887
commit f7393d2
Showing
7 changed files
with
68 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// RUN: %clang_cc1 -verify -Wno-objc-root-class -fsyntax-only %s | ||
|
||
__attribute__((objc_nonlazy_class)) | ||
@interface A | ||
@end | ||
@implementation A | ||
@end | ||
|
||
__attribute__((objc_nonlazy_class)) int X; // expected-error {{'objc_nonlazy_class' attribute only applies to Objective-C interfaces}} | ||
|
||
__attribute__((objc_nonlazy_class())) | ||
@interface B | ||
@end | ||
@implementation B | ||
@end | ||
|
||
__attribute__((objc_nonlazy_class("foo"))) // expected-error{{'objc_nonlazy_class' attribute takes no arguments}} | ||
@interface C | ||
@end | ||
@implementation C | ||
@end | ||
|
||
__attribute__((objc_nonlazy_class)) // expected-error {{'objc_nonlazy_class' attribute only applies to Objective-C interfaces}} | ||
@protocol B | ||
@end | ||
|
||
__attribute__((objc_nonlazy_class)) // expected-error {{'objc_nonlazy_class' attribute only applies to Objective-C interfaces}} | ||
void foo(); | ||
|
||
@interface E | ||
@end | ||
__attribute__((objc_nonlazy_class)) | ||
@implementation E // expected-error {{prefix attribute must be followed by an interface or protocol}} | ||
@end |