[PATCH] D115106: [clang-tidy] Fix `readability-static-accessed-through-instance` false negative for static methods

Simon Giesecke via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 9 01:49:02 PST 2021


simon.giesecke added a comment.

In D115106#3180439 <https://reviews.llvm.org/D115106#3180439>, @aaron.ballman wrote:

> In D115106#3172949 <https://reviews.llvm.org/D115106#3172949>, @simon.giesecke wrote:
>
>> Thanks a lot for addressing this issue! I am just trying it on our codebase.
>>
>>> The problem actually has nothing to do with the out-of-line definition being inline; the problem is that hasDeclaration() of the memberExpr() will match the out-of-line definition, which obviously isn't marked static, so isStaticStorageClass() won't match.
>>
>> Hm, an out-of-line definition *cannot* have the `static` keyword. I wonder if it's actually a bug (in the AST? or just the matcher?) that `isStaticStorageClass` doesn't match here? I guess that other checks that use `isStaticStorageClass` might be affected by this too?
>
> `isStaticStorageClass()` calls through to `FunctionDecl::getStorageClass()` which reports the storage as written on that declaration in source. So this isn't a bug in the AST, it's a more of a misunderstanding of whether we're querying the storage duration/linkage for the method or whether we're querying whether it was written with the static keyword.

I see, makes sense.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115106



More information about the cfe-commits mailing list