[PATCH] D22391: [Sema] Add warning for implicitly casting a null constant to a non null pointer type

2018-07-16 Thread Jordan Rose via Phabricator via cfe-commits
jordan_rose added inline comments. Comment at: test/Sema/conditional-expr.c:20 vp = 0 ? (double *)0 : (void *)0; - ip = 0 ? (double *)0 : (void *)0; // expected-warning {{incompatible pointer types assigning to 'int *' from 'double *'}} + ip = 0 ? (double *)0 : (void *)0;

[PATCH] D22391: [Sema] Add warning for implicitly casting a null constant to a non null pointer type

2018-07-16 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments. Comment at: test/Sema/conditional-expr.c:20 vp = 0 ? (double *)0 : (void *)0; - ip = 0 ? (double *)0 : (void *)0; // expected-warning {{incompatible pointer types assigning to 'int *' from 'double *'}} + ip = 0 ? (double *)0 : (void *)0; //

[PATCH] D22391: [Sema] Add warning for implicitly casting a null constant to a non null pointer type

2018-07-11 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments. Comment at: test/Analysis/nullability_nullonly.mm:103 void testObjCARCExplicitZeroInitialization() { - TestObject * _Nonnull explicitlyZeroInitialized = nil; // expected-warning {{nil assigned to a pointer which is expected to have non-null value}}

[PATCH] D22391: [Sema] Add warning for implicitly casting a null constant to a non null pointer type

2018-07-10 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments. Comment at: lib/Sema/SemaExpr.cpp:11103 + if (const auto *DeclRef = dyn_cast(LHSExpr)) +checkNullConstantToNonNull(DeclRef->getType(), RHS.get()); jordan_rose wrote: > This could come later, but what about struct members or

[PATCH] D22391: [Sema] Add warning for implicitly casting a null constant to a non null pointer type

2018-07-10 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 154908. ahatanak marked 3 inline comments as done. ahatanak added a comment. Address review comments. Repository: rC Clang https://reviews.llvm.org/D22391 Files: include/clang/Basic/DiagnosticGroups.td include/clang/Basic/DiagnosticSemaKinds.td

[PATCH] D22391: [Sema] Add warning for implicitly casting a null constant to a non null pointer type

2018-07-10 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ edited subscribers, added: NoQ; removed: dergachev.a. NoQ added inline comments. Comment at: test/Analysis/nullability_nullonly.mm:103 void testObjCARCExplicitZeroInitialization() { - TestObject * _Nonnull explicitlyZeroInitialized = nil; // expected-warning {{nil

[PATCH] D22391: [Sema] Add warning for implicitly casting a null constant to a non null pointer type

2018-07-10 Thread Jordan Rose via Phabricator via cfe-commits
jordan_rose added a subscriber: dergachev.a. jordan_rose added a comment. Sorry for the delay. I think this is mostly good, but I do still have a concern about the diagnostics change. Comment at: lib/Sema/SemaExpr.cpp:7117 +if (E && S.checkNonNullExpr(E)) + return

[PATCH] D22391: [Sema] Add warning for implicitly casting a null constant to a non null pointer type

2018-07-09 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment. Herald added a subscriber: dexonsmith. ping Repository: rC Clang https://reviews.llvm.org/D22391 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[PATCH] D22391: [Sema] Add warning for implicitly casting a null constant to a non null pointer type

2018-06-06 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments. Comment at: lib/Sema/SemaExpr.cpp:7117 +if (E && S.checkNonNullExpr(E)) + return NullabilityKind::Nullable; + jordan_rose wrote: > This isn't quite correct, unfortunately. `(_Nonnull id)nil` should be > considered

[PATCH] D22391: [Sema] Add warning for implicitly casting a null constant to a non null pointer type

2018-06-06 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 150218. ahatanak marked an inline comment as done. ahatanak added a reviewer: dcoughlin. ahatanak set the repository for this revision to rC Clang. ahatanak added a comment. Sorry for the delay in responding. I've addressed Jordan's review comments. I had

[PATCH] D22391: [Sema] Add warning for implicitly casting a null constant to a non null pointer type

2017-03-22 Thread Jordan Rose via Phabricator via cfe-commits
jordan_rose added a comment. This looks like it's only coming up for declarations. What about assignments? int x; int * _Nonnull p = p = NULL; // warn here? Comment at: lib/Sema/SemaExpr.cpp:7117 +if (E && S.checkNonNullExpr(E)) + return

[PATCH] D22391: [Sema] Add warning for implicitly casting a null constant to a non null pointer type

2017-03-21 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 92583. ahatanak added a comment. Rebase and ping. https://reviews.llvm.org/D22391 Files: include/clang/Basic/DiagnosticGroups.td include/clang/Basic/DiagnosticSemaKinds.td include/clang/Sema/Sema.h lib/Sema/SemaChecking.cpp lib/Sema/SemaDecl.cpp

[PATCH] D22391: [Sema] Add warning for implicitly casting a null constant to a non null pointer type

2017-02-03 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 87016. ahatanak marked 2 inline comments as done. ahatanak added a comment. Turning the warning on by default caused clang to issue warnings in many other cases, including Objective-C methods returning nil, which was something r240153 tried to avoid. If we

[PATCH] D22391: [Sema] Add warning for implicitly casting a null constant to a non null pointer type

2017-01-24 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments. Comment at: include/clang/Basic/DiagnosticGroups.td:290 def NullableToNonNullConversion : DiagGroup<"nullable-to-nonnull-conversion">; +def NullConstToNonnull : DiagGroup<"null-const-to-nonnull">; def NullabilityCompletenessOnArrays :

[PATCH] D22391: [Sema] Add warning for implicitly casting a null constant to a non null pointer type

2017-01-24 Thread Jordan Rose via Phabricator via cfe-commits
jordan_rose added inline comments. Comment at: include/clang/Basic/DiagnosticGroups.td:290 def NullableToNonNullConversion : DiagGroup<"nullable-to-nonnull-conversion">; +def NullConstToNonnull : DiagGroup<"null-const-to-nonnull">; def NullabilityCompletenessOnArrays :

[PATCH] D22391: [Sema] Add warning for implicitly casting a null constant to a non null pointer type

2017-01-24 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 85651. ahatanak added a reviewer: jordan_rose. ahatanak added a comment. Rebase. https://reviews.llvm.org/D22391 Files: include/clang/Basic/DiagnosticGroups.td include/clang/Basic/DiagnosticSemaKinds.td include/clang/Sema/Sema.h lib/Sema/Sema.cpp

Re: [PATCH] D22391: [Sema] Add warning for implicitly casting a null constant to a non null pointer type

2016-07-25 Thread Akira Hatanaka via cfe-commits
ahatanak updated this revision to Diff 65446. ahatanak added a comment. Addressed review comment and made a couple of other changes. - Move Sema::diagnoseNullPtrToNonnullCast to SemaChecking.cpp. - In diagnoseNullPtrToNonnullCast, call "Type::isAnyPointerType" instead of "Type::isPointerType"

Re: [PATCH] D22391: [Sema] Add warning for implicitly casting a null constant to a non null pointer type

2016-07-14 Thread Doug Gregor via cfe-commits
doug.gregor added a comment. I think this check should go into SemaChecking.cpp https://reviews.llvm.org/D22391 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[PATCH] D22391: [Sema] Add warning for implicitly casting a null constant to a non null pointer type

2016-07-14 Thread Akira Hatanaka via cfe-commits
ahatanak created this revision. ahatanak added a reviewer: doug.gregor. ahatanak added a subscriber: cfe-commits. This patch makes clang issue a warning when a null constant is used in a context where a non null expression is expected. For example: ``` int * _Nonnull p0 = 0; // warning expected