[clang] [Clang][NFC] Introduce no local variable to avoid use after move (PR #139784)
via cfe-commits
cfe-commits at lists.llvm.org
Tue May 13 12:52:45 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Shafik Yaghmour (shafik)
<details>
<summary>Changes</summary>
Static analysis flagged the use of Left.size() because we just moved out of Left and that would be undefined behavior. Fix is to take the size and store it in a local variable instead.
---
Full diff: https://github.com/llvm/llvm-project/pull/139784.diff
1 Files Affected:
- (modified) clang/lib/Sema/SemaConcept.cpp (+2-1)
``````````diff
diff --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index 15b9c97489e7f..543bd450c554e 100644
--- a/clang/lib/Sema/SemaConcept.cpp
+++ b/clang/lib/Sema/SemaConcept.cpp
@@ -1999,8 +1999,9 @@ FormulaType SubsumptionChecker::Normalize(const NormalizedConstraint &NC) {
});
if (NC.getCompoundKind() == FormulaType::Kind) {
+ auto SizeLeft = Left.size();
Res = std::move(Left);
- Res.reserve(Left.size() + Right.size());
+ Res.reserve(SizeLeft + Right.size());
std::for_each(std::make_move_iterator(Right.begin()),
std::make_move_iterator(Right.end()), Add);
return Res;
``````````
</details>
https://github.com/llvm/llvm-project/pull/139784
More information about the cfe-commits
mailing list