[PATCH] [UBSan] Add returns-nonnull sanitizer.
Alexey Samsonov
vonosmas at gmail.com
Tue Aug 12 17:29:26 PDT 2014
Thanks! Submitting this now.
================
Comment at: projects/compiler-rt/lib/ubsan/ubsan_handlers.cc:319
@@ +318,3 @@
+
+ Diag(Loc, DL_Error, "null return value where non-null is required");
+}
----------------
Richard Smith wrote:
> 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.
Changed the error message as suggested.
================
Comment at: tools/clang/lib/CodeGen/CGCall.cpp:2005
@@ +2004,3 @@
+ CurGD.getDecl()->hasAttr<ReturnsNonNullAttr>() &&
+ RV->getType()->getPointerAddressSpace() == 0) {
+ SanitizerScope SanScope(this);
----------------
Richard Smith wrote:
> 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.
Done
http://reviews.llvm.org/D4849
More information about the cfe-commits
mailing list