I was looking at CERT ARR32-C "Ensure size arguments for variable length arrays are in a valid range". The VLA should not have a size that is larger than std::numeric_limits<size_t>::max(), in other words "fit into a size_t value", or not?
Yes creating the too large VLA in itself is not a bug, only when sizeof is called on it because it can not return the correct size. A non-fatal error is a better option, or delay the check until the sizeof call. But probably the create of such a big array in itself is sign of code smell. The array actually does not need to be created to make the problem happen, only a sizeof call on a typedef-ed and too large VLA. (What does mean that "result of sizeof is implementation-defined"? Probably it can return not the size in bytes or "chars" but something other? In such a case the checker would be not correct.)
Thu, May 28
Fri, May 15
Tue, May 12
(Maybe this will make Phab not show "✅ Accepted"...)
Please check the summary of the patch, it seems to contain old information as well.
Wed, May 6
Apr 24 2020
@steakhal You might want to update the patch summary before committing this to the upstream (it still mentions "not needing a visitor" 😄)
Apr 23 2020
First things first, we were 50 thousand (!) patches behind reality. Rebased to master. Fixed it to compile, too. Otherwise, NFC so far.
Assuming direct control. Previous colleagues and university mates departed for snowier pastures, time to try to do something with this check.
Apr 22 2020
- Re-organised code, removed debug prints, rebased, the usual tidy-up.
- Bug fixes on certain crashes like incomplete types, conversion operator templates, etc.
- Even more bug fixes against crashes, hopefully... sorry I lost the individual commits in a squash I think
- Better organisation of code, cleanup of debug prints, fix nomenclature of functions
- Explicitly mention the first and last param of the range for clarity
- Downlift the logic of joining and breaking ranges to main patch (this isn't terribly useful at this point, but both subsequent improvements to the check depend on this change)
- Basically no longer assume that if param N can be swapped with param 1, then it can also be swapped with 2, 3, etc. without checking.
- Made the list of ignored parameter and type names configurable as a checker option
- Changed the default value of MinimumLength to 2, as prescribed in the guideline's text.
Apr 21 2020
Apr 14 2020
Adding @martong, he might have knowledge about the whole summary thing as he's tinkering the(?) STL checker.
Mar 23 2020
I think we want to keep the experimental checks grouped to their parent module rather than being in a module of their own.
Forgive me if I'm wrong, but these kinds of changes typically don't require a review.
Mar 21 2020
- Renamed check to experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type.
- s/argument/parameter/g in the code and output where appropriate.
ClangTidyForceLinker.h also contained the entries without alphabetic order.
@aaron.ballman I've gone over LLVM (and a few other projects). Some general observations:
Mar 17 2020
Feb 26 2020
Also, errors should conceptually break the operation at hand, so this thing should be a warning instead?
Do you have access to the Driver somehow? Instead of a cerr (-ish) output, something that is formatted like a "true" error diagnostic (or warning), such as "no such file or directory" would be much better, I fear this [ERROR] will simply be flooded away with the usual diagnostic output on screen, especially if multiple files are concerned.
Feb 25 2020
WIP because there's a lot of debug stuff that should be cleared out from here. This is a crude patch. It works fancy, but the code is crude.
Btw, we should update the terminology in the patch to use parameter instead of argument (parameters are what the function declares, arguments are what are passed in at the call site and they bind to parameters -- the issue this check is trying to solve is on the declaration side, not the caller side).
@aaron.ballman @vingeldal I'll go over the findings (as I've run this on LLVM and various other projects, a few examples are uploaded in my first comment as HTML renders of the bug report!) soon, but I want to wait until a research paper I have based on this topic gets a final decision. (It should happen soon.) I also plan to refurbish D20689 and have it upstreamed as a "co-checker" of this (one for the interface rule, one for the call sites, they kinda want to solve different aspects of the same issue, let it be up for the project how much they wish to enforce).
I think this value very well may strike a good balance in that compromise but I still think it is a clear deviation from the guideline as specified.
IMO all deviations from the guideline should be explicitly requested by the user, not set by default, no matter how useful that deviation is.
Doesn't clang-tidy exclude warnings from system headers by default though?
Third-party SDKs are not always brought in as system headers, unfortunately. Even ignoring system and third-party headers, having two parameters of the same type is a natural occurrence for some data types (like bool) where it is going to be extremely hard to tell whether they're related or unrelated parameters.
Feb 24 2020
I am also concerned about the false positives from this check because I don't think there's going to be an easy heuristic for determining whether two identifiers are "related" to one another.
I'd rather not call them false positive because the definition of false positive is ugly and mushy with regards to this check. This check attempts to enforce an interface rule, whether you(r project) wants to adhere the rule is a concise decision. A type equivalence (or convertibility in case of the follow-up patch D75041 that considers implicit conversions) should be a "true positive" in every case, as an indicator of potentially bad design.
Jan 1 2020
There are a few really minor bug fixes, test additions, documentation update, etc. coming along soon, but I've some more pressing matters. However, please feel free to review the patch as-is!
Dec 31 2019
@vingeldal Apologies, in that case. However, I would still claim that style (as a potential severity) has its purpose for Tidy checkers, not just for clang-format.
Dec 30 2019
- Style: things that are handled by clang-format rather than clang-tidy.
Dec 24 2019
The checks.rst has recently been updated to show "normal" (main entry) checks and "aliases" in different tables in D36051. Please register the alias-ness accordingly.
Dec 22 2019
Dec 20 2019
I am a little bit conflicted about the Severity column. While I know our people put a great deal of effort into keeping this classification sane, what was put into CodeChecker is, at the end of the day, a pretty arbitrary classification.
Dec 17 2019
Are buffers otherwise modelled by the Analyser, such as results of the malloc family and alloca intentionally not matched, or are there some tests missing regarding this?
Dec 12 2019
I have developed a related check in D69560. That one considers types, but is an interface rule checker, and does not consider (any) potential call sites. Moreover, it does not consider "swaps" that happen across a function call, only, as the name implies, adjacent similar-type ranges.
Dec 9 2019
Can you refresh my memory on whether a rule for "if init expr is constant, initialise in class body instead" exists for init list members? If so, this will be a funny "two pass needed to fix" kind of check.
Dec 5 2019
While I can't pitch in with actual findings of this check, @MyDeveloperDay, you're right in many aspects, including those specific examples not firing. But an example that actually fires this check indicates a very specific undefined behaviour case. So if such bogus code (that would trigger on this check) did not cause run-time issues so far, it's because they never free() their memory allocations (really bad?), or their platform is particular enough that it allows calling free into the buffer, not only for the start of the buffer.
Nov 18 2019
Oct 31 2019
- Removed This check from the documentation comment of the check's class too.
- Fix some comments, formatting and documentation
- Organised test files to be in the same directory as others on the Monorepo structure
- Helper functions moved from namespace (anonymous) to static.
- Added test for C and enabled check for C code.
Oct 29 2019
@Szelethus and @baloghadamsoftware are colleagues to me whom are far more knowledgeable about check development and I want them to see that I want a review from them. I specifically didn't do an "internal with colleagues" downstream review with regards to this code.
A few interesting "true positive" findings:
Aug 30 2019
Aug 16 2019
Apr 29 2019
@dcoughlin How would removing the USAGE part of the dump and keeping only the list of options and their formatted help sound? That way, this option will not invite the user to directly call the analyzer.
I think this is good. Patch still marked as Needs review for some reason. 😦 Can we look up this blocking review thing? Perhaps this could be marked ready to roll once the dependency patch is ironed out.
@Szelethus I know the dependent patch D59464 will move examples/analyzer-plugin to test/Analysis/plugins/..., but this patch still seems to affect examples/. Are you sure this is the right diff? Because you are adding brand new files and brand new "folders", I don't think that'll apply cleanly.
Apr 26 2019
Mar 12 2019
In case no bug reports against the checker are reported on the mailing list or Bugzilla, I wholeheartedly agree with kicking the ball here.
Feb 18 2019
Yeah, it seems upstream has moved away due to @Szelethus' implementation of a much more manageable "checker dependency" system. You most likely will have to rebase your patch first, then check what you missed which got added to other merged, existing checkers.
Jan 23 2019
Jan 18 2019
Dec 14 2018
Dec 3 2018
Nov 21 2018
Bar the previous comments, I really like this. The test suite is massive and well-constructed. Do we know of any real-world findings, maybe even from LLVM?
GCC 7 introduced -Wduplicated-branches, so will be good idea to run this check on associated regression(s).