DHowett-MSFT updated this revision to Diff 141450. DHowett-MSFT added a comment.
Added a test per @rjmccall's suggestion. I chose to test this by emitting assembly because the llvm ir is significantly harder to pick apart for the true _size_ of the protocol. Repository: rC Clang https://reviews.llvm.org/D45305 Files: lib/CodeGen/CGObjCGNU.cpp test/CodeGenObjC/undefined-protocol-v3.m Index: test/CodeGenObjC/undefined-protocol-v3.m =================================================================== --- /dev/null +++ test/CodeGenObjC/undefined-protocol-v3.m @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fobjc-runtime=gnustep-1.9 -S -o - %s | FileCheck %s + +@protocol X; + +__attribute__((objc_root_class)) +@interface Z <X> +@end + +@implementation Z +@end + +// CHECK-DAG: .objc_protocol: +// CHECK-DAG: .long 3 +// CHECK-DAG: .size .objc_protocol, 36 Index: lib/CodeGen/CGObjCGNU.cpp =================================================================== --- lib/CodeGen/CGObjCGNU.cpp +++ lib/CodeGen/CGObjCGNU.cpp @@ -1813,11 +1813,13 @@ llvm::ConstantInt::get(Int32Ty, ProtocolVersion), IdTy)); Elements.add(MakeConstantString(ProtocolName, ".objc_protocol_name")); - Elements.add(ProtocolList); - Elements.add(MethodList); - Elements.add(MethodList); - Elements.add(MethodList); - Elements.add(MethodList); + Elements.add(ProtocolList); /* .protocol_list */ + Elements.add(MethodList); /* .instance_methods */ + Elements.add(MethodList); /* .class_methods */ + Elements.add(MethodList); /* .optional_instance_methods */ + Elements.add(MethodList); /* .optional_class_methods */ + Elements.add(NULLPtr); /* .properties */ + Elements.add(NULLPtr); /* .optional_properties */ return Elements.finishAndCreateGlobal(".objc_protocol", CGM.getPointerAlign()); }
Index: test/CodeGenObjC/undefined-protocol-v3.m =================================================================== --- /dev/null +++ test/CodeGenObjC/undefined-protocol-v3.m @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fobjc-runtime=gnustep-1.9 -S -o - %s | FileCheck %s + +@protocol X; + +__attribute__((objc_root_class)) +@interface Z <X> +@end + +@implementation Z +@end + +// CHECK-DAG: .objc_protocol: +// CHECK-DAG: .long 3 +// CHECK-DAG: .size .objc_protocol, 36 Index: lib/CodeGen/CGObjCGNU.cpp =================================================================== --- lib/CodeGen/CGObjCGNU.cpp +++ lib/CodeGen/CGObjCGNU.cpp @@ -1813,11 +1813,13 @@ llvm::ConstantInt::get(Int32Ty, ProtocolVersion), IdTy)); Elements.add(MakeConstantString(ProtocolName, ".objc_protocol_name")); - Elements.add(ProtocolList); - Elements.add(MethodList); - Elements.add(MethodList); - Elements.add(MethodList); - Elements.add(MethodList); + Elements.add(ProtocolList); /* .protocol_list */ + Elements.add(MethodList); /* .instance_methods */ + Elements.add(MethodList); /* .class_methods */ + Elements.add(MethodList); /* .optional_instance_methods */ + Elements.add(MethodList); /* .optional_class_methods */ + Elements.add(NULLPtr); /* .properties */ + Elements.add(NULLPtr); /* .optional_properties */ return Elements.finishAndCreateGlobal(".objc_protocol", CGM.getPointerAlign()); }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits