- std::pair<StringRef, StringRef> Plus = Attrs.split('+');
-
- while (1) {
- StringRef Attr = Plus.first;
- StripSpaces(Attr);
-
- // Look up the attribute.
- for (unsigned i = 0; ; ++i) {
- if (SectionAttrDescriptors[i].AttrFlag == AttrFlagEnd)
- return "mach-o section specifier has invalid attribute";
-
- if (SectionAttrDescriptors[i].AssemblerName &&
- Attr == SectionAttrDescriptors[i].AssemblerName) {
- TAA |= SectionAttrDescriptors[i].AttrFlag;
- break;
- }
- }
-
- if (Plus.second.empty()) break;
- Plus = Plus.second.split('+');
- };
+ SmallVector<StringRef, 1> SectionAttrs;
+ Attrs.split(SectionAttrs, '+', /*MaxSplit=*/-1, /*KeepEmpty=*/false);
+
+ for (StringRef &SectionAttr : SectionAttrs) {
+ auto AttrDescriptorI = std::find_if(
+ std::begin(SectionAttrDescriptors), std::end(SectionAttrDescriptors),
+ [&](decltype(*SectionAttrDescriptors) &Descriptor) {
+ return Descriptor.AssemblerName &&
+ SectionAttr.trim() == Descriptor.AssemblerName;
+ });
+ if (AttrDescriptorI == std::end(SectionAttrDescriptors))
+ return "mach-o section specifier has invalid attribute";
+
+ TAA |= AttrDescriptorI->AttrFlag;
+ }