-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Open
Labels
Description
Our code base has a recurring pattern like the following:
#if defined(MY_DEBUG)
#define NAME "debug"
#else
#define NAME
#endif
class Foo {
public:
Foo();
Foo(const char* const aName);
};
class Bar {
private:
Foo mFoo{NAME};
};
Which produces the following warning:
<source>:16:13: warning: initializer for member 'mFoo' is redundant [readability-redundant-member-init]
16 | Foo mFoo{NAME};
| ^~~~~~
1 warning generated.
It is a little more complicated in practice; we use the extra information in debug or profiling builds, but I wanted simplify for the bug report.
Anyway, I noticed that checkers like modernize-use-equals-default
recently got support to ignore special member functions with macros used in their bodies. It would be nice if readability-redundant-member-init
could do the same thing.