This checker adds nullability-related assumptions to methods annotated with returns_nonnull attribute.
Details
Diff Detail
Event Timeline
Lovely! I have some nits.
@NoQ is my actual account, sorry for the mess >.<
clang/lib/StaticAnalyzer/Checkers/TrustReturnsNonnullChecker.cpp | ||
---|---|---|
1–2 | This line broke. | |
42 | Parameter C appears to be unused. | |
47 | Call.getDecl() has to be checked for null. Calls with null decls appear when the function being called is unknown, eg. during calls through unknown/symbolic pointer-to-function: void test(void *(*f)(void)) { // will probably crash the compiler, worth a test case f(); } | |
48 | if (x) { return true; } return false; can usually be shortened to return x; . |
Great, thanks!
The phabricator expects complete patches reuploaded (i.e., diffs against main branch rather than diffs against the previous upload); but it knows how to produce patches-on-patches from complete patches through the History tab. Another reason to upload complete patches is to unconfuse pre-merge buildbots (the "Build Status: patch application failed" part).
So please re-upload and that'd be a ✅
clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt | ||
---|---|---|
114–115 | As this checker mimics that other checker, the question inevitably arises whether the two can be merged. The other checker is currently stuffed with extra code to handle operator == which is possibly no longer necessary since D82445 provides a more general solution. I guess this could be an interesting refactoring pass. | |
clang/test/Analysis/test-decl-crash.cpp | ||
6 ↗ | (On Diff #405030) | It makes sense to put the new test into the same file given that they share the RUN: line. |
As this checker mimics that other checker, the question inevitably arises whether the two can be merged. The other checker is currently stuffed with extra code to handle operator == which is possibly no longer necessary since D82445 provides a more general solution. I guess this could be an interesting refactoring pass.