Issue 152496
Summary [LifetimeSafety] Add the core analysis engine & basic error reporting (milestone 1)
Labels clang:memory-safety
Assignees
Reporter usx95
    **Goal**: Establish the foundational analysis engine for toplevel raw C++ pointers and report basic use-after-scope and return-stack-address bugs. 

Deliverable:

Basic return-stack-addr with C++ raw pointers.
```cpp
int* foo() {
  int a = 1;
  int* res = &a;
  return res;   // warning: returning address of local variable 'a'.
}
```

Basic use-after-scope with C++ raw pointers.
```cpp
void bar(bool cond) {
  int* res = nullptr;
  if (cond) {
    int a = 1;
    res = &a;   // warning: 'a' may not live long enough.
  }
  use(res);     // note: later used here.
}
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to