[cfe-dev] Add a clang-tidy check for inadvertent conversions
Roman Lebedev via cfe-dev
cfe-dev at lists.llvm.org
Mon Mar 26 06:01:45 PDT 2018
On Wed, Mar 21, 2018 at 3:00 AM, Andrzej Krzemienski via cfe-dev
<cfe-dev at lists.llvm.org> wrote:
>
>
> 2018-03-20 22:03 GMT+01:00 Richard via cfe-dev <cfe-dev at lists.llvm.org>:
>>
>> [Please reply *only* to the list and do not include my email directly
>> in the To: or Cc: of your reply; otherwise I will not see your reply.
>> Thanks.]
>>
>> In article
>> <BN6PR13MB1569F3CBF08B69AED1DEC207E8D40 at BN6PR13MB1569.namprd13.prod.outlook.com>,
>> "Krzemienski, Andrzej via cfe-dev" <cfe-dev at lists.llvm.org> writes:
>>
>>
>> > It would be too much false positives to NOLINT.
>>
>> It seems that you have to do the edits to add the attribute, so how is
>> that different from doing the edits to add NOLINT?
>
>
> The way I see the difference is that putting a NOLINT is an indication of
> either:
> 1. An inaccurate check (it has false positives that I have to silence)
> 2. My inability to fix my code (because I am not in control of it, or
> because I have no time to investigate)
>
> Silencing the warning with a dedicated attribute is saying: the check is
> accurate, my code is correct and clearly states intentions.
>
> And there is still this other point. I only want to check for inadvertent
> conversions caused by programmer forgetting to declare her constructor
> explicit. I *do not want* to warn on non-explicit conversions operators:
> they are never added by omission.
> If I go with google-explicit-constructor I will have to NOLINT every
> non-explicit conversion operator.
> If I go with the proposed check (which does not check conversion operators -- only constructors)
Ah. Then i'd suggest to simply extend
clang-tools-extra/clang-tidy/google/ExplicitConstructorCheck.cpp
with two options, toggling checking of constructors, and conversion
operators. (both default to on)
That sounds so less intrusive, and cleaner, no?
> I do not have to NOLINT any conversion operator.
>
> Does this make sense?
>
> Regards,
> &rzej;
Roman.
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
More information about the cfe-dev
mailing list