llvm.org GIT mirror llvm / ff48266
Fix autoupgrade logic for Objective-C class properties module flag Previous we were issuing an error when linking a module containing the new Objective-C metadata structure for class properties with an "old" one. Now instead we downgrade the module flag so that the Objective-C runtime does not expect the new metadata structure. This is consistent with what ld64 is doing on binary files. Differential Revision: https://reviews.llvm.org/D24620 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@281685 91177308-0d34-0410-b5e6-96231b3b80d8 Mehdi Amini 3 years ago
4 changed file(s) with 26 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
15861586 }
15871587 // "Objective-C Class Properties" is recently added for Objective-C. We
15881588 // upgrade ObjC bitcodes to contain a "Objective-C Class Properties" module
1589 // flag of value 0, so we can correclty report error when trying to link
1590 // an ObjC bitcode without this module flag with an ObjC bitcode with this
1591 // module flag.
1589 // flag of value 0, so we can correclty downgrade this flag when trying to
1590 // link an ObjC bitcode without this module flag with an ObjC bitcode with
1591 // this module flag.
15921592 if (HasObjCFlag && !HasClassProperties) {
1593 M.addModuleFlag(llvm::Module::Error, "Objective-C Class Properties",
1593 M.addModuleFlag(llvm::Module::Override, "Objective-C Class Properties",
15941594 (uint32_t)0);
15951595 return true;
15961596 }
55 !0 = !{i32 1, !"Objective-C Image Info Version", i32 0}
66
77 ; CHECK: !0 = !{i32 1, !"Objective-C Image Info Version", i32 0}
8 ; CHECK: !1 = !{i32 1, !"Objective-C Class Properties", i32 0}
8 ; CHECK: !1 = !{i32 4, !"Objective-C Class Properties", i32 0}
0
1 !llvm.module.flags = !{!0, !1}
2
3 !0 = !{i32 1, !"Objective-C Image Info Version", i32 0}
4 !1 = !{i32 1, !"Objective-C Class Properties", i32 64}
0 ; RUN: llvm-as < %s -o %t1.bc
1 ; RUN: llvm-as < %p/Inputs/objectivec-class-property-flag-mismatch.ll -o %t2.bc
2
3
4 ; RUN: llvm-link %t1.bc %t2.bc -S | FileCheck %s
5 ; RUN: llvm-link %t2.bc %t1.bc -S | FileCheck %s
6
7
8 ; CHECK: !0 = !{i32 1, !"Objective-C Image Info Version", i32 0}
9 ; CHECK: !1 = !{i32 4, !"Objective-C Class Properties", i32 0}
10
11
12
13 !llvm.module.flags = !{!0}
14
15 !0 = !{i32 1, !"Objective-C Image Info Version", i32 0}