From 7e690db5157bfda1a2be3a99d16e8875a2d42b96 Mon Sep 17 00:00:00 2001 From: Shafik Yaghmour Date: Wed, 14 May 2025 07:31:14 -0700 Subject: [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. --- clang/lib/Sema/SemaConcept.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'clang/lib/Sema/SemaConcept.cpp') diff --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp index 15b9c97..543bd45 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; -- cgit v1.1