llvm / llvm/llvm-project

[clang-tidy] extend `readability-make-member-function-const` to allow calls to private `const`-qualified member functions

Open
#193,425 2 comments 0 reactions 1 assignee Claimed by @ashthedash2k View on GitHub
clang-tidy enhancement
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

```cpp
struct S
{
private:
int get_x() const;
int get_y() const;
public:
int get() /*const*/
{
return get_x() * get_y();
}
};
```

https://godbolt.org/z/9fcrvofcf

I would have expected that `const` is being suggested for above code since it appears to be straight-forward. But after reading the documentation it is clear why that is not the case.

But as someone would *probably* mark `get()` as `const` when writing/reviewing the code, adding an option which also allows calls to private `const`-qualified member functions seems acceptable to me.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.