aboutsummaryrefslogtreecommitdiff
path: root/lld/MachO/ObjC.cpp
diff options
context:
space:
mode:
authoralx32 <103613512+alx32@users.noreply.github.com>2024-02-01 10:31:27 -0800
committerGitHub <noreply@github.com>2024-02-01 10:31:27 -0800
commitf0c8d88e25dbed02605994da227dfa75c1304d4a (patch)
tree8cbee9bfe9e3a04e8dedf73ac5e3c6ba830abe8e /lld/MachO/ObjC.cpp
parent10a55caccf4e2d397f94c1455b93d774591be45f (diff)
downloadllvm-f0c8d88e25dbed02605994da227dfa75c1304d4a.tar.gz
llvm-f0c8d88e25dbed02605994da227dfa75c1304d4a.tar.bz2
llvm-f0c8d88e25dbed02605994da227dfa75c1304d4a.zip
[lld-macho] Make ObjC category checker print the source file name of category (#80221)
When printing category conflicts in the ObjC category checker, also print the source file name of the problematic categories. Currently we only print the object file name. This change is mostly useful only for thinLTO builds, where the object file name will be of form 999.arm64.lto.o and thus does not reveal any information about the original source file. --------- Co-authored-by: Alex Borcan <alexborcan@meta.com>
Diffstat (limited to 'lld/MachO/ObjC.cpp')
-rw-r--r--lld/MachO/ObjC.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/lld/MachO/ObjC.cpp b/lld/MachO/ObjC.cpp
index 7e8cec026d2f..67254ec53a21 100644
--- a/lld/MachO/ObjC.cpp
+++ b/lld/MachO/ObjC.cpp
@@ -237,12 +237,23 @@ void ObjcCategoryChecker::parseMethods(const ConcatInputSection *methodsIsec,
StringRef newCatName =
getReferentString(*containerIsec->getRelocAt(catLayout.nameOffset));
+ auto formatObjAndSrcFileName = [](const InputSection *section) {
+ lld::macho::InputFile *inputFile = section->getFile();
+ std::string result = toString(inputFile);
+
+ auto objFile = dyn_cast_or_null<ObjFile>(inputFile);
+ if (objFile && objFile->compileUnit)
+ result += " (" + objFile->sourceFile() + ")";
+
+ return result;
+ };
+
StringRef containerType = mc.kind == MCK_Category ? "category" : "class";
warn("method '" + methPrefix + methodName.val() +
"' has conflicting definitions:\n>>> defined in category " +
- newCatName + " from " + toString(containerIsec->getFile()) +
+ newCatName + " from " + formatObjAndSrcFileName(containerIsec) +
"\n>>> defined in " + containerType + " " + containerName + " from " +
- toString(mc.isec->getFile()));
+ formatObjAndSrcFileName(mc.isec));
}
}