diff options
author | Zhikai Zeng <backlight.zzk@gmail.com> | 2025-06-11 02:50:22 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-06-10 11:50:22 -0700 |
commit | 46b7a88548e5016f403cdc5f2cb1e4ff09353c3b (patch) | |
tree | 0e192be7d99a7df69c3b4c5f203e226cc9748029 /clang-tools-extra/clang-tidy/linuxkernel/LinuxKernelTidyModule.cpp | |
parent | 4e706adc5ed8e064a29fd4193b2f7ba9858eeb1d (diff) | |
download | llvm-46b7a88548e5016f403cdc5f2cb1e4ff09353c3b.zip llvm-46b7a88548e5016f403cdc5f2cb1e4ff09353c3b.tar.gz llvm-46b7a88548e5016f403cdc5f2cb1e4ff09353c3b.tar.bz2 |
fix access checking about function overloading (#107768)
fix https://github.com/llvm/llvm-project/issues/107629
After some more debugging, I find out that we will check access here at
https://github.com/llvm/llvm-project/blob/8e010ac5a173c9dee44b44324169a3e100a1a6fc/clang/lib/Sema/SemaInit.cpp#L7807
And for `f()` inside code below, `Found.getAccess()` is `AS_none` hence
`CheckAddressOfMemberAccess` return `AR_accessible` directly.
```cpp
struct Base {
public:
int f(int);
private:
int f(); // expect-note {{declared private here}}
};
struct Derived : public Base {};
void f() {
int(Derived::* public_f)(int) = &Derived::f;
int(Derived::* private_f)() = &Derived::f; // expect-error {{'f' is a private member of 'Base'}}
}
```
I think the `Found.getAccess()` is intended to be `AS_none` so I just
add one more access check for the `UnresolvedLookupExpr` when
`Found.getAccess()` is `AS_none`. If add the check unconditionally clang
will report lots of duplicate errors and cause several unit tests to
fail.
I also test the UB mentioned in
https://github.com/llvm/llvm-project/issues/107629 and clang now display
4 `false` as expecetd.
Co-authored-by: Erich Keane <ekeane@nvidia.com>
Diffstat (limited to 'clang-tools-extra/clang-tidy/linuxkernel/LinuxKernelTidyModule.cpp')
0 files changed, 0 insertions, 0 deletions