[lld] [lld] Add explicit conversion for enum to Twine. (PR #100627)

via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 25 11:31:06 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lld-macho

Author: Scott Todd (ScottTodd)

<details>
<summary>Changes</summary>

This fixes `error: ambiguous conversion for functional-style cast from 'lld::macho::InputSection::Kind' to 'llvm::Twine'`, observed when building with clang-9 and reported here: https://github.com/llvm/llvm-project/pull/96268#discussion_r1691909931.

---
Full diff: https://github.com/llvm/llvm-project/pull/100627.diff


1 Files Affected:

- (modified) lld/MachO/BPSectionOrderer.cpp (+2-2) 


``````````diff
diff --git a/lld/MachO/BPSectionOrderer.cpp b/lld/MachO/BPSectionOrderer.cpp
index 26d4e0cb3987d..f6a974370836b 100644
--- a/lld/MachO/BPSectionOrderer.cpp
+++ b/lld/MachO/BPSectionOrderer.cpp
@@ -48,9 +48,9 @@ getRelocHash(const Reloc &reloc,
     sectionIdx = sectionIdxIt->getSecond();
   std::string kind;
   if (isec)
-    kind = ("Section " + Twine(isec->kind())).str();
+    kind = ("Section " + Twine((uint8_t)isec->kind())).str();
   if (auto *sym = reloc.referent.dyn_cast<Symbol *>()) {
-    kind += (" Symbol " + Twine(sym->kind())).str();
+    kind += (" Symbol " + Twine((uint8_t)sym->kind())).str();
     if (auto *d = dyn_cast<Defined>(sym)) {
       if (isa_and_nonnull<CStringInputSection>(isec))
         return getRelocHash(kind, 0, isec->getOffset(d->value), reloc.addend);

``````````

</details>


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


More information about the llvm-commits mailing list