[cfe-users] clang-tidy

Mario Charest via cfe-users cfe-users at lists.llvm.org
Thu Jan 30 10:02:37 PST 2020


Hello,

First post, be gentle ;-)

I'm trying to find a clean solution to an error message that clang-tidy is
giving, tried with 10 and 11)

This is the code:

struct Foo
{
    Foo(const std::string &value) : m_name(value) {}
    Foo(std::string &&value) : m_name(std::move(value)) {}
    std::string m_name;
};

The message is :

warning: pass by value and use std::move [modernize-pass-by-value]
    Foo(const std::string &value) : m_name(value) {}
        ^~~~~~~~~~~~~~~~~~~
        std::string                        std::move( )

I understand the logic behind the warning.  Unfortunately the solution
cannot be apply because of the move constructor. Won't compile.  One might
argue the move constructor could be remove. But I did not make that post to
get into that.  What I would like to know if it would make sense to make
clang-tidy smarter about this and not generate that message if a move
constructor is present ?

Regards,

- Mario
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-users/attachments/20200130/4c90938b/attachment.html>


More information about the cfe-users mailing list