[PATCH] D110614: [clang-tidy] Fix false positives in cppcoreguidelines-virtual-class-destructor

Whisperity via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 30 04:39:33 PDT 2021


whisperity added a comment.

In D110614#3032818 <https://reviews.llvm.org/D110614#3032818>, @carlosgalvezp wrote:

> Moved the condition of public-virtual / protected-non-virtual to the check stage instead of the match stage. This way is more similar to the equivalent Sema check and it passes all the tests. Let me know what you think!

I'll let @aaron.ballman take a look at how well the test coverage increased, this is a drive-by comment from my part due to being a bit too busy. I'll look at this at a later point, hopefully still this week!

Either way, you could create your own local matcher predicate function and use it as a submatcher, so you can do the test during matching instead of checking.

Adding

  AST_MATCHER(Decl, myFancyMatcher) {
    return Node.something();
  }

to the code will give you `myFancyMatcher()`, which you can embed. First parameter is the node type you want to match on. Inside the `{ }` you are essentially within a function's scope, so you can write arbitrary code, returning true is you want to match.

If you check the AST Matcher library header, it uses this same macro extensively. Perhaps you could check how the `isVirtual` matcher is implemented there?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D110614/new/

https://reviews.llvm.org/D110614



More information about the cfe-commits mailing list