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;
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; //
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}}
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
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
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
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
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
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
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
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
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
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
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 :
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 :
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
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"
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
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
19 matches
Mail list logo