Issue 152024
Summary readability-redundant-member-init when member variable initialized with macro
Labels new issue
Assignees
Reporter nick-potenski
    Our code base has a recurring pattern like the following:
```c++
#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; we use it 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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to