FYI: Clang has a new lifetime checker that leverages [[gsl::Pointer]] now
#380
SidneyCogdill
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Refer to https://discourse.llvm.org/t/rfc-intra-procedural-lifetime-analysis-in-clang/86291 for information.
Currently this requires marking the
proxyclass with the[[gsl::Pointer]]attribute:https://godbolt.org/z/cov3MG5v5
Compiling with the latest Clang trunk, using
-std=c++20 -Wno-c++23-extensions -Werror=experimental-lifetime-safety -Werror=experimental-lifetime-safety-cross-tu-suggestions -Wexperimental-lifetime-safety-intra-tu-suggestions -Xclang -fexperimental-lifetime-safety -Xclang -fexperimental-lifetime-safety-inference[1]:It's still experimental, there are still many cases where the UAF doesn't get caught, the lifetime checker behavior may change any time. Since
pro::proxyacts sometimes as agsl::Ownerand sometimes as agsl::Pointer, I'm not sure whether it will introduce false positives with codes that use Proxy, as the lifetime checker gets stronger and stronger in the future. However, for now it seems to work correctly when interacting with othergsl::Ownertypes such asunique_ptr.[1] For some reasons the checker does not inference lifetime constraint when using
-std=c++23/-std=c++26. llvm/llvm-project#176292Beta Was this translation helpful? Give feedback.
All reactions