CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
145 lines
3.9 KiB
C++
145 lines
3.9 KiB
C++
// RUN: %check_clang_tidy -std=c++23-or-later %s readability-convert-member-functions-to-static %t
|
|
#include <string>
|
|
|
|
namespace std{
|
|
void println(const char *format, const std::string &str) {}
|
|
}
|
|
|
|
struct Hello {
|
|
std::string str_;
|
|
|
|
void ByValueSelf(this Hello self) { std::println("Hello, {0}!", self.str_); }
|
|
|
|
void ByLRefSelf(this Hello &self) { std::println("Hello, {0}!", self.str_); }
|
|
|
|
void ByRRefSelf(this Hello&& self) {}
|
|
|
|
template<typename Self> void ByForwardRefSelf(this Self&& self) {}
|
|
|
|
void MultiParam(this Hello &self, int a, double b) {}
|
|
|
|
void UnnamedExplicitObjectParam(this Hello &) {}
|
|
};
|
|
|
|
class BaseOverloadedAutoLambdaTest {
|
|
public:
|
|
void BaseOverloadedMethod();
|
|
void BaseOverloadedMethod(int a) { };
|
|
};
|
|
|
|
|
|
class OverloadedAutoLambdaTest : public BaseOverloadedAutoLambdaTest {
|
|
public:
|
|
void CallFunVar();
|
|
// CHECK-FIXES: static void CallFunVar();
|
|
void LambdaUsesThis1(int a);
|
|
void LambdaUsesThis2(int a);
|
|
void LambdaUsesThis3(int a);
|
|
void LambdaUsesThis4();
|
|
void LambdaUsesThis5();
|
|
|
|
void LambdaNoThis1(int a);
|
|
// CHECK-FIXES: static void LambdaNoThis1(int a);
|
|
void LambdaNoThis2(int a);
|
|
// CHECK-FIXES: static void LambdaNoThis2(int a);
|
|
void LambdaNoThis3(int a);
|
|
// CHECK-FIXES: static void LambdaNoThis3(int a);
|
|
void LambdaNoThis4(int a);
|
|
// CHECK-FIXES: static void LambdaNoThis4(int a);
|
|
void LambdaNoThis5(int a);
|
|
// CHECK-FIXES: static void LambdaNoThis5(int a);
|
|
|
|
void OverloadedMethod();
|
|
void OverloadedMethod(int a) { };
|
|
|
|
template <typename T>
|
|
void TemplatedOverloadedMethod(T);
|
|
void TemplatedOverloadedMethod(int);
|
|
};
|
|
|
|
void OverloadedAutoLambdaTest::CallFunVar() {
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:32: warning: method 'CallFunVar' can be made static [readability-convert-member-functions-to-static]
|
|
auto fun = [&](auto a) {
|
|
var(a);
|
|
};
|
|
}
|
|
|
|
void OverloadedAutoLambdaTest::LambdaUsesThis1(int a) {
|
|
auto fun = [&](auto b) {
|
|
OverloadedMethod(b);
|
|
};
|
|
}
|
|
|
|
void OverloadedAutoLambdaTest::LambdaUsesThis2(int a) {
|
|
auto fun = [&](auto b) {
|
|
this->OverloadedMethod(b);
|
|
};
|
|
}
|
|
|
|
void OverloadedAutoLambdaTest::LambdaNoThis1(int a) {
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:32: warning: method 'LambdaNoThis1' can be made static [readability-convert-member-functions-to-static]
|
|
OverloadedAutoLambdaTest f;
|
|
auto fun = [&](auto b) {
|
|
f.OverloadedMethod(b);
|
|
};
|
|
}
|
|
|
|
void OverloadedAutoLambdaTest::LambdaUsesThis3(int a) {
|
|
OverloadedAutoLambdaTest g;
|
|
auto fun1 = [&](auto a) {
|
|
auto fun2 = [&](auto b) {
|
|
OverloadedMethod(b);
|
|
};
|
|
fun2(a);
|
|
};
|
|
}
|
|
|
|
void OverloadedAutoLambdaTest::LambdaNoThis2(int a) {
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:32: warning: method 'LambdaNoThis2' can be made static [readability-convert-member-functions-to-static]
|
|
OverloadedAutoLambdaTest g;
|
|
auto fun1 = [&](auto a) {
|
|
auto fun2 = [&](auto b) {
|
|
g.OverloadedMethod(b);
|
|
};
|
|
fun2(a);
|
|
};
|
|
}
|
|
|
|
void OverloadedAutoLambdaTest::LambdaUsesThis4() {
|
|
auto fun = [&](auto a) {
|
|
OverloadedMethod(a);
|
|
};
|
|
}
|
|
|
|
void OverloadedAutoLambdaTest::LambdaNoThis3(int a) {
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:32: warning: method 'LambdaNoThis3' can be made static [readability-convert-member-functions-to-static]
|
|
OverloadedAutoLambdaTest f;
|
|
auto fun = [&](auto b) {
|
|
f.OverloadedMethod(b);
|
|
};
|
|
}
|
|
|
|
void OverloadedAutoLambdaTest::LambdaNoThis4(int a) {
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:32: warning: method 'LambdaNoThis4' can be made static [readability-convert-member-functions-to-static]
|
|
BaseOverloadedAutoLambdaTest f;
|
|
auto fun = [&](auto b) {
|
|
f.BaseOverloadedMethod(b);
|
|
};
|
|
}
|
|
|
|
void OverloadedAutoLambdaTest::LambdaNoThis5(int a) {
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:32: warning: method 'LambdaNoThis5' can be made static [readability-convert-member-functions-to-static]
|
|
OverloadedAutoLambdaTest f;
|
|
auto fun = [&](auto b) {
|
|
f.BaseOverloadedMethod(b);
|
|
};
|
|
}
|
|
|
|
void OverloadedAutoLambdaTest::LambdaUsesThis5() {
|
|
auto fun = [&](auto b) {
|
|
TemplatedOverloadedMethod(b);
|
|
};
|
|
}
|
|
|
|
void Var(int a) { }
|