Commit 3247dca
RepeatedPtrIterator is a view type
After llvm/llvm-project#177660, Clang tracks iterator lifetimes through transparent functions (like .begin(), operator*) and allows to detect the following case:
```cpp
const UafSubProto* ReturnSubProtoFromForLoop(bool condition) {
const UafSubProto* p = nullptr;
UafProto proto;
for (const UafSubProto& sub_proto : proto.repeated_sub_protos()) { // expected-error {{address of stack memory is returned later}}
if (condition) {
return &sub_proto; // expected-note {{returned here}}
}
}
for (const UafSubProto& sub_proto : proto.repeated_sub_protos()) { // expected-error {{address of stack memory is returned later}}
if (condition) {
p = &sub_proto;
return p; // expected-note {{returned here}}
}
}
return p;
}
```
PiperOrigin-RevId: 8650274611 parent 0dd552c commit 3247dca
1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1980 | 1980 | | |
1981 | 1981 | | |
1982 | 1982 | | |
1983 | | - | |
| 1983 | + | |
1984 | 1984 | | |
1985 | 1985 | | |
1986 | 1986 | | |
| |||
0 commit comments