[lld] [lld-macho][NFC] Track category merger input data source language for better verification (PR #95473)

Ellis Hoag via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 13 15:47:09 PDT 2024


================
@@ -1151,22 +1162,26 @@ void ObjcCategoryMerger::collectAndValidateCategoriesData() {
       if (nlCategories.count(categorySym))
         continue;
 
-      assert(categorySym->getName().starts_with(objc::symbol_names::category) ||
-             categorySym->getName().starts_with(
-                 objc::symbol_names::swift_objc_category));
-
       auto *catBodyIsec = dyn_cast<ConcatInputSection>(categorySym->isec());
       assert(catBodyIsec &&
              "Category data section is not an ConcatInputSection");
 
+      InfoInputCategory catInputInfo{catListCisec, catBodyIsec, off};
+      if (categorySym->getName().starts_with(objc::symbol_names::category))
+        catInputInfo.sourceLanguage = SourceLanguage::SourceObjC;
+      else if (categorySym->getName().starts_with(
+                   objc::symbol_names::swift_objc_category))
+        catInputInfo.sourceLanguage = SourceLanguage::SourceSwift;
+      else
+        llvm_unreachable("Unexpected category symbol name");
----------------
ellishg wrote:

Why not set the language to `Unknown` instead of failing? Same for in `mergeCategoriesIntoBaseClass()` below.

https://github.com/llvm/llvm-project/pull/95473


More information about the llvm-commits mailing list