aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 66ecc69..6e93872 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -293,10 +293,18 @@ static Expected<bool> hasObjCCategoryInModule(BitstreamCursor &Stream) {
std::string S;
if (convertToString(Record, 0, S))
return error("Invalid section name record");
+
// Check for the i386 and other (x86_64, ARM) conventions
- if (S.find("__DATA,__objc_catlist") != std::string::npos ||
- S.find("__OBJC,__category") != std::string::npos ||
- S.find("__TEXT,__swift") != std::string::npos)
+
+ auto [Segment, Section] = StringRef(S).split(",");
+ Segment = Segment.trim();
+ Section = Section.trim();
+
+ if (Segment == "__DATA" && Section.starts_with("__objc_catlist"))
+ return true;
+ if (Segment == "__OBJC" && Section.starts_with("__category"))
+ return true;
+ if (Segment == "__TEXT" && Section.starts_with("__swift"))
return true;
break;
}