Febbe added a comment.

In D137205#3920016 <https://reviews.llvm.org/D137205#3920016>, @firewave wrote:

> Getting this false positive:
>
>   #include <string>
>   
>   extern std::string str()
>   {
>       std::string ret;
>       return ret.empty() ? ret : ret.substr(1);
>   }
>
>
>
>   input.cpp:6:23: warning: Parameter 'ret' is copied on last use, consider 
> moving it instead. [performance-unnecessary-copy-on-last-use]
>           return ret.empty() ? ret : ret.substr(1);
>                                ^
>                                std::move( )
>
> Appears to be caused by the ternary since I also have it inline with a 
> function parameter in another case.

As I know, the compilers can't copy elide always on ternary operators. 
Therefore, I have also a test, suggesting it on return.



================
Comment at: 
clang-tools-extra/docs/clang-tidy/checks/performance/unnecessary-copy-on-last-use.rst:50
+
+   A string specifying which include-style is used, `llvm` or `google`. Default
+   is `llvm`.
----------------
Eugene.Zelenko wrote:
> Could such option be shared between different checks? Or even rely on 
> `.clang-format`?
I just oriented myself at other similar checks, which introduced this. It uses 
both there:

```
UnnecessaryCopyOnLastUseCheck::UnnecessaryCopyOnLastUseCheck(
    StringRef Name, ClangTidyContext *Context)
    : ClangTidyCheck(Name, Context),
      Inserter(Options.getLocalOrGlobal("IncludeStyle",
                                        utils::IncludeSorter::IS_LLVM),
```

Do you mean, that I can just remove the description of the option, because it 
is taken from global options?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137205/new/

https://reviews.llvm.org/D137205

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to