aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineCombiner.cpp
diff options
context:
space:
mode:
authorSam McCall <sam.mccall@gmail.com>2024-03-14 16:45:24 +0100
committerGitHub <noreply@github.com>2024-03-14 16:45:24 +0100
commit92a09c0165b87032e1bd05020a78ed845cf35661 (patch)
treee8db8a4685d6163cd981cecb789557918b597115 /llvm/lib/CodeGen/MachineCombiner.cpp
parent8481fb1698a4a54b3965a1654046df736a57e144 (diff)
downloadllvm-92a09c0165b87032e1bd05020a78ed845cf35661.zip
llvm-92a09c0165b87032e1bd05020a78ed845cf35661.tar.gz
llvm-92a09c0165b87032e1bd05020a78ed845cf35661.tar.bz2
[clang][nullability] allow _Nonnull etc on nullable class types (#82705)
This enables clang and external nullability checkers to make use of these annotations on nullable C++ class types like unique_ptr. These types are recognized by the presence of the _Nullable attribute. Nullable standard library types implicitly receive this attribute. Existing static warnings for raw pointers are extended to smart pointers: - nullptr used as return value or argument for non-null functions (`-Wnonnull`) - assigning or initializing nonnull variables with nullable values (`-Wnullable-to-nonnull-conversion`) It doesn't implicitly add these attributes based on the assume_nonnull pragma, nor warn on missing attributes where the pragma would apply them. I'm not confident that the pragma's current behavior will work well for C++ (where type-based metaprogramming is much more common than C/ObjC). We'd like to revisit this once we have more implementation experience. Support can be detected as `__has_feature(nullability_on_classes)`. This is needed for back-compatibility, as previously clang would issue a hard error when _Nullable appears on a smart pointer. UBSan's `-fsanitize=nullability` will not check smart-pointer types. It can be made to do so by synthesizing calls to `operator bool`, but that's left for future work. Discussion: https://discourse.llvm.org/t/rfc-allowing-nonnull-etc-on-smart-pointers/77201/26
Diffstat (limited to 'llvm/lib/CodeGen/MachineCombiner.cpp')
0 files changed, 0 insertions, 0 deletions