[clang] 7e690db - [Clang][NFC] Introduce no local variable to avoid use after move (#139784)
via cfe-commits
cfe-commits at lists.llvm.org
Wed May 14 07:31:18 PDT 2025
Author: Shafik Yaghmour
Date: 2025-05-14T07:31:14-07:00
New Revision: 7e690db5157bfda1a2be3a99d16e8875a2d42b96
URL: https://github.com/llvm/llvm-project/commit/7e690db5157bfda1a2be3a99d16e8875a2d42b96
DIFF: https://github.com/llvm/llvm-project/commit/7e690db5157bfda1a2be3a99d16e8875a2d42b96.diff
LOG: [Clang][NFC] Introduce no local variable to avoid use after move (#139784)
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.
Added:
Modified:
clang/lib/Sema/SemaConcept.cpp
Removed:
################################################################################
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;
More information about the cfe-commits
mailing list