[llvm] [MC][DXContainer] Avoid reading moved-from ContentEntry (PR #211741)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 24 00:37:37 PDT 2026
https://github.com/tfzee created https://github.com/llvm/llvm-project/pull/211741
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.
>From 3b46b587b52a382bf728c4f99a1fe804a49c4abd Mon Sep 17 00:00:00 2001
From: tfzee <tim.ziegler at intel.com>
Date: Fri, 24 Jul 2026 09:36:10 +0200
Subject: [PATCH] [MC][DXContainer] Avoid reading moved-from ContentEntry
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 the move is overloaded in the future for ContentEntry or its Parameters member.
This fix removes this fragility at no costs.
---
llvm/lib/MC/DXContainerInfo.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
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));
}
More information about the llvm-commits
mailing list