[llvm] [MC][DXContainer] Avoid reading moved-from ContentEntry (PR #211741)

via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 24 00:38:31 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-directx

Author: tfzee (tfzee)

<details>
<summary>Changes</summary>

While technically correct in this specific case to use the moved value since its a scalar, it might break in the future. For example if the move is overloaded for ContentEntry or its Parameters member.

This fix removes this fragility.

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


1 Files Affected:

- (modified) llvm/lib/MC/DXContainerInfo.cpp (+2-1) 


``````````diff
diff --git a/llvm/lib/MC/DXContainerInfo.cpp b/llvm/lib/MC/DXContainerInfo.cpp
index 2584bae0ef2e8..909207b39ee17 100644
--- a/llvm/lib/MC/DXContainerInfo.cpp
+++ b/llvm/lib/MC/DXContainerInfo.cpp
@@ -206,11 +206,12 @@ void SourceInfoBuilder::computeEntries() {
     SourceInfo::SourceContents::Entry ContentEntry;
     ContentEntry.FileContent = NameContent.second.str();
     ContentEntry.compute();
+    auto ContentSize = ContentEntry.Parameters.ContentSizeInBytes;
     BaseData.Contents.Entries.emplace_back(std::move(ContentEntry));
 
     SourceInfo::SourceNames::Entry NameEntry;
     NameEntry.FileName = NameContent.first;
-    NameEntry.compute(ContentEntry.Parameters.ContentSizeInBytes);
+    NameEntry.compute(ContentSize);
     BaseData.Names.Entries.emplace_back(std::move(NameEntry));
   }
 

``````````

</details>


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


More information about the llvm-commits mailing list