[clang] [LifetimeSafety] Introduce buildOriginFlowChain for use-after-scope (PR #199345)
Utkarsh Saxena via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 2 10:50:06 PDT 2026
================
@@ -1042,9 +1069,12 @@ void operator_star_arrow_of_iterators_false_positive_no_cfg_analysis() {
const std::string& r = (*v.begin()).second;
auto temporary = []() { return std::vector<std::pair<int, std::string>>{{1, "1"}}; };
- const char* x = temporary().begin()->second.data(); // cfg-warning {{local temporary object does not live long enough}} cfg-note {{destroyed here}}
- const char* y = (*temporary().begin()).second.data(); // cfg-warning {{local temporary object does not live long enough}} cfg-note {{destroyed here}}
- const std::string& z = (*temporary().begin()).second; // cfg-warning {{local temporary object does not live long enough}} cfg-note {{destroyed here}}
+ const char* x = temporary().begin()->second.data(); // cfg-warning {{local temporary object does not live long enough}} cfg-note {{destroyed here}} \
+ // cfg-note 4 {{expression aliases the storage of local temporary object}}
----------------
usx95 wrote:
nit: Can you add this example in the PR description.
https://github.com/llvm/llvm-project/pull/199345
More information about the cfe-commits
mailing list