[clang] [analyzer] Remove some false negatives in StackAddrEscapeChecker (PR #125638)
Michael Flanders via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 7 09:55:23 PST 2025
================
@@ -912,3 +924,33 @@ void top_malloc_no_crash_fn() {
free(pptr);
}
} // namespace alloca_region_pointer
+
+namespace true_negatives_return_expressions {
+struct Container { int *x; };
+
+int test2() {
+ int x = 14;
----------------
Flandini wrote:
Added in 51f8e2e589424b67b5d3cfcec660800bcaab9a49.
Here is the new test case:
```
int make_x();
int return_symbol_safe() {
int x = make_x();
clang_analyzer_dump(x); // expected-warning-re {{conj_$2{int, {{.+}}}}}
return x; // no-warning
}
```
There were also some similar pre-existing test cases like these:
```
int get_value();
const int &get_reference1() { return get_value(); } // expected-warning{{Address of stack memory associated with temporary object of type 'int' returned}} expected-warning {{returning reference to local temporary}}
const int &get_reference2() {
const int &x = get_value(); // expected-note {{binding reference variable 'x' here}}
return x; // expected-warning{{Address of stack memory associated with temporary object of type 'int' lifetime extended by local variable 'x' returned to caller}} expected-warning {{returning reference to local temporary}}
}
```
https://github.com/llvm/llvm-project/pull/125638
More information about the cfe-commits
mailing list