- User Since
- Jul 19 2017, 6:59 AM (40 w, 2 h)
In this diff I
- added a Pedantic flag that is set to false by default to filter out results from objects that don't have a single field initialized,
- made it so that fields that are declared in system headers are now ignored,
- refactored isFullyInitialized to hasUnintializedFields (it returned true when there were in fact uninit fields),
- fixed everything mentioned in inline comments aside from the naming and the category,
- added TODOs for FieldChainInfo::toString, I decided to fix those in a later patch to keep the diff just a little bit smaller,
- added many more test cases, including tests for the Pedantic flag
- added support for arrays. Granted, they worked wonderfully with the checker before, but there was nothing mentioned about them in the code.
I'd also like to point out that as I mentioned before, the checker's name itself is misleading (it is a leftover from an earlier implementation of this checker). Here are just some ideas I came up with:
Of these I like the first the most, but I'm open for anything, if you have an idea for it.
Sounds good! I just finished implementing it along with a few minor (like some TODOs and fixes according to inline comments) and not-so-minor (like ignoring fields from system headers) changes. I'll update the diff and post results on it once I finish checking the LLVM/Clang project. I feel very confident about the upcoming version.
Can someone commit this for me? I don't have a write access.
Tue, Apr 17
Mon, Apr 16
Would be interesting to extend this checker (maybe in an upcoming patch) to report on uninitialized members not only in constructors, but also copy constructors and move constructors.
Added 3 new test cases. to cover them. Interestingly, move constructors don't emit any warnings - the core can only assert that the fields after a move construction are valid (returns true for Val::isValid()`).
Came to think of it, I'm not 100% confident in the checkers name. It could be misleading, as this checker doesn't check constructors, but rather objects after construction. The end of a constructor call is only the point at which we know that analysis can be done.
This bug report also mentions assignment operator. But for that a warning may be not so useful. In that case the members of the assigned to object should have some initialized value already which the programmer may not want to overwrite in the assignment operator.
I believe there's a checker for that already, but I'm really not sure whether UndefinedAssignmentChecker covers all such cases.
I just had a look with -analyzer-config notes-as-events=true, and it works (with CodeChecker, at least). I'd still implement a better support for notes, but this is a great workaround for now. Thanks!
Sun, Apr 15
Btw, what sort of UI are you trying to make these extra note pieces of mine work with?
I'm also developing a checker: https://reviews.llvm.org/D45532. This checker emits very important information in notes. When I tried testing it with Ericsson's CodeChecker, I realized that notes aren't displayed. I'm planning to extend it so it will be able to.
Note that there was a comment made about the test files being too long. I still haven't split them, as I didn't find a good "splitting point". Is this okay, or shall I try to split these into numerous smaller ones?
Among many other things:
- The checker class is now on top of the file.
- Reviewed all comments, fixed typos, tried to make the general idea more understandable.
- Removed all (at least, all I could find) unnecessary functions and function arguments.
- Removed support for unions entirely.
I'm about to update the diff, I changed a quite a lot of stuff, so I'm not sure that I'd be able to respond to these inline comments.
Thu, Apr 12
Did you have some time to check on those programs? :)
Thank you for all your comments so far! I'll probably only be able to update the diff tomorrow (with me being in the GMT + 1 timezone).
Wed, Apr 11
Reuploaded the diff with full context.
Sun, Apr 8
Sat, Apr 7
Feb 14 2018
Just noticed that I can't mark your inline comment as done, since the file got renamed. The typo is also fixed (Classname -> Class name).
Renamed the checker from misc-throw-keyword-missing to bugprone-throw-keyword-missing.
Feb 13 2018
Feb 12 2018
Fixed almost everything mentioned in comments. The warning message now also contains the object's type (more on that in an inline comment).
Feb 9 2018
Changes made according to @whisperity's comments.