[PATCH] D22794: [Sema] Propagate nullability when deducing type of auto

Akira Hatanaka via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 16 13:10:27 PDT 2016


ahatanak added a comment.

I didn't think of this case, but no, it isn't a good idea. We shouldn't issue a warning unless we know the returned pointer is nullable.


================
Comment at: lib/Sema/SemaDecl.cpp:9739
@@ +9738,3 @@
+      DeducedType = DeducedType.setNullability(
+          Init->getType()->getNullability(Context), Context);
+
----------------
manmanren wrote:
> Do we propagate other attributes for deduced types?
QualType::setNullability can drop attributes on typedefs because it desugars the type until all nullability specifiers are stripped. I didn't try very hard to make sure QualType::setNullability preserve all the attributes because I couldn't come up with a case where dropping an attribute attached to a typedef for a pointer type would cause clang to mis-compile or issue a wrong diagnostic, so I thought it was safe.


https://reviews.llvm.org/D22794





More information about the cfe-commits mailing list