Skip to content

Another merge of the upstream 8.x branch #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 36 commits into from
Feb 25, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
be8c9e3
Merging r352707, r352714, r352886, r352892, r352895, r352908, r352917…
zmodem Feb 13, 2019
6e3c4d5
Revert r350404
zmodem Feb 13, 2019
c957a99
Merging r353976:
zmodem Feb 14, 2019
1152134
Merging r353968:
zmodem Feb 14, 2019
ff29092
Merging r354074:
zmodem Feb 15, 2019
8015928
Merging r353943:
zmodem Feb 15, 2019
a7da36b
Merging r354035:
zmodem Feb 18, 2019
07a7439
Merging r354147:
zmodem Feb 18, 2019
25c79d9
Merging r354128 and r354131:
zmodem Feb 18, 2019
783fd93
Merging r354144:
zmodem Feb 18, 2019
46fbca3
Merging r353642:
zmodem Feb 18, 2019
096ef4c
Merging r354029:
zmodem Feb 18, 2019
81bd9db
Merging r354122:
zmodem Feb 18, 2019
6051407
Merging r353907:
zmodem Feb 18, 2019
cc3d3f1
Merging r354034 and r354117:
zmodem Feb 18, 2019
e3d91da
[ReleaseNotes] Add note about removal of Nios2 backend. Add some note…
topperc Feb 18, 2019
79a42b6
docs: Remove in-progress warning
zmodem Feb 19, 2019
81717ef
remove another in-progress note
zmodem Feb 19, 2019
6a57428
ReleaseNotes: remove in-progress warning, and minor tweaks
zmodem Feb 19, 2019
363f1d0
ReleaseNotes: remove in-progress warning and doxygen link
zmodem Feb 19, 2019
b1c5e90
ReleaseNotes: remove in-progress warning
zmodem Feb 19, 2019
fbaa8ef
ReleaseNotes: remove in-progress warning
zmodem Feb 19, 2019
5decb13
Merging r354422:
zmodem Feb 20, 2019
d6e87c2
ReleaseNotes: initial ppc support in llvm-exegesis
zmodem Feb 20, 2019
6977a57
ReleaseNotes: mention the new rotation builtins, text by Sanjay
zmodem Feb 20, 2019
e4bde92
ReleaseNotes: AArch64 tiny code model
zmodem Feb 20, 2019
b936e1c
ReleaseNotes: all PowerPC changes
zmodem Feb 20, 2019
83dcd05
Merging r354351:
zmodem Feb 20, 2019
cd76cba
Merging r354402:
zmodem Feb 20, 2019
0157e01
ReleaseNotes: profile-driven cache prefetching. Text by Mircea!
zmodem Feb 21, 2019
96ddd7d
Merging r354497:
zmodem Feb 21, 2019
9d332ff
ReleaseNotes: speculative load hardening; text by Kristof
zmodem Feb 21, 2019
5a681e4
ReleaseNotes: speculative load hardening; text by Kristof
zmodem Feb 21, 2019
6f2b277
Release notes: a few lldb changes, by Raphael Isemann!
zmodem Feb 22, 2019
b821974
ReleaseNotes: -ftrivial-auto-var-init
zmodem Feb 22, 2019
2400dc6
Merge remote-tracking branch 'llvm/release/8.x' into rustc/8.0-2019-0…
alexcrichton Feb 25, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merging r353976:
------------------------------------------------------------------------
r353976 | epilk | 2019-02-13 21:32:37 +0100 (Wed, 13 Feb 2019) | 11 lines

[Sema] Delay checking whether objc_designated_initializer is being applied to an init method

This fixes a regression that was caused by r335084, which reversed
the order that attributes are applied. objc_method_family can change
whether a method is an init method, so the order that these
attributes are applied matters. The commit fixes this by delaying the
init check until after all attributes have been applied.

rdar://47829358

Differential revision: https://reviews.llvm.org/D58152
------------------------------------------------------------------------

llvm-svn: 354015
  • Loading branch information
zmodem committed Feb 14, 2019
commit c957a992959b7c1e5a613d8a953df8a029f922c0
9 changes: 1 addition & 8 deletions clang/include/clang/Basic/Attr.td
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,6 @@ def ObjCInstanceMethod : SubsetSubject<ObjCMethod,
[{S->isInstanceMethod()}],
"Objective-C instance methods">;

def ObjCInterfaceDeclInitMethod : SubsetSubject<ObjCMethod,
[{S->getMethodFamily() == OMF_init &&
(isa<ObjCInterfaceDecl>(S->getDeclContext()) ||
(isa<ObjCCategoryDecl>(S->getDeclContext()) &&
cast<ObjCCategoryDecl>(S->getDeclContext())->IsClassExtension()))}],
"init methods of interface or class extension declarations">;

def Struct : SubsetSubject<Record,
[{!S->isUnion()}], "structs">;

Expand Down Expand Up @@ -1762,7 +1755,7 @@ def ObjCExplicitProtocolImpl : InheritableAttr {

def ObjCDesignatedInitializer : Attr {
let Spellings = [Clang<"objc_designated_initializer">];
let Subjects = SubjectList<[ObjCInterfaceDeclInitMethod], ErrorDiag>;
let Subjects = SubjectList<[ObjCMethod], ErrorDiag>;
let Documentation = [Undocumented];
}

Expand Down
3 changes: 3 additions & 0 deletions clang/include/clang/Basic/DiagnosticSemaKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -3460,6 +3460,9 @@ def warn_objc_secondary_init_missing_init_call : Warning<
def warn_objc_implementation_missing_designated_init_override : Warning<
"method override for the designated initializer of the superclass %objcinstance0 not found">,
InGroup<ObjCDesignatedInit>;
def err_designated_init_attr_non_init : Error<
"'objc_designated_initializer' attribute only applies to init methods "
"of interface or class extension declarations">;

// objc_bridge attribute diagnostics.
def err_objc_attr_not_id : Error<
Expand Down
26 changes: 24 additions & 2 deletions clang/lib/Sema/SemaDeclAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5116,11 +5116,22 @@ static void handleObjCBridgeRelatedAttr(Sema &S, Decl *D,

static void handleObjCDesignatedInitializer(Sema &S, Decl *D,
const ParsedAttr &AL) {
DeclContext *Ctx = D->getDeclContext();

// This attribute can only be applied to methods in interfaces or class
// extensions.
if (!isa<ObjCInterfaceDecl>(Ctx) &&
!(isa<ObjCCategoryDecl>(Ctx) &&
cast<ObjCCategoryDecl>(Ctx)->IsClassExtension())) {
S.Diag(D->getLocation(), diag::err_designated_init_attr_non_init);
return;
}

ObjCInterfaceDecl *IFace;
if (auto *CatDecl = dyn_cast<ObjCCategoryDecl>(D->getDeclContext()))
if (auto *CatDecl = dyn_cast<ObjCCategoryDecl>(Ctx))
IFace = CatDecl->getClassInterface();
else
IFace = cast<ObjCInterfaceDecl>(D->getDeclContext());
IFace = cast<ObjCInterfaceDecl>(Ctx);

if (!IFace)
return;
Expand Down Expand Up @@ -7067,6 +7078,17 @@ void Sema::ProcessDeclAttributeList(Scope *S, Decl *D,
}
}
}

// Do this check after processing D's attributes because the attribute
// objc_method_family can change whether the given method is in the init
// family, and it can be applied after objc_designated_initializer. This is a
// bit of a hack, but we need it to be compatible with versions of clang that
// processed the attribute list in the wrong order.
if (D->hasAttr<ObjCDesignatedInitializerAttr>() &&
cast<ObjCMethodDecl>(D)->getMethodFamily() != OMF_init) {
Diag(D->getLocation(), diag::err_designated_init_attr_non_init);
D->dropAttr<ObjCDesignatedInitializerAttr>();
}
}

// Helper for delayed processing TransparentUnion attribute.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
// CHECK-NEXT: ObjCBridge (SubjectMatchRule_record, SubjectMatchRule_type_alias)
// CHECK-NEXT: ObjCBridgeMutable (SubjectMatchRule_record)
// CHECK-NEXT: ObjCBridgeRelated (SubjectMatchRule_record)
// CHECK-NEXT: ObjCDesignatedInitializer (SubjectMatchRule_objc_method)
// CHECK-NEXT: ObjCException (SubjectMatchRule_objc_interface)
// CHECK-NEXT: ObjCExplicitProtocolImpl (SubjectMatchRule_objc_protocol)
// CHECK-NEXT: ObjCExternallyRetained (SubjectMatchRule_variable_not_is_parameter, SubjectMatchRule_function, SubjectMatchRule_block, SubjectMatchRule_objc_method)
Expand Down
15 changes: 14 additions & 1 deletion clang/test/SemaObjC/attr-designated-init.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#define NS_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer))
#define NS_UNAVAILABLE __attribute__((unavailable))

void fnfoo(void) NS_DESIGNATED_INITIALIZER; // expected-error {{only applies to init methods of interface or class extension declarations}}
void fnfoo(void) NS_DESIGNATED_INITIALIZER; // expected-error {{'objc_designated_initializer' attribute only applies to Objective-C methods}}

@protocol P1
-(id)init NS_DESIGNATED_INITIALIZER; // expected-error {{only applies to init methods of interface or class extension declarations}}
Expand Down Expand Up @@ -428,3 +428,16 @@ - (instancetype)init NS_DESIGNATED_INITIALIZER;
@interface CategoryForMissingInterface(Cat) // expected-error{{cannot find interface declaration}}
- (instancetype)init NS_DESIGNATED_INITIALIZER; // expected-error{{only applies to init methods of interface or class extension declarations}}
@end

@interface TwoAttrs
-(instancetype)foo
__attribute__((objc_designated_initializer))
__attribute__((objc_method_family(init)));
-(instancetype)bar
__attribute__((objc_method_family(init)))
__attribute__((objc_designated_initializer));
-(instancetype)baz
__attribute__((objc_designated_initializer, objc_method_family(init)));
-(instancetype)quux
__attribute__((objc_method_family(init), objc_designated_initializer));
@end