[clang-tools-extra] [clang-tidy] Fix false positive in bugprone-use-after-move for std::tie (PR #192895)
Zeyi Xu via cfe-commits
cfe-commits at lists.llvm.org
Sun Apr 26 00:19:22 PDT 2026
================
@@ -1789,4 +1790,39 @@ void Run() {
RegularReset(db6);
db6.Query();
}
+
} // namespace custom_reinitialization
+
+// Tests for std::tie() reinitialization.
+std::pair<std::string, std::string> makeStringPair(std::string a,
+ std::string b);
+
+void stdTieIsReinit() {
+ // std::tie on the LHS reinitializes all captured variables.
+ std::string a, b;
+ std::move(a);
+ std::move(b);
+ std::tie(a, b) = makeStringPair("x", "y"); // no-warning: both reinitialized
+ a.size();
+ b.size();
+}
+
----------------
zeyi2 wrote:
Can we add tests like: `std::tie(a, std::ignore) = makeStringPair("x", "y");`?
https://github.com/llvm/llvm-project/pull/192895
More information about the cfe-commits
mailing list