-
Notifications
You must be signed in to change notification settings - Fork 11.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[-Wnullable-to-nonnull-conversion] should warn in more cases, and shouldn't in some #57546
Comments
Could you please change the title to something that could be considered professional and constructive instead of "weak and dumb"? |
Sure. Done. Sorry I was a bit unimaginative for that yesterday. :) |
I would guess that
I could understand if |
tldr
In Detail@dwblaikie, the page you linked says that dereferences are supposed to be handled when they are annotated. My reading is that this is Put differently,the checker only checks for
Similar to the page you linked, this page has the description and the ensuing discussion. The source is in NullabilityChecker.cpp and there are some useful comments which address the design choices. There is also some logic in SemaType.cpp, around local variables and declaration shadowing. This is where I suspect the complexity around f4 comes in.
|
Hi!
Seems reasonable, especially since you have the
Hmm, since this warning is out of -Wextra, then it also seems reasonable. BTW, I'd like to ask if there's a way to run the static analyzer as easily as GCC's Is there some command that I can run on files, as Should I open an issue to request this feature?
I'd love that.
Thanks a lot! Alex |
Yes, but I don't remember offhand. We had these build commands saved to build config files, so my muscle memory is lacking here. Let me look it up.
My limited understanding of the dark "magic" is that it traverses a giant syntax tree. (as part of the compilation, it parses the code into an Abstract Syntax Tree aka AST.) Simplistically, static analyzers are implemented as tree-traversal functions.
Yes, same as above.
I'm not a maintainer/collaborator, so grain of salt, but in my opinion this issue can be used. Let's see what the others think. |
🤦♂️right, should be simple. You can add The list of warnings is here |
No, what I meant with "it's not in |
I would like some static analyzer that has no false positives, like hopefully https://clang-analyzer.llvm.org/, to be able to run it in my build system. If you can find the commands to run it as a simple command on files, without telling it about my build system, it would be great! |
This came up today on LKML: https://lore.kernel.org/lkml/CAHk-=wiP0983VQYvhgJQgvk-VOwSfwNQUiy5RLr_ipz8tbaK4Q@mail.gmail.com/ Personally, I was surprised that #include <stddef.h>
int * _Nonnull foo (void) {
return &foo;
}
int * _Nonnull baz (void) {
return NULL; // null returned from function that requires a non-null return value [-Wnonnull]
}
void bar (void) {
if (foo() == NULL) // maybe should warn that foo() returns _Nonnull?
bar();
} especially since android is adding these to bionic. |
I was trying the feature, but it is trivial to silence warnings, and it also warns in some cases where it shouldn't:
The text was updated successfully, but these errors were encountered: