[PATCH] D26118: [clang-tidy] Change readability-redundant-member-init to get base type from constructor
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 2 10:06:32 PDT 2016
aaron.ballman added inline comments.
Comment at: clang-tidy/readability/RedundantMemberInitCheck.cpp:57
"initializer for base class %0 is redundant")
- << Init->getTypeSourceInfo()->getType()
+ << Construct->getType()
> aaron.ballman wrote:
> > Why is it more correct to use the CXXConstructExpr type information rather than the CXXCtorInitializer?
> Something to do with templates and namespaces.
> In the bug report, `CXXCtorInitializer` had type `std::__1::bitset<128>` and `CXXConstructExpr` had type `std::bitset<MAX_SUBTARGET_FEATURES>`.
> I don't know why.
I believe it's because `__1` is an inline namespace, and the printing policy matters. IIRC, there's the `SuppressUnwrittenScope` policy data member, that if you set it to true, it won't print the inline or anonymous namespace when printing types.
We should understand why there's a difference before applying this change. I think using the CXXCtorInitializer's type is more correct than using the CXXConstructExpr's type (due to implicit type conversions). Given that the printing policy controls whether inline namespaces are printed, I would have expected these both to print without the inline namespace (the type changed, but not the printing policy) -- the fact that the behavior differs makes me worried there's a bug somewhere else and this fix is masking it.
More information about the cfe-commits