diff options
| author | Nico Weber <nicolasweber@gmx.de> | 2015-12-03 17:44:51 +0000 |
|---|---|---|
| committer | Nico Weber <nicolasweber@gmx.de> | 2015-12-03 17:44:51 +0000 |
| commit | 08c9333df2916dff643e7c5d6174867f199af0cb (patch) | |
| tree | 4da76242d850440f6829b3ead6c11014d71908a0 /clang/lib/CodeGen | |
| parent | 0d4505c0677796aba5a54069154c8ae491786c0f (diff) | |
| download | bcm5719-llvm-08c9333df2916dff643e7c5d6174867f199af0cb.tar.gz bcm5719-llvm-08c9333df2916dff643e7c5d6174867f199af0cb.zip | |
Fix Objective-C metadata for properties from class extensions after r251874
After, properties from class extensions no longer show up in
ObjCInterfaceDecl::properties(). Make ObjCCommonMac::EmitPropertyList()
explicitly look for properties in class extensions before looking at
direct properties.
Also add a test that passes both with clang before r251874 and after this
patch (but fails with r251874 and without this patch).
llvm-svn: 254622
Diffstat (limited to 'clang/lib/CodeGen')
| -rw-r--r-- | clang/lib/CodeGen/CGObjCMac.cpp | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp index 78f32363a43..c29b435b978 100644 --- a/clang/lib/CodeGen/CGObjCMac.cpp +++ b/clang/lib/CodeGen/CGObjCMac.cpp @@ -2908,15 +2908,26 @@ llvm::Constant *CGObjCCommonMac::EmitPropertyList(Twine Name, const ObjCCommonTypesHelper &ObjCTypes) { SmallVector<llvm::Constant *, 16> Properties; llvm::SmallPtrSet<const IdentifierInfo*, 16> PropertySet; + + auto AddProperty = [&](const ObjCPropertyDecl *PD) { + llvm::Constant *Prop[] = {GetPropertyName(PD->getIdentifier()), + GetPropertyTypeString(PD, Container)}; + Properties.push_back(llvm::ConstantStruct::get(ObjCTypes.PropertyTy, Prop)); + }; + if (const ObjCInterfaceDecl *OID = dyn_cast<ObjCInterfaceDecl>(OCD)) + for (const ObjCCategoryDecl *ClassExt : OID->known_extensions()) + for (auto *PD : ClassExt->properties()) { + PropertySet.insert(PD->getIdentifier()); + AddProperty(PD); + } for (const auto *PD : OCD->properties()) { - PropertySet.insert(PD->getIdentifier()); - llvm::Constant *Prop[] = { - GetPropertyName(PD->getIdentifier()), - GetPropertyTypeString(PD, Container) - }; - Properties.push_back(llvm::ConstantStruct::get(ObjCTypes.PropertyTy, - Prop)); + // Don't emit duplicate metadata for properties that were already in a + // class extension. + if (!PropertySet.insert(PD->getIdentifier()).second) + continue; + AddProperty(PD); } + if (const ObjCInterfaceDecl *OID = dyn_cast<ObjCInterfaceDecl>(OCD)) { for (const auto *P : OID->all_referenced_protocols()) PushProtocolProperties(PropertySet, Properties, Container, P, ObjCTypes); |

