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

via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 13 17:30:22 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");
----------------
alx32 wrote:

The idea is that If the symbol pattern changes, we're in an unknown scenario and it's likely that other things might be not as expected - i.e. we don't want to be running category merger in such a scenario. 

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


More information about the llvm-commits mailing list