This patch adds a runtime check verifying that functions
annotated with "returns_nonnull" attribute do in fact return nonnull pointers.
It is based on suggestion by Jakub Jelinek:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20140623/223693.html.
Details
Diff Detail
Event Timeline
Looks good, a couple of minor comments.
projects/compiler-rt/lib/ubsan/ubsan_handlers.cc | ||
---|---|---|
319 | Maybe "null pointer returned from function declared to never return null"? If we can produce a note pointing at the non-null attribute, that'd be even better. | |
tools/clang/lib/CodeGen/CGCall.cpp | ||
2005 | I don't think you should perform this address space check. LLVM is going to assume the pointer is non-null regardless of address space (see CodeGenModule::ConstructAttributeList) so we should sanitize it regardless. |
Renamed the -fsanitize= flag value to "-fsanitize=returns-nonnull-attribute" and added the documentation.
Addressed reviewer's comments.
Maybe "null pointer returned from function declared to never return null"? If we can produce a note pointing at the non-null attribute, that'd be even better.