microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.54k stars 1.56k forks source link

Provide Quick Fix action for clang-tidy warning 'readability-make-member-function-const' #12971

Closed davidavetyan closed 1 week ago

davidavetyan commented 1 week ago

Feature Request

Currently, when a Member function 'f' can be made const clang-tidy [readability-make-member-function-const] warning pops up, no quick fix action is available in the tooltip.

Please add a code action, to append const to the method's declaration/definition.

sean-mcmanus commented 1 week ago

@davidavetyan It works for me. Your repro text is different from mine though -- it looks like you may be using another extension or an older version of clang-tidy?

Image

Image

Image

class foo
{
  int i;
public:
    int bar() { return i; }
};
davidavetyan commented 1 week ago

@sean-mcmanus I also have the 'clangd' extension installed. After disabling it, I got the quick fix action for this warning. So I guess this is an issue in clangd, when the method is defined in a different file than the declaration (otherwise seems to work there also, like for your example). Thanks.