In D123901, the or_null, and_nonnull templates were deprecated intended to be replaced with if_present and and_present.
In light of this, The clang-tidy check that enforces correct use of isa and dyn_cast should also be updated with this syntax.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang-tools-extra/docs/ReleaseNotes.rst | ||
---|---|---|
322 | Please use double back-ticks. |
This is great, thank you for doing this! I'm not a competent reviewer for the actual clang-tidy code changes but the +1 for the idea :)
clang-tools-extra/test/clang-tidy/checkers/llvm/prefer-isa-or-dyn-cast-in-conditionals.cpp | ||
---|---|---|
13–14 | Will the tests pass properly once the fixes are applied, even though the replaced code refers to a symbol (isa_and_present) that is not declared in the TU? |
The problem with the approval here is that a single approval will turn the patch into a fully approved state, which breaks the dashboards for people added to the patch (i.e., other reviewers will think the patch is already approved, and thus perhaps will not consider putting effort into reviewing it!).
However, I think you should try the Award Token option from the menu on the right! Somewhere the awarded tokens should show up on the patch, tallying up support!
Ah I had no idea, thanks for pointing that out. I was looking at the Code Review document (https://llvm.org/docs/CodeReview.html), I'll put up a patch to add a short section on this.
clang-tools-extra/test/clang-tidy/checkers/llvm/prefer-isa-or-dyn-cast-in-conditionals.cpp | ||
---|---|---|
13–14 | The current tests would fail if ran once the fixes are applied as isa_and_nonnull doesn't exist in this TU. Most tidy checks (for better or worse) don't check for existence of an identifier that is expected to be there when making replacements. |
Added dynamic checking for existence of isa_and_present before suggesting it as a replacement
clang-tools-extra/clang-tidy/llvm/PreferIsaOrDynCastInConditionalsCheck.cpp | ||
---|---|---|
39 | allOf is redudant | |
46 | no need for allOf, just put those unless directly under callExpr | |
47 | this also doesn't look to be needed.. | |
47 | maybe check argument count first argumentCountIs(1) | |
57 | Let me quote You: "Rather than calling traverse, the canoncial way to handle this is by overriding the getCheckTraversalKind virtual function to return TK_IgnoreUnlessSpelledInSource" | |
59 | Change name of this any, on first look I mistook this for a anything() | |
61 | no need for allOf, all those matchers are variadic... | |
65–66 | I think that hasRHS(ignoringImpCasts(CallExpression)) should do a trick. | |
96 | This is not a Decl but an Expr | |
155–156 | Maybe MatchedDecl->getSourceRange () ? | |
clang-tools-extra/clang-tidy/llvm/PreferIsaOrDynCastInConditionalsCheck.h | ||
61 | no need for mutable, its used only form Check that isn't const. |
@PiotrZSL Thank you for your review, however we tend to only comment on code that has been changed by the patch. You have made some good points about parts of this check, but they can be addressed in an NFC commit.
clang-tools-extra/clang-tidy/llvm/PreferIsaOrDynCastInConditionalsCheck.h | ||
---|---|---|
61 | Good spot. |
clang-tools-extra/clang-tidy/llvm/PreferIsaOrDynCastInConditionalsCheck.h | ||
---|---|---|
61 | Comment not yet addressed, do you intend to? | |
clang-tools-extra/docs/ReleaseNotes.rst | ||
323 | Would it make more sense to point to an actual commit in the repo? A review may or may not have been merged. | |
clang-tools-extra/test/clang-tidy/checkers/llvm/prefer-isa-or-dyn-cast-in-conditionals.cpp | ||
1 | Typo |
no need for mutable, its used only form Check that isn't const.
Maybe better HasIsPresentCache ?